}
// Check access for edit/update/delete links
// (presumably if a record is shown in SearchKit the user already has view access, and the check is expensive)
- if ($link['entity'] && $link['action'] && !in_array($link['action'], ['view', 'preview'], TRUE)) {
+ if ($link['entity'] && !empty($link['action']) && !in_array($link['action'], ['view', 'preview'], TRUE)) {
$idField = CoreUtil::getIdFieldName($link['entity']);
$idKey = $this->getIdKeyName($link['entity']);
$id = $data[$link['prefix'] . $idKey] ?? NULL;
$link['title'] = $link['title'] ?: $task['title'];
// Fill in the api action if known, for the sake of $this->checkLinkAccess
$link['action'] = $task['apiBatch']['action'] ?? NULL;
- $link['task'] = array_intersect_key($task, ['apiBatch' => 1, 'uiDialog' => 1]);
}
}
}
this.isDisplayReady = function() {
return !displayCtrl.loading && displayCtrl.results && displayCtrl.results.length;
};
+ this.getTaskInfo = function(taskName) {
+ return _.findWhere(mngr.tasks, {name: taskName});
+ };
this.doTask = function(task, ids) {
var data = {
const mngr = this.taskManager;
event.preventDefault();
mngr.getMetadata().then(function() {
- mngr.doTask(_.extend({title: link.title}, link.task), [id]);
+ mngr.doTask(_.extend({title: link.title}, mngr.getTaskInfo(link.task)), [id]);
});
}
},
this.selectedRows.splice(index, 1);
}
}
+ else if (status === 'success' && !editedRow && apiResults.run && apiResults.run[0]) {
+ const mngr = this.taskManager;
+ // If results contain a link to a task, prefetch task info to prevent latency when clicking the link
+ _.each(apiResults.run[0].columns, function(column) {
+ if ((column.link && column.link.task) || _.find(column.links || [], 'task')) {
+ mngr.getMetadata();
+ }
+ });
+ }
}]
};
$this->assertStringContainsString('id=' . $contributions[0]['id'] . '&qfKey=', $result[0]['columns'][1]['links'][0]['url']);
// 2nd link is to the native SK bulk-update task
$this->assertArrayNotHasKey('url', $result[0]['columns'][1]['links'][1]);
- $this->assertArrayHasKey('uiDialog', $result[0]['columns'][1]['links'][1]['task']);
+ $this->assertEquals('update', $result[0]['columns'][1]['links'][1]['task']);
// 3rd link is a popup link to the delete contribution quickform
$this->assertStringContainsString('action=delete&id=' . $contributions[0]['id'], $result[0]['columns'][1]['links'][2]['url']);
$this->assertEquals('crm-popup', $result[0]['columns'][1]['links'][2]['target']);