From a2ff16b9a24bfe137bbce647dfcc175f15307c5e Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 24 Jan 2017 07:57:13 +0100 Subject: [PATCH] create and continue --- @salix/crud/src/client/create/index.html | 3 ++- @salix/crud/src/client/create/index.js | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) 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);