Search ext: Ensure all entities have titlePlural to fix sort/display
authorColeman Watts <coleman@civicrm.org>
Fri, 9 Oct 2020 21:12:57 +0000 (17:12 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 9 Oct 2020 21:12:57 +0000 (17:12 -0400)
Civi/Api4/Action/Entity/Get.php
ext/search/CRM/Search/Page/Ang.php
ext/search/ang/search/crmSearchActions/crmSearchActionUpdate.html

index 044105e4e5a639afd7395a160301dff0e1d3d31f..2d14f325be91559b8b8504a986cad93c7e9454ff 100644 (file)
@@ -20,6 +20,7 @@
 namespace Civi\Api4\Action\Entity;
 
 use Civi\Api4\CustomGroup;
+use Civi\Api4\Service\Schema\Joinable\CustomGroupJoinable;
 
 /**
  * Get the names & docblocks of all APIv4 entities.
@@ -91,10 +92,12 @@ class Get extends \Civi\Api4\Generic\BasicGetAction {
       ->execute();
     foreach ($customEntities as $customEntity) {
       $fieldName = 'Custom_' . $customEntity['name'];
+      $baseEntity = '\Civi\Api4\\' . CustomGroupJoinable::getEntityFromExtends($customEntity['extends']);
       $entities[$fieldName] = [
         'name' => $fieldName,
         'title' => $customEntity['title'],
-        'description' => 'Custom group - extends ' . $customEntity['extends'],
+        'titlePlural' => $customEntity['title'],
+        'description' => ts('Custom group for %1', [1 => $baseEntity::getInfo()['titlePlural']]),
         'see' => [
           'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets',
           '\\Civi\\Api4\\CustomGroup',
index 0c9c228f21635b92fde815c23eeab4624191f656..22cab1dcfabc6e89bfecc4a471ed6c3f84353b74 100644 (file)
@@ -99,8 +99,6 @@ class CRM_Search_Page_Ang extends CRM_Core_Page {
         if ($loadOptions) {
           $entity['optionsLoaded'] = TRUE;
         }
-        // Because multivalue custom pseudo-entities don't have titlePlural
-        $entity['titlePlural'] = $entity['titlePlural'] ?? $entity['title'];
         $entity['fields'] = civicrm_api4($entity['name'], 'getFields', [
           'select' => $getFields,
           'where' => [['permission', 'IS NULL']],
index 63178a0baed16f857e05bcda12abba5cf2ddc74a..fac9c10af20efc54027d5e1c7ccc7339480e31ff 100644 (file)
@@ -10,7 +10,7 @@
     <hr />
     <div class="buttons pull-right">
       <button type="button" ng-click="$ctrl.cancel()" class="btn btn-danger">{{:: ts('Cancel') }}</button>
-      <button ng-click="$ctrl.save()" class="btn btn-primary" ng-disabled="!$ctrl.values.length">{{:: ts('Update %1 %2', {1: model.ids.length, 2: $ctrl.entity.title}) }}</button>
+      <button ng-click="$ctrl.save()" class="btn btn-primary" ng-disabled="!$ctrl.values.length">{{:: ts('Update %1 %2', {1: model.ids.length, 2: (model.ids.length === 1 ? $ctrl.entity.title : $ctrl.entity.titlePlural)}) }}</button>
     </div>
   </div>
 </div>