Skip to content

Commit

Permalink
Adding color filter + Compatibility with Calendar and Wiki theme
Browse files Browse the repository at this point in the history
  • Loading branch information
JB committed Oct 28, 2019
1 parent fc2a04c commit 4c8ec53
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 5 deletions.
23 changes: 23 additions & 0 deletions ColorModel.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ class ColorModel extends BaseColorModel
)
);

/**
* Get available colors
*
* @access public
* @param bool $prepend
* @return array
*/
public function getList($prepend = false, $defaultLanguage = false)
{
$listing = $prepend ? array('' => t('All colors')) : array();
foreach ($this->default_colors as $color_id => $color) {
if ($defaultLanguage) {
$listing[$color_id] = $color['name'];
} else {
$listing[$color_id] = t($color['name']);
}
}

$this->hook->reference('model:color:get-list', $listing);

return $listing;
}

/**
* Get CSS stylesheet of all colors
*
Expand Down
60 changes: 60 additions & 0 deletions MyProjectHeaderHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Kanboard\Plugin\Greenwing;

use Kanboard\Core\Base;

/**
* Project Header Helper
*
* @package helper
* @author Frederic Guillot
*/
class MyProjectHeaderHelper extends Base
{
/**
* Get current search query
*
* @access public
* @param array $project
* @return string
*/
public function getSearchQuery(array $project)
{
$search = $this->request->getStringParam('search', $this->userSession->getFilters($project['id']));
$this->userSession->setFilters($project['id'], $search);
return urldecode($search);
}

/**
* Render project header (views switcher and search box)
*
* @access public
* @param array $project
* @param string $controller
* @param string $action
* @param bool $boardView
* @param string $plugin
* @return string
*/
public function render(array $project, $controller, $action, $boardView = false, $plugin = '')
{
$filters = array(
'controller' => $controller,
'action' => $action,
'project_id' => $project['id'],
'search' => $this->getSearchQuery($project),
'plugin' => $plugin,
);

return $this->template->render('project_header/header', array(
'project' => $project,
'filters' => $filters,
'categories_list' => $this->categoryModel->getList($project['id'], false),
'colors_list' => $this->colorModel->getList(false, true),
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], false),
'custom_filters_list' => $this->customFilterModel->getAll($project['id'], $this->userSession->getId()),
'board_view' => $boardView,
));
}
}
3 changes: 3 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function initialize() {
$this->template->setTemplateOverride( 'user_view/profile', 'Greenwing:profile' );
$this->template->setTemplateOverride( 'auth/index', 'Greenwing:login' );
$this->template->setTemplateOverride( 'password_reset/create', 'Greenwing:password_reset' );
$this->template->setTemplateOverride( 'project_header/search', 'Greenwing:search' );
$this->template->setTemplateOverride( 'board/view_private', 'Greenwing:view_private' );

$this->container['colorModel'] = $this->container->factory( function ( $c ) {
return new ColorModel( $c );
Expand All @@ -52,6 +54,7 @@ public function initialize() {
$this->helper->register( 'myTaskHelper', '\Kanboard\Plugin\Greenwing\MyTaskHelper' );
$this->helper->register( 'myAvatarHelper', '\Kanboard\Plugin\Greenwing\MyAvatarHelper' );
$this->helper->register( 'myFormHelper', '\Kanboard\Plugin\Greenwing\MyFormHelper' );
$this->helper->register( 'myProjectHeaderHelper', '\Kanboard\Plugin\Greenwing\MyProjectHeaderHelper' );

$this->setContentSecurityPolicy( array( 'font-src' => "'self' fonts.gstatic.com" ) );

Expand Down
3 changes: 2 additions & 1 deletion Template/project_header.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="project-header <?= $filters['plugin'] ? 'color-' : '' ?><?= $filters['plugin'] ? $filters['plugin']['task']['color_id'] : '' ?>">
<div class="project-header <?= $filters['plugin'] && gettype($filters['plugin']) == 'array' ? 'color-' : '' ?><?= $filters['plugin'] && gettype($filters['plugin']) == 'array' ? $filters['plugin']['task']['color_id'] : '' ?>">
<?php $filters['plugin'] = '' ?>

<?= $this->hook->render('template:project:header:before', array('project' => $project)) ?>
Expand All @@ -15,6 +15,7 @@
'filters' => $filters,
'custom_filters_list' => isset($custom_filters_list) ? $custom_filters_list : array(),
'users_list' => isset($users_list) ? $users_list : array(),
'colors_list' => isset($colors_list) ? $colors_list : array(),
'categories_list' => isset($categories_list) ? $categories_list : array(),
)) ?>
</div>
Expand Down
71 changes: 71 additions & 0 deletions Template/search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<div class="filter-box">
<form method="get" action="<?= $this->url->dir() ?>" class="search">
<?= $this->form->hidden('controller', $filters) ?>
<?= $this->form->hidden('action', $filters) ?>
<?= $this->form->hidden('plugin', $filters) ?>
<?= $this->form->hidden('project_id', $filters) ?>

<div class="input-addon">
<?= $this->form->text('search', $filters, array(), array('placeholder="'.t('Filter').'"'), 'input-addon-field') ?>
<div class="input-addon-item">
<?= $this->render('app/filters_helper', array('reset' => 'status:open', 'project' => $project)) ?>
</div>

<?php if (isset($custom_filters_list) && ! empty($custom_filters_list)): ?>
<div class="input-addon-item">
<div class="dropdown">
<a href="#" class="dropdown-menu dropdown-menu-link-icon" title="<?= t('Custom filters') ?>"><i class="fa fa-bookmark fa-fw"></i><i class="fa fa-caret-down"></i></a>
<ul>
<?php foreach ($custom_filters_list as $filter): ?>
<li><a href="#" class="filter-helper" data-<?php if ($filter['append']): ?><?= 'append-' ?><?php endif ?>filter='<?= $this->text->e($filter['filter']) ?>'><?= $this->text->e($filter['name']) ?></a></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php endif ?>

<?php if (isset($users_list)): ?>
<div class="input-addon-item">
<div class="dropdown">
<a href="#" class="dropdown-menu dropdown-menu-link-icon" title="<?= t('User filters') ?>"><i class="fa fa-users fa-fw"></i> <i class="fa fa-caret-down"></i></a>
<ul>
<li><a href="#" class="filter-helper" data-unique-filter="assignee:nobody"><?= t('Not assigned') ?></a></li>
<?php foreach ($users_list as $user): ?>
<li><a href="#" class="filter-helper" data-unique-filter='assignee:"<?= $this->text->e($user) ?>"'><?= $this->text->e($user) ?></a></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php endif ?>

<?php if (isset($categories_list) && ! empty($categories_list)): ?>
<div class="input-addon-item">
<div class="dropdown">
<a href="#" class="dropdown-menu dropdown-menu-link-icon" title="<?= t('Category filters') ?>"><i class="fa fa-tags fa-fw"></i><i class="fa fa-caret-down"></i></a>
<ul>
<li><a href="#" class="filter-helper" data-unique-filter="category:none"><?= t('No category') ?></a></li>
<?php foreach ($categories_list as $category): ?>
<li><a href="#" class="filter-helper" data-unique-filter='category:"<?= $this->text->e($category) ?>"'><?= $this->text->e($category) ?></a></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php endif ?>

<div class="input-addon-item">
<div class="dropdown">
<a href="#" class="dropdown-menu dropdown-menu-link-icon" title="<?= t('Category filters') ?>"><i class="fa fa-paint-brush fa-fw"></i><i class="fa fa-caret-down"></i></a>
<ul>
<?php foreach ($colors_list as $color): ?>
<li>
<div class="color-picker-square color-<?= str_replace(' ', '_', strtolower($color)) ?>"></div>
<a href="#" class="filter-helper" data-unique-filter='color:"<?= $this->text->e($color) ?>"'><?= $this->text->e($color) ?></a>
</li>
<?php endforeach ?>
</ul>
</div>
</div>
</div>

</form>
</div>
12 changes: 12 additions & 0 deletions Template/view_private.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section id="main">

<?= $this->myProjectHeaderHelper->render($project, 'BoardViewController', 'show', true) ?>

<?= $this->render('board/table_container', array(
'project' => $project,
'swimlanes' => $swimlanes,
'board_private_refresh_interval' => $board_private_refresh_interval,
'board_highlight_period' => $board_highlight_period,
)) ?>

</section>
2 changes: 2 additions & 0 deletions dist/main-e6cea98ce5.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/main-e6cea98ce5.css.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/main-f1edf4f1ce.css

This file was deleted.

1 change: 0 additions & 1 deletion dist/main-f1edf4f1ce.css.map

This file was deleted.

2 changes: 1 addition & 1 deletion dist/rev-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"main.css": "main-f1edf4f1ce.css"
"main.css": "main-e6cea98ce5.css"
}

0 comments on commit 4c8ec53

Please sign in to comment.