From de4519fa2c45ca96d4bf0b9ce288cad600d09854 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 19 Feb 2016 22:59:47 -0500 Subject: Add subtasks drag and drop --- app/Controller/Subtask.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'app/Controller/Subtask.php') diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index f8798906..a0a3eb66 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -23,7 +23,6 @@ class Subtask extends Base 'project' => $this->getProject(), 'subtasks' => $this->subtask->getAll($task['id']), 'editable' => true, - 'redirect' => 'subtask', ))); } @@ -169,15 +168,15 @@ class Subtask extends Base */ public function movePosition() { - $this->checkCSRFParam(); $project_id = $this->request->getIntegerParam('project_id'); $task_id = $this->request->getIntegerParam('task_id'); - $subtask_id = $this->request->getIntegerParam('subtask_id'); - $direction = $this->request->getStringParam('direction'); - $method = $direction === 'up' ? 'moveUp' : 'moveDown'; - $redirect = $this->request->getStringParam('redirect', 'task'); + $values = $this->request->getJson(); + + if (! empty($values) && $this->helper->user->hasProjectAccess('Subtask', 'movePosition', $project_id)) { + $result = $this->subtask->changePosition($task_id, $values['subtask_id'], $values['position']); + $this->response->json(array('result' => $result)); + } - $this->subtask->$method($task_id, $subtask_id); - $this->response->redirect($this->helper->url->to($redirect, 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks')); + $this->forbidden(); } } -- cgit v1.2.3