You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bh-submit directive currently stops all propagation (does not call the submit method) if the form.$invalid flag is set.
The goal of this issue is to find a way to allow controllers to perform tasks if the form is invalid, often revolving around informing the user. For example:
Display a danger notification
Handle an unrelated error
Scroll to the invalid form element
One suggestion for how this could be achieved is to remove the $invalid check from the bh-submit directive - this will always call the submission method and the directive can no longer assume a Promise will be returned.
One way of accomidating this is to check if the required method (finally) is returned in the function call - if not the loading state should simply be reverted.
For example:
FormController.$toggleLoading();letresponse=$scope.submit();if(response.finally){// attach method to clean up loading state response.finally(()=>FromController.$toggleLoading());}else{// method either did not return or quit early - retract loading stateFormController.$toggleLoading();}
Disadvantages:
If the controller forgets to return a promise to the loading directive it will simple toggle loading off. This is a programmer mistake but may not be easy to catch
@IMA-WorldHealth/local-contributors This will change the way the submission directive works so should first be approved.
The text was updated successfully, but these errors were encountered:
This commit implements the suggestions proposed in #431. The `bhSubmit`
directive responsible for toggle the form's $loading state now supports
inputs other than Promises. If the input is not a promise, the form
immediately cancels the $loading state. Otherwise, the $loading state
is toggled off on resolution of the Promise.
Closes#431.
This commit implements the suggestions proposed in #431. The `bhSubmit`
directive responsible for toggle the form's $loading state now supports
inputs other than Promises. If the input is not a promise, the form
immediately cancels the $loading state. Otherwise, the $loading state
is toggled off on resolution of the Promise.
Closes#431.
This commit implements the suggestions proposed in #431. The `bhSubmit`
directive responsible for toggle the form's $loading state now supports
inputs other than Promises. If the input is not a promise, the form
immediately cancels the $loading state. Otherwise, the $loading state
is toggled off on resolution of the Promise.
Closes#431.
The
bh-submit
directive currently stops all propagation (does not call the submit method) if theform.$invalid
flag is set.The goal of this issue is to find a way to allow controllers to perform tasks if the form is invalid, often revolving around informing the user. For example:
One suggestion for how this could be achieved is to remove the
$invalid
check from thebh-submit
directive - this will always call the submission method and the directive can no longer assume a Promise will be returned.One way of accomidating this is to check if the required method (
finally
) is returned in the function call - if not the loading state should simply be reverted.For example:
Disadvantages:
@IMA-WorldHealth/local-contributors This will change the way the submission directive works so should first be approved.
The text was updated successfully, but these errors were encountered: