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/Project.php | |
parent | deeebd8e72a13fcbe6d357aefed9130671ee5161 (diff) |
Add pagination/column sorting for search and completed tasks
Diffstat (limited to 'app/Controller/Project.php')
-rw-r--r-- | app/Controller/Project.php | 50 |
1 files changed, 32 insertions, 18 deletions
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), |