salix/client/ticket/src/index/index.js

74 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-03-12 13:02:29 +00:00
import ngModule from '../module';
import './style.scss';
2018-03-12 13:02:29 +00:00
export default class Controller {
constructor($scope, $state) {
this.$ = $scope;
this.$state = $state;
this.selectedTicket = null;
this.moreOptions = [
{callback: this.goToTurns, name: 'Turns', always: true},
];
2018-12-10 13:14:40 +00:00
let today = new Date();
let offset = today.getTimezoneOffset() * 60000;
today.setHours(0, 0, 0, 0);
today.setTime(today.getTime() - offset);
2018-12-12 13:52:20 +00:00
let tomorrow = new Date(today);
tomorrow.setHours(23, 59, 59, 59);
tomorrow.setTime(tomorrow.getTime() - offset);
this.filter = {myTeam: true, from: today, to: tomorrow};
}
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
showDescriptor(event, clientFk) {
event.preventDefault();
event.stopImmediatePropagation();
this.$.descriptor.clientFk = clientFk;
this.$.descriptor.parent = event.target;
this.$.descriptor.show();
}
2018-04-10 05:48:04 +00:00
2018-04-19 12:56:05 +00:00
preview(event, ticket) {
event.preventDefault();
event.stopImmediatePropagation();
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
Controller.$inject = ['$scope', '$state'];
2018-03-12 13:02:29 +00:00
ngModule.component('vnTicketIndex', {
template: require('./index.html'),
2018-03-12 13:02:29 +00:00
controller: Controller
});