feature : persistent sort
This commit is contained in:
69
Template/board/sort_control.php
Normal file
69
Template/board/sort_control.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// Per-column persistent-sort control. Rendered by template:board:column:dropdown (so it sits in the
|
||||
// column header, as its own dropdown); relocate.js hides the native fa-sort menu in its favour.
|
||||
// Icon: native double-arrow when persistent is off, a red single arrow (up=asc / down=desc) when on.
|
||||
if ($column['nb_tasks'] <= 0 || ! $this->user->hasProjectAccess('TaskModificationController', 'update', $column['project_id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pid = $column['project_id'];
|
||||
$cid = $column['id'];
|
||||
$sid = $swimlane['id'];
|
||||
|
||||
$sticky = $this->OrganonSortHelper->isSticky($pid, $cid);
|
||||
$curBy = $this->OrganonSortHelper->sortBy($pid, $cid);
|
||||
$curDir = $this->OrganonSortHelper->sortDir($pid, $cid);
|
||||
$applied = $curBy !== '';
|
||||
$desc = $curDir === 'desc';
|
||||
|
||||
$criteria = array(
|
||||
array('title', 'asc', t('Title (A to Z)')),
|
||||
array('title', 'desc', t('Title (Z to A)')),
|
||||
array('id', 'asc', t('Id (ASC)')),
|
||||
array('id', 'desc', t('Id (DESC)')),
|
||||
array('priority', 'asc', t('Priority (ASC)')),
|
||||
array('priority', 'desc', t('Priority (DESC)')),
|
||||
array('due-date', 'asc', t('Due date (ASC)')),
|
||||
array('due-date', 'desc', t('Due date (DESC)')),
|
||||
array('assignee', 'asc', t('Assignee (A-Z)')),
|
||||
array('assignee', 'desc', t('Assignee (Z-A)')),
|
||||
array('assignee-priority', 'asc', t('Assignee + priority (ASC)')),
|
||||
array('assignee-priority', 'desc', t('Assignee + priority (DESC)')),
|
||||
);
|
||||
?>
|
||||
<span class="dropdown organontweaks-sort">
|
||||
<a href="#" class="dropdown-menu" title="<?= t('Sort this column') ?>">
|
||||
<?php if ($sticky && $applied): ?>
|
||||
<?php /* Persistent ON: a single red arrow for the direction (8593 up / 8595 down),
|
||||
written as HTML entities so the source stays ASCII. OFF = the native
|
||||
double-arrow (fa-sort) below -- the natural, non-sticky state. */ ?>
|
||||
<span class="organontweaks-sort-arrow" style="color: #c0392b;"><?= $desc ? '↓' : '↑' ?></span>
|
||||
<?php else: ?>
|
||||
<i class="fa fa-sort fa-fw" aria-hidden="true"></i>
|
||||
<?php endif ?>
|
||||
</a>
|
||||
<ul>
|
||||
<li>
|
||||
<?= $this->url->link(
|
||||
'<i class="fa fa-thumb-tack fa-fw"></i> '.($sticky ? t('Persistent sort: ON') : t('Persistent sort: OFF')),
|
||||
'OrganonSortController',
|
||||
'toggle',
|
||||
array('plugin' => 'OrganonTweaks', 'project_id' => $pid, 'column_id' => $cid),
|
||||
true
|
||||
) ?>
|
||||
</li>
|
||||
<li class="no-hover"><strong><?= t('Sort by') ?></strong></li>
|
||||
<?php foreach ($criteria as $c): ?>
|
||||
<?php $active = ($curBy === $c[0] && $curDir === $c[1]); ?>
|
||||
<li>
|
||||
<?= $this->url->link(
|
||||
'<i class="fa '.($active ? 'fa-check' : '').' fa-fw"></i> '.$this->text->e($c[2]),
|
||||
'OrganonSortController',
|
||||
'sort',
|
||||
array('plugin' => 'OrganonTweaks', 'project_id' => $pid, 'column_id' => $cid, 'swimlane_id' => $sid, 'sort' => $c[0], 'direction' => $c[1]),
|
||||
true
|
||||
) ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</span>
|
||||
Reference in New Issue
Block a user