Merge pull-request #1350

This commit is contained in:
Frederic Guillot
2015-10-12 11:49:56 -04:00
9 changed files with 39 additions and 7 deletions

View File

@@ -116,6 +116,10 @@ class Customfilter extends Base
$values += array('is_shared' => 0); $values += array('is_shared' => 0);
} }
if (! isset($values['append'])) {
$values += array('append' => 0);
}
list($valid, $errors) = $this->customFilter->validateModification($values); list($valid, $errors) = $this->customFilter->validateModification($values);
if ($valid) { if ($valid) {

View File

@@ -40,7 +40,8 @@ class CustomFilter extends Base
self::TABLE.'.project_id', self::TABLE.'.project_id',
self::TABLE.'.filter', self::TABLE.'.filter',
self::TABLE.'.name', self::TABLE.'.name',
self::TABLE.'.is_shared' self::TABLE.'.is_shared',
self::TABLE.'.append'
) )
->asc(self::TABLE.'.name') ->asc(self::TABLE.'.name')
->join(User::TABLE, 'id', 'user_id') ->join(User::TABLE, 'id', 'user_id')

View File

@@ -6,7 +6,12 @@ use PDO;
use Core\Security; use Core\Security;
use Model\Link; use Model\Link;
const VERSION = 90; const VERSION = 91;
function version_91($pdo)
{
$pdo->exec("ALTER TABLE custom_filters ADD COLUMN append TINYINT(1) DEFAULT 0");
}
function version_90($pdo) function version_90($pdo)
{ {

View File

@@ -6,7 +6,12 @@ use PDO;
use Core\Security; use Core\Security;
use Model\Link; use Model\Link;
const VERSION = 70; const VERSION = 71;
function version_71($pdo)
{
$pdo->exec("ALTER TABLE custom_filters ADD COLUMN append BOOLEAN DEFAULT '0'");
}
function version_70($pdo) function version_70($pdo)
{ {

View File

@@ -6,7 +6,12 @@ use Core\Security;
use PDO; use PDO;
use Model\Link; use Model\Link;
const VERSION = 85; const VERSION = 86;
function version_86($pdo)
{
$pdo->exec("ALTER TABLE custom_filters ADD COLUMN append INTEGER DEFAULT 0");
}
function version_85($pdo) function version_85($pdo)
{ {

View File

@@ -16,6 +16,8 @@
<?= $this->form->checkbox('is_shared', t('Share with all project members'), 1) ?> <?= $this->form->checkbox('is_shared', t('Share with all project members'), 1) ?>
<?php endif ?> <?php endif ?>
<?= $this->form->checkbox('append', t('Append filter (instead of replacement)'), 1) ?>
<div class="form-actions"> <div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
</div> </div>

View File

@@ -22,6 +22,8 @@
<?= $this->form->hidden('is_shared', $values) ?> <?= $this->form->hidden('is_shared', $values) ?>
<?php endif ?> <?php endif ?>
<?= $this->form->checkbox('append', t('Append filter (instead of replacement)'), 1, $values['append'] == 1) ?>
<div class="form-actions"> <div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
<?= t('or') ?> <?= t('or') ?>

View File

@@ -8,6 +8,7 @@
<th><?= t('Name') ?></th> <th><?= t('Name') ?></th>
<th><?= t('Filter') ?></th> <th><?= t('Filter') ?></th>
<th><?= t('Shared') ?></th> <th><?= t('Shared') ?></th>
<th><?= t('Append/Replace') ?></th>
<th><?= t('Owner') ?></th> <th><?= t('Owner') ?></th>
<th><?= t('Actions') ?></th> <th><?= t('Actions') ?></th>
</tr> </tr>
@@ -22,6 +23,13 @@
<?= t('No') ?> <?= t('No') ?>
<?php endif ?> <?php endif ?>
</td> </td>
<td>
<?php if ($filter['append'] == 1): ?>
<?= t('Append') ?>
<?php else: ?>
<?= t('Replace') ?>
<?php endif ?>
</td>
<td><?= $this->e($filter['owner_name'] ?: $filter['owner_username']) ?></td> <td><?= $this->e($filter['owner_name'] ?: $filter['owner_username']) ?></td>
<td> <td>
<?php if ($filter['user_id'] == $this->user->getId() || $this->user->isProjectManagementAllowed($project['id'])): ?> <?php if ($filter['user_id'] == $this->user->getId() || $this->user->isProjectManagementAllowed($project['id'])): ?>

View File

@@ -68,7 +68,7 @@
<i class="fa fa-caret-down"></i> <a href="#" class="dropdown-menu"><?= t('My filters') ?></a> <i class="fa fa-caret-down"></i> <a href="#" class="dropdown-menu"><?= t('My filters') ?></a>
<ul> <ul>
<?php foreach ($custom_filters_list as $filter): ?> <?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> <li><a href="#" class="filter-helper" data-<?php if($filter['append']): ?><?= 'append-' ?><?php endif ?>filter='<?= $this->e($filter['filter']) ?>'><?= $this->e($filter['name']) ?></a></li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
</div> </div>