link fields filters fix

This commit is contained in:
yuri
2015-05-20 12:02:07 +03:00
parent deaa3f3f73
commit d17257fc95
6 changed files with 50 additions and 33 deletions
@@ -33,19 +33,10 @@ Espo.define('Views.Fields.AssignedUser', 'Views.Fields.UserWithAvatar', function
getSelectBoolFilterList: function () {
if (this.assignmentPermission == 'team') {
return {'onlyMyTeam': true};
return ['onlyMyTeam'];
}
},
getAutocompleteUrl: function () {
var url = Dep.prototype.getAutocompleteUrl.call(this);
if (this.assignmentPermission == 'team') {
url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=onlyMyTeam';
}
return url;
},
});
});
@@ -62,7 +62,7 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) {
getSelectBoolFilterList: function () {},
getPrimaryFilterName: function () {},
getSelectPrimaryFilterName: function () {},
setup: function () {
this.nameHashName = this.name + 'Names';
@@ -94,7 +94,7 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) {
createButton: this.mode != 'search',
filters: this.getSelectFilters(),
boolFilterList: this.getSelectBoolFilterList(),
primaryFilterName: this.getPrimaryFilterName(),
primaryFilterName: this.getSelectPrimaryFilterName(),
multiple: true
}, function (dialog) {
dialog.render();
@@ -118,7 +118,18 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) {
},
getAutocompleteUrl: function () {
return this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var boolList = this.getSelectBoolFilterList();
if (boolList) {
boolList.forEach(function(item) {
url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item;
}, this);
}
var primary = this.getSelectPrimaryFilterName();
if (primary) {
url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary;
}
return url;
},
afterRender: function () {
@@ -60,7 +60,7 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) {
getSelectBoolFilterList: function () {},
getPrimaryFilterName: function () {},
getSelectPrimaryFilterName: function () {},
setup: function () {
this.nameName = this.name + 'Name';
@@ -90,7 +90,7 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) {
createButton: this.mode != 'search',
filters: this.getSelectFilters(),
boolFilterList: this.getSelectBoolFilterList(),
primaryFilterName: this.getPrimaryFilterName(),
primaryFilterName: this.getSelectPrimaryFilterName(),
}, function (dialog) {
dialog.render();
Espo.Ui.notify(false);
@@ -116,7 +116,18 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) {
},
getAutocompleteUrl: function () {
return this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var boolList = this.getSelectBoolFilterList();
if (boolList) {
boolList.forEach(function(item) {
url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item;
}, this);
}
var primary = this.getSelectPrimaryFilterName();
if (primary) {
url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary;
}
return url;
},
afterRender: function () {
+14 -3
View File
@@ -59,7 +59,7 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) {
getSelectBoolFilterList: function () {},
getPrimaryFilterName: function () {},
getSelectPrimaryFilterName: function () {},
setup: function () {
this.nameName = this.name + 'Name';
@@ -79,7 +79,7 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) {
createButton: this.mode != 'search',
filters: this.getSelectFilters(),
boolFilterList: this.getSelectBoolFilterList(),
primaryFilterName: this.getPrimaryFilterName()
primaryFilterName: this.getSelectPrimaryFilterName()
}, function (view) {
view.render();
this.notify(false);
@@ -125,7 +125,18 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) {
},
getAutocompleteUrl: function () {
return this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
var boolList = this.getSelectBoolFilterList();
if (boolList) {
boolList.forEach(function(item) {
url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=' + item;
}, this);
}
var primary = this.getSelectPrimaryFilterName();
if (primary) {
url += '&where%5B0%5D%5Btype%5D=primary&where%5B0%5D%5Bvalue%5D=' + primary;
}
return url;
},
afterRender: function () {
+1 -12
View File
@@ -30,21 +30,10 @@ Espo.define('Views.Fields.Teams', 'Views.Fields.LinkMultiple', function (Dep) {
getSelectBoolFilterList: function () {
if (this.assignmentPermission == 'team' || this.assignmentPermission == 'no') {
return {'onlyMy': true};
return ['onlyMy'];
}
},
getAutocompleteUrl: function () {
var url = Dep.prototype.getAutocompleteUrl.call(this);
if (this.assignmentPermission == 'team' || this.assignmentPermission == 'no') {
url += '&where%5B0%5D%5Btype%5D=bool&where%5B0%5D%5Bvalue%5D%5B%5D=onlyMy';
}
return url;
},
});
});
@@ -50,7 +50,7 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
setup: function () {
this.filters = this.options.filters || {};
this.boolFilterList = this.options.boolFilterList || {};
this.boolFilterList = this.options.boolFilterList || [];
this.primaryFilterName = this.options.primaryFilterName || null;
if ('multiple' in this.options) {
@@ -122,7 +122,11 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
searchManager.setAdvanced(this.filters);
}
if (this.boolFilterList) {
searchManager.setBool(this.boolFilterList);
var d = {};
this.boolFilterList.forEach(function (item) {
d[item] = true;
});
searchManager.setBool(d);
}
if (this.primaryFilterName) {
searchManager.setPrimary(this.primaryFilterName);