Merge pull request #32 from alasdaircr/ArrayFilters

Allow filtering array field types. fixes #17
This commit is contained in:
Yuri Kuznetsov
2015-01-08 12:18:36 +02:00
3 changed files with 20 additions and 2 deletions
@@ -290,7 +290,7 @@ class Base
$a = $this->getWherePart($i);
foreach ($a as $left => $right) {
if (!empty($right)) {
$arr[$left] = $right;
$arr[] = array($left => $right);
}
}
}
@@ -15,7 +15,7 @@
"hidden": true
}
],
"filter": false,
"filter": true,
"notCreatable": false,
"fieldDefs":{
"type":"jsonArray"
+18
View File
@@ -201,6 +201,24 @@ Espo.define('Views.Fields.Array', 'Views.Fields.Enum', function (Dep) {
return data;
},
fetchSearch: function () {
var field = this.name;
var arr = [];
$.each(this.$el.find('[name="' + this.name + '"]').find('option:selected'), function (i, el) {
arr.push( {type: 'like', field: field, value: "%" + $(el).val() + "%"} );
});
if (arr.length == 0) {
return false;
}
var data = {
type: 'or',
value: arr
};
return data;
},
validateRequired: function () {
if (this.params.required || this.model.isRequired(this.name)) {
var value = this.model.get(this.name);