-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
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.
👍 Thanks @kjac I'll give it a whirl :) |
Ok validation has some issues. When I tick the |
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 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 |
@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)? |
@Nicholas-Westby you can download the source branch (submit-watcher) from my fork. |
@Nicholas-Westby this is how I checkout pull requests: https://gist.github.com/piscisaureus/3342247
This will get you on a branch named You'd then have to build it by running
To make things easier you can just run |
@kgiszewski Seems to be working. Here's what I did to test:
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. 👍 |
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. |
@kgiszewski https://github.com/kgiszewski awesome. One thing that's worth
|
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). |
👍 Good work everyone. We may need to address performance if it becomes an issue. |
Whooooo awesome :-D
|
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 theformSubmitting
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 theformSubmitting
event handler chain. This allows us to broadcast our own eventarchetypeFormSubmitting
to all the Archetype properties, so they in turn can update theirmodel.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: