Fixed a few search related bugs based on PR review feedback

This commit is contained in:
Michael Abashian 2017-01-12 10:38:40 -05:00
parent 46491a59e6
commit 18fcfee96d
2 changed files with 11 additions and 4 deletions

View File

@ -1830,7 +1830,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
// smart-search directive
html += `
<div
ng-hide="${itm}.length === 0 && (${collection.iterator}_searchTags | isEmpty)">
ng-hide="${itm}.length === 0 && (searchTags | isEmpty)">
<smart-search
django-model="${itm}"
search-size="${width}"
@ -1855,7 +1855,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += `
<div
class="row"
ng-show="${itm}.length === 0 && !(${collection.iterator}_searchTags | isEmpty)">
ng-show="${itm}.length === 0 && !(searchTags | isEmpty)">
<div class="col-lg-12 List-searchNoResults">
No records matched your search.
</div>
@ -1865,7 +1865,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
// Show the "no items" box when loading is done and the user isn't actively searching and there are no results
var emptyListText = (collection.emptyListText) ? collection.emptyListText : i18n._("PLEASE ADD ITEMS TO THIS LIST");
html += `<div ng-hide="is_superuser">`;
html += `<div class="List-noItems" ng-show="${itm}.length === 0 && (${collection.iterator}_searchTags | isEmpty)"> ${emptyListText} </div>`;
html += `<div class="List-noItems" ng-show="${itm}.length === 0 && (searchTags | isEmpty)"> ${emptyListText} </div>`;
html += '</div>';
html += `

View File

@ -85,12 +85,19 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
else {
encodeParams.searchTerm = true;
}
removed = qs.encodeParam(encodeParams);
}
else {
removed = setDefaults(tagToRemove);
}
removed = qs.encodeParam(encodeParams);
}
_.each(removed, (value, key) => {
if (Array.isArray(queryset[key])){
_.remove(queryset[key], (item) => item === value);
// If the array is now empty, remove that key
if(queryset[key].length === 0) {
delete queryset[key];
}
}
else {
delete queryset[key];