2017-01-31 13:13:06 +00:00
|
|
|
import template from './index.html';
|
|
|
|
import {module} from '../module';
|
|
|
|
require('./style.css');
|
|
|
|
|
|
|
|
export const NAME = 'vnClientIndex';
|
|
|
|
export const COMPONENT = {
|
|
|
|
template: template,
|
|
|
|
controllerAs: 'search',
|
|
|
|
controller: function($http) {
|
2017-02-07 12:24:04 +00:00
|
|
|
var self = this;
|
2017-01-31 13:13:06 +00:00
|
|
|
this.find = function() {
|
2017-02-07 12:24:04 +00:00
|
|
|
var where = {};
|
2017-01-31 13:13:06 +00:00
|
|
|
var filter = this.filter;
|
|
|
|
var search = filter.search;
|
|
|
|
if (search)
|
|
|
|
where = {name: {ilike: search}};
|
|
|
|
|
|
|
|
var params = filter.params;
|
|
|
|
if (params) {
|
|
|
|
where = {};
|
|
|
|
let partials = {
|
|
|
|
alias: true,
|
|
|
|
name: true,
|
|
|
|
socialName: true,
|
|
|
|
city: true,
|
|
|
|
email: true
|
|
|
|
};
|
|
|
|
for (let param in params)
|
|
|
|
if (params[param]) {
|
|
|
|
if (partials[param])
|
|
|
|
where[param] = {ilike: params[param]};
|
|
|
|
else
|
2017-02-07 12:24:04 +00:00
|
|
|
where[param] = params[param];
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
|
|
|
filter.params = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (where) {
|
2017-02-07 12:24:04 +00:00
|
|
|
self.filter = where;
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
this.filter = {};
|
|
|
|
this.find();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
COMPONENT.controller.$inject = ['$http'];
|
|
|
|
module.component(NAME, COMPONENT);
|