From 4736288b5ccaa24d21c61f53ebe7f5a904ac80ef Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 27 May 2021 20:26:30 -0400 Subject: [PATCH] SearchKit - Organize main entity selector with primary entities first Adds a collapsed optgroup for secondary entities so they are available but not as prominent as the commonly-searched primary entities. --- .../crmSearchAdmin.component.js | 19 +++++++++++++------ .../ang/crmSearchAdmin/crmSearchAdmin.html | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js index e74f79a6d0..75373b9b15 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js @@ -30,12 +30,6 @@ {k: 'INNER', v: ts('With (required)')}, {k: 'EXCLUDE', v: ts('Without')}, ]; - // Try to create a sensible list of entities one might want to search for, - // excluding those whos primary purpose is to provide joins or option lists to other entities - var primaryEntities = _.filter(CRM.crmSearchAdmin.schema, function(entity) { - return !_.includes(entity.type, 'EntityBridge') && !_.includes(entity.type, 'OptionList'); - }); - $scope.entities = formatForSelect2(primaryEntities, 'name', 'title_plural', ['description', 'icon']); $scope.getEntity = searchMeta.getEntity; $scope.getField = searchMeta.getField; this.perm = { @@ -63,6 +57,19 @@ }); } + var primaryEntities = _.filter(CRM.crmSearchAdmin.schema, function(entity) { + return entity.searchable === 'primary' && !_.includes(entity.type, 'EntityBridge'); + }); + var secondaryEntities = _.filter(CRM.crmSearchAdmin.schema, function(entity) { + return entity.searchable === 'secondary' && !_.includes(entity.type, 'EntityBridge'); + }); + $scope.mainEntitySelect = formatForSelect2(primaryEntities, 'name', 'title_plural', ['description', 'icon']); + $scope.mainEntitySelect.push({ + text: ts('More...'), + description: ts('Other less-commonly searched entities'), + children: formatForSelect2(secondaryEntities, 'name', 'title_plural', ['description', 'icon']) + }); + $scope.$watchCollection('$ctrl.savedSearch.api_params.select', onChangeSelect); $scope.$watch('$ctrl.savedSearch.api_params.where', onChangeFilters, true); diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.html b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.html index ac8dc8a689..db7c24aa50 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.html +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.html @@ -18,7 +18,7 @@
- +