salix/client/client/src/index/index.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

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;
this.find = function() {
2017-02-07 12:24:04 +00:00
var where = {};
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];
}
filter.params = undefined;
}
if (where) {
2017-02-07 12:24:04 +00:00
self.filter = where;
}
};
this.filter = {};
this.find();
}
};
COMPONENT.controller.$inject = ['$http'];
module.component(NAME, COMPONENT);