Add formatters

This commit is contained in:
Frederic Guillot
2015-09-20 22:18:56 -04:00
parent f579663adc
commit 689687dd4e
20 changed files with 651 additions and 377 deletions

View File

@@ -213,7 +213,7 @@ class App extends Base
{
$search = $this->request->getStringParam('term');
$filter = $this->taskFilter
$filter = $this->taskFilterAutoCompleteFormatter
->create()
->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()))
->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')));
@@ -226,6 +226,6 @@ class App extends Base
$filter->filterByTitle($search);
}
$this->response->json($filter->toAutoCompletion());
$this->response->json($filter->format());
}
}

View File

@@ -37,20 +37,20 @@ class Calendar extends Base
$end = $this->request->getStringParam('end');
// Common filter
$filter = $this->taskFilter
$filter = $this->taskFilterCalendarFormatter
->search($this->userSession->getFilters($project_id))
->filterByProject($project_id);
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
$events = $filter->copy()->filterByCreationDateRange($start, $end)->toDateTimeCalendarEvents('date_creation', 'date_completed');
$events = $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format();
}
else {
$events = $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed');
$events = $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format();
}
// Tasks with due date
$events = array_merge($events, $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents());
$events = array_merge($events, $filter->copy()->filterByDueDateRange($start, $end)->setColumns('date_due')->setFullDay()->format());
$events = $this->hook->merge('controller:calendar:project:events', $events, array(
'project_id' => $project_id,
@@ -71,17 +71,17 @@ 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);
$filter = $this->taskFilterCalendarFormatter->create()->filterByOwner($user_id)->filterByStatus(TaskModel::STATUS_OPEN);
// Task with due date
$events = $filter->copy()->filterByDueDateRange($start, $end)->toAllDayCalendarEvents();
$events = $filter->copy()->filterByDueDateRange($start, $end)->setColumns('date_due')->setFullDay()->format();
// 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'));
$events = array_merge($events, $filter->copy()->filterByCreationDateRange($start, $end)->setColumns('date_creation', 'date_completed')->format());
}
else {
$events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->toDateTimeCalendarEvents('date_started', 'date_completed'));
$events = array_merge($events, $filter->copy()->filterByStartDateRange($start, $end)->setColumns('date_started', 'date_completed')->format());
}
// Subtasks time tracking

View File

@@ -25,7 +25,7 @@ class Gantt extends Base
}
$this->response->html($this->template->layout('gantt/projects', array(
'projects' => $this->project->getGanttBars($project_ids),
'projects' => $this->projectGanttFormatter->filter($project_ids)->format(),
'title' => t('Gantt chart for all projects'),
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
)));
@@ -57,7 +57,7 @@ class Gantt extends Base
public function project()
{
$params = $this->getProjectFilters('gantt', 'project');
$filter = $this->taskFilter->search($params['filters']['search'])->filterByProject($params['project']['id']);
$filter = $this->taskFilterGanttFormatter->search($params['filters']['search'])->filterByProject($params['project']['id']);
$sorting = $this->request->getStringParam('sorting', 'board');
if ($sorting === 'date') {
@@ -70,7 +70,7 @@ class Gantt extends Base
$this->response->html($this->template->layout('gantt/project', $params + array(
'users_list' => $this->projectPermission->getMemberList($params['project']['id'], false),
'sorting' => $sorting,
'tasks' => $filter->toGanttBars(),
'tasks' => $filter->format(),
)));
}

View File

@@ -29,7 +29,7 @@ class Ical extends Base
}
// Common filter
$filter = $this->taskFilter
$filter = $this->taskFilterICalendarFormatter
->create()
->filterByOwner($user['id']);
@@ -58,7 +58,7 @@ class Ical extends Base
}
// Common filter
$filter = $this->taskFilter
$filter = $this->taskFilterICalendarFormatter
->create()
->filterByProject($project['id']);
@@ -83,16 +83,31 @@ class Ical extends Base
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
$filter->copy()->filterByCreationDateRange($start, $end)->addDateTimeIcalEvents('date_creation', 'date_completed', $calendar);
$filter
->copy()
->filterByCreationDateRange($start, $end)
->setColumns('date_creation', 'date_completed')
->setCalendar($calendar)
->addDateTimeEvents();
}
else {
$filter->copy()->filterByStartDateRange($start, $end)->addDateTimeIcalEvents('date_started', 'date_completed', $calendar);
$filter
->copy()
->filterByStartDateRange($start, $end)
->setColumns('date_started', 'date_completed')
->setCalendar($calendar)
->addDateTimeEvents($calendar);
}
// Tasks with due date
$filter->copy()->filterByDueDateRange($start, $end)->addAllDayIcalEvents('date_due', $calendar);
$filter
->copy()
->filterByDueDateRange($start, $end)
->setColumns('date_due')
->setCalendar($calendar)
->addFullDayEvents($calendar);
$this->response->contentType('text/calendar; charset=utf-8');
echo $calendar->render();
echo $filter->setCalendar($calendar)->format();
}
}