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

dev/core#4519 SearchKit - Fix tasks when ID column is not present #27123

Merged
merged 1 commit into from
Aug 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ protected function formatResult(iterable $result): array {
'columns' => $columns,
'cssClass' => implode(' ', $style),
];
if (isset($data[$keyName])) {
$row['key'] = $data[$keyName];
if (isset($record[$keyName])) {
$row['key'] = $record[$keyName];
}
$rows[] = $row;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ public function testInPlaceEditAndCreate() {
];
$result = civicrm_api4('SearchDisplay', 'run', $params);

$this->assertEquals($contacts[0], $result[0]['key']);

// Contact 1 first name can be updated
$this->assertEquals('One', $result[0]['columns'][0]['val']);
$this->assertEquals($contacts[0], $result[0]['columns'][0]['edit']['record']['id']);
Expand Down Expand Up @@ -1507,6 +1509,7 @@ public function testEditableContactFields() {
// Second Individual
$expectedFirstNameEdit['record']['id'] = $contact[1]['id'];
$expectedFirstNameEdit['value'] = NULL;
$this->assertEquals($contact[1]['id'], $result[1]['key']);
$this->assertEquals($expectedFirstNameEdit, $result[1]['columns'][0]['edit']);
$this->assertTrue(!isset($result[1]['columns'][1]['edit']));
$this->assertTrue(!isset($result[1]['columns'][2]['edit']));
Expand Down Expand Up @@ -1743,6 +1746,49 @@ public function testContactTypeIcons(): void {
$this->assertEquals('fa-star', $result[2]['columns'][0]['icons'][0]['class']);
}

public function testKeyIsReturned(): void {
$id = $this->createTestRecord('Email')['id'];
$params = [
'checkPermissions' => FALSE,
'return' => 'page:1',
'savedSearch' => [
'api_entity' => 'Email',
'api_params' => [
'version' => 4,
'select' => ['email'],
'where' => [
['id', 'IN', [$id]],
],
],
],
'display' => [
'type' => 'table',
'label' => '',
'settings' => [
'limit' => 20,
'pager' => TRUE,
'actions' => TRUE,
'columns' => [
[
'key' => 'email',
'label' => 'Email',
'dataType' => 'String',
'type' => 'field',
],
],
'sort' => [
['id', 'ASC'],
],
],
],
'afform' => NULL,
];

$result = civicrm_api4('SearchDisplay', 'run', $params);
$this->assertCount(1, $result);
$this->assertEquals($id, $result[0]['key']);
}

/**
* Returns all contacts in VIEW mode but only specified contact for EDIT.
*
Expand Down