chg: [genericElement:single_view] Bit of refactoring and

skip_meta_template option
pull/37/head
mokaddem 2020-12-11 09:01:46 +01:00
parent 3806533abb
commit f279939c8b
1 changed files with 18 additions and 6 deletions

View File

@ -9,21 +9,22 @@
* elements passed as to be displayed in the <ul> element.
* format:
* [
'key' => '' // key to be displayed
* 'key' => '' // key to be displayed
* 'path' => '' // path for the value to be parsed
* 'type' => '' // generic assumed if not filled, uses SingleViews/Fields/* elements
* ]
* ],
* 'children' => [
* // Additional elements attached to the currently viewed object. index views will be appended via ajax calls below.
[
* [
* 'title' => '',
* 'url' => '', //cakephp compatible url, can be actual url or array for the constructor
* 'collapsed' => 0|1 // defaults to 0, whether to display it by default or not
* 'loadOn' => 'ready|expand' // load the data directly or only when expanded from a collapsed state
*
* ],
* ]
* ],
* 'skip_meta_templates' => false // should the meta templates not be displayed
* ]);
*
*/
@ -34,7 +35,10 @@
$field['type'] = 'generic';
}
$listElements .= sprintf(
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
"<tr class=\"row\">
<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',
@ -44,7 +48,7 @@
}
}
$metaTemplateTabs = '';
if (!empty($data['metaTemplates'])) {
if (!empty($data['metaTemplates']) && (empty($skip_meta_templates))) {
$tabData = [
'navs' => [],
'content' => []
@ -105,7 +109,15 @@
__('{0} view', \Cake\Utility\Inflector::singularize(\Cake\Utility\Inflector::humanize($this->request->getParam('controller')))) :
$title;
echo sprintf(
'<div><h2>%s</h2>%s%s<div class="px-3"><table class="table table-striped col-sm-8">%s</table></div><div id="metaTemplates" class="col-lg-8 px-0">%s</div><div id="accordion">%s</div></div>',
"<div>
<h2>%s</h2>
%s%s
<div class=\"px-3\">
<table class=\"table table-striped col-sm-8\">%s</table>
</div>
<div id=\"metaTemplates\" class=\"col-lg-8 px-0\">%s</div>
<div id=\"accordion\">%s</div>
</div>",
h($title),
empty($description) ? '' : sprintf('<p>%s</p>', h($description)),
empty($description_html) ? '' : sprintf('<p>%s</p>', $description_html),