chg: [genericElement:single_view] Usage of factories
parent
64ca0179bf
commit
1251d0f168
|
@ -45,6 +45,7 @@ echo $this->element(
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'metaTemplates' => empty($metaFields) ? [] : $metaFields,
|
'metaTemplates' => empty($metaFields) ? [] : $metaFields,
|
||||||
|
'combinedFieldsView' => true,
|
||||||
'children' => []
|
'children' => []
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,74 +25,42 @@
|
||||||
* ],
|
* ],
|
||||||
* ],
|
* ],
|
||||||
* 'skip_meta_templates' => false // should the meta templates not be displayed
|
* 'skip_meta_templates' => false // should the meta templates not be displayed
|
||||||
|
* 'combinedFieldsView' => false // should the default fields and meta fields displayed in a merged interface
|
||||||
* ]);
|
* ]);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$tableRandomValue = Cake\Utility\Security::randomString(8);
|
$tableRandomValue = Cake\Utility\Security::randomString(8);
|
||||||
$listElements = '';
|
$listTableOptions = [
|
||||||
if (!empty($fields)) {
|
'id' => "single-view-table-{$tableRandomValue}",
|
||||||
foreach ($fields as $field) {
|
'hover' => false,
|
||||||
if (empty($field['type'])) {
|
'tableClass' => 'col-sm-8',
|
||||||
$field['type'] = 'generic';
|
'elementsRootPath' => '/genericElements/SingleViews/Fields/'
|
||||||
}
|
];
|
||||||
$listElements .= sprintf(
|
if (!empty($data['metaTemplates']) && (empty($skip_meta_templates)) && !empty($combinedFieldsView)) {
|
||||||
"<tr class=\"row\">
|
$listTableOptions['tableClass'] = '';
|
||||||
<td class=\"col-sm-2 font-weight-bold\">%s</td>
|
|
||||||
<td class=\"col-sm-10\">%s</td>
|
|
||||||
</tr>",
|
|
||||||
h($field['key']),
|
|
||||||
$this->element(
|
|
||||||
'/genericElements/SingleViews/Fields/' . $field['type'] . 'Field',
|
|
||||||
['data' => $data, 'field' => $field]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$metaTemplateTabs = '';
|
$listTable = $this->Bootstrap->listTable($listTableOptions,[
|
||||||
|
'item' => $entity,
|
||||||
|
'fields' => $fields
|
||||||
|
]);
|
||||||
|
|
||||||
|
$metafieldsPanel = '';
|
||||||
if (!empty($data['metaTemplates']) && (empty($skip_meta_templates))) {
|
if (!empty($data['metaTemplates']) && (empty($skip_meta_templates))) {
|
||||||
$tabData = [
|
$metaFieldsData = [
|
||||||
'navs' => [],
|
'data' => $data,
|
||||||
'content' => []
|
|
||||||
];
|
];
|
||||||
foreach($data['metaTemplates'] as $metaTemplate) {
|
if (!empty($combinedFieldsView)) {
|
||||||
if (!empty($metaTemplate->meta_template_fields)) {
|
$metaFieldsData['additionalTabs'] = [
|
||||||
if ($metaTemplate->is_default) {
|
'navs' => [
|
||||||
$tabData['navs'][] = [
|
['text' => __('Default')]
|
||||||
'html' => $this->element('/genericElements/MetaTemplates/metaTemplateNav', ['metaTemplate' => $metaTemplate])
|
],
|
||||||
];
|
'content' => [
|
||||||
} else {
|
$listTable
|
||||||
$tabData['navs'][] = [
|
]
|
||||||
'text' => $metaTemplate->name
|
];
|
||||||
];
|
$listTable = '';
|
||||||
}
|
|
||||||
$fieldsHtml = '<table class="table table-striped">';
|
|
||||||
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
|
||||||
$metaField = $metaTemplateField->meta_fields[0];
|
|
||||||
$fieldsHtml .= sprintf(
|
|
||||||
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
|
|
||||||
h($metaField->field),
|
|
||||||
$this->element(
|
|
||||||
'/genericElements/SingleViews/Fields/genericField',
|
|
||||||
[
|
|
||||||
'data' => $metaField->value,
|
|
||||||
'field' => [
|
|
||||||
'raw' => $metaField->value
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$fieldsHtml .= '</table>';
|
|
||||||
$tabData['content'][] = $fieldsHtml;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($tabData['navs'])) {
|
|
||||||
$metaTemplateTabs = $this->Bootstrap->Tabs([
|
|
||||||
'pills' => true,
|
|
||||||
'card' => true,
|
|
||||||
'data' => $tabData
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
$metafieldsPanel = $this->element('/genericElements/SingleViews/metafields_panel', $metaFieldsData);
|
||||||
}
|
}
|
||||||
$ajaxLists = '';
|
$ajaxLists = '';
|
||||||
if (!empty($children)) {
|
if (!empty($children)) {
|
||||||
|
@ -113,19 +81,16 @@
|
||||||
"<div id=\"single-view-table-container-%s\">
|
"<div id=\"single-view-table-container-%s\">
|
||||||
<h2>%s</h2>
|
<h2>%s</h2>
|
||||||
%s%s
|
%s%s
|
||||||
<div class=\"px-3\">
|
<div>%s</div>
|
||||||
<table id=\"single-view-table-%s\" class=\"table table-striped col-sm-8\">%s</table>
|
<div id=\"metafieldsPanel\" class=\"col-lg-8 px-0\">%s</div>
|
||||||
</div>
|
|
||||||
<div id=\"metaTemplates\" class=\"col-lg-8 px-0\">%s</div>
|
|
||||||
<div id=\"accordion\">%s</div>
|
<div id=\"accordion\">%s</div>
|
||||||
</div>",
|
</div>",
|
||||||
$tableRandomValue,
|
$tableRandomValue,
|
||||||
h($title),
|
h($title),
|
||||||
empty($description) ? '' : sprintf('<p>%s</p>', h($description)),
|
empty($description) ? '' : sprintf('<p>%s</p>', h($description)),
|
||||||
empty($description_html) ? '' : sprintf('<p>%s</p>', $description_html),
|
empty($description_html) ? '' : sprintf('<p>%s</p>', $description_html),
|
||||||
$tableRandomValue,
|
$listTable,
|
||||||
$listElements,
|
$metafieldsPanel,
|
||||||
$metaTemplateTabs,
|
|
||||||
$ajaxLists
|
$ajaxLists
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue