chg: migrate /tags/add view to factory

pull/7656/head
Luciano Righetti 2021-08-11 16:04:14 +02:00
parent 485c8e5928
commit a9d8609297
2 changed files with 51 additions and 42 deletions

View File

@ -207,6 +207,8 @@ class TagsController extends AppController
$users = [0 => 'Unrestricted'] + $users;
$this->set('users', $users);
}
$this->set('menuData', ['menuList' => 'tags', 'menuItem' => 'add']);
}
public function quickAdd()
@ -281,8 +283,9 @@ class TagsController extends AppController
));
$users = [0 => 'Unrestricted'] + $users;
$this->set('users', $users);
$this->set('menuData', ['menuList' => 'tags', 'menuItem' => 'edit']);
$this->request->data = $this->Tag->read(null, $id);
$this->render('add');
}
public function delete($id)

View File

@ -1,46 +1,52 @@
<div class="tag form">
<?php echo $this->Form->create('Tag');?>
<fieldset>
<legend><?php echo __('Add Tag');?></legend>
<?php
echo $this->Form->input('name', array(
));
echo $this->Form->input('colour', array(
));
echo $this->Form->input('org_id', array(
<?php
echo $this->element('genericElements/Form/genericForm', [
'data' => [
'title' => isset($edit) ? __('Edit Tag') : __('Add Tag'),
'fields' => [
[
'field' => 'name',
'label' => __('Name')
],
[
'field' => 'colour',
'label' => __('Colour'),
'class' => 'colorpicker-element'
],
[
'field' => 'org_id',
'label' => __('Restrict tagging to org'),
'options' => $orgs,
'label' => __('Restrict tagging to org')
));
if ($isSiteAdmin) {
echo $this->Form->input('user_id', array(
'options' => $users,
'label' => __('Restrict tagging to user')
));
}
?>
<div class="clear"></div>
<?php
echo $this->Form->input('exportable', array(
'type' => 'checkbox', 'checked' => true
));
?>
<div class="clear"></div>
<?php
echo $this->Form->input('hide_tag', array(
'type' => 'checkbox', 'checked' => false
));
?>
</fieldset>
<?php
echo $this->Form->button(__('Add'), array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
</div>
<?php
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'tags', 'menuItem' => 'add'));
'type' => 'dropdown'
],
[
'field' => 'user_id',
'label' => __('Restrict tagging to user'),
'options' => $users,
'type' => 'dropdown',
'requirements' => $isSiteAdmin,
],
[
'field' => 'exportable',
'default' => 1,
'type' => 'checkbox'
],
[
'field' => 'hide_tag',
'type' => 'checkbox'
]
],
'submit' => [
'action' => $this->request->params['action'],
'ajaxSubmit' => 'submitGenericFormInPlace();'
]
]
]);
if (!$ajax) {
echo $this->element('/genericElements/SideMenu/side_menu', $menuData);
}
?>
<script>
$(function(){
$(function() {
$('#TagColour').colorpicker();
});
</script>
</script>