import ngModule from '../module'; export default class Controller { constructor($scope, $state) { this.$ = $scope; this.$state = $state; this.clientSelected = null; } exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) ? {id: value} : {name: {like: `%${value}%`}}; case 'phone': return { or: [ {phone: value}, {mobile: value} ] }; case 'name': case 'socialName': case 'city': return {[param]: {like: `%${value}%`}}; case 'id': case 'fi': case 'postcode': case 'email': case 'salesPersonFk': return {[param]: value}; } } openSummary(client, event) { if (event.defaultPrevented) return; event.preventDefault(); event.stopPropagation(); this.clientSelected = client; this.$.dialogSummaryClient.show(); } filterTickets(client, event) { if (event.defaultPrevented) return; event.preventDefault(); event.stopPropagation(); this.$state.go(`ticket.index`, {q: JSON.stringify({clientFk: client.id})}); } } Controller.$inject = ['$scope', '$state']; ngModule.component('vnClientIndex', { template: require('./index.html'), controller: Controller });