Split the config / options page into tabs based on Category.
Still a lot of work to do such as displaying the proper input type based on option, however basic tabbing and saving works, as does the on-hover tooltip (I think I put that in this commit).
This commit is contained in:
parent
964e1919bc
commit
d64a09576f
|
@ -2,9 +2,21 @@
|
||||||
class ConfigController extends AppController {
|
class ConfigController extends AppController {
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$configs['fields'] = array('Name', 'Id', 'Value', 'Prompt', 'Type');
|
// Get a list of categories
|
||||||
$configs['order'] = array('Config.Category ASC');
|
$categories = $this->Config->find('all', array('fields' => array('Category'), 'group' => array('Category')));
|
||||||
$this->set('configs', $this->Config->find('all', $configs));
|
$this->set('categories', $categories);
|
||||||
|
|
||||||
|
// Build an array of categories with each child option under that category
|
||||||
|
$options = array();
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$name = $category['Config']['Category'];
|
||||||
|
$configs = $this->Config->findAllByCategory($name,
|
||||||
|
array('Name', 'Id', 'Value', 'Prompt', 'Type', 'Category'));
|
||||||
|
$options[$name] = $configs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass the completed array to the view
|
||||||
|
$this->set('options', $options);
|
||||||
|
|
||||||
if (!empty($this->request->data)) {
|
if (!empty($this->request->data)) {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
|
@ -1,21 +1,34 @@
|
||||||
<h2>Configs</h2>
|
<?php echo $this->Form->create('Config', array(
|
||||||
<?php
|
|
||||||
echo $this->Form->create('Config', array(
|
|
||||||
'url' => '/config',
|
'url' => '/config',
|
||||||
'novalidate' => true
|
'novalidate' => true
|
||||||
));
|
)); ?>
|
||||||
foreach ($configs as $config):
|
|
||||||
$id = $config['Config']['Id'];
|
<div id="tabs">
|
||||||
$inputname = 'Config.' . $id . '.' . $config['Config']['Name'];
|
<ul>
|
||||||
|
<?php
|
||||||
|
foreach ($categories as $key => $value) {
|
||||||
|
$category = $value['Config']['Category'];
|
||||||
|
echo '<li><a href="#tabs-'.$category.'">' . $category . '</a></li>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach ($options as $option => $value) {
|
||||||
|
echo "<div id=\"tabs-$option\">";
|
||||||
|
foreach ($value as $val) {
|
||||||
|
$id = $val['Config']['Id'];
|
||||||
|
$inputname = 'Config.' . $id . '.' . $val['Config']['Name'];
|
||||||
echo $this->Form->input($inputname, array(
|
echo $this->Form->input($inputname, array(
|
||||||
'default' => $config['Config']['Value'],
|
'default' => $val['Config']['Value'],
|
||||||
'label' => $config['Config']['Name'],
|
'label' => $val['Config']['Name'],
|
||||||
'after' => $config['Config']['Prompt'],
|
'title' => $val['Config']['Prompt']
|
||||||
));
|
));
|
||||||
echo "\n";
|
echo "\n";
|
||||||
endforeach;
|
}
|
||||||
unset($config);
|
echo "</div>"; // End each category div
|
||||||
echo $this->Form->end('Save Config');
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</table>
|
</div> <!-- End the tabs div -->
|
||||||
|
|
||||||
|
<? echo $this->Form->end('Save Config'); ?>
|
||||||
|
|
|
@ -39,6 +39,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
||||||
echo $this->Html->script('jquery-2.0.1.min');
|
echo $this->Html->script('jquery-2.0.1.min');
|
||||||
echo $this->Html->script('jquery-ui.min');
|
echo $this->Html->script('jquery-ui.min');
|
||||||
echo $this->Html->script('events.js');
|
echo $this->Html->script('events.js');
|
||||||
|
echo $this->Html->script('config.js');
|
||||||
echo $this->Js->writeBuffer();
|
echo $this->Js->writeBuffer();
|
||||||
?>
|
?>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#tabs").tabs();
|
||||||
|
$(document).tooltip({ track:true });
|
||||||
|
});
|
Loading…
Reference in New Issue