feature : persistent sort

This commit is contained in:
2026-07-13 10:25:28 -03:00
parent 7ba4348de1
commit d079198103
7 changed files with 335 additions and 1 deletions

View 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 ? '&#8595;' : '&#8593;' ?></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>

View File

@@ -55,6 +55,13 @@
<p class="form-help"><?= t('On the board and the card view, click the title to open the edit modal (only where you may edit).') ?></p>
</fieldset>
<fieldset>
<legend><?= t('Board columns') ?></legend>
<?= $this->form->checkbox('organon_tweaks_persistent_sort', t('Per-column persistent sort'), 1, isset($values['organon_tweaks_persistent_sort']) && $values['organon_tweaks_persistent_sort'] == 1) ?>
<p class="form-help"><?= t('Replaces the native column sort with a control that adds a number-aware Title sort and a "Persistent sort: ON/OFF" toggle. When ON, the column is re-sorted whenever a card is dropped in or created, so it stays sorted (a red up/down arrow marks it). OFF is the native one-shot sort.') ?></p>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
</div>