52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
export default class Controller {
|
|
constructor($scope, $stateParams) {
|
|
this.$ = $scope;
|
|
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();
|
|
}
|
|
}
|
|
Controller.$inject = ['$scope', '$stateParams'];
|
|
|
|
ngModule.component('vnClientIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|