118 lines
3.1 KiB
JavaScript
118 lines
3.1 KiB
JavaScript
import ngModule from '../module';
|
|
import './style.scss';
|
|
|
|
export default class Controller {
|
|
constructor($scope, $state, $stateParams) {
|
|
this.$ = $scope;
|
|
this.$stateParams = $stateParams;
|
|
this.$state = $state;
|
|
this.selectedTicket = null;
|
|
this.moreOptions = [
|
|
{callback: () => {
|
|
this.goToTurns('ticket.weekly');
|
|
}, name: 'Turns', always: true},
|
|
];
|
|
this.filter = {};
|
|
|
|
if (!$stateParams.q) {
|
|
let today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
let tomorrow = new Date(today);
|
|
tomorrow.setHours(23, 59, 59, 999);
|
|
|
|
let sixDays = new Date(today);
|
|
sixDays.setDate(today.getDate() + 6);
|
|
sixDays.setHours(23, 59, 59, 999);
|
|
|
|
this.filter = Object.assign(this.filter, {myTeam: true, from: today, to: sixDays});
|
|
}
|
|
}
|
|
|
|
$postLink() {
|
|
if (this.filter && this.filter != {})
|
|
this.onSearch(this.filter);
|
|
}
|
|
|
|
onSearch(params) {
|
|
if (params)
|
|
this.$.model.applyFilter(null, params);
|
|
else
|
|
this.$.model.clear();
|
|
}
|
|
|
|
goToLines(event, ticketFk) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
this.$state.go('ticket.card.sale', {id: ticketFk});
|
|
}
|
|
|
|
goToTurns() {
|
|
this.$state.go('ticket.weekly');
|
|
}
|
|
|
|
onMoreOpen() {
|
|
let options = this.moreOptions.filter(o => o.always || this.isChecked);
|
|
this.$.moreButton.data = options;
|
|
}
|
|
|
|
onMoreChange(callback) {
|
|
callback.call(this);
|
|
}
|
|
|
|
compareDate(date) {
|
|
let today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
let timeTicket = new Date(date);
|
|
timeTicket.setHours(0, 0, 0, 0);
|
|
|
|
let comparation = today - timeTicket;
|
|
|
|
if (comparation == 0)
|
|
return 'warning';
|
|
if (comparation < 0)
|
|
return 'success';
|
|
}
|
|
|
|
stateColor(ticket) {
|
|
if (ticket.alertLevelCode === 'OK')
|
|
return 'success';
|
|
else if (ticket.alertLevelCode === 'FREE')
|
|
return 'notice';
|
|
else if (ticket.alertLevel === 1)
|
|
return 'warning';
|
|
else if (ticket.alertLevel === 0)
|
|
return 'alert';
|
|
}
|
|
|
|
showClientDescriptor(event, clientFk) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
this.$.clientDescriptor.clientFk = clientFk;
|
|
this.$.clientDescriptor.parent = event.target;
|
|
this.$.clientDescriptor.show();
|
|
}
|
|
|
|
showWorkerDescriptor(event, userId) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
this.selectedWorker = userId;
|
|
this.$.workerDescriptor.parent = event.target;
|
|
this.$.workerDescriptor.show();
|
|
}
|
|
|
|
preview(event, ticket) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
this.selectedTicket = ticket;
|
|
this.$.summary.show();
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope', '$state', '$stateParams'];
|
|
|
|
ngModule.component('vnTicketIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|