2018-03-12 13:02:29 +00:00
|
|
|
import ngModule from '../module';
|
2018-11-08 08:20:06 +00:00
|
|
|
import './style.scss';
|
2018-03-12 13:02:29 +00:00
|
|
|
|
|
|
|
export default class Controller {
|
2019-01-24 07:21:00 +00:00
|
|
|
constructor($scope, $state, $stateParams) {
|
2018-10-30 12:58:02 +00:00
|
|
|
this.$ = $scope;
|
2019-01-24 07:21:00 +00:00
|
|
|
this.$stateParams = $stateParams;
|
2018-11-08 08:20:06 +00:00
|
|
|
this.$state = $state;
|
2018-10-30 12:58:02 +00:00
|
|
|
this.selectedTicket = null;
|
2018-11-08 08:20:06 +00:00
|
|
|
this.moreOptions = [
|
2019-02-06 08:55:17 +00:00
|
|
|
{callback: () => {
|
|
|
|
this.goToTurns('ticket.weekly');
|
|
|
|
}, name: 'Turns', always: true},
|
2018-11-08 08:20:06 +00:00
|
|
|
];
|
2018-12-10 13:14:40 +00:00
|
|
|
|
2019-01-24 07:21:00 +00:00
|
|
|
if (!$stateParams.q) {
|
2019-01-23 11:30:32 +00:00
|
|
|
let today = new Date();
|
|
|
|
let offset = today.getTimezoneOffset() * 60000;
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
today.setTime(today.getTime() - offset);
|
|
|
|
|
|
|
|
let tomorrow = new Date(today);
|
|
|
|
tomorrow.setHours(23, 59, 59, 999);
|
|
|
|
tomorrow.setTime(tomorrow.getTime() - offset);
|
2018-12-10 13:14:40 +00:00
|
|
|
|
2019-01-23 11:30:32 +00:00
|
|
|
let sixDays = new Date(today);
|
|
|
|
sixDays.setDate(today.getDate() + 6);
|
|
|
|
sixDays.setHours(23, 59, 59, 999);
|
|
|
|
sixDays.setTime(sixDays.getTime() - offset);
|
2018-12-12 13:52:20 +00:00
|
|
|
|
2019-01-23 11:30:32 +00:00
|
|
|
this.filter = {mine: true, from: today, to: sixDays};
|
|
|
|
}
|
2019-01-22 15:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$postLink() {
|
2019-01-23 11:30:32 +00:00
|
|
|
if (this.filter)
|
|
|
|
this.onSearch(this.filter);
|
2018-12-19 07:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onSearch(params) {
|
|
|
|
if (params)
|
|
|
|
this.$.model.applyFilter(null, params);
|
|
|
|
else
|
|
|
|
this.$.model.clear();
|
2018-11-08 08:20:06 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 08:55:17 +00:00
|
|
|
goToLines(ticketFk) {
|
|
|
|
this.$state.go('ticket.card.lines', {id: ticketFk});
|
|
|
|
}
|
|
|
|
|
2018-11-08 08:20:06 +00:00
|
|
|
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);
|
2018-04-10 05:48:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
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';
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-08-23 08:08:06 +00:00
|
|
|
|
2018-12-21 06:53:04 +00:00
|
|
|
stateColor(ticket) {
|
|
|
|
if (ticket.alertLevelCode === 'OK')
|
|
|
|
return 'alertOk';
|
|
|
|
else if (ticket.alertLevelCode === 'FREE')
|
|
|
|
return 'alertFree';
|
|
|
|
else if (ticket.alertLevel === 1)
|
|
|
|
return 'alert1';
|
|
|
|
else if (ticket.alertLevel === 0)
|
|
|
|
return 'alert0';
|
|
|
|
}
|
|
|
|
|
2018-07-26 10:06:53 +00:00
|
|
|
showDescriptor(event, clientFk) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
2018-10-30 12:58:02 +00:00
|
|
|
this.$.descriptor.clientFk = clientFk;
|
|
|
|
this.$.descriptor.parent = event.target;
|
|
|
|
this.$.descriptor.show();
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
preview(event, ticket) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
2018-10-30 12:58:02 +00:00
|
|
|
this.selectedTicket = ticket;
|
|
|
|
this.$.summary.show();
|
2018-04-19 12:56:05 +00:00
|
|
|
}
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
2019-01-24 07:21:00 +00:00
|
|
|
Controller.$inject = ['$scope', '$state', '$stateParams'];
|
2018-03-12 13:02:29 +00:00
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
ngModule.component('vnTicketIndex', {
|
|
|
|
template: require('./index.html'),
|
2018-03-12 13:02:29 +00:00
|
|
|
controller: Controller
|
|
|
|
});
|