', h($data['title']));
- }
- if (!empty($data['description'])) {
- echo sprintf(
- '
',
- empty($data['description']) ? '' : h($data['description'])
- );
- }
- echo '
';
- if (!empty($data['html'])) {
- echo sprintf('
%s
', $data['html']);
- }
- $skipPagination = isset($data['skip_pagination']) ? $data['skip_pagination'] : 0;
- if (!$skipPagination) {
- $paginationData = !empty($data['paginatorOptions']) ? $data['paginatorOptions'] : [];
- echo $this->element(
- '/genericElements/IndexTable/pagination',
- [
- 'paginationOptions' => $paginationData,
- 'tableRandomValue' => $tableRandomValue
- ]
- );
- echo $this->element(
- '/genericElements/IndexTable/pagination_links'
- );
- }
- $multiSelectData = getMultiSelectData($data['top_bar']);
- if (!empty($multiSelectData)) {
- $multiSelectField = [
- 'element' => 'selector',
- 'class' => 'short',
- 'data' => $multiSelectData['data']
+$newMetaFields = [];
+if (!empty($requestedMetaFields)) { // Create mapping for new index table fields on the fly
+ foreach ($requestedMetaFields as $requestedMetaField) {
+ $template_id = $requestedMetaField['template_id'];
+ $meta_template_field_id = $requestedMetaField['meta_template_field_id'];
+ $newMetaFields[] = [
+ 'name' => $meta_templates[$template_id]['meta_template_fields'][$meta_template_field_id]['field'],
+ 'data_path' => "MetaTemplates.{$template_id}.meta_template_fields.{$meta_template_field_id}.metaFields.{n}.value",
+ 'element' => 'generic_field',
+ '_metafield' => true,
+ '_automatic_field' => true,
];
- array_unshift($data['fields'], $multiSelectField);
}
- if (!empty($data['top_bar'])) {
- echo $this->element(
- '/genericElements/ListTopBar/scaffold',
- [
- 'data' => $data['top_bar'],
- 'table_data' => $data,
- 'tableRandomValue' => $tableRandomValue
- ]
- );
- }
- $rows = '';
- $row_element = isset($data['row_element']) ? $data['row_element'] : 'row';
- $options = isset($data['options']) ? $data['options'] : [];
- $actions = isset($data['actions']) ? $data['actions'] : [];
- if ($this->request->getParam('prefix') === 'Open') {
- $actions = [];
- }
- $dblclickActionArray = !empty($actions) ? $this->Hash->extract($actions, '{n}[dbclickAction]') : [];
- $dbclickAction = '';
- foreach ($data['data'] as $k => $data_row) {
- $primary = null;
- if (!empty($data['primary_id_path'])) {
- $primary = $this->Hash->extract($data_row, $data['primary_id_path'])[0];
- }
- if (!empty($dblclickActionArray)) {
- $dbclickAction = sprintf("changeLocationFromIndexDblclick(%s)", $k);
- }
- $rows .= sprintf(
- '
%s
',
- h($k),
- empty($dbclickAction) ? '' : 'ondblclick="' . $dbclickAction . '"',
- empty($primary) ? '' : 'data-primary-id="' . $primary . '"',
- empty($data['row_modifier']) ? '' : h($data['row_modifier']($data_row)),
- empty($data['class']) ? '' : h($data['row_class']),
- $this->element(
- '/genericElements/IndexTable/' . $row_element,
- [
- 'k' => $k,
- 'row' => $data_row,
- 'fields' => $data['fields'],
- 'options' => $options,
- 'actions' => $actions,
- 'primary' => $primary,
- 'tableRandomValue' => $tableRandomValue
+}
+$data['fields'] = array_merge($data['fields'], $newMetaFields);
+
+$tableRandomValue = Cake\Utility\Security::randomString(8);
+echo '
';
+if (!empty($data['title'])) {
+ echo Text::insert(
+ '
:title :help
',
+ [
+ 'title' => h($data['title']),
+ 'help' => $this->Bootstrap->icon('info', [
+ 'class' => ['fs-6', 'align-text-top',],
+ 'title' => empty($data['description']) ? '' : h($data['description']),
+ 'params' => [
+ 'data-bs-toggle' => 'tooltip',
]
- )
- );
+ ]),
+ ]
+ );
+}
+echo '
';
+if (!empty($data['html'])) {
+ echo sprintf('
%s
', $data['html']);
+}
+$skipPagination = isset($data['skip_pagination']) ? $data['skip_pagination'] : 0;
+if (!$skipPagination) {
+ $paginationData = !empty($data['paginatorOptions']) ? $data['paginatorOptions'] : [];
+ echo $this->element(
+ '/genericElements/IndexTable/pagination',
+ [
+ 'paginationOptions' => $paginationData,
+ 'tableRandomValue' => $tableRandomValue
+ ]
+ );
+ echo $this->element(
+ '/genericElements/IndexTable/pagination_links'
+ );
+}
+$multiSelectData = getMultiSelectData($data['top_bar']);
+if (!empty($multiSelectData)) {
+ $multiSelectField = [
+ 'element' => 'selector',
+ 'class' => 'short',
+ 'data' => $multiSelectData['data']
+ ];
+ array_unshift($data['fields'], $multiSelectField);
+}
+if (!empty($data['top_bar'])) {
+ echo $this->element(
+ '/genericElements/ListTopBar/scaffold',
+ [
+ 'data' => $data['top_bar'],
+ 'table_data' => $data,
+ 'tableRandomValue' => $tableRandomValue
+ ]
+ );
+}
+$rows = '';
+$row_element = isset($data['row_element']) ? $data['row_element'] : 'row';
+$options = isset($data['options']) ? $data['options'] : [];
+$actions = isset($data['actions']) ? $data['actions'] : [];
+if ($this->request->getParam('prefix') === 'Open') {
+ $actions = [];
+}
+$dblclickActionArray = !empty($actions) ? $this->Hash->extract($actions, '{n}[dbclickAction]') : [];
+$dbclickAction = '';
+foreach ($data['data'] as $k => $data_row) {
+ $primary = null;
+ if (!empty($data['primary_id_path'])) {
+ $primary = $this->Hash->extract($data_row, $data['primary_id_path'])[0];
}
- $tbody = '
' . $rows . '';
- echo sprintf(
- '
',
- $tableRandomValue,
- $tableRandomValue,
- h($this->Url->build(['action' => $this->request->getParam('action'),])),
+ if (!empty($dblclickActionArray)) {
+ $dbclickAction = sprintf("changeLocationFromIndexDblclick(%s)", $k);
+ }
+ $rows .= sprintf(
+ '
%s
',
+ h($k),
+ empty($dbclickAction) ? '' : 'ondblclick="' . $dbclickAction . '"',
+ empty($primary) ? '' : 'data-primary-id="' . $primary . '"',
+ empty($data['row_modifier']) ? '' : h($data['row_modifier']($data_row)),
+ empty($data['class']) ? '' : h($data['row_class']),
$this->element(
- '/genericElements/IndexTable/headers',
+ '/genericElements/IndexTable/' . $row_element,
[
+ 'k' => $k,
+ 'row' => $data_row,
'fields' => $data['fields'],
- 'paginator' => $this->Paginator,
- 'actions' => (empty($actions) ? false : true),
+ 'options' => $options,
+ 'actions' => $actions,
+ 'primary' => $primary,
'tableRandomValue' => $tableRandomValue
]
- ),
- $tbody
+ )
);
- if (!$skipPagination) {
- echo $this->element('/genericElements/IndexTable/pagination_counter', $paginationData);
- echo $this->element('/genericElements/IndexTable/pagination_links');
- }
- echo '
';
- echo '
';
+}
+$tbody = '
' . $rows . '';
+echo sprintf(
+ '
',
+ $tableRandomValue,
+ $tableRandomValue,
+ h($this->Url->build(['action' => $this->request->getParam('action'),])),
+ $this->element(
+ '/genericElements/IndexTable/headers',
+ [
+ 'fields' => $data['fields'],
+ 'paginator' => $this->Paginator,
+ 'actions' => (empty($actions) ? false : true),
+ 'tableRandomValue' => $tableRandomValue
+ ]
+ ),
+ $tbody
+);
+if (!$skipPagination) {
+ echo $this->element('/genericElements/IndexTable/pagination_counter', $paginationData);
+ echo $this->element('/genericElements/IndexTable/pagination_links');
+}
+echo '