diff --git a/@salix/crud/src/client/create/index.html b/@salix/crud/src/client/create/index.html index 95f373f8d..e31fcf7de 100644 --- a/@salix/crud/src/client/create/index.html +++ b/@salix/crud/src/client/create/index.html @@ -14,7 +14,8 @@ - + + diff --git a/@salix/crud/src/client/create/index.js b/@salix/crud/src/client/create/index.js index 9f0bd7479..2c7d51c14 100644 --- a/@salix/crud/src/client/create/index.js +++ b/@salix/crud/src/client/create/index.js @@ -5,14 +5,26 @@ export const NAME = "vnClientCreate"; export const COMPONENT = { template: template, controllerAs: "create", - controller: function($http, $state) { + controller: function($http, $state, $window) { this.submit = function() { + this.create('clientCard.basicData'); + }; + + this.create = state => { this.model.active = true; $http.post('/client/api/Clients', this.model).then( - json => $state.go('clientCard.basicData', {id: json.data.id}) + json => this.navigate(json.data.id, state) ); }; + + this.navigate = (id, state) => { + if (state) + $state.go(state, {id: id}); + else + $window.history.back(); + }; } + }; -COMPONENT.controller.$inject = ['$http', '$state']; +COMPONENT.controller.$inject = ['$http', '$state', '$window']; module.component(NAME, COMPONENT);