Skip to content
Permalink
Browse files

Modifying bake templates for a fresher look.

Some of the highlights:

* It uses a couple foundation css classes, I plan to remove this later
* Index tables are limited to 7 fields
* TEXT type fields are removed for the index table
* Reordered the pagination elements for a better look
  • Loading branch information...
lorenzo committed Sep 5, 2014
1 parent edf9187 commit 205f3e97c7379837d1c6d829290b1215c1d986d7
Showing with 75 additions and 63 deletions.
  1. +23 −22 src/Template/Bake/default/views/form.ctp
  2. +52 −41 src/Template/Bake/default/views/index.ctp
@@ -13,8 +13,30 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Utility\Inflector;
?>
<div class="<?= $pluralVar ?> form">
<div class="actions columns large-2 medium-3">
<h3><?= "<?= __('Actions') ?>" ?></h3>
<ul class="side-nav">
<?php if (strpos($action, 'add') === false): ?>
<li><?= "<?= \$this->Form->postLink(__('Delete'), ['action' => 'delete', \${$singularVar}->{$primaryKey[0]}], ['confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}->{$primaryKey[0]})]) ?>" ?></li>
<?php endif; ?>
<li><?= "<?= \$this->Html->link(__('List " . $pluralHumanName . "'), ['action' => 'index']) ?>" ?></li>
<?php
$done = [];
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?= \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']) ?> </li>\n";
echo "\t\t<li><?= \$this->Html->link(__('New " . Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']) ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
</div>
<div class="<?= $pluralVar ?> form large-10 medium-9 columns">
<?= "<?= \$this->Form->create(\${$singularVar}) ?>\n" ?>
<fieldset>
<legend><?= sprintf("<?= __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName) ?></legend>
@@ -45,24 +67,3 @@ use Cake\Utility\Inflector;
echo "<?= \$this->Form->end() ?>\n";
?>
</div>
<div class="actions">
<h3><?= "<?= __('Actions') ?>" ?></h3>
<ul>
<?php if (strpos($action, 'add') === false): ?>
<li><?= "<?= \$this->Form->postLink(__('Delete'), ['action' => 'delete', \${$singularVar}->{$primaryKey[0]}], ['confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}->{$primaryKey[0]})]) ?>" ?></li>
<?php endif; ?>
<li><?= "<?= \$this->Html->link(__('List " . $pluralHumanName . "'), ['action' => 'index']) ?>" ?></li>
<?php
$done = [];
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?= \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']) ?> </li>\n";
echo "\t\t<li><?= \$this->Html->link(__('New " . Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']) ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
</div>
@@ -13,73 +13,84 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Utility\Inflector;
$fields = collection($fields)
->filter(function($field) use ($schema) {
return !in_array($schema->columnType($field), ['binary', 'text']);
})
->take(7);
?>
<div class="actions columns large-2 medium-3">
<h3><?= "<?= __('Actions') ?>"; ?></h3>
<ul class="side-nav">
<li><?= "<?= \$this->Html->link(__('New " . $singularHumanName . "'), ['action' => 'add']) ?>"; ?></li>
<?php
$done = [];
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?= \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']) ?> </li>\n";
echo "\t\t<li><?= \$this->Html->link(__('New " . Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']) ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
<div class="<?= $pluralVar ?> index">
<h2><?= "<?= __('{$pluralHumanName}') ?>"; ?></h2>
</ul>
</div>
<div class="<?= $pluralVar ?> index large-10 medium-9 columns">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<?php foreach ($fields as $field): ?>
<th><?= "<?= \$this->Paginator->sort('{$field}') ?>"; ?></th>
<th><?= "<?= \$this->Paginator->sort('{$field}') ?>"; ?></th>
<?php endforeach; ?>
<th class="actions"><?= "<?= __('Actions') ?>"; ?></th>
<th class="actions"><?= "<?= __('Actions') ?>"; ?></th>
</tr>
</thead>
<tbody>
<?php
echo "<?php foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
echo "\t<tr>\n";
echo "\t\t<tr>\n";
foreach ($fields as $field) {
$isKey = false;
if (!empty($associations['BelongsTo'])) {
foreach ($associations['BelongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<td>\n\t\t\t<?= \${$singularVar}->has('{$details['property']}') ? \$this->Html->link(\${$singularVar}->{$details['property']}->{$details['displayField']}, ['controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}->{$details['property']}->{$details['primaryKey'][0]}]) : '' ?>\n\t\t</td>\n";
echo "\t\t\t<td>\n\t\t\t\t<?= \${$singularVar}->has('{$details['property']}') ? \$this->Html->link(\${$singularVar}->{$details['property']}->{$details['displayField']}, ['controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}->{$details['property']}->{$details['primaryKey'][0]}]) : '' ?>\n\t\t\t</td>\n";
break;
}
}
}
if ($isKey !== true) {
echo "\t\t<td><?= h(\${$singularVar}->{$field}) ?>&nbsp;</td>\n";
echo "\t\t\t<td><?= h(\${$singularVar}->{$field}) ?>&nbsp;</td>\n";
}
}
$pk = "\${$singularVar}->{$primaryKey[0]}";
echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t<?= \$this->Html->link(__('View'), ['action' => 'view', {$pk}]) ?>\n";
echo "\t\t\t<?= \$this->Html->link(__('Edit'), ['action' => 'edit', {$pk}]) ?>\n";
echo "\t\t\t<?= \$this->Form->postLink(__('Delete'), ['action' => 'delete', {$pk}], ['confirm' => __('Are you sure you want to delete # {0}?', {$pk})]) ?>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?= \$this->Html->link(__('View'), ['action' => 'view', {$pk}]) ?>\n";
echo "\t\t\t\t<?= \$this->Html->link(__('Edit'), ['action' => 'edit', {$pk}]) ?>\n";
echo "\t\t\t\t<?= \$this->Form->postLink(__('Delete'), ['action' => 'delete', {$pk}], ['confirm' => __('Are you sure you want to delete # {0}?', {$pk})]) ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";
echo "\t<?php endforeach; ?>\n";
?>
</thead>
</table>
<p><?= "<?= \$this->Paginator->counter() ?>"; ?></p>
<ul class="pagination">
<?php
echo "<?php\n";
echo "\t\techo \$this->Paginator->prev('< ' . __('previous'));\n";
echo "\t\techo \$this->Paginator->numbers();\n";
echo "\t\techo \$this->Paginator->next(__('next') . ' >');\n";
echo "\t?>\n";
?>
</ul>
</div>
<div class="actions">
<h3><?= "<?= __('Actions') ?>"; ?></h3>
<ul>
<li><?= "<?= \$this->Html->link(__('New " . $singularHumanName . "'), ['action' => 'add']) ?>"; ?></li>
<?php
$done = [];
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?= \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']) ?> </li>\n";
echo "\t\t<li><?= \$this->Html->link(__('New " . Inflector::humanize(Inflector::singularize(Inflector::underscore($alias))) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']) ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
<div class="paginator">
<ul class="pagination">
<?php
echo "<?php\n";
echo "\t\t\techo \$this->Paginator->prev('< ' . __('previous'));\n";
echo "\t\t\techo \$this->Paginator->numbers();\n";
echo "\t\t\techo \$this->Paginator->next(__('next') . ' >');\n";
echo "\t\t?>\n";
?>
</ul>
<p><?= "<?= \$this->Paginator->counter() ?>"; ?></p>
</div>
</div>

0 comments on commit 205f3e9

Please sign in to comment.
You can’t perform that action at this time.