salix/modules/client/front/credit/create/index.js

52 lines
1.1 KiB
JavaScript

import ngModule from '../../module';
class Controller {
constructor($http, $scope, $state) {
this.$http = $http;
this.$scope = $scope;
this.$state = $state;
}
onSubmit() {
this.$http.get(`/client/api/Recoveries/${this.$state.params.id}/hasActiveRecovery`).then(res => {
let activeRecovery = res.data;
if (activeRecovery)
this.$scope.confirmation.show();
else
this.addCredit();
});
}
cancel() {
this.goToIndex();
}
returnDialog(response) {
if (response === 'ACCEPT')
this.addCredit();
}
goToIndex() {
this.$state.go('client.card.credit.index');
}
addCredit() {
this.$scope.watcher.submit().then(
() => {
this.goToIndex();
}
);
}
}
Controller.$inject = ['$http', '$scope', '$state'];
ngModule.component('vnClientCreditCreate', {
template: require('./index.html'),
controller: Controller,
bindings: {
client: '<'
}
});