Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add weights to links on multipleRecordFieldsListing #27284

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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