2020-09-28 01:26:50 +02:00
|
|
|
<?php
|
|
|
|
echo $this->element('genericElements/IndexTable/index_table', [
|
|
|
|
'data' => [
|
|
|
|
'data' => $data,
|
|
|
|
'top_bar' => [
|
|
|
|
'children' => [
|
2020-12-07 16:06:01 +01:00
|
|
|
[
|
|
|
|
'type' => 'context_filters',
|
2020-12-08 15:15:58 +01:00
|
|
|
'context_filters' => $filteringContexts
|
2020-12-07 16:06:01 +01:00
|
|
|
],
|
2020-09-28 01:26:50 +02:00
|
|
|
[
|
|
|
|
'type' => 'search',
|
|
|
|
'button' => __('Filter'),
|
|
|
|
'placeholder' => __('Enter value to search'),
|
|
|
|
'data' => '',
|
|
|
|
'searchKey' => 'value'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'fields' => [
|
|
|
|
[
|
|
|
|
'name' => '#',
|
|
|
|
'sort' => 'id',
|
|
|
|
'data_path' => 'id',
|
|
|
|
],
|
2020-11-20 11:09:24 +01:00
|
|
|
[
|
|
|
|
'name' => 'Enabled',
|
|
|
|
'sort' => 'enabled',
|
|
|
|
'data_path' => 'enabled',
|
2020-12-07 14:17:10 +01:00
|
|
|
'element' => 'toggle',
|
2020-12-10 15:18:02 +01:00
|
|
|
'url' => '/metaTemplates/toggle/{{0}}',
|
|
|
|
'url_params_vars' => ['id'],
|
|
|
|
'toggle_data' => [
|
|
|
|
'requirement' => [
|
|
|
|
'function' => function($row, $options) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => 'Default',
|
|
|
|
'sort' => 'is_default',
|
|
|
|
'data_path' => 'is_default',
|
|
|
|
'element' => 'toggle',
|
|
|
|
'url' => '/metaTemplates/toggle/{{0}}/{{1}}',
|
|
|
|
'url_params_vars' => [['datapath' => 'id'], ['raw' => 'is_default']],
|
|
|
|
'toggle_data' => [
|
|
|
|
'requirement' => [
|
|
|
|
'function' => function($row, $options) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'confirm' => [
|
|
|
|
'enable' => [
|
|
|
|
'titleHtml' => __('Make {{0}} the default template?'),
|
|
|
|
'titleHtml_vars' => ['name'],
|
|
|
|
'bodyHtml' => $this->Html->nestedList([
|
|
|
|
__('Only one template per scope can be set as the default template'),
|
2020-12-10 17:05:51 +01:00
|
|
|
'{{0}}',
|
2020-12-10 15:18:02 +01:00
|
|
|
]),
|
2020-12-10 16:50:46 +01:00
|
|
|
'bodyHtml_vars' => [
|
|
|
|
[
|
|
|
|
'function' => function($row, $data) {
|
|
|
|
$conflictingTemplate = getConflictingTemplate($row, $data);
|
|
|
|
if (!empty($conflictingTemplate)) {
|
2020-12-10 17:05:51 +01:00
|
|
|
return sprintf(
|
|
|
|
"<span class=\"text-danger font-weight-bolder\">%s</span> %s.<br />
|
|
|
|
<span class=\"font-weight-bolder\">%s</span> %s <span class=\"font-weight-bolder\">%s</span>",
|
|
|
|
__('Conflict with:'),
|
|
|
|
$this->Html->link(
|
|
|
|
h($conflictingTemplate->name),
|
|
|
|
'/metaTemplates/view/' . h($conflictingTemplate->id),
|
|
|
|
['target' => '_blank']
|
|
|
|
),
|
|
|
|
__('By proceeding'),
|
|
|
|
h($conflictingTemplate->name),
|
|
|
|
__('will not be the default anymore')
|
|
|
|
);
|
2020-12-10 16:50:46 +01:00
|
|
|
}
|
|
|
|
return __('Current scope: {0}', h($row->scope));
|
|
|
|
},
|
|
|
|
'data' => [
|
|
|
|
'defaultTemplatePerScope' => $defaultTemplatePerScope
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'type' => [
|
|
|
|
'function' => function($row, $data) {
|
|
|
|
$conflictingTemplate = getConflictingTemplate($row, $data);
|
|
|
|
if (!empty($conflictingTemplate)) {
|
|
|
|
return 'confirm-danger';
|
|
|
|
}
|
|
|
|
return 'confirm-warning';
|
|
|
|
},
|
|
|
|
'data' => [
|
|
|
|
'defaultTemplatePerScope' => $defaultTemplatePerScope
|
|
|
|
]
|
|
|
|
],
|
2020-12-10 15:18:02 +01:00
|
|
|
'confirmText' => __('Yes, set as default')
|
|
|
|
],
|
|
|
|
'disable' => [
|
|
|
|
'titleHtml' => __('Remove {{0}} as the default template?'),
|
|
|
|
'titleHtml_vars' => ['name'],
|
|
|
|
'type' => 'confirm-warning',
|
|
|
|
'confirmText' => __('Yes, do not set as default')
|
|
|
|
]
|
|
|
|
]
|
2020-12-08 09:07:00 +01:00
|
|
|
]
|
2020-11-20 11:09:24 +01:00
|
|
|
],
|
2020-09-28 01:26:50 +02:00
|
|
|
[
|
|
|
|
'name' => __('Scope'),
|
|
|
|
'sort' => 'scope',
|
|
|
|
'data_path' => 'scope',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('Name'),
|
|
|
|
'sort' => 'name',
|
|
|
|
'data_path' => 'name',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('Namespace'),
|
|
|
|
'sort' => 'namespace',
|
|
|
|
'data_path' => 'namespace',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('UUID'),
|
|
|
|
'sort' => 'uuid',
|
|
|
|
'data_path' => 'uuid'
|
2020-11-20 11:09:24 +01:00
|
|
|
]
|
2020-09-28 01:26:50 +02:00
|
|
|
],
|
|
|
|
'title' => __('Meta Field Templates'),
|
|
|
|
'description' => __('The various templates used to enrich certain objects by a set of standardised fields.'),
|
|
|
|
'pull' => 'right',
|
|
|
|
'actions' => [
|
|
|
|
[
|
|
|
|
'url' => '/metaTemplates/view',
|
|
|
|
'url_params_data_paths' => ['id'],
|
|
|
|
'icon' => 'eye'
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
2020-12-10 16:50:46 +01:00
|
|
|
|
|
|
|
function getConflictingTemplate($row, $data) {
|
|
|
|
if (!empty($data['data']['defaultTemplatePerScope'][$row->scope])) {
|
|
|
|
$conflictingTemplate = $data['data']['defaultTemplatePerScope'][$row->scope];
|
|
|
|
if (!empty($conflictingTemplate)) {
|
|
|
|
return $conflictingTemplate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
2020-09-28 01:26:50 +02:00
|
|
|
?>
|