86 lines
2.5 KiB
JavaScript
86 lines
2.5 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
export default class Controller {
|
|
constructor($scope, vnApp, $translate, $http) {
|
|
this.$ = $scope;
|
|
this.vnApp = vnApp;
|
|
this.$translate = $translate;
|
|
this.$http = $http;
|
|
|
|
this.ticketSelected = null;
|
|
|
|
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'}
|
|
];
|
|
}
|
|
|
|
onWeekdayUpdate(ticketFk, weekDay) {
|
|
const params = {ticketFk, weekDay};
|
|
this.$http.patch('TicketWeeklies/', params).then(() => {
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
});
|
|
}
|
|
|
|
deleteWeekly(index) {
|
|
this.ticketIndex = index;
|
|
this.$.deleteWeekly.show();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
showClientDescriptor(event, clientFk) {
|
|
this.$.clientDescriptor.clientFk = clientFk;
|
|
this.$.clientDescriptor.parent = event.target;
|
|
this.$.clientDescriptor.show();
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
showTicketDescriptor(event, ticketFk) {
|
|
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();
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
this.$.popover.relocate();
|
|
}
|
|
|
|
preventNavigation(event) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
returnDialog(response) {
|
|
const ticket = this.$.model.data[this.ticketIndex];
|
|
if (response === 'accept') {
|
|
this.$http.delete(`TicketWeeklies/${ticket.ticketFk}`).then(() => {
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
this.$.model.remove(this.ticketIndex);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope', 'vnApp', '$translate', '$http'];
|
|
|
|
ngModule.component('vnTicketWeeklyIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|