diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-05-16 21:04:46 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-05-16 21:04:46 -0400 |
commit | e94a2f6a00b59a6e2b63d461794b01a2b9d07473 (patch) | |
tree | 4e097bcad8f070515dcf9a0edf1af5acef0305aa /app/Controller | |
parent | b028b3586c5022753e9ff390a042aac9f5b863f4 (diff) |
Display tasks in the calendar + improve settings
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Calendar.php | 49 | ||||
-rw-r--r-- | app/Controller/Config.php | 45 |
2 files changed, 74 insertions, 20 deletions
diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php index 49c7f56e..41642a59 100644 --- a/app/Controller/Calendar.php +++ b/app/Controller/Calendar.php @@ -47,7 +47,8 @@ class Calendar extends Base $start = $this->request->getStringParam('start'); $end = $this->request->getStringParam('end'); - $due_tasks = $this->taskFilter + // Common filter + $filter = $this->taskFilter ->create() ->filterByProject($project_id) ->filterByCategory($this->request->getIntegerParam('category_id', -1)) @@ -55,11 +56,20 @@ class Calendar extends Base ->filterByColumn($this->request->getIntegerParam('column_id', -1)) ->filterBySwimlane($this->request->getIntegerParam('swimlane_id', -1)) ->filterByColor($this->request->getStringParam('color_id')) - ->filterByStatus($this->request->getIntegerParam('is_active', -1)) - ->filterByDueDateRange($start, $end) - ->toCalendarEvents(); + ->filterByStatus($this->request->getIntegerParam('is_active', -1)); - $this->response->json($due_tasks); + // Tasks + if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') { + $events = $filter->copy()->filterByCreationDateRange($start, $end)->toDateTimeCalendarEvents('date_creation', 'date_completed'); + } + else { + $events = $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed'); + } + + // Tasks with due date + $events = array_merge($events, $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents()); + + $this->response->json($events); } /** @@ -72,19 +82,30 @@ class Calendar extends Base $user_id = $this->request->getIntegerParam('user_id'); $start = $this->request->getStringParam('start'); $end = $this->request->getStringParam('end'); + $filter = $this->taskFilter->create()->filterByOwner($user_id)->filterByStatus(TaskModel::STATUS_OPEN); - $due_tasks = $this->taskFilter - ->create() - ->filterByOwner($user_id) - ->filterByStatus(TaskModel::STATUS_OPEN) - ->filterByDueDateRange($start, $end) - ->toCalendarEvents(); + // Task with due date + $events = $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents(); - $subtask_timeslots = $this->subtaskTimeTracking->getUserCalendarEvents($user_id, $start, $end); + // Tasks + if ($this->config->get('calendar_user_tasks', 'date_started') === 'date_creation') { + $events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->toDateTimeCalendarEvents('date_creation', 'date_completed')); + } + else { + $events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed')); + } + + // Subtasks time tracking + if ($this->config->get('calendar_user_subtasks_time_tracking') == 1) { + $events = array_merge($events, $this->subtaskTimeTracking->getUserCalendarEvents($user_id, $start, $end)); + } - $subtask_forcast = $this->config->get('subtask_forecast') == 1 ? $this->subtaskForecast->getCalendarEvents($user_id, $end) : array(); + // Subtask estimates + if ($this->config->get('calendar_user_subtasks_forecast') == 1) { + $events = array_merge($events, $this->subtaskForecast->getCalendarEvents($user_id, $end)); + } - $this->response->json(array_merge($due_tasks, $subtask_timeslots, $subtask_forcast)); + $this->response->json($events); } /** diff --git a/app/Controller/Config.php b/app/Controller/Config.php index c17b9f64..fbd374ab 100644 --- a/app/Controller/Config.php +++ b/app/Controller/Config.php @@ -40,11 +40,16 @@ class Config extends Base $values = $this->request->getValues(); - if ($redirect === 'board') { - $values += array('subtask_restriction' => 0, 'subtask_time_tracking' => 0, 'subtask_forecast' => 0); - } - else if ($redirect === 'integrations') { - $values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0, 'integration_gravatar' => 0, 'integration_jabber' => 0); + switch ($redirect) { + case 'project': + $values += array('subtask_restriction' => 0, 'subtask_time_tracking' => 0); + break; + case 'integrations': + $values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0, 'integration_gravatar' => 0, 'integration_jabber' => 0); + break; + case 'calendar': + $values += array('calendar_user_subtasks_forecast' => 0, 'calendar_user_subtasks_time_tracking' => 0); + break; } if ($this->config->save($values)) { @@ -90,6 +95,21 @@ class Config extends Base } /** + * Display the project settings page + * + * @access public + */ + public function project() + { + $this->common('project'); + + $this->response->html($this->layout('config/project', array( + 'default_columns' => implode(', ', $this->board->getDefaultColumns()), + 'title' => t('Settings').' > '.t('Project settings'), + ))); + } + + /** * Display the board settings page * * @access public @@ -99,12 +119,25 @@ class Config extends Base $this->common('board'); $this->response->html($this->layout('config/board', array( - 'default_columns' => implode(', ', $this->board->getDefaultColumns()), 'title' => t('Settings').' > '.t('Board settings'), ))); } /** + * Display the calendar settings page + * + * @access public + */ + public function calendar() + { + $this->common('calendar'); + + $this->response->html($this->layout('config/calendar', array( + 'title' => t('Settings').' > '.t('Calendar settings'), + ))); + } + + /** * Display the integration settings page * * @access public |