salix/modules/client/front/index/index.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-06-03 11:01:47 +00:00
import ngModule from '../module';
2017-06-03 11:01:47 +00:00
export default class Controller {
constructor($scope, $state) {
this.$ = $scope;
this.$state = $state;
this.clientSelected = null;
2017-07-03 12:23:53 +00:00
}
exprBuilder(param, value) {
switch (param) {
case 'search':
2018-07-03 15:41:41 +00:00
return /^\d+$/.test(value)
? {id: value}
2019-01-15 10:15:30 +00:00
: {name: {like: `%${value}%`}};
case 'phone':
return {
or: [
{phone: value},
{mobile: value}
]
};
case 'name':
case 'socialName':
case 'city':
2019-01-21 10:45:53 +00:00
return {[param]: {like: `%${value}%`}};
case 'id':
case 'fi':
case 'postcode':
case 'email':
case 'salesPersonFk':
return {[param]: value};
}
}
2019-02-21 09:10:38 +00:00
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'];
2017-06-03 11:01:47 +00:00
ngModule.component('vnClientIndex', {
template: require('./index.html'),
controller: Controller
2017-06-03 11:01:47 +00:00
});