salix/client/client/src/descriptor/index.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-06-03 11:01:47 +00:00
import ngModule from '../module';
2018-05-23 12:26:51 +00:00
class Controller {
constructor($http, $state) {
this.$state = $state;
this.$http = $http;
}
_getClientDebt(clientFk) {
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
.then(response => {
this.clientDebt = response.data.debt;
});
}
_getClient(clientFk) {
this.$http.get(`/client/api/Clients/${clientFk}/card`)
.then(response => {
Object.assign(this.client, response.data);
});
}
goToClientTickets() {
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
}
$onChanges(changes) {
if (changes.client && this.client) {
this._getClient(this.client.id);
this._getClientDebt(this.client.id);
}
}
}
2018-05-31 06:57:25 +00:00
Controller.$inject = ['$http', '$state'];
ngModule.component('vnClientDescriptor', {
2018-05-23 12:26:51 +00:00
template: require('./index.html'),
bindings: {
client: '<'
},
2018-05-23 12:26:51 +00:00
controller: Controller
2017-06-03 11:01:47 +00:00
});