diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-05-17 17:35:39 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-05-17 17:35:39 -0400 |
commit | 5e4b40665fa11ce0fd0fe957a19e2b7e63f47446 (patch) | |
tree | b0e458788f84c03608154866ec3e964ec89ccb14 /controllers | |
parent | 09da5720e8dccaa2437a7b25d992eaa104753684 (diff) |
Rewrite board drag and drop with jquery (touch devices, IE, auto-update)
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/base.php | 3 | ||||
-rw-r--r-- | controllers/board.php | 50 |
2 files changed, 38 insertions, 15 deletions
diff --git a/controllers/base.php b/controllers/base.php index b4f438c3..37353ff0 100644 --- a/controllers/base.php +++ b/controllers/base.php @@ -212,8 +212,9 @@ abstract class Base $this->response->redirect('?controller=user&action=forbidden'); } - // Attach events for automatic actions + // Attach events $this->action->attachEvents(); + $this->project->attachEvents(); } /** diff --git a/controllers/board.php b/controllers/board.php index 4fae32ea..8eea4dcc 100644 --- a/controllers/board.php +++ b/controllers/board.php @@ -174,20 +174,13 @@ class Board extends Base $this->notfound(); } - $filters = array(); - $users = $this->project->getUsersList($project_id, true, true); - - if ($user_id !== \Model\User::EVERYBODY_ID && in_array($user_id, array_keys($users))) { - $filters[] = array('column' => 'owner_id', 'operator' => 'eq', 'value' => $user_id); - } - $this->response->html($this->template->layout('board_index', array( - 'users' => $users, + 'users' => $this->project->getUsersList($project_id, true, true), 'filters' => array('user_id' => $user_id), 'projects' => $projects, 'current_project_id' => $project_id, 'current_project_name' => $projects[$project_id], - 'columns' => $this->board->get($project_id, $filters), + 'board' => $this->board->get($project_id), 'menu' => 'boards', 'title' => $projects[$project_id] ))); @@ -351,14 +344,43 @@ class Board extends Base public function save() { $project_id = $this->request->getIntegerParam('project_id'); + $values = $this->request->getValues(); if ($project_id > 0 && ! $this->project->isUserAllowed($project_id, $this->acl->getUserId())) { - $this->response->json(array('result' => false), 401); + $this->response->text('Not Authorized', 401); + } + + if (isset($values['positions'])) { + $this->board->saveTasksPosition($values['positions']); } - $this->response->json(array( - 'result' => $this->board->saveTasksPosition($this->request->getValues()), - 'refresh' => $this->event->getLastListenerExecuted() !== '' - )); + $this->response->html( + $this->template->load('board_show', array('current_project_id' => $project_id, 'board' => $this->board->get($project_id))), + 201 + ); + } + + /** + * Check if the board have been changed + * + * @access public + */ + public function check() + { + $project_id = $this->request->getIntegerParam('project_id'); + $timestamp = $this->request->getIntegerParam('timestamp'); + + if ($project_id > 0 && ! $this->project->isUserAllowed($project_id, $this->acl->getUserId())) { + $this->response->text('Not Authorized', 401); + } + + if ($this->project->isModifiedSince($project_id, $timestamp)) { + $this->response->html( + $this->template->load('board_show', array('current_project_id' => $project_id, 'board' => $this->board->get($project_id))) + ); + } + else { + $this->response->status(304); + } } } |