2019-07-29 11:12:36 +00:00
|
|
|
import ngModule from '../../module';
|
2018-10-30 13:57:22 +00:00
|
|
|
|
|
|
|
export default class Controller {
|
2019-05-21 07:03:57 +00:00
|
|
|
constructor($scope, vnApp, $translate, $http) {
|
|
|
|
this.$ = $scope;
|
2018-11-02 14:44:27 +00:00
|
|
|
this.vnApp = vnApp;
|
2019-05-21 07:03:57 +00:00
|
|
|
this.$translate = $translate;
|
|
|
|
this.$http = $http;
|
2018-11-02 14:44:27 +00:00
|
|
|
|
2018-10-30 13:57:22 +00:00
|
|
|
this.ticketSelected = null;
|
2018-11-02 14:44:27 +00:00
|
|
|
|
2018-10-30 13:57:22 +00:00
|
|
|
this.weekdays = [
|
|
|
|
{id: 0, name: 'Monday'},
|
|
|
|
{id: 1, name: 'Tuesday'},
|
|
|
|
{id: 2, name: 'Wednesday'},
|
|
|
|
{id: 3, name: 'Thursday'},
|
|
|
|
{id: 4, name: 'Friday'},
|
|
|
|
{id: 5, name: 'Saturday'},
|
|
|
|
{id: 6, name: 'Sunday'}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-05-21 07:03:57 +00:00
|
|
|
onWeekdayUpdate(ticketFk, weekDay) {
|
|
|
|
const params = {ticketFk, weekDay};
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.patch('TicketWeeklies/', params).then(() => {
|
2019-05-21 07:03:57 +00:00
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
|
|
});
|
2018-10-30 13:57:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 07:03:57 +00:00
|
|
|
deleteWeekly(index) {
|
|
|
|
this.ticketIndex = index;
|
|
|
|
this.$.deleteWeekly.show();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSearch(params) {
|
|
|
|
if (params)
|
|
|
|
this.$.model.applyFilter(null, params);
|
|
|
|
else
|
|
|
|
this.$.model.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-30 13:57:22 +00:00
|
|
|
showClientDescriptor(event, clientFk) {
|
2019-05-21 07:03:57 +00:00
|
|
|
this.$.clientDescriptor.clientFk = clientFk;
|
|
|
|
this.$.clientDescriptor.parent = event.target;
|
|
|
|
this.$.clientDescriptor.show();
|
2018-10-30 13:57:22 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
showTicketDescriptor(event, ticketFk) {
|
2019-05-21 07:03:57 +00:00
|
|
|
this.$.ticketDescriptor.ticketFk = ticketFk;
|
|
|
|
this.$.ticketDescriptor.parent = event.target;
|
|
|
|
this.$.ticketDescriptor.show();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
showWorkerDescriptor(event, workerFk) {
|
|
|
|
this.$.workerDescriptor.workerFk = workerFk;
|
|
|
|
this.$.workerDescriptor.parent = event.target;
|
|
|
|
this.$.workerDescriptor.show();
|
2018-10-30 13:57:22 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDescriptorLoad() {
|
2019-05-21 07:03:57 +00:00
|
|
|
this.$.popover.relocate();
|
2018-10-30 13:57:22 +00:00
|
|
|
}
|
|
|
|
|
2018-11-20 15:33:09 +00:00
|
|
|
preventNavigation(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
2019-05-21 07:03:57 +00:00
|
|
|
returnDialog(response) {
|
|
|
|
const ticket = this.$.model.data[this.ticketIndex];
|
2019-10-30 15:57:14 +00:00
|
|
|
if (response === 'accept') {
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.delete(`TicketWeeklies/${ticket.ticketFk}`).then(() => {
|
2019-05-21 07:03:57 +00:00
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
|
|
this.$.model.remove(this.ticketIndex);
|
|
|
|
});
|
|
|
|
}
|
2018-10-30 13:57:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 07:03:57 +00:00
|
|
|
|
|
|
|
Controller.$inject = ['$scope', 'vnApp', '$translate', '$http'];
|
2018-10-30 13:57:22 +00:00
|
|
|
|
2019-07-29 11:12:36 +00:00
|
|
|
ngModule.component('vnTicketWeeklyIndex', {
|
2018-10-30 13:57:22 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|