From f6677b753927cd53ca1b31d8ed0a3f0d6742a777 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 31 Aug 2023 21:03:50 +1200 Subject: [PATCH] Add weights to links on multipleRecordFieldsListing --- CRM/Custom/Page/AJAX.php | 4 ++-- .../Page/MultipleRecordFieldsListing.php | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CRM/Custom/Page/AJAX.php b/CRM/Custom/Page/AJAX.php index 5ddbb19ccd..2deb349df6 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -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 = []; diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index dd521bd1d7..00e507f139 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -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©ValueId=%%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; -- 2.25.1