2018-03-27 12:26:20 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
|
2018-04-05 09:09:22 +00:00
|
|
|
class Controller {
|
2019-01-22 09:04:42 +00:00
|
|
|
constructor($scope, $state, vnApp, $translate, $http) {
|
|
|
|
this.$http = $http;
|
2018-03-27 12:26:20 +00:00
|
|
|
this.$ = $scope;
|
|
|
|
this.$state = $state;
|
2018-04-05 09:09:22 +00:00
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$translate = $translate;
|
2018-03-27 12:26:20 +00:00
|
|
|
this.ticket = {
|
2018-05-31 09:52:39 +00:00
|
|
|
ticketFk: $state.params.id
|
2018-03-27 12:26:20 +00:00
|
|
|
};
|
2019-01-22 09:04:42 +00:00
|
|
|
this.params = {ticketFk: $state.params.id};
|
2018-03-27 12:26:20 +00:00
|
|
|
}
|
2019-01-22 09:04:42 +00:00
|
|
|
|
|
|
|
$onInit() {
|
|
|
|
this.getPickerDesignedState();
|
|
|
|
}
|
|
|
|
|
|
|
|
set stateFk(value) {
|
|
|
|
this.params.stateFk = value;
|
|
|
|
this.isPickerDesignedState = this.getIsPickerDesignedState(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
get stateFk() {
|
|
|
|
return this.params.stateFk;
|
|
|
|
}
|
|
|
|
|
|
|
|
set workerFk(value) {
|
|
|
|
this.params.workerFk = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
get workerFk() {
|
|
|
|
return this.params.workerFk;
|
|
|
|
}
|
|
|
|
|
|
|
|
getPickerDesignedState() {
|
|
|
|
let filter = {
|
|
|
|
where: {
|
|
|
|
code: 'PICKER_DESIGNED'
|
2018-03-27 12:26:20 +00:00
|
|
|
}
|
2019-01-22 09:04:42 +00:00
|
|
|
};
|
|
|
|
let json = encodeURIComponent(JSON.stringify(filter));
|
|
|
|
this.$http.get(`/api/States?filter=${json}`).then(res => {
|
|
|
|
if (res && res.data)
|
|
|
|
this.pickerDesignedState = res.data[0].id;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getIsPickerDesignedState(value) {
|
|
|
|
if (value == this.pickerDesignedState)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit() {
|
|
|
|
this.$http.post(`/api/TicketTrackings/changeState`, this.params).then(() => {
|
|
|
|
this.$.watcher.updateOriginalData();
|
|
|
|
this.card.reload();
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
|
|
this.$state.go('ticket.card.tracking.index');
|
|
|
|
});
|
2018-03-27 12:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-22 09:04:42 +00:00
|
|
|
Controller.$inject = ['$scope', '$state', 'vnApp', '$translate', '$http'];
|
2018-03-27 12:26:20 +00:00
|
|
|
|
|
|
|
ngModule.component('vnTicketTrackingEdit', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-05-08 07:30:55 +00:00
|
|
|
controller: Controller,
|
|
|
|
require: {
|
|
|
|
card: '^vnTicketCard'
|
|
|
|
}
|
2018-03-27 12:26:20 +00:00
|
|
|
});
|