Search in sources :

Example 1 with TaskDateType

use of de.symeda.sormas.api.task.TaskDateType in project SORMAS-Project by hzi-braunschweig.

the class TaskGridFilterForm method buildWeekAndDateFilter.

private HorizontalLayout buildWeekAndDateFilter() {
    EpiWeekAndDateFilterComponent<TaskDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(false, false, null, TaskDateType.values(), I18nProperties.getString(Strings.promptTaskDateType), TaskDateType.DUE_DATE, this);
    weekAndDateFilter.getWeekFromFilter().setInputPrompt(I18nProperties.getString(Strings.promptTaskEpiWeekFrom));
    weekAndDateFilter.getWeekToFilter().setInputPrompt(I18nProperties.getString(Strings.promptTaskEpiWeekTo));
    weekAndDateFilter.getDateFromFilter().setInputPrompt(I18nProperties.getString(Strings.promptTaskDateFrom));
    weekAndDateFilter.getDateToFilter().setInputPrompt(I18nProperties.getString(Strings.promptTaskDateTo));
    addApplyHandler(e -> onApplyClick(weekAndDateFilter));
    HorizontalLayout dateFilterRowLayout = new HorizontalLayout();
    dateFilterRowLayout.setSpacing(true);
    dateFilterRowLayout.setSizeUndefined();
    dateFilterRowLayout.addComponent(weekAndDateFilter);
    return dateFilterRowLayout;
}
Also used : TaskDateType(de.symeda.sormas.api.task.TaskDateType) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with TaskDateType

use of de.symeda.sormas.api.task.TaskDateType in project SORMAS-Project by hzi-braunschweig.

the class TaskGridFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(TaskCriteria newValue) {
    // Date/Epi week filter
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    TaskDateType taskDateType = newValue.getStartDateFrom() != null ? TaskDateType.SUGGESTED_START_DATE : newValue.getDueDateFrom() != null ? TaskDateType.DUE_DATE : null;
    weekAndDateFilter.getDateTypeSelector().setValue(taskDateType);
    weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
    Date dateFrom = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateFrom() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateFrom() : null;
    Date dateTo = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateTo() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateTo() : null;
    if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
        weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
        weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
    } else {
        weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
        weekAndDateFilter.getDateToFilter().setValue(dateTo);
    }
}
Also used : NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) TaskDateType(de.symeda.sormas.api.task.TaskDateType) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)

Example 3 with TaskDateType

use of de.symeda.sormas.api.task.TaskDateType in project SORMAS-Project by hzi-braunschweig.

the class TaskGridFilterForm method onApplyClick.

private void onApplyClick(EpiWeekAndDateFilterComponent<TaskDateType> weekAndDateFilter) {
    TaskCriteria criteria = getValue();
    DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
    Date fromDate, toDate;
    if (dateFilterOption == DateFilterOption.DATE) {
        Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
        fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
        Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
        toDate = dateFrom != null ? DateHelper.getEndOfDay(dateTo) : null;
    } else {
        fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
        toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
    }
    if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
        TaskDateType taskDateType = (TaskDateType) weekAndDateFilter.getDateTypeSelector().getValue();
        if (taskDateType == TaskDateType.DUE_DATE) {
            criteria.dueDateBetween(fromDate, toDate);
            criteria.startDateBetween(null, null);
        } else {
            criteria.startDateBetween(fromDate, toDate);
            criteria.dueDateBetween(null, null);
        }
        criteria.dateFilterOption(dateFilterOption);
    } else {
        weekAndDateFilter.setNotificationsForMissingFilters();
    }
}
Also used : DateFilterOption(de.symeda.sormas.api.utils.DateFilterOption) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) TaskDateType(de.symeda.sormas.api.task.TaskDateType) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Aggregations

TaskDateType (de.symeda.sormas.api.task.TaskDateType)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 EpiWeekAndDateFilterComponent (de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)2 Date (java.util.Date)2 NewCaseDateType (de.symeda.sormas.api.caze.NewCaseDateType)1 TaskCriteria (de.symeda.sormas.api.task.TaskCriteria)1 DateFilterOption (de.symeda.sormas.api.utils.DateFilterOption)1 EpiWeek (de.symeda.sormas.api.utils.EpiWeek)1