Search in sources :

Example 91 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class TaskGridFilterForm method addDistrictField.

private ComboBox addDistrictField() {
    final ComboBox districtField = addField(FieldConfiguration.pixelSized(TaskIndexDto.DISTRICT, 200));
    districtField.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
    return districtField;
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Example 92 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class TravelEntryDataForm method addFields.

@Override
protected void addFields() {
    Label travelEntryDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingTravelEntryData));
    travelEntryDataHeadingLabel.addStyleName(H3);
    getContent().addComponent(travelEntryDataHeadingLabel, TRAVEL_ENTRY_HEADING_LOC);
    addField(TravelEntryDto.REPORT_DATE, DateField.class);
    addFields(TravelEntryDto.UUID, TravelEntryDto.REPORTING_USER);
    TextField externalIdField = addField(TravelEntryDto.EXTERNAL_ID, TextField.class);
    style(externalIdField, ERROR_COLOR_PRIMARY);
    ComboBox diseaseField = addDiseaseField(TravelEntryDto.DISEASE, false);
    ComboBox diseaseVariantField = addField(TravelEntryDto.DISEASE_VARIANT, ComboBox.class);
    diseaseVariantField.setNullSelectionAllowed(true);
    diseaseVariantField.setVisible(false);
    addField(TravelEntryDto.DISEASE_DETAILS, TextField.class);
    TextField diseaseVariantDetailsField = addField(TravelEntryDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    addField(TravelEntryDto.RECOVERED).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
    addField(TravelEntryDto.VACCINATED).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
    addField(TravelEntryDto.TESTED_NEGATIVE).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
    addField(TravelEntryDto.DATE_OF_ARRIVAL).setRequired(true);
    Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
    jurisdictionHeadingLabel.addStyleName(H3);
    getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
    responsibleRegion = addInfrastructureField(TravelEntryDto.RESPONSIBLE_REGION);
    responsibleRegion.setRequired(true);
    responsibleDistrict = addInfrastructureField(TravelEntryDto.RESPONSIBLE_DISTRICT);
    responsibleDistrict.setRequired(true);
    responsibleCommunity = addInfrastructureField(TravelEntryDto.RESPONSIBLE_COMMUNITY);
    responsibleCommunity.setNullSelectionAllowed(true);
    responsibleCommunity.addStyleName(SOFT_REQUIRED);
    InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
    differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
    differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
    Label pointOfEntryHeadingLabel = new Label(I18nProperties.getCaption(Captions.travelEntryPointOfEntry));
    pointOfEntryHeadingLabel.addStyleName(H3);
    getContent().addComponent(pointOfEntryHeadingLabel, POINT_OF_ENTRY_HEADING_LOC);
    ComboBox regionCombo = addInfrastructureField(TravelEntryDto.REGION);
    districtCombo = addInfrastructureField(TravelEntryDto.DISTRICT);
    differentPointOfEntryJurisdiction.addValueChangeListener(e -> {
        if (!ignoreDifferentPointOfEntryJurisdiction) {
            if (differentPointOfEntryJurisdiction.booleanValue()) {
                districtCombo.setValue(null);
            }
            cbPointOfEntry.setValue(null);
            updatePointsOfEntry();
        }
    });
    cbPointOfEntry = addInfrastructureField(TravelEntryDto.POINT_OF_ENTRY);
    cbPointOfEntry.setImmediate(true);
    TextField tfPointOfEntryDetails = addField(TravelEntryDto.POINT_OF_ENTRY_DETAILS, TextField.class);
    tfPointOfEntryDetails.setVisible(false);
    regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    regionCombo.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    districtCombo.addValueChangeListener(e -> {
        if (differentPointOfEntryJurisdiction.booleanValue()) {
            updatePointsOfEntry();
        }
    });
    quarantine = addField(TravelEntryDto.QUARANTINE);
    quarantine.addValueChangeListener(e -> onQuarantineValueChange());
    quarantineFrom = addField(TravelEntryDto.QUARANTINE_FROM, DateField.class);
    quarantineTo = addDateField(TravelEntryDto.QUARANTINE_TO, DateField.class, -1);
    quarantineFrom.addValidator(new DateComparisonValidator(quarantineFrom, quarantineTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, quarantineFrom.getCaption(), quarantineTo.getCaption())));
    quarantineTo.addValidator(new DateComparisonValidator(quarantineTo, quarantineFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, quarantineTo.getCaption(), quarantineFrom.getCaption())));
    quarantineOrderedVerbally = addField(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, CheckBox.class);
    CssStyles.style(quarantineOrderedVerbally, CssStyles.FORCE_CAPTION);
    addField(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY_DATE, DateField.class);
    quarantineOrderedOfficialDocument = addField(TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CheckBox.class);
    CssStyles.style(quarantineOrderedOfficialDocument, CssStyles.FORCE_CAPTION);
    addField(TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, DateField.class);
    CheckBox quarantineOfficialOrderSent = addField(TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, CheckBox.class);
    CssStyles.style(quarantineOfficialOrderSent, FORCE_CAPTION);
    addField(TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, DateField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Collections.singletonList(Boolean.TRUE), true);
    quarantineExtended = addField(TravelEntryDto.QUARANTINE_EXTENDED, CheckBox.class);
    quarantineExtended.setEnabled(false);
    quarantineExtended.setVisible(false);
    CssStyles.style(quarantineExtended, CssStyles.FORCE_CAPTION);
    quarantineReduced = addField(TravelEntryDto.QUARANTINE_REDUCED, CheckBox.class);
    quarantineReduced.setEnabled(false);
    quarantineReduced.setVisible(false);
    CssStyles.style(quarantineReduced, CssStyles.FORCE_CAPTION);
    TextField quarantineHelpNeeded = addField(TravelEntryDto.QUARANTINE_HELP_NEEDED, TextField.class);
    quarantineHelpNeeded.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    TextField quarantineTypeDetails = addField(TravelEntryDto.QUARANTINE_TYPE_DETAILS, TextField.class);
    quarantineTypeDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    addField(TravelEntryDto.QUARANTINE_HOME_POSSIBLE, NullableOptionGroup.class);
    addField(TravelEntryDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TextField.class);
    addField(TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, NullableOptionGroup.class);
    addField(TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TextField.class);
    addField(TravelEntryDto.DELETION_REASON);
    addField(TravelEntryDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, TravelEntryDto.DELETION_REASON, TravelEntryDto.OTHER_DELETION_REASON);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.QUARANTINE_FROM, TravelEntryDto.QUARANTINE_TO, TravelEntryDto.QUARANTINE_HELP_NEEDED), TravelEntryDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) || isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT), TravelEntryDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TravelEntryDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, TravelEntryDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_TYPE_DETAILS, TravelEntryDto.QUARANTINE, Arrays.asList(QuarantineType.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_ORDERED_VERBALLY_DATE, TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, Collections.singletonList(Boolean.TRUE), true);
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    setRequired(true, TravelEntryDto.REPORT_DATE, TravelEntryDto.POINT_OF_ENTRY, TravelEntryDto.DISEASE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), TravelEntryDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), TravelEntryDto.DISEASE, Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.RECOVERED, TravelEntryDto.VACCINATED, TravelEntryDto.TESTED_NEGATIVE), TravelEntryDto.DISEASE, Disease.DISEASE_LIST, true);
    cbPointOfEntry.addValueChangeListener(e -> updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails));
    FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), true);
    FieldHelper.setRequiredWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
    setReadOnly(true, TravelEntryDto.UUID, TravelEntryDto.REPORTING_USER);
    responsibleDistrict.addValueChangeListener(e -> {
        if (!differentPointOfEntryJurisdiction.booleanValue()) {
            updatePointsOfEntry();
        }
    });
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        diseaseVariantField.setVisible(disease != null && isVisibleAllowed(TravelEntryDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DeaContentEntry(de.symeda.sormas.api.travelentry.DeaContentEntry) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) CssStyles(de.symeda.sormas.ui.utils.CssStyles) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) UserRole(de.symeda.sormas.api.user.UserRole) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) UserProvider(de.symeda.sormas.ui.UserProvider) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ComboBox(com.vaadin.v7.ui.ComboBox) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) List(java.util.List) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) TextField(com.vaadin.v7.ui.TextField) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) FacadeProvider(de.symeda.sormas.api.FacadeProvider) Converter(com.vaadin.v7.data.util.converter.Converter) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) CollectionUtils(org.apache.commons.collections.CollectionUtils) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) SOFT_REQUIRED(de.symeda.sormas.ui.utils.CssStyles.SOFT_REQUIRED) Captions(de.symeda.sormas.api.i18n.Captions) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Disease(de.symeda.sormas.api.Disease) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) TextArea(com.vaadin.v7.ui.TextArea) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CheckBox(com.vaadin.v7.ui.CheckBox) TextField(com.vaadin.v7.ui.TextField) List(java.util.List) DateField(com.vaadin.v7.ui.DateField)

Example 93 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class TravelEntryCreateForm method addFields.

@Override
protected void addFields() {
    addField(TravelEntryDto.REPORT_DATE, DateField.class);
    TextField externalIdField = addField(TravelEntryDto.EXTERNAL_ID, TextField.class);
    style(externalIdField, ERROR_COLOR_PRIMARY);
    ComboBox diseaseField = addDiseaseField(TravelEntryDto.DISEASE, false, true);
    ComboBox diseaseVariantField = addField(TravelEntryDto.DISEASE_VARIANT, ComboBox.class);
    diseaseVariantField.setNullSelectionAllowed(true);
    diseaseVariantField.setVisible(false);
    addField(TravelEntryDto.DISEASE_DETAILS, TextField.class);
    TextField diseaseVariantDetailsField = addField(TravelEntryDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    addField(TravelEntryDto.DATE_OF_ARRIVAL).setRequired(true);
    Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
    jurisdictionHeadingLabel.addStyleName(H3);
    getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
    responsibleRegion = addInfrastructureField(TravelEntryDto.RESPONSIBLE_REGION);
    responsibleRegion.setRequired(true);
    responsibleDistrict = addInfrastructureField(TravelEntryDto.RESPONSIBLE_DISTRICT);
    responsibleDistrict.setRequired(true);
    responsibleCommunity = addInfrastructureField(TravelEntryDto.RESPONSIBLE_COMMUNITY);
    responsibleCommunity.setNullSelectionAllowed(true);
    responsibleCommunity.addStyleName(SOFT_REQUIRED);
    InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
    CheckBox differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
    differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
    Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.travelEntryPointOfEntry));
    placeOfStayHeadingLabel.addStyleName(H3);
    getContent().addComponent(placeOfStayHeadingLabel, POINT_OF_ENTRY_HEADING_LOC);
    ComboBox regionCombo = addInfrastructureField(TravelEntryDto.REGION);
    districtCombo = addInfrastructureField(TravelEntryDto.DISTRICT);
    cbPointOfEntry = addInfrastructureField(TravelEntryDto.POINT_OF_ENTRY);
    cbPointOfEntry.setImmediate(true);
    TextField tfPointOfEntryDetails = addField(TravelEntryDto.POINT_OF_ENTRY_DETAILS, TextField.class);
    tfPointOfEntryDetails.setVisible(false);
    personCreateForm = new PersonCreateForm(false, true, false);
    personCreateForm.setWidth(100, Unit.PERCENTAGE);
    personCreateForm.setValue(new PersonDto());
    getContent().addComponent(personCreateForm, TravelEntryDto.PERSON);
    regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    regionCombo.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    districtCombo.addValueChangeListener(e -> {
        if (differentPointOfEntryJurisdiction.getValue()) {
            DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
            getPointsOfEntryForDistrict(districtDto);
        }
    });
    differentPointOfEntryJurisdiction.addValueChangeListener(v -> {
        if (differentPointOfEntryJurisdiction.getValue()) {
            cbPointOfEntry.removeAllItems();
        } else {
            getPointsOfEntryForDistrict((DistrictReferenceDto) responsibleDistrict.getValue());
        }
    });
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    setRequired(true, TravelEntryDto.REPORT_DATE, TravelEntryDto.POINT_OF_ENTRY, TravelEntryDto.DISEASE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), TravelEntryDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), TravelEntryDto.DISEASE, Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
    cbPointOfEntry.addValueChangeListener(e -> updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails));
    FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), true);
    FieldHelper.setRequiredWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
    responsibleDistrict.addValueChangeListener(e -> {
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        getPointsOfEntryForDistrict(districtDto);
    });
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        diseaseVariantField.setVisible(disease != null && isVisibleAllowed(TravelEntryDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
        personCreateForm.updatePresentConditionEnum(disease);
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    addValueChangeListener(e -> {
        if (personDto != null) {
            personCreateForm.setVisible(false);
            personCreateForm.setReadOnly(false);
        } else {
            personCreateForm.enablePersonFields(true);
        }
    });
}
Also used : AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) CheckBox(com.vaadin.v7.ui.CheckBox) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) DeaContentEntry(de.symeda.sormas.api.travelentry.DeaContentEntry) Converter(com.vaadin.v7.data.util.converter.Converter) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) PersonDto(de.symeda.sormas.api.person.PersonDto) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) CollectionUtils(org.apache.commons.collections.CollectionUtils) Label(com.vaadin.ui.Label) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) UserRole(de.symeda.sormas.api.user.UserRole) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) DEAFormBuilder(de.symeda.sormas.ui.travelentry.DEAFormBuilder) UserProvider(de.symeda.sormas.ui.UserProvider) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) SOFT_REQUIRED(de.symeda.sormas.ui.utils.CssStyles.SOFT_REQUIRED) Captions(de.symeda.sormas.api.i18n.Captions) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) List(java.util.List) Disease(de.symeda.sormas.api.Disease) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) TextField(com.vaadin.v7.ui.TextField) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) Collections(java.util.Collections) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) CheckBox(com.vaadin.v7.ui.CheckBox) PersonDto(de.symeda.sormas.api.person.PersonDto) Label(com.vaadin.ui.Label) TextField(com.vaadin.v7.ui.TextField) List(java.util.List) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 94 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasOptionsForm method addFields.

@Override
protected void addFields() {
    ComboBox availableServersCombo = addField(SormasToSormasOptionsDto.ORGANIZATION, ComboBox.class);
    availableServersCombo.setRequired(true);
    List<SormasServerDescriptor> availableServers = FacadeProvider.getSormasToSormasFacade().getAllAvailableServers();
    availableServersCombo.addItems(availableServers);
    if (hasOptions) {
        CheckBox handoverOwnership = addField(SormasToSormasOptionsDto.HAND_OVER_OWNERSHIP);
        CheckBox pseudonimyzePersonalData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_PERSONAL_DATA);
        CheckBox pseudonymizeSensitiveData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_SENSITIVE_DATA);
        pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
        availableServersCombo.addValueChangeListener(e -> {
            SormasServerDescriptor selectedServer = (SormasServerDescriptor) e.getProperty().getValue();
            if (selectedServer == null) {
                return;
            }
            Optional<SormasToSormasShareInfoDto> previousShare = findShareByOrganization(currentShares, selectedServer.getId());
            previousShare.ifPresent(s -> {
                if (s.getRequestStatus() != ShareRequestStatus.ACCEPTED) {
                    handoverOwnership.setValue(s.isOwnershipHandedOver());
                }
                pseudonimyzePersonalData.setValue(s.isPseudonymizedPersonalData());
                pseudonimyzePersonalData.setValue(s.isPseudonymizedSensitiveData());
                if (updateCustomOptionsByPreviousShare != null) {
                    updateCustomOptionsByPreviousShare.accept(this, s);
                }
            });
        });
        handoverOwnership.addValueChangeListener(e -> {
            boolean ownershipHandedOver = (boolean) e.getProperty().getValue();
            pseudonimyzePersonalData.setEnabled(!ownershipHandedOver);
            pseudonymizeSensitiveData.setEnabled(!ownershipHandedOver);
            if (ownershipHandedOver) {
                pseudonimyzePersonalData.setValue(false);
                pseudonymizeSensitiveData.setValue(false);
            }
        });
        pseudonimyzePersonalData.addValueChangeListener(e -> {
            boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonymizeSensitiveData.getValue();
            handoverOwnership.setEnabled(!pseudonimyze);
            if (pseudonimyze) {
                handoverOwnership.setValue(false);
            }
        });
        pseudonymizeSensitiveData.addValueChangeListener(e -> {
            boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonimyzePersonalData.getValue();
            handoverOwnership.setEnabled(!pseudonimyze);
            if (pseudonimyze) {
                handoverOwnership.setValue(false);
            }
        });
        addFields(customOptions);
        TextArea comment = addField(SormasToSormasOptionsDto.COMMENT, TextArea.class);
        comment.setRows(3);
        if (customFieldDependencies != null) {
            customFieldDependencies.accept(this);
        }
        if (CollectionUtils.isEmpty(customOptions)) {
            pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
        } else {
            getField(customOptions.get(customOptions.size() - 1)).addStyleNames(CssStyles.VSPACE_3);
        }
    }
}
Also used : SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) CheckBox(com.vaadin.v7.ui.CheckBox)

Example 95 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class PrescriptionForm method addFields.

@Override
protected void addFields() {
    ComboBox prescriptionTypeField = addField(PrescriptionDto.PRESCRIPTION_TYPE, ComboBox.class);
    prescriptionTypeField.setImmediate(true);
    TextField prescriptionDetailsField = addField(PrescriptionDto.PRESCRIPTION_DETAILS, TextField.class);
    addField(PrescriptionDto.TYPE_OF_DRUG, NullableOptionGroup.class);
    addField(PrescriptionDto.PRESCRIPTION_DATE, DateField.class);
    addField(PrescriptionDto.PRESCRIBING_CLINICIAN, TextField.class);
    DateField prescriptionStartField = addDateField(PrescriptionDto.PRESCRIPTION_START, DateField.class, -1);
    DateField prescriptionEndField = addDateField(PrescriptionDto.PRESCRIPTION_END, DateField.class, -1);
    prescriptionEndField.setImmediate(true);
    addField(PrescriptionDto.FREQUENCY, TextField.class);
    addField(PrescriptionDto.DOSE, TextField.class);
    ComboBox routeField = addField(PrescriptionDto.ROUTE, ComboBox.class);
    addField(PrescriptionDto.ROUTE_DETAILS, TextField.class);
    TextArea additionalNotes = addField(PrescriptionDto.ADDITIONAL_NOTES, TextArea.class);
    additionalNotes.setRows(6);
    additionalNotes.setDescription(I18nProperties.getPrefixDescription(PrescriptionDto.I18N_PREFIX, PrescriptionDto.ADDITIONAL_NOTES, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    initializeAccessAndAllowedAccesses();
    setRequired(true, PrescriptionDto.PRESCRIPTION_TYPE, PrescriptionDto.PRESCRIPTION_DATE);
    if (isEditableAllowed(PrescriptionDto.PRESCRIPTION_DETAILS)) {
        FieldHelper.setRequiredWhen(getFieldGroup(), prescriptionTypeField, Collections.singletonList(PrescriptionDto.PRESCRIPTION_DETAILS), Arrays.asList(TreatmentType.OTHER, TreatmentType.DRUG_INTAKE));
    }
    if (isEditableAllowed(PrescriptionDto.ROUTE_DETAILS)) {
        FieldHelper.setRequiredWhen(getFieldGroup(), routeField, Arrays.asList(PrescriptionDto.ROUTE_DETAILS), Arrays.asList(TreatmentRoute.OTHER));
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.ROUTE_DETAILS, PrescriptionDto.ROUTE, Arrays.asList(TreatmentRoute.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.TYPE_OF_DRUG, PrescriptionDto.PRESCRIPTION_TYPE, Arrays.asList(TreatmentType.DRUG_INTAKE), true);
    prescriptionTypeField.addValueChangeListener(e -> {
        if (e.getProperty().getValue() == TreatmentType.DRUG_INTAKE) {
            prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.DRUG_INTAKE_DETAILS));
        } else {
            prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_DETAILS));
        }
    });
    prescriptionStartField.addValidator(new DateComparisonValidator(prescriptionStartField, prescriptionEndField, true, false, I18nProperties.getValidationError(Validations.beforeDate, prescriptionStartField.getCaption(), prescriptionEndField.getCaption())));
    prescriptionEndField.addValidator(new DateComparisonValidator(prescriptionEndField, prescriptionStartField, false, false, I18nProperties.getValidationError(Validations.afterDate, prescriptionEndField.getCaption(), prescriptionStartField.getCaption())));
}
Also used : TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14