Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Fix #261 #262

Merged
merged 1 commit into from
Apr 15, 2015
Merged

Fix #261 #262

merged 1 commit into from
Apr 15, 2015

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Apr 4, 2015

The formSubmitting event handlers are called synchronously, and apparently in the order which they were subscribed to the event. By adding an event handler to the formSubmitting event for each property added to a fieldset (after the property itself has been added), we can make sure that Archetype gets "the last say" in the formSubmitting event handler chain. This allows us to broadcast our own event archetypeFormSubmitting to all the Archetype properties, so they in turn can update their model.value if need be, before the entire Archetype is submitted.

PLEASE NOTE
I am submitting this only halfway tested - some family stuff is going to keep me busy for a while, so I thought I'd submit it now for someone else to test, rather than sit on it until I could complete testing it myself.
Off the top of my head I can think of a few things that need to be tested:

  • Validation - specially for mandatory member pickers, but also validation in general.
  • Multiple Archetypes on one content type - is the new event isolated to each Archetype, because it will be broadcast for each of the.
  • Nested Archetypes (same potential issue as in the last point).

Add a watch to the "formSubmitting" event for each property added to a
fieldset, to make sure Archetype gets the last say in the
"formSubmitting" event.
@kgiszewski
Copy link
Owner

👍 Thanks @kjac I'll give it a whirl :)

@kgiszewski
Copy link
Owner

Whelp, so far so good, as you can see in the screenshot I've tested the following:

  • Standalone Member Group Picker
  • Single Archetype with MGP
  • Nested Archetype with MGP
  • Multiple Archetypes on same tab
  • Multiple Archetypes on different tabs

Still need to check validation.

screen shot 2015-04-04 at 6 40 38 pm

@kgiszewski
Copy link
Owner

Ok validation has some issues. When I tick the Required box, it's hit and miss on whether the validation is picked up.

@kgiszewski
Copy link
Owner

I think I found the solution (though @kjac did all the work :))...

If you add an MGP (that is required) item then save; then remove it; then save; it passes validation.

If we replace the validation line to listen to Kenn's new event, validation seems to work properly:

https://github.com/imulus/Archetype/blob/master/app/directives/archetypeproperty.js#L89

I propose we change from formSubmitting to archetypeFormSubmitting for validation. I noticed the new event fires a couple of extra times when we do so, but not 100's of times. I think the screenshot generated 18 events.

Reason it works with the new event is because validation was originally firing on the same event that MGP is setting it's model which causes model confusion.

Anyway...

Looks good to go if we change that event 👍

I would like @Nicholas-Westby to give it a shot if possible.

This also probably fixes an old issue (#105 reported by @AussieInSeattle).

Thanks @kjac and good luck with your family issue. #h5yr

@Nicholas-Westby
Copy link
Contributor

@kgiszewski Will see if I can try it in the morning. Do you have some code committed that I can compile (maybe in another branch or something)?

@kjac
Copy link
Contributor Author

kjac commented Apr 6, 2015

@Nicholas-Westby you can download the source branch (submit-watcher) from my fork.

@kgiszewski
Copy link
Owner

@Nicholas-Westby this is how I checkout pull requests: https://gist.github.com/piscisaureus/3342247

  1. Add this line to your .git/config in your Archetype root directory: fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
  2. Run git fetch origin (from your Archetype directory)
  3. Run git checkout pr/262

This will get you on a branch named pr/262 locally.

You'd then have to build it by running grunt from the CLI. This will run all of the build tasks and create a new set of files in /dist (Archetype root folder). You'll then copy this stuff to an Umbraco install for testing.

If you get an error saying it can't find grunt you'll need to make sure you have node.js installed locally and type npm install from the Archetype root afterwards. https://nodejs.org/download/

To make things easier you can just run grunt watch --target="c:\dev\myUmbracoDevFolder" and it'll copy any changes you make to an Umbraco install. This is great for development or tweaking PR's.

@Nicholas-Westby
Copy link
Contributor

@kgiszewski Seems to be working. Here's what I did to test:

  • Cloned Kenn's fork, and switched to his "submit-watcher" branch.
  • Changed event to "archetypeFormSubmitting" on this line: https://github.com/kjac/Archetype/blob/submit-watcher/app/directives/archetypeproperty.js#L89
  • Reapplied a custom performance enhancement to the JavaScript I've been using on my projects.
  • Ran npm install to get all the Node stuff.
  • Ran grunt.
  • Copied the updated files in "dist" to my website.
  • Removed my temporary workaround in \Umbraco\Js\umbraco.controllers.js.
  • Cleared App_Data\TEMP, cleared browser cache, rebuilt my solution, and ran it.

I did a few tests removing and adding member groups in my archetype consisting of a member group picker. All seemed to work as expected. I didn't happen to have any nested archetypes with a member group picker to test on though.

By the way, thanks for that tip regarding setting the target in the grunt command line. Could come in useful for some other stuff I'm working on. 👍

@kgiszewski
Copy link
Owner

Awesome! @tomfulton came up with the grunt integrations.

I'm gonna give it a few more days (or until @kjac is back) before I merge and release. Thanks for testing.

@kjac
Copy link
Contributor Author

kjac commented Apr 6, 2015

@kgiszewski https://github.com/kgiszewski awesome. One thing that's worth
looking into: for performance considerations, maybe it's possible after all
fieldsets have loaded, to unsubscribe all watchers but the last one from
the formSubmitting event?
On Apr 6, 2015 5:57 PM, "Kevin Giszewski" notifications@github.com wrote:

Awesome! @tomfulton https://github.com/tomfulton came up with the grunt
integrations.

I'm gonna give it a few more days (or until @kjac
https://github.com/kjac is back) before I merge and release. Thanks for
testing.


Reply to this email directly or view it on GitHub
#262 (comment).

@Nicholas-Westby
Copy link
Contributor

In regards to performance, it may also be useful to use try $scope.$emit("archetypeFormSubmitting") rather than $scope.$broadcast("archetypeFormSubmitting"). You might also cancel the event if you don't want it traversing to ancestor scopes (though, that may complicate the implementation, so attempt that at your own risk).

kgiszewski added a commit that referenced this pull request Apr 15, 2015
@kgiszewski kgiszewski merged commit 0174f6d into kgiszewski:master Apr 15, 2015
@kgiszewski
Copy link
Owner

👍 Good work everyone. We may need to address performance if it becomes an issue.

@kjac
Copy link
Contributor Author

kjac commented Apr 15, 2015

Whooooo awesome :-D
On Apr 15, 2015 9:36 PM, "Kevin Giszewski" notifications@github.com wrote:

[image: 👍] Good work everyone. We may need to address performance if
it becomes an issue.


Reply to this email directly or view it on GitHub
#262 (comment).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants