protected function formatResult(iterable $result): array {
$rows = [];
$keyName = CoreUtil::getIdFieldName($this->savedSearch['api_entity']);
+ if ($this->savedSearch['api_entity'] === 'RelationshipCache') {
+ $keyName = 'relationship_id';
+ }
foreach ($result as $index => $record) {
$data = $columns = [];
foreach ($this->getSelectClause() as $key => $item) {
*/
public function _run(\Civi\Api4\Generic\Result $result) {
// Adding checkPermissions filters out actions the user is not allowed to perform
- $entity = Entity::get($this->checkPermissions)->addWhere('name', '=', $this->entity)
+ $entityName = ($this->entity === 'RelationshipCache') ? 'Relationship' : $this->entity;
+ $entity = Entity::get($this->checkPermissions)->addWhere('name', '=', $entityName)
->addSelect('name', 'title_plural')
->setChain([
'actions' => ['$name', 'getActions', ['where' => [['name', 'IN', ['update', 'delete']]]], 'name'],
return $scope.$eval('' + ctrl.ids.length + action.number);
};
+ this.updateActionData = function() {
+ if (this.entity === 'RelationshipCache') {
+ this.entity = 'Relationship';
+ this.entityInfo.title = ts('Relationship');
+ this.entityInfo.title_plural = ts('Relationships');
+ }
+ };
+
this.getActionTitle = function(action) {
if (ctrl.isActionAllowed(action)) {
+ ctrl.updateActionData();
return ctrl.ids.length ?
ts('Perform action on %1 %2', {1: ctrl.ids.length, 2: ctrl.entityInfo[ctrl.ids.length === 1 ? 'title' : 'title_plural']}) :
ts('Perform action on all %1', {1: ctrl.entityInfo.title_plural});
if (!ctrl.isActionAllowed(action)) {
return;
}
+ // Update data specific to entity actions.
+ ctrl.updateActionData();
+
var data = {
ids: ctrl.ids,
entity: ctrl.entity,