diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-10-12 14:28:08 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-10-12 14:28:08 -0400 |
commit | b7060b33ef317eeac576c504b1fb840d4471e411 (patch) | |
tree | 8acf657eda4df76285905fc5e774aacecb02f488 /app/Controller | |
parent | deeebd8e72a13fcbe6d357aefed9130671ee5161 (diff) |
Add pagination/column sorting for search and completed tasks
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Base.php | 1 | ||||
-rw-r--r-- | app/Controller/Project.php | 50 | ||||
-rw-r--r-- | app/Controller/Task.php | 2 |
3 files changed, 34 insertions, 19 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php index abe702a2..9fab0752 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -30,6 +30,7 @@ use Model\LastLogin; * @property \Model\Task $task * @property \Model\TaskHistory $taskHistory * @property \Model\TaskExport $taskExport + * @property \Model\TaskFinder $taskFinder * @property \Model\TaskPermission $taskPermission * @property \Model\TaskValidator $taskValidator * @property \Model\CommentHistory $commentHistory diff --git a/app/Controller/Project.php b/app/Controller/Project.php index b1c67960..f998e5d6 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -395,26 +395,31 @@ class Project extends Base { $project = $this->getProject(); $search = $this->request->getStringParam('search'); + $direction = $this->request->getStringParam('direction', 'DESC'); + $order = $this->request->getStringParam('order', 'tasks.id'); + $offset = $this->request->getIntegerParam('offset', 0); $tasks = array(); $nb_tasks = 0; + $limit = 25; if ($search !== '') { - - $filters = array( - array('column' => 'project_id', 'operator' => 'eq', 'value' => $project['id']), - 'or' => array( - array('column' => 'title', 'operator' => 'like', 'value' => '%'.$search.'%'), - //array('column' => 'description', 'operator' => 'like', 'value' => '%'.$search.'%'), - ) - ); - - $tasks = $this->task->find($filters); - $nb_tasks = count($tasks); + $tasks = $this->taskFinder->search($project['id'], $search, $offset, $limit, $order, $direction); + $nb_tasks = $this->taskFinder->countSearch($project['id'], $search); } $this->response->html($this->template->layout('project_search', array( 'tasks' => $tasks, 'nb_tasks' => $nb_tasks, + 'pagination' => array( + 'controller' => 'project', + 'action' => 'search', + 'params' => array('search' => $search, 'project_id' => $project['id']), + 'direction' => $direction, + 'order' => $order, + 'total' => $nb_tasks, + 'offset' => $offset, + 'limit' => $limit, + ), 'values' => array( 'search' => $search, 'controller' => 'project', @@ -436,16 +441,25 @@ class Project extends Base public function tasks() { $project = $this->getProject(); + $direction = $this->request->getStringParam('direction', 'DESC'); + $order = $this->request->getStringParam('order', 'tasks.date_completed'); + $offset = $this->request->getIntegerParam('offset', 0); + $limit = 25; - $filters = array( - array('column' => 'project_id', 'operator' => 'eq', 'value' => $project['id']), - array('column' => 'is_active', 'operator' => 'eq', 'value' => TaskModel::STATUS_CLOSED), - ); - - $tasks = $this->task->find($filters); - $nb_tasks = count($tasks); + $tasks = $this->taskFinder->getClosedTasks($project['id'], $offset, $limit, $order, $direction); + $nb_tasks = $this->task->countByProjectId($project['id'], array(TaskModel::STATUS_CLOSED)); $this->response->html($this->template->layout('project_tasks', array( + 'pagination' => array( + 'controller' => 'project', + 'action' => 'tasks', + 'params' => array('project_id' => $project['id']), + 'direction' => $direction, + 'order' => $order, + 'total' => $nb_tasks, + 'offset' => $offset, + 'limit' => $limit, + ), 'project' => $project, 'columns' => $this->board->getColumnsList($project['id']), 'categories' => $this->category->getList($project['id'], false), diff --git a/app/Controller/Task.php b/app/Controller/Task.php index 695e29ec..4c15d8df 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -365,7 +365,7 @@ class Task extends Base if ($this->request->getStringParam('confirmation') === 'yes') { $this->checkCSRFParam(); - $task_id = $this->task->duplicateSameProject($task); + $task_id = $this->task->duplicateToSameProject($task); if ($task_id) { $this->session->flash(t('Task created successfully.')); |