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}; } } onClick(event) { if (event.defaultPrevented) event.stopImmediatePropagation(); } openSummary(client, event) { event.preventDefault(); this.clientSelected = client; this.$.dialogSummaryClient.show(); } filterTickets(client, event) { let state = `ticket.index`; let params = {q: `{"clientFk": ${client.id}}`}; event.preventDefault(); this.$state.go(state, params); } } Controller.$inject = ['$scope', '$state']; ngModule.component('vnClientIndex', { template: require('./index.html'), controller: Controller });