import ngModule from '../module'; import './style.scss'; export default class Controller { constructor($scope, $state) { this.$ = $scope; this.$state = $state; this.selectedTicket = null; this.moreOptions = [ {callback: this.goToTurns, name: 'Turns', always: true}, ]; 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, 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); } 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'; } showDescriptor(event, clientFk) { event.preventDefault(); event.stopImmediatePropagation(); this.$.descriptor.clientFk = clientFk; this.$.descriptor.parent = event.target; this.$.descriptor.show(); } preview(event, ticket) { event.preventDefault(); event.stopImmediatePropagation(); this.selectedTicket = ticket; this.$.summary.show(); } } Controller.$inject = ['$scope', '$state']; ngModule.component('vnTicketIndex', { template: require('./index.html'), controller: Controller });