diff --git a/app/templates/element/form/listItem.php b/app/templates/element/form/listItem.php index a68337709..ce97436a4 100644 --- a/app/templates/element/form/listItem.php +++ b/app/templates/element/form/listItem.php @@ -35,10 +35,11 @@ // - 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 ', @@ -46,7 +47,7 @@ }; // Class calculation by field name -$classes .= match ($arguments['fieldName']) { +$classes .= match ($fieldName) { 'source_record' => 'source-record ', 'retry_interval', 'login' => 'subfield ', @@ -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); +} + ?>