marmelab / ng-admin

Add an AngularJS admin GUI to any RESTful API
http://ng-admin-book.marmelab.com/
MIT License
3.95k stars 728 forks source link

Previous state in onSubmitSuccess #1371

Open tomy2105 opened 6 years ago

tomy2105 commented 6 years ago

Has been mentioned long ago in https://github.com/marmelab/ng-admin/pull/898.

It would be nice if previous state was available in onSubmitSuccess so one can redirect to (e.g list page) with correct pagination and filters.

As stated by @windmaomao in mentioned comment, something like this would be nice

        editionView.onSubmitSuccess(['previousState', 'progression', 'notification', '$state', 'entry', 'entity', function(previousState, progression, notification, $state, entry, entity) {
            // stop the progress bar
            progression.done();
            // add a notification
            notification.log(`Element #${entry._identifierValue} successfully edited.`, { addnCls: 'humane-flatty-success' });
            // redirect to the list view
            $state.go(previousState.name, previousState.params);
            // cancel the default action (redirect to the edition view)
            return false;
        }])
tomy2105 commented 6 years ago

Have fix for this but since it depends on https://github.com/marmelab/ng-admin/pull/1361 and https://github.com/marmelab/ng-admin/pull/1362 I'll submit pull when those two are merged.