-
Notifications
You must be signed in to change notification settings - Fork 711
Open
Description
Description
In the documentation onSubmitSuccess is possible to add logic for change the flow of the success in this case with this code :
Email.creationView()
.fields([nga.field('subject').validation({ required: true }),
nga.field('content', 'wysiwyg').validation({ required: true })])
.onSubmitSuccess(['progression', 'notification', '$state', 'entity', 'entry', function (progression, notification, $state, entity, entry) {
// stop the progress bar
progression.done();
// add a notification
notification.log('Email Sent', { addnCls: 'humane-flatty-success' });
// redirect to the show view
$state.go($state.get('show'), { entity: entity.name(), id: entry.identifierValue });
// cancel the default action (redirect to the show view)
return false;
}]);
Expected behavior: [What you expected to happen]
- Redirection should send user to show view
- Notification Email sent should be display
Actual behavior: [What actually happened]
- Redirection should send user to show view
- Notification Email sent should be display
- Notification with message that
Element Successfully Createdis displayed
In this case, i was expecting that the Element Successfully Created notification was overridden for the behavior in the block in the function onSubmitSuccess
In the base code in the FormController.js line 65 starts the function submitCreation and after the cancel default action the only thing that is cancelled is the redirection as you can see in the source code :
.then(entry => view.onSubmitSuccess() && this.$injector.invoke(
view.onSubmitSuccess(),
view,
{ $event, entity, entry, route, controller: this, form: this.form, progression, notification }
))
.then(customHandlerReturnValue => (customHandlerReturnValue === false) ?
new Promise(resolve => resolve()) :
$state.go(this.$state.get(route), { entity: entity.name(), id: entry.identifierValue })
)
.then(() => progression.done())
.then(() => $translate('CREATION_SUCCESS'))
.then(text => notification.log(text, { addnCls: 'humane-flatty-success' }))
Metadata
Metadata
Assignees
Labels
No labels