Skip to content

Commit

Permalink
Merge pull request #27284 from eileenmcnaughton/weigh_multi
Browse files Browse the repository at this point in the history
Add weights to links on multipleRecordFieldsListing
  • Loading branch information
colemanw authored Sep 4, 2023
2 parents 9b672b6 + f6677b7 commit b99d2bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CRM/Custom/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function fixOrdering() {
/**
* 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');
Expand All @@ -118,7 +118,7 @@ public static function getMultiRecordFieldList() {
$obj->_DTparams['sort'] = $params['sortBy'];
}

list($fields, $attributes) = $obj->browse();
[$fields, $attributes] = $obj->browse();

// format params and add class attributes
$fieldList = [];
Expand Down
19 changes: 12 additions & 7 deletions CRM/Profile/Page/MultipleRecordFieldsListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@ public function &links() {
$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}";

Expand All @@ -94,7 +97,7 @@ public function &links() {
$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';
Expand All @@ -110,6 +113,7 @@ public function &links() {
'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),
];
}

Expand Down Expand Up @@ -154,12 +158,12 @@ public function run() {
* 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,
Expand Down Expand Up @@ -265,7 +269,7 @@ public function browse() {
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;
Expand All @@ -290,8 +294,8 @@ public function browse() {
$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) {
Expand Down Expand Up @@ -404,6 +408,7 @@ public function browse() {
$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;
Expand Down

0 comments on commit b99d2bc

Please sign in to comment.