create and continue

This commit is contained in:
Javi Gallego 2017-01-24 07:57:13 +01:00
parent b4cf63b8fb
commit a2ff16b9a2
2 changed files with 17 additions and 4 deletions

View File

@ -14,7 +14,8 @@
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Crear"></vn-submit>
<vn-submit label="Crear y continuar"></vn-submit>
<vn-button label="Crear" ng-click="create.create()"></vn-button>
</vn-button-bar>
</form>
</div>

View File

@ -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);