summaryrefslogtreecommitdiff
path: root/app/Template/link
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-14 16:11:13 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-14 16:11:13 -0500
commitf7e4c3928aba9cb7f5222cb4af67846312bbb435 (patch)
tree78f5854a0bdc538c977bad718a11d605a4caaca6 /app/Template/link
parent364382b1b58db8bf1bd2c8866e21c869a7a5d6d0 (diff)
Refactoring/simplification of the pull-request about links
Diffstat (limited to 'app/Template/link')
-rw-r--r--app/Template/link/create.php18
-rw-r--r--app/Template/link/edit.php48
-rw-r--r--app/Template/link/index.php21
-rw-r--r--app/Template/link/remove.php26
4 files changed, 52 insertions, 61 deletions
diff --git a/app/Template/link/create.php b/app/Template/link/create.php
new file mode 100644
index 00000000..12589574
--- /dev/null
+++ b/app/Template/link/create.php
@@ -0,0 +1,18 @@
+<div class="page-header">
+ <h2><?= t('Add a new link') ?></h2>
+</div>
+
+<form action="<?= $this->u('link', 'save') ?>" method="post" autocomplete="off">
+
+ <?= $this->formCsrf() ?>
+
+ <?= $this->formLabel(t('Label'), 'label') ?>
+ <?= $this->formText('label', $values, $errors, array('required')) ?>
+
+ <?= $this->formLabel(t('Opposite label'), 'opposite_label') ?>
+ <?= $this->formText('opposite_label', $values, $errors) ?>
+
+ <div class="form-actions">
+ <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
+ </div>
+</form> \ No newline at end of file
diff --git a/app/Template/link/edit.php b/app/Template/link/edit.php
index 71d4f3ca..d9ce280c 100644
--- a/app/Template/link/edit.php
+++ b/app/Template/link/edit.php
@@ -1,49 +1,21 @@
-<section id="link-edit-section">
-<?php use Model\Link;
-if (! isset($edit)): ?>
- <h3><?= t('Add a new link label') ?></h3>
-<?php else: ?>
<div class="page-header">
- <h2><?= t('Edit the link label') ?></h2>
+ <h2><?= t('Link modification') ?></h2>
</div>
-<?php endif ?>
-<form method="post" action="<?= $this->u('link', isset($edit) ? 'update' : 'save', array('project_id' => $project['id'], 'link_id' => @$values['id'])) ?>" autocomplete="off">
+<form action="<?= $this->u('link', 'update', array('link_id' => $link['id'])) ?>" method="post" autocomplete="off">
+
<?= $this->formCsrf() ?>
+ <?= $this->formHidden('id', $values) ?>
- <?php if (isset($edit)): ?>
- <?= $this->formHidden('link_id', $values) ?>
- <?= $this->formHidden('id[0]', $values[0]) ?>
- <?php if (isset($values[1])): ?>
- <?= $this->formHidden('id[1]', $values[1]) ?>
- <?php endif ?>
- <?php endif ?>
- <?= $this->formHidden('project_id', $values) ?>
+ <?= $this->formLabel(t('Label'), 'label') ?>
+ <?= $this->formText('label', $values, $errors, array('required')) ?>
- <?= $this->formLabel(t('Link Label'), 'label[0]') ?>
- <?= $this->formText('label[0]', $values[0], $errors, array('required', 'autofocus', 'placeholder="'.t('precedes').'"')) ?> &raquo;
-
- <?= $this->formCheckbox('behaviour[0]', t('Bidrectional link label'), Link::BEHAVIOUR_BOTH, (isset($values[0]['behaviour']) && Link::BEHAVIOUR_BOTH == $values[0]['behaviour']), 'behaviour') ?>
+ <?= $this->formLabel(t('Opposite label'), 'opposite_id') ?>
+ <?= $this->formSelect('opposite_id', $labels, $values, $errors) ?>
- <div class="link-inverse-label">
- <?= $this->formLabel(t('Link Inverse Label'), 'label[1]') ?>
- &laquo; <?= $this->formText('label[1]', isset($values[1]) ? $values[1] : $values, $errors, array('placeholder="'.t('follows').'"')) ?>
- </div>
-
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
- <?php if (isset($edit)): ?>
<?= t('or') ?>
- <?= $this->a(t('cancel'), 'link', 'index', array('project_id' => $project['id'])) ?>
- <?php endif ?>
- </div>
- <?php if (! isset($edit)): ?>
- <div class="alert alert-info">
- <strong><?= t('Example:') ?></strong>
- <i><?= t('#9 precedes #10') ?></i>
- <?= t('and therefore') ?>
- <i><?= t('#10 follows #9') ?></i>
+ <?= $this->a(t('cancel'), 'link', 'index') ?>
</div>
- <?php endif ?>
-</form>
-</section> \ No newline at end of file
+</form> \ No newline at end of file
diff --git a/app/Template/link/index.php b/app/Template/link/index.php
index 0c19b614..90d1c357 100644
--- a/app/Template/link/index.php
+++ b/app/Template/link/index.php
@@ -1,30 +1,33 @@
<div class="page-header">
<h2><?= t('Link labels') ?></h2>
</div>
-
-<section>
<?php if (! empty($links)): ?>
<table>
<tr>
- <th width="70%"><?= t('Link labels') ?></th>
+ <th class="column-70"><?= t('Link labels') ?></th>
<th><?= t('Actions') ?></th>
</tr>
<?php foreach ($links as $link): ?>
<tr>
- <td><?= t($this->e($link['label'])) ?><?php if (isset($link['label_inverse']) && !empty($link['label_inverse'])): ?> | <?= t($this->e($link['label_inverse'])) ?><?php endif ?></td>
+ <td>
+ <strong><?= t($link['label']) ?></strong>
+
+ <?php if (! empty($link['opposite_label'])): ?>
+ | <?= t($link['opposite_label']) ?>
+ <?php endif ?>
+ </td>
<td>
<ul>
- <?= $this->a(t('Edit'), 'link', 'edit', array('link_id' => $link['link_id'], 'project_id' => $link['project_id'])) ?>
+ <?= $this->a(t('Edit'), 'link', 'edit', array('link_id' => $link['id'])) ?>
<?= t('or') ?>
- <?= $this->a(t('Remove'), 'link', 'confirm', array('link_id' => $link['link_id'], 'project_id' => $link['project_id'])) ?>
+ <?= $this->a(t('Remove'), 'link', 'confirm', array('link_id' => $link['id'])) ?>
</ul>
</td>
</tr>
<?php endforeach ?>
</table>
<?php else: ?>
- <?= t('There is no link yet.') ?>
+ <?= t('There is no link.') ?>
<?php endif ?>
-</section>
-<?= $this->render('link/edit', array('values' => $values, 'errors' => $errors, 'project' => $project)) ?>
+<?= $this->render('link/create', array('values' => $values, 'errors' => $errors)) ?> \ No newline at end of file
diff --git a/app/Template/link/remove.php b/app/Template/link/remove.php
index d0b14b08..a802feb0 100644
--- a/app/Template/link/remove.php
+++ b/app/Template/link/remove.php
@@ -1,17 +1,15 @@
-<section id="main">
- <div class="page-header">
- <h2><?= t('Remove a link') ?></h2>
- </div>
+<div class="page-header">
+ <h2><?= t('Remove a link') ?></h2>
+</div>
- <div class="confirm">
- <p class="alert alert-info">
- <?= t('Do you really want to remove this link: "%s"?', t($link[0]['label']).(isset($link[1]['label']) ? ' | '.t($link[1]['label']) : '')) ?>
- </p>
+<div class="confirm">
+ <p class="alert alert-info">
+ <?= t('Do you really want to remove this link: "%s"?', $link['label']) ?>
+ </p>
- <div class="form-actions">
- <?= $this->a(t('Yes'), 'link', 'remove', array('project_id' => $project['id'], 'link_id' => $link[0]['link_id']), true, 'btn btn-red') ?>
- <?= t('or') ?>
- <?= $this->a(t('cancel'), 'link', 'index', array('project_id' => $project['id'])) ?>
- </div>
+ <div class="form-actions">
+ <?= $this->a(t('Yes'), 'link', 'remove', array('link_id' => $link['id']), true, 'btn btn-red') ?>
+ <?= t('or') ?>
+ <?= $this->a(t('cancel'), 'link', 'index') ?>
</div>
-</section> \ No newline at end of file
+</div> \ No newline at end of file