SearchKit - Only show tags filter if tags exist
authorColeman Watts <coleman@civicrm.org>
Thu, 28 Oct 2021 13:50:36 +0000 (09:50 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 31 Oct 2021 15:10:31 +0000 (11:10 -0400)
Remove clutter if an org does not use tags.
Also removes an unused copy-pasted function.

ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.component.js
ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.html

index 19dc5a6567366b1677162ef0a4ab3b2db0ccb84e..6509a165694af1908ceced680f17825d7bb65dd2 100644 (file)
         return {results: formatForSelect2(CRM.crmSearchAdmin.tags, 'id', 'name', ['color', 'description'])};
       };
 
-      this.getEntities = function() {
-        return {results: formatForSelect2(CRM.crmSearchAdmin.tags, 'id', 'name', ['color', 'description'])};
-      };
-
       function buildDisplaySettings() {
         ctrl.display = {
           type: 'table',
index 473f38b89e40f020a8d10bde942c34b85cd7abff..9bab8797707919d5f1a09badd2fec74acdbffbae 100644 (file)
@@ -4,7 +4,9 @@
     <input class="form-control" type="search" ng-model="$ctrl.filters.label" placeholder="{{:: ts('Filter by label...') }}">
     <input class="form-control" type="search" ng-model="$ctrl.filters['created_id.display_name,modified_id.display_name']" placeholder="{{:: ts('Filter by author...') }}">
     <input class="form-control collapsible-optgroups" ng-model="$ctrl.filters.api_entity" ng-list crm-ui-select="{multiple: true, data: $ctrl.entitySelect, placeholder: ts('Filter by entity...')}">
-    <input class="form-control" ng-model="$ctrl.filters.tags" ng-list crm-ui-select="{multiple: true, data: $ctrl.getTags, placeholder: ts('Filter by tags...')}">
+    <span ng-if="$ctrl.getTags().results.length">
+      <input class="form-control" ng-model="$ctrl.filters.tags" ng-list crm-ui-select="{multiple: true, data: $ctrl.getTags, placeholder: ts('Filter by tags...')}">
+    </span>
     <a class="btn btn-primary pull-right" href="#/create/Contact/">
       <i class="crm-i fa-plus"></i>
       {{:: ts('New Search') }}