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;
}
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);
}
}
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();
}
}
Aggregations