Add custom filters (refactoring of pull-request #1312)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
'filters' => $filters,
|
||||
'categories_list' => $categories_list,
|
||||
'users_list' => $users_list,
|
||||
'custom_filters_list' => $custom_filters_list,
|
||||
'is_board' => true,
|
||||
)) ?>
|
||||
|
||||
|
||||
22
app/Template/custom_filter/add.php
Normal file
22
app/Template/custom_filter/add.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Add a new filter') ?></h2>
|
||||
</div>
|
||||
<form method="post" action="<?= $this->url->href('customfilter', 'save', array('project_id' => $project['id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('project_id', $values) ?>
|
||||
|
||||
<?= $this->form->label(t('Name'), 'name') ?>
|
||||
<?= $this->form->text('name', $values, $errors, array('required', 'maxlength="100"')) ?>
|
||||
|
||||
<?= $this->form->label(t('Filter'), 'filter') ?>
|
||||
<?= $this->form->text('filter', $values, $errors, array('required', 'maxlength="100"')) ?>
|
||||
|
||||
<?php if ($this->user->isProjectManagementAllowed($project['id'])): ?>
|
||||
<?= $this->form->checkbox('is_shared', t('Share with all project members'), 1) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
|
||||
</div>
|
||||
</form>
|
||||
30
app/Template/custom_filter/edit.php
Normal file
30
app/Template/custom_filter/edit.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Edit custom filter') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="<?= $this->url->href('customfilter', 'update', array('project_id' => $filter['project_id'], 'filter_id' => $filter['id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
|
||||
<?= $this->form->hidden('id', $values) ?>
|
||||
<?= $this->form->hidden('user_id', $values) ?>
|
||||
<?= $this->form->hidden('project_id', $values) ?>
|
||||
|
||||
<?= $this->form->label(t('Name'), 'name') ?>
|
||||
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="100"')) ?>
|
||||
|
||||
<?= $this->form->label(t('Filter'), 'filter') ?>
|
||||
<?= $this->form->text('filter', $values, $errors, array('required', 'maxlength="100"')) ?>
|
||||
|
||||
<?php if ($this->user->isProjectManagementAllowed($project['id'])): ?>
|
||||
<?= $this->form->checkbox('is_shared', t('Share with all project members'), 1, $values['is_shared'] == 1) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->form->hidden('is_shared', $values) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
|
||||
<?= t('or') ?>
|
||||
<?= $this->url->link(t('cancel'), 'customfilter', 'index', array('project_id' => $project['id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
40
app/Template/custom_filter/index.php
Normal file
40
app/Template/custom_filter/index.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php if (! empty($custom_filters)): ?>
|
||||
<div class="page-header">
|
||||
<h2><?= t('Custom filters') ?></h2>
|
||||
</div>
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<th><?= t('Name') ?></th>
|
||||
<th><?= t('Filter') ?></th>
|
||||
<th><?= t('Shared') ?></th>
|
||||
<th><?= t('Owner') ?></th>
|
||||
<th><?= t('Actions') ?></th>
|
||||
</tr>
|
||||
<?php foreach ($custom_filters as $filter): ?>
|
||||
<tr>
|
||||
<td><?= $this->e($filter['name']) ?></td>
|
||||
<td><?= $this->e($filter['filter']) ?></td>
|
||||
<td>
|
||||
<?php if ($filter['is_shared'] == 1): ?>
|
||||
<?= t('Yes') ?>
|
||||
<?php else: ?>
|
||||
<?= t('No') ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td><?= $this->e($filter['owner_name'] ?: $filter['owner_username']) ?></td>
|
||||
<td>
|
||||
<?php if ($filter['user_id'] == $this->user->getId() || $this->user->isProjectManagementAllowed($project['id'])): ?>
|
||||
<ul>
|
||||
<li><?= $this->url->link(t('Remove'), 'customfilter', 'remove', array('project_id' => $filter['project_id'], 'filter_id' => $filter['id']), true) ?></li>
|
||||
<li><?= $this->url->link(t('Edit'), 'customfilter', 'edit', array('project_id' => $filter['project_id'], 'filter_id' => $filter['id'])) ?></li>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->render('custom_filter/add', array('project' => $project, 'values' => $values, 'errors' => $errors)) ?>
|
||||
@@ -2,6 +2,10 @@
|
||||
<i class="fa fa-dashboard fa-fw"></i>
|
||||
<?= $this->url->link(t('Activity'), 'activity', 'project', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-filter fa-fw"></i>
|
||||
<?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
|
||||
<?php if ($project['is_public']): ?>
|
||||
<li>
|
||||
|
||||
@@ -86,5 +86,16 @@
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($custom_filters_list) && ! empty($custom_filters_list)): ?>
|
||||
<div class="dropdown filters">
|
||||
<i class="fa fa-caret-down"></i> <a href="#" class="dropdown-menu"><?= t('My filters') ?></a>
|
||||
<ul>
|
||||
<?php foreach ($custom_filters_list as $filter): ?>
|
||||
<li><a href="#" class="filter-helper" data-filter='<?= $this->e($filter['filter']) ?>'><?= $this->e($filter['name']) ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,6 +4,9 @@
|
||||
<li <?= $this->app->getRouterAction() === 'show' ? 'class="active"' : '' ?>>
|
||||
<?= $this->url->link(t('Summary'), 'project', 'show', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
<li <?= $this->app->getRouterController() === 'customfilter' && $this->app->getRouterAction() === 'index' ? 'class="active"' : '' ?>>
|
||||
<?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
|
||||
<?php if ($this->user->isProjectManagementAllowed($project['id'])): ?>
|
||||
<li <?= $this->app->getRouterController() === 'project' && $this->app->getRouterAction() === 'share' ? 'class="active"' : '' ?>>
|
||||
|
||||
Reference in New Issue
Block a user