chg: migrate /templates/view/:id to view factory

pull/7593/head
Luciano Righetti 2021-07-22 11:07:32 +02:00
parent 2e8e013cd0
commit d55a689ce3
4 changed files with 61 additions and 57 deletions

View File

@ -0,0 +1,9 @@
<?php
if (!empty($data['TemplateTag'])) {
foreach ($data['TemplateTag'] as $tag) {
?>
<span class="tagComplete" style="background-color:<?php echo h($tag['Tag']['colour']); ?>;color:<?php echo $this->TextColour->getTextColour($tag['Tag']['colour']); ?>"><?php echo h($tag['Tag']['name']); ?></span>
<?php
}
} else echo '&nbsp';

View File

@ -0,0 +1,7 @@
<div id="templateElements" class="view">
<script type="text/javascript">
$(document).ready(function() {
updateIndex(<?php echo $templateId ?>, 'template');
});
</script>
</div>

View File

@ -1,9 +1,12 @@
<?php
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'templates', 'menuItem' => 'add'));
$edit = $this->request->params['action'] === 'edit' ? true : false;
echo $this->element('/genericElements/SideMenu/side_menu', [
'menuList' => 'templates',
'menuItem' => $edit ? 'edit' : 'add'
]);
echo $this->element('genericElements/Form/genericForm', [
'data' => [
'title' => $edit ? __('Edit Template') : __('Create Template'),

View File

@ -1,56 +1,41 @@
<div class="templates view">
<h2><?php echo __('Template');?></h2>
<dl>
<dt><?php echo __('Id'); ?></dt>
<dd>
<?php echo h($template['Template']['id']); ?>
&nbsp;
</dd>
<dt><?php echo __('Name'); ?></dt>
<dd>
<?php echo h($template['Template']['name']); ?>
&nbsp;
</dd>
<dt><?php echo __('Description'); ?></dt>
<dd>
<?php echo h($template['Template']['description']); ?>
&nbsp;
</dd>
<dt><?php echo __('Tags'); ?></dt>
<dd>
<table>
<tr id = "tags">
<?php
if (!empty($template['TemplateTag'])) {
foreach ($template['TemplateTag'] as $tag) {
echo $this->element('ajaxTemplateTag', array('tag' => $tag, 'editable' => 'no'));
}
} else echo '&nbsp';
?>
</tr>
</table>
</dd>
<dt><?php echo __('Organisation'); ?></dt>
<dd>
<?php echo h($template['Template']['org']); ?>
&nbsp;
</dd>
<dt><?php echo __('Shareable'); ?></dt>
<dd>
<?php
if ($template['Template']['share']) echo __('Yes');
else echo __('No');
?>
</dd>
</dl>
<div id="templateElements">
</div>
</div>
<?php
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'templates', 'menuItem' => 'view', 'mayModify' => $mayModify));
?>
<script type="text/javascript">
$(document).ready( function () {
updateIndex(<?php echo $template['Template']['id']?>, 'template');
});
</script>
$this->set('menuData', ['menuList' => 'templates', 'menuItem' => 'view', 'mayModify' => $mayModify]);
echo $this->element(
'genericElements/SingleViews/single_view',
[
'title' => 'Template',
'data' => $template,
'fields' => [
[
'key' => __('Id'),
'path' => 'Template.id'
],
[
'key' => __('Name'),
'path' => 'Template.name'
],
[
'key' => __('Description'),
'path' => 'Template.description'
],
[
'key' => __('Tags'),
'path' => 'TemplateTag',
'type' => 'tags'
],
[
'key' => __('Organisation'),
'path' => 'Template.org',
],
[
'key' => __('Shareable'),
'path' => 'Template.share',
'type' => 'boolean'
]
]
]
);
echo $this->element('templateElements/templateElements', ['templateId' => $template['Template']['id']]);