Add weights to links on multipleRecordFieldsListing
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 31 Aug 2023 09:03:50 +0000 (21:03 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 4 Sep 2023 05:19:37 +0000 (17:19 +1200)
CRM/Custom/Page/AJAX.php
CRM/Profile/Page/MultipleRecordFieldsListing.php

index 5ddbb19ccd19426f7f86ceef8cdd57c72ddf884e..2deb349df6cc18b7e615b9a8c9daf976bdddef96 100644 (file)
@@ -93,7 +93,7 @@ class CRM_Custom_Page_AJAX {
   /**
    * Get list of Multi Record Fields.
    */
-  public static function getMultiRecordFieldList() {
+  public static function getMultiRecordFieldList(): void {
 
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(0, 10);
     $params['cid'] = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
@@ -118,7 +118,7 @@ class CRM_Custom_Page_AJAX {
       $obj->_DTparams['sort'] = $params['sortBy'];
     }
 
-    list($fields, $attributes) = $obj->browse();
+    [$fields, $attributes] = $obj->browse();
 
     // format params and add class attributes
     $fieldList = [];
index dd521bd1d7c0d9fa1bcedda16cd3ec8d7cc682b7..00e507f139cd5e7a880c449462d717071944ede0 100644 (file)
@@ -70,20 +70,23 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
       $links[CRM_Core_Action::VIEW] = [
         'name' => ts('View'),
         'title' => ts('View %1', [1 => $this->_customGroupTitle . ' record']),
+        'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::VIEW),
       ];
 
       $links[CRM_Core_Action::UPDATE] = [
         'name' => ts('Edit'),
         'title' => ts('Edit %1', [1 => $this->_customGroupTitle . ' record']),
+        'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::UPDATE),
       ];
 
       $links[CRM_Core_Action::DELETE] = [
         'name' => ts('Delete'),
         'title' => ts('Delete %1', [1 => $this->_customGroupTitle . ' record']),
+        'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::DELETE),
       ];
 
       // urls and queryStrings
-      if ($this->_pageViewType == 'profileDataView') {
+      if ($this->_pageViewType === 'profileDataView') {
         $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/profile/view';
         $links[CRM_Core_Action::VIEW]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$view}";
 
@@ -94,7 +97,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
         $links[CRM_Core_Action::DELETE]['qs'] = "reset=1&id=%%id%%&recordId=%%recordId%%&gid=%%gid%%&multiRecord={$delete}";
 
       }
-      elseif ($this->_pageViewType == 'customDataView') {
+      elseif ($this->_pageViewType === 'customDataView') {
         // custom data specific view links
         $links[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/view/cd';
         $links[CRM_Core_Action::VIEW]['qs'] = 'reset=1&gid=%%gid%%&cid=%%cid%%&recId=%%recId%%&cgcount=%%cgcount%%&multiRecordDisplay=single&mode=view';
@@ -110,6 +113,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
           'title' => ts('Copy %1', [1 => $this->_customGroupTitle . ' record']),
           'url' => 'civicrm/contact/view/cd/edit',
           'qs' => 'reset=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%newCgCount%%&multiRecordDisplay=single&copyValueId=%%cgcount%%&mode=copy',
+          'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::COPY),
         ];
       }
 
@@ -154,12 +158,12 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
    * Browse the listing.
    *
    */
-  public function browse() {
+  public function browse(): array {
     $dateFields = NULL;
     $newCgCount = $cgcount = 0;
     $attributes = $result = $headerAttr = [];
     $dateFieldsVals = NULL;
-    if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
+    if ($this->_pageViewType === 'profileDataView' && $this->_profileId) {
       $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL,
         NULL, NULL,
         FALSE, NULL,
@@ -265,7 +269,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
       unset($result['count']);
       unset($result['sortedResult']);
 
-      if ($this->_pageViewType == 'profileDataView') {
+      if ($this->_pageViewType === 'profileDataView') {
         if (!empty($fieldIDs)) {
           //get the group info of multi rec fields in listing view
           $fieldInput = $fieldIDs;
@@ -290,8 +294,8 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
       $cgcount = 1;
       $newCgCount = (!$reached) ? $resultCount + 1 : NULL;
       if (!empty($result) && empty($this->_headersOnly)) {
-        $links = self::links();
-        if ($this->_pageViewType == 'profileDataView') {
+        $links = $this->links();
+        if ($this->_pageViewType === 'profileDataView') {
           $pageCheckSum = $this->get('pageCheckSum');
           if ($pageCheckSum) {
             foreach ($links as $key => $link) {
@@ -404,6 +408,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
                 $links[CRM_Core_Action::DELETE]['url'] = '#';
                 $links[CRM_Core_Action::DELETE]['extra'] = ' data-delete_params="' . htmlspecialchars(json_encode($deleteData)) . '"';
                 $links[CRM_Core_Action::DELETE]['class'] = 'delete-custom-row';
+                $links[CRM_Core_Action::DELETE]['weight'] = CRM_Core_Action::getWeight(CRM_Core_Action::DELETE);
               }
               if (!empty($pageCheckSum)) {
                 $actionParams['cs'] = $pageCheckSum;