use of org.activityinfo.model.type.time.PeriodValue in project activityinfo by bedatadriven.
the class AbstractWeekWidget method onDatePickerSelected.
private void onDatePickerSelected(SelectEvent event) {
FieldInput input = input();
if (input.getState() == FieldInput.State.VALID) {
PeriodValue value = (PeriodValue) input.getValue();
dateMenu.getDatePicker().setValue(value.asInterval().getStartDate().atMidnightInMyTimezone());
} else {
dateMenu.getDatePicker().setValue(new Date());
}
dateMenu.show(pickButton);
}
use of org.activityinfo.model.type.time.PeriodValue in project activityinfo by bedatadriven.
the class SubFormViewModelBuilder method computeActiveSubRecord.
private RecordRef computeActiveSubRecord(RecordRef parentRecordRef, FormInputModel inputModel) {
// Has the user chosen a specific period?
Optional<RecordRef> activeSubRecord = inputModel.getActiveSubRecord(fieldId);
if (activeSubRecord.isPresent()) {
return activeSubRecord.get();
}
// Otherwise choose the active record based on the user's previous choices
// or the current date
PeriodValue activePeriod = subFormKind.getPeriodType().containingDate(memory.getLastUsedDate());
ResourceId recordId = ResourceId.periodSubRecordId(parentRecordRef, activePeriod);
return new RecordRef(subFormId, recordId);
}
use of org.activityinfo.model.type.time.PeriodValue in project activityinfo by bedatadriven.
the class SubFormViewModelBuilder method find.
private FormInputViewModel find(RecordRef activeRecord, List<FormInputViewModel> subRecordViews) {
for (FormInputViewModel subRecordView : subRecordViews) {
if (subRecordView.getRecordRef().equals(activeRecord)) {
return subRecordView;
}
}
if (keyField.isPresent()) {
PeriodType periodType = (PeriodType) keyField.get().getType();
PeriodValue periodValue = periodType.fromSubFormKey(activeRecord);
return formBuilder.placeholder(activeRecord, keyField.get(), periodValue);
} else {
return formBuilder.placeholder(activeRecord);
}
}
use of org.activityinfo.model.type.time.PeriodValue in project activityinfo by bedatadriven.
the class KeyedSubFormPanel method onPeriodSelected.
private void onPeriodSelected(FieldInput input) {
if (input.getState() == FieldInput.State.VALID) {
PeriodValue periodValue = (PeriodValue) input.getValue();
changeActivePeriod(periodValue);
}
}
Aggregations