Skip to content

Commit

Permalink
Add frozen and plugin configuration handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 29, 2024
1 parent d69bb7c commit 73c0755
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions app/templates/element/form/listItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@
// - wrap them in an array.
// We choose the latter.
$this->set('fieldName', $arguments['fieldName']);
$fieldName = $arguments['fieldName'];
$this->set('vv_field_arguments', $arguments);

// Class calculation by field Type
$classes = match ($this->Fieeld->getFieldType($arguments['fieldName'])) {
$classes = match ($this->Fieeld->getFieldType($fieldName)) {
'date',
'datetime',
'timestamp' => 'fields-datepicker ',
default => ''
};

// Class calculation by field name
$classes .= match ($arguments['fieldName']) {
$classes .= match ($fieldName) {
'source_record' => 'source-record ',
'retry_interval',
'login' => 'subfield ',
Expand All @@ -58,6 +59,46 @@
$classes .= 'fields-people-autocomplete ';
}


// If an attribute is frozen, inject a special link to unfreeze it, since
// the attribute is read-only and the admin can't simply uncheck the setting
if($fieldName == 'frozen' && $this->Fieeld->getEntity()->frozen) {
$url = [
'label' => __d('operation', 'unfreeze'),
'url' => [
'plugin' => null,
'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Fieeld->getEntity()),
'action' => 'unfreeze',
$this->Fieeld->getEntity()->id
]
];
$arguments = [
...$arguments,
'status' => __d('field', 'frozen'),
'link' => $url,
];
$this->set('vv_field_arguments', $arguments);
}

// If an attribute is a plugin, return the link to its configuration
if($fieldName == 'plugin' && $vv_action == 'edit') {
$url = [
'label' => __d('operation', 'configure.plugin'),
'url' => [
'plugin' => null,
'controller' => \App\Lib\Util\StringUtilities::entityToClassname($this->Fieeld->getEntity()),
'action' => 'configure',
$this->Fieeld->getEntity()->id
]
];
$arguments = [
...$arguments,
'status' => $this->Fieeld->getEntity()->$fieldName,
'link' => $url,
];
$this->set('vv_field_arguments', $arguments);
}

?>

<li class="<?= trim($classes) ?>">
Expand Down

0 comments on commit 73c0755

Please sign in to comment.