Skip to content

Commit

Permalink
Allow Searching and show/hide empty projects
Browse files Browse the repository at this point in the history
  • Loading branch information
stinnux committed Sep 28, 2018
1 parent 706fca9 commit 2fb4782
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 46 deletions.
136 changes: 99 additions & 37 deletions Controller/Bigboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,46 @@ class Bigboard extends BaseController
*/
public function index()
{
if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds();
} else {
$project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());
}
$project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());

$search = urldecode($this->request->getStringParam('search'));

#print $search;
// ->withFilter(new TaskProjectsFilter(array_keys($projects)))

/* $query = $this->taskLexer
->build($search)
->getQuery();
$nb_projects = count($project_ids);
print $query->buildSelectQuery(); */


$nb_projects = count($project_ids);
// Draw a header First
$this->response->html($this->helper->layout->app('bigboard:board/show', array(
'title' => t('Bigboard').' ('.$nb_projects.')',
'board_selector' => false,
'title' => t('Bigboard').' ('.$nb_projects.')',
'board_selector' => false,
)));

echo $this->template->render('bigboard:board/dropdown', array(
'bigboarddisplaymode' => $this->userSession->isBigboardCollapsed(),
'bigboarddisplaymode' => $this->userMetadataCacheDecorator->get("BIGBOARD_COLLAPSED", 0) == 1,
'bigboardprojectmode' => $this->userMetadataCacheDecorator->get("BIGBOARD_SHOWEMPTY", 0) == 1
));

$filters = array(
'controller' => "Bigboard",
'action' => "index",
'search' => $search,
'plugin' => "Bigboard",
);
echo $this->template->render('project_header/search', array(
'filters' => $filters,
'users_list' => $this->userModel->getActiveUsersList(),
));

$this->showProjects($project_ids);
echo "<p>";

$this->showProjects($project_ids);
}

/**
Expand All @@ -54,20 +75,34 @@ private function showProjects($project_ids)
$project = $this->projectModel->getByIdWithOwner($project_id);
$search = $this->helper->projectHeader->getSearchQuery($project);

$this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, $this->userSession->isBigboardCollapsed());

echo $this->template->render('bigboard:board/view', array(
'no_layout' => true,
'board_selector' => false,
'project' => $project,
'title' => $project['name'],
'description' => $this->helper->projectHeader->getDescription($project),
'board_private_refresh_interval' => $this->configModel->get('board_private_refresh_interval'),
'board_highlight_period' => $this->configModel->get('board_highlight_period'),
'swimlanes' => $this->taskLexer
->build($search)
->format(BoardFormatter::getInstance($this->container)->withProjectId($project['id'])),
));
$this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id,
$this->userMetadataCacheDecorator->get("BIGBOARD_COLLAPSED", 0));

$swimlanes = $this->taskLexer
->build($search)
->format(BoardFormatter::getInstance($this->container)->withProjectId($project['id']));

if ($this->userMetadataCacheDecorator->get("BIGBOARD_SHOWEMPTY", 0) == 0) {
# It's only necessary to calculate when empty projects are hidden.
$nb_tasks = 0;
foreach ($swimlanes as $index => $swimlane) {
$nb_tasks += $swimlane['nb_tasks'];
}
}

if ($this->userMetadataCacheDecorator->get("BIGBOARD_SHOWEMPTY", 0) == 1 || $nb_tasks > 0)
{
echo $this->template->render('bigboard:board/view', array(
'no_layout' => true,
'board_selector' => false,
'project' => $project,
'title' => $project['name'],
'description' => $this->helper->projectHeader->getDescription($project),
'board_private_refresh_interval' => $this->configModel->get('board_private_refresh_interval'),
'board_highlight_period' => $this->configModel->get('board_highlight_period'),
'swimlanes' => $swimlanes,
));
}
}

print "</div>";
Expand All @@ -84,20 +119,47 @@ public function expandAll()
$this->changeDisplayMode(false);
}

private function changeDisplayMode($mode)
public function hideEmpty()
{
session_set('bigboardCollapsed', $mode);

if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds();
} else {
$project_ids = $this->projectPermissionModel->getActiveProjectIds(session_get('user')['id']);
}
$this->changeProjectMode(false);
}

if ($this->request->isAjax()) {
$this->showProjects($project_ids);
} else {
$this->response->redirect($this->helper->url->to('Bigboard', 'index', array('plugin' => 'Bigboard')));
}
public function showEmpty()
{
$this->changeProjectMode(true);
}

private function changeProjectMode($mode)
{
$this->userMetadataCacheDecorator->set("BIGBOARD_SHOWEMPTY", $mode);

if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds();
} else {
$project_ids = $this->projectPermissionModel->getActiveProjectIds(session_get('user')['id']);
}

if ($this->request->isAjax()) {
$this->showProjects($project_ids);
} else {
$this->response->redirect($this->helper->url->to('Bigboard', 'index', array('plugin' => 'Bigboard')));
}
}

private function changeDisplayMode($mode)
{
$this->userMetadataCacheDecorator->set("BIGBOARD_COLLAPSED", $mode);

if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds();
} else {
$project_ids = $this->projectPermissionModel->getActiveProjectIds(session_get('user')['id']);
}

if ($this->request->isAjax()) {
$this->showProjects($project_ids);
} else {
$this->response->redirect($this->helper->url->to('Bigboard', 'index', array('plugin' => 'Bigboard')));
}
}
}
5 changes: 1 addition & 4 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public function initialize()
public function getClasses()
{
return array(
'Plugin\Bigboard' => array(
'UserSession'
),
'Plugin\Bigboard\Controller' => array(
'Bigboard',
'BoardAjaxController'
Expand Down Expand Up @@ -54,7 +51,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.5';
return '1.0.6';
}

public function getPluginHomepage()
Expand Down
10 changes: 10 additions & 0 deletions Template/board/dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
<?= $this->url->link(t('Collapse tasks'), 'Bigboard', 'collapseAll', array('plugin' => 'Bigboard'), false, 'board-display-mode', t('Keyboard shortcut: "%s"', 's')) ?>
</span>
</li>
<li>
<span class="filter-display-mode" <?= $bigboardprojectmode ? '' : 'style="display: none;"' ?>>
<i class="fa fa-eye-slash fa-fw"></i>
<?= $this->url->link(t('Hide empty projects'), 'Bigboard', 'hideEmpty', array('plugin' => 'Bigboard'), false, 'board-project-mode', t('Keyboard shortcut: "%s"', 's')) ?>
</span>
<span class="filter-display-mode" <?= $bigboardprojectmode ? 'style="display: none;"' : '' ?>>
<i class="fa fa-eye fa-fw"></i>
<?= $this->url->link(t('Show empty projects'), 'Bigboard', 'showEmpty', array('plugin' => 'Bigboard'), false, 'board-project-mode', t('Keyboard shortcut: "%s"', 's')) ?>
</span>
</li>
<li>
<span class="filter-compact">
<i class="fa fa-th fa-fw"></i> <a href="#" class="filter-toggle-scrolling" title="<?= t('Keyboard shortcut: "%s"', 'c') ?>"><?= t('Compact view') ?></a>
Expand Down
19 changes: 14 additions & 5 deletions Template/board/show.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?

// just an empty file by intent

?>
<!-- <div class="filter-box margin-bottom">
<form method="get" action="<?= $this->url->dir() ?>" class="search">
<?= $this->form->hidden('controller', array('controller' => 'Bigboard')) ?>
<?= $this->form->hidden('action', array('action' => 'index')) ?>
<?= $this->form->hidden('plugin', array('plugin' => 'Bigboard')) ?>
<div class="input-addon">
<?= $this->form->text('search', $values, array(), array(empty($values['search']) ? 'autofocus' : '', 'placeholder="'.t('Search').'"'), 'input-addon-field') ?>
<div class="input-addon-item">
<?= $this->render('app/filters_helper') ?>
</div>
</div>
</form>
</div>
-->

0 comments on commit 2fb4782

Please sign in to comment.