import ngModule from '../module'; import Section from 'salix/components/section'; export default class Controller extends Section { 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 'email': return {[param]: {like: `%${value}%`}}; case 'id': case 'fi': case 'postcode': 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})}); } } ngModule.component('vnClientIndex', { template: require('./index.html'), controller: Controller });