dev/user-interface#49 SearchKit default label
authorcolemanw <coleman@civicrm.org>
Tue, 12 Dec 2023 17:29:11 +0000 (12:29 -0500)
committercolemanw <coleman@civicrm.org>
Tue, 12 Dec 2023 17:29:11 +0000 (12:29 -0500)
ext/search_kit/Civi/Search/Admin.php
ext/search_kit/ang/crmSearchAdmin.module.js
ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js

index 14e4adc53990768c5312bbfa33ff3d95dca4a43e..bb4535b6eeec019f6c914e2e5cad7cad092506fc 100644 (file)
@@ -46,7 +46,6 @@ class Admin {
       'defaultPagerSize' => (int) \Civi::settings()->get('default_pager_size'),
       'defaultDisplay' => SearchDisplay::getDefault(FALSE)->setSavedSearch(['id' => NULL])->execute()->first(),
       'modules' => \CRM_Core_BAO_Managed::getBaseModules(),
-      'defaultContactType' => \CRM_Contact_BAO_ContactType::basicTypeInfo()['Individual']['name'] ?? NULL,
       'defaultDistanceUnit' => \CRM_Utils_Address::getDefaultDistanceUnit(),
       'jobFrequency' => \Civi\Api4\Job::getFields()
         ->addWhere('name', '=', 'run_frequency')
@@ -56,6 +55,7 @@ class Admin {
         ->addSelect('id', 'label', 'color', 'is_selectable', 'description')
         ->addWhere('used_for', 'CONTAINS', 'civicrm_saved_search')
         ->execute(),
+      'myName' => \CRM_Core_Session::singleton()->getLoggedInContactDisplayName(),
     ];
     $perms = \Civi\Api4\Permission::get()
       ->addWhere('group', 'IN', ['civicrm', 'cms'])
index c1c8f9fbcf1180d98a9be1bbb14a3298d225d002..00bbfadee40d1d660479d5d48588a0c0b42fe3f2 100644 (file)
@@ -88,7 +88,7 @@
       // Changing entity will refresh the angular page
       $scope.$watch('$ctrl.savedSearch.api_entity', function(newEntity, oldEntity) {
         if (newEntity && oldEntity && newEntity !== oldEntity) {
-          $location.url('/create/' + newEntity + (ctrl.savedSearch.label ? '?label=' + ctrl.savedSearch.label : ''));
+          $location.url('/create/' + newEntity + ($routeParams.label ? '?label=' + $routeParams.label : ''));
         }
       });
     })
index 0f551306111944a9f266646eab7599cd7ffa90e2..9f0062392c7e9d65fc5b2a56aab7c130c4562bd0 100644 (file)
             defaults[param] = [];
           }
         });
-        // Default to Individuals
-        if (this.savedSearch.api_entity === 'Contact' && CRM.crmSearchAdmin.defaultContactType) {
-          defaults.where.push(['contact_type:name', '=', CRM.crmSearchAdmin.defaultContactType]);
-        }
 
         $scope.$bindToRoute({
           param: 'params',
           default: defaults
         });
 
+        // Set default label
+        ctrl.savedSearch.label = ts('%1 Search by %2', {
+          1: searchMeta.getEntity(ctrl.savedSearch.api_entity).title,
+          2: CRM.crmSearchAdmin.myName
+        });
         $scope.$bindToRoute({
           param: 'label',
           expr: '$ctrl.savedSearch.label',
           format: 'raw',
-          default: ''
+          default: ctrl.savedSearch.label
         });
       }