Refactoring/simplification of the pull-request about links
This commit is contained in:
27
app/Template/tasklink/create.php
Normal file
27
app/Template/tasklink/create.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Add a new link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form action="<?= $this->u('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('task_id', $values) ?>
|
||||
<?= $this->formHidden('opposite_task_id', $values) ?>
|
||||
|
||||
<?= $this->formLabel(t('Label'), 'link_id') ?>
|
||||
<?= $this->formSelect('link_id', $labels, $values, $errors) ?>
|
||||
|
||||
<?= $this->formLabel(t('Task'), 'title') ?>
|
||||
<?= $this->formText(
|
||||
'title',
|
||||
$values,
|
||||
$errors,
|
||||
array('required', 'data-dst-field="opposite_task_id"', 'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"'),
|
||||
'task-autocomplete') ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,53 +0,0 @@
|
||||
<div class="page-header">
|
||||
<?php if (! isset($edit)): ?>
|
||||
<h2><?= t('Add a link') ?></h2>
|
||||
<?php else: ?>
|
||||
<h2><?= t('Edit a link') ?></h2>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($link_list)): ?>
|
||||
<form method="post" action="<?= $this->u('tasklink', isset($edit) ? 'update' : 'save', array('task_id' => $task['id'], 'link_id' => @$values['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
|
||||
<?php if (isset($edit)): ?>
|
||||
<?= $this->formHidden('id', $values) ?>
|
||||
<?= $this->formHidden('task_link_inverse_id', $values) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->formHidden('task_id', $values) ?>
|
||||
|
||||
#<?= $task['id'] ?>
|
||||
 
|
||||
<?= $this->formSelect('link_label_id', $link_list, $values, $errors, 'required autofocus') ?>
|
||||
 
|
||||
#<?= $this->formNumeric('task_inverse_id', $values, $errors, array('required', 'placeholder="'.t('Task id').'"', 'title="'.t('Linked task id').'"', 'list="task_inverse_ids"')) ?>
|
||||
<?php if (!empty($task_list)): ?>
|
||||
<datalist id="task_inverse_ids">
|
||||
<select>
|
||||
<?php foreach ($task_list as $task_inverse_id => $task_inverse_title): ?>
|
||||
<option value="<?= $task_inverse_id ?>">#<?= $task_inverse_id.' '.$task_inverse_title ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</datalist>
|
||||
<?php endif ?>
|
||||
<br/>
|
||||
|
||||
<?php if (! isset($edit)): ?>
|
||||
<?= $this->formCheckbox('another_link', t('Create another link'), 1, isset($values['another_link']) && $values['another_link'] == 1) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-info">
|
||||
<?= t('You need to add link labels to this project before to link this task to another one.') ?>
|
||||
<ul>
|
||||
<li><?= $this->a(t('Add link labels'), 'link', 'index', array('project_id' => $task['project_id'])) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -4,13 +4,11 @@
|
||||
|
||||
<div class="confirm">
|
||||
<p class="alert alert-info">
|
||||
<?= t('Do you really want to remove this link with task #%s?', $link['task_inverse_id']) ?>
|
||||
<br />
|
||||
|
||||
<?= t('Do you really want to remove this link with task #%d?', $link['opposite_task_id']) ?>
|
||||
</p>
|
||||
|
||||
<div class="form-actions">
|
||||
<?= $this->a(t('Yes'), 'tasklink', 'remove', array('task_id' => $task['id'], 'link_id' => $link['id'], 'project_id' => $task['project_id']), true, 'btn btn-red') ?>
|
||||
<?= $this->a(t('Yes'), 'tasklink', 'remove', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), true, 'btn btn-red') ?>
|
||||
<?= t('or') ?>
|
||||
<?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</div>
|
||||
|
||||
@@ -1,68 +1,41 @@
|
||||
<?php if (! empty($links)): ?>
|
||||
<aside id="links" class="task-show-section">
|
||||
<div class="page-header">
|
||||
<h2><?= t('Links') ?></h2>
|
||||
</div>
|
||||
|
||||
<table class="link-table">
|
||||
<tr>
|
||||
<th><?= t('Label') ?></th>
|
||||
<th width="70%"><?= t('Task') ?></th>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<th><?= t('Actions') ?></th>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php $previous_link = null;
|
||||
foreach ($links as $link): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php if (null == $previous_link || $previous_link != $link['label']):
|
||||
$previous_link = $link['label']; ?>
|
||||
<?= t($this->e($link['label'])) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (0 == $link['task_inverse_is_active']): ?><span class="task-closed"><?php endif ?>
|
||||
<?= $this->e($link['task_inverse_category']) ?>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<?= $this->a('#'.$this->e($link['task_inverse_id']).' - '.trim($this->e($link['task_inverse_title'])), 'task', 'show', array('task_id' => $link['task_inverse_id'], 'project_id' => $link['task_inverse_project_id'])) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->a('#'.$this->e($link['task_inverse_id']).' - '.trim($this->e($link['task_inverse_title'])), 'task', 'readonly', array('task_id' => $link['task_inverse_id'], 'project_id' => $link['task_inverse_project_id'], 'token' => $project['token'])) ?>
|
||||
<?php endif ?>
|
||||
<?php if (0 == $link['task_inverse_is_active']): ?></span><?php endif ?>
|
||||
</td>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<td>
|
||||
<ul>
|
||||
<li><?= $this->a(t('Edit'), 'tasklink', 'edit', array('task_id' => $task['id'], 'link_id' => $link['id'], 'project_id' => $task['project_id'])) ?></li>
|
||||
<li><?= $this->a(t('Remove'), 'tasklink', 'confirm', array('task_id' => $task['id'], 'link_id' => $link['id'], 'project_id' => $task['project_id'])) ?></li>
|
||||
</ul>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
||||
<?php if (! isset($not_editable) && !empty($link_list)): ?>
|
||||
<form method="post" action="<?= $this->u('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('task_id', array('task_id' => $task['id'])) ?>
|
||||
#<?= $this->e($task['id']) ?>
|
||||
 
|
||||
<?= $this->formSelect('link_label_id', $link_list, array(), array(), 'required autofocus') ?>
|
||||
 
|
||||
#<?= $this->formNumeric('task_inverse_id', array(), array(), array('required', 'placeholder="'.t('Task id').'"', 'title="'.t('Linked task id').'"', 'list="task_inverse_ids"')) ?>
|
||||
<?php if (!empty($task_list)): ?>
|
||||
<datalist id="task_inverse_ids">
|
||||
<select>
|
||||
<?php foreach ($task_list as $task_inverse_id => $task_inverse_title): ?>
|
||||
<option value="<?= $task_inverse_id ?>">#<?= $task_inverse_id.' '.$task_inverse_title ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</datalist>
|
||||
<div class="page-header">
|
||||
<h2><?= t('Links') ?></h2>
|
||||
</div>
|
||||
<table class="table-fixed" id="links">
|
||||
<tr>
|
||||
<th class="column-30"><?= t('Label') ?></th>
|
||||
<th class="column-60"><?= t('Task') ?></th>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<th><?= t('Action') ?></th>
|
||||
<?php endif ?>
|
||||
<input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
</aside>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php foreach ($links as $link): ?>
|
||||
<tr>
|
||||
<td><?= t('This task') ?> <strong><?= t($link['label']) ?></strong></td>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<td>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' - '.$link['title']),
|
||||
'task', 'show', array('task_id' => $link['task_id'], 'project_id' => $link['project_id']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $this->a(t('Remove'), 'tasklink', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' - '.$link['title']),
|
||||
'task', 'readonly', array('task_id' => $link['task_id'], 'token' => $project['token']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
</td>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
Reference in New Issue
Block a user