create and continue
This commit is contained in:
parent
b4cf63b8fb
commit
a2ff16b9a2
|
@ -14,7 +14,8 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<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>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,14 +5,26 @@ export const NAME = "vnClientCreate";
|
||||||
export const COMPONENT = {
|
export const COMPONENT = {
|
||||||
template: template,
|
template: template,
|
||||||
controllerAs: "create",
|
controllerAs: "create",
|
||||||
controller: function($http, $state) {
|
controller: function($http, $state, $window) {
|
||||||
this.submit = function() {
|
this.submit = function() {
|
||||||
|
this.create('clientCard.basicData');
|
||||||
|
};
|
||||||
|
|
||||||
|
this.create = state => {
|
||||||
this.model.active = true;
|
this.model.active = true;
|
||||||
$http.post('/client/api/Clients', this.model).then(
|
$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);
|
module.component(NAME, COMPONENT);
|
||||||
|
|
Loading…
Reference in New Issue