diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-07-12 16:51:20 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-07-12 16:51:20 -0400 |
commit | bf59465b10c3f360d8c860b55bcd40d78af74f4a (patch) | |
tree | e1a1178444db243cd1465ec8684ff20283ab7165 /app | |
parent | 59df72d4763bbe640543f3026f33c15363e14116 (diff) |
Use ajax requests for board collapse/expand
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/Board.php | 58 | ||||
-rw-r--r-- | app/Template/project/filters.php | 7 |
2 files changed, 40 insertions, 25 deletions
diff --git a/app/Controller/Board.php b/app/Controller/Board.php index ac80a192..50d9c62e 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -88,15 +88,7 @@ class Board extends Base return $this->response->status(400); } - $this->response->html( - $this->template->render('board/table_container', array( - 'project' => $this->project->getById($project_id), - 'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id), - 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), - 'board_highlight_period' => $this->config->get('board_highlight_period'), - )), - 201 - ); + $this->response->html($this->renderBoard($project_id), 201); } /** @@ -121,14 +113,7 @@ class Board extends Base return $this->response->status(304); } - $this->response->html( - $this->template->render('board/table_container', array( - 'project' => $this->project->getById($project_id), - 'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id), - 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), - 'board_highlight_period' => $this->config->get('board_highlight_period'), - )) - ); + $this->response->html($this->renderBoard($project_id)); } /** @@ -318,9 +303,7 @@ class Board extends Base */ public function collapse() { - $project_id = $this->request->getIntegerParam('project_id'); - $this->userSession->setBoardDisplayMode($project_id, true); - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); + $this->changeDisplayMode(true); } /** @@ -330,8 +313,39 @@ class Board extends Base */ public function expand() { + $this->changeDisplayMode(false); + } + + /** + * Change display mode + * + * @access private + */ + private function changeDisplayMode($mode) + { $project_id = $this->request->getIntegerParam('project_id'); - $this->userSession->setBoardDisplayMode($project_id, false); - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); + $this->userSession->setBoardDisplayMode($project_id, $mode); + + if ($this->request->isAjax()) { + $this->response->html($this->renderBoard($project_id)); + } + else { + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); + } + } + + /** + * Render board + * + * @access private + */ + private function renderBoard($project_id) + { + return $this->template->render('board/table_container', array( + 'project' => $this->project->getById($project_id), + 'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id), + 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), + 'board_highlight_period' => $this->config->get('board_highlight_period'), + )); } } diff --git a/app/Template/project/filters.php b/app/Template/project/filters.php index cb6f11d3..e2fdc751 100644 --- a/app/Template/project/filters.php +++ b/app/Template/project/filters.php @@ -5,13 +5,14 @@ <ul> <?php if (isset($is_board)): ?> <li> - <?php if ($this->board->isCollapsed($project['id'])): ?> + <span class="filter-display-mode" <?= $this->board->isCollapsed($project['id']) ? '' : 'style="display: none;"' ?>> <i class="fa fa-expand fa-fw"></i> <?= $this->url->link(t('Expand tasks'), 'board', 'expand', array('project_id' => $project['id']), false, 'board-display-mode', t('Keyboard shortcut: "%s"', 's')) ?> - <?php else: ?> + </span> + <span class="filter-display-mode" <?= $this->board->isCollapsed($project['id']) ? 'style="display: none;"' : '' ?>> <i class="fa fa-compress fa-fw"></i> <?= $this->url->link(t('Collapse tasks'), 'board', 'collapse', array('project_id' => $project['id']), false, 'board-display-mode', t('Keyboard shortcut: "%s"', 's')) ?> - <?php endif ?> + </span> </li> <li> <span class="filter-compact"> |