import ngModule from '../module'; export default class Controller { constructor($scope) { this.$ = $scope; this.ticketSelected = null; this.filter = { include: [ { relation: 'address', scope: { fields: ['provinceFk'], include: { relation: 'province', scope: { fields: ['name'] } } } }, { relation: 'warehouse', scope: { fields: ['name'] } }, { relation: 'agencyMode', scope: { fields: ['name'] } }, { relation: 'tracking', scope: { fields: ['stateFk'], include: { relation: 'state', scope: { fields: ['name'] } } } }, { relation: 'client', scope: { fields: ['salesPersonFk'], include: { relation: 'salesPerson', scope: { fields: ['name'] } } } } ], order: 'shipped DESC' }; } exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) ? {id: value} : {nickname: {regexp: value}}; case 'from': return {shipped: {gte: value}}; case 'to': return {shipped: {lte: value}}; case 'nickname': return {[param]: {regexp: value}}; case 'id': case 'clientFk': case 'agencyModeFk': case 'warehouseFk': return {[param]: value}; } } 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) { this.$.descriptor.clientFk = clientFk; this.$.descriptor.parent = event.target; this.$.descriptor.show(); event.preventDefault(); event.stopImmediatePropagation(); } onDescriptorLoad() { this.$.popover.relocate(); } preview(event, ticket) { event.preventDefault(); event.stopImmediatePropagation(); this.$.dialogSummaryTicket.show(); this.ticketSelected = ticket; } } Controller.$inject = ['$scope']; ngModule.component('vnTicketIndex', { template: require('./index.html'), controller: Controller });