Search in sources :

Example 1 with PeriodValue

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);
}
Also used : PeriodValue(org.activityinfo.model.type.time.PeriodValue) FieldInput(org.activityinfo.ui.client.input.model.FieldInput) LocalDate(org.activityinfo.model.type.time.LocalDate) Date(java.util.Date)

Example 2 with PeriodValue

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);
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) RecordRef(org.activityinfo.model.type.RecordRef) PeriodValue(org.activityinfo.model.type.time.PeriodValue)

Example 3 with PeriodValue

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);
    }
}
Also used : PeriodType(org.activityinfo.model.type.time.PeriodType) PeriodValue(org.activityinfo.model.type.time.PeriodValue)

Example 4 with PeriodValue

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);
    }
}
Also used : PeriodValue(org.activityinfo.model.type.time.PeriodValue)

Aggregations

PeriodValue (org.activityinfo.model.type.time.PeriodValue)4 Date (java.util.Date)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 RecordRef (org.activityinfo.model.type.RecordRef)1 LocalDate (org.activityinfo.model.type.time.LocalDate)1 PeriodType (org.activityinfo.model.type.time.PeriodType)1 FieldInput (org.activityinfo.ui.client.input.model.FieldInput)1