diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/UiUtil.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/UiUtil.java index b28dbe97886..ece7ef2904a 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/UiUtil.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/UiUtil.java @@ -24,7 +24,11 @@ public static boolean permitted(UserRight userRight) { } public static boolean enabled(FeatureType featureType) { - return !FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(featureType); + return !disabled(featureType); + } + + public static boolean disabled(FeatureType featureType) { + return FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(featureType); } public static boolean enabled(Set features) { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaigndata/CampaignFormDataFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaigndata/CampaignFormDataFilterForm.java index 9cd3d3132e9..66876352485 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaigndata/CampaignFormDataFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaigndata/CampaignFormDataFilterForm.java @@ -44,13 +44,14 @@ public class CampaignFormDataFilterForm extends AbstractFilterForm formMetaChangedCallback; private ComboBox cbCampaignForm; - private ComboBox regionFilter; - private ComboBox districtFilter; - private ComboBox communityFilter; protected CampaignFormDataFilterForm() { - super(CampaignFormDataCriteria.class, CampaignFormDataDto.I18N_PREFIX); + super( + CampaignFormDataCriteria.class, + CampaignFormDataDto.I18N_PREFIX, + JurisdictionFieldConfig + .of(CampaignFormDataCriteria.REGION, CampaignFormDataCriteria.DISTRICT, CampaignFormDataCriteria.COMMUNITY)); formActionButtonsComponent.style(CssStyles.FORCE_CAPTION); formActionButtonsComponent.setSpacing(false); formActionButtonsComponent.setSizeFull(); @@ -84,17 +85,17 @@ protected void addFields() { }); } - regionFilter = addField( + ComboBox regionFilter = addField( FieldConfiguration.withCaptionAndPixelSized(CampaignFormDataCriteria.REGION, I18nProperties.getCaption(Captions.Campaign_region), 200)); regionFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllRegions)); regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry()); - districtFilter = addField( + ComboBox districtFilter = addField( FieldConfiguration .withCaptionAndPixelSized(CampaignFormDataCriteria.DISTRICT, I18nProperties.getCaption(Captions.Campaign_district), 200)); districtFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllDistricts)); - communityFilter = addField( + ComboBox communityFilter = addField( FieldConfiguration .withCaptionAndPixelSized(CampaignFormDataCriteria.COMMUNITY, I18nProperties.getCaption(Captions.Campaign_community), 200)); communityFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllCommunities)); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaignstatistics/CampaignStatisticsFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaignstatistics/CampaignStatisticsFilterForm.java index cb22a3f0b2c..384806a00e7 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaignstatistics/CampaignStatisticsFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaignstatistics/CampaignStatisticsFilterForm.java @@ -28,13 +28,14 @@ public class CampaignStatisticsFilterForm extends AbstractFilterForm formMetaChangedCallback; private ComboBox cbCampaignForm; - private ComboBox regionFilter; - private ComboBox districtFilter; - private ComboBox communityFilter; protected CampaignStatisticsFilterForm() { - super(CampaignStatisticsCriteria.class, CampaignStatisticsDto.I18N_PREFIX); + super( + CampaignStatisticsCriteria.class, + CampaignStatisticsDto.I18N_PREFIX, + JurisdictionFieldConfig + .of(CampaignStatisticsCriteria.REGION, CampaignStatisticsCriteria.DISTRICT, CampaignStatisticsCriteria.COMMUNITY)); formActionButtonsComponent.style(CssStyles.FORCE_CAPTION); formActionButtonsComponent.setSpacing(false); formActionButtonsComponent.setSizeFull(); @@ -68,17 +69,17 @@ protected void addFields() { }); } - regionFilter = addField( + ComboBox regionFilter = addField( FieldConfiguration.withCaptionAndPixelSized(CampaignStatisticsCriteria.REGION, I18nProperties.getCaption(Captions.Campaign_region), 200)); regionFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllRegions)); regionFilter.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry()); - districtFilter = addField( + ComboBox districtFilter = addField( FieldConfiguration .withCaptionAndPixelSized(CampaignStatisticsCriteria.DISTRICT, I18nProperties.getCaption(Captions.Campaign_district), 200)); districtFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllDistricts)); - communityFilter = addField( + ComboBox communityFilter = addField( FieldConfiguration .withCaptionAndPixelSized(CampaignStatisticsCriteria.COMMUNITY, I18nProperties.getCaption(Captions.Campaign_community), 200)); communityFilter.setInputPrompt(I18nProperties.getString(Strings.promptAllCommunities)); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/AbstractCaseGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/AbstractCaseGrid.java index 04270341103..a589a9f5378 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/AbstractCaseGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/AbstractCaseGrid.java @@ -36,7 +36,6 @@ import de.symeda.sormas.api.contact.ContactIndexDto; import de.symeda.sormas.api.contact.FollowUpStatus; import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.followup.FollowUpLogic; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.location.LocationDto; @@ -45,6 +44,7 @@ import de.symeda.sormas.api.utils.DateHelper; import de.symeda.sormas.api.utils.SortProperty; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; import de.symeda.sormas.ui.utils.CssStyles; @@ -105,7 +105,7 @@ protected void initColumns() { Column visitsColumn = addColumn(entry -> { Integer numberOfVisits = entry.getVisitCount(); Integer numberOfMissedVisits = entry.getMissedVisitsCount(); - if (numberOfVisits != null && numberOfMissedVisits != null ) { + if (numberOfVisits != null && numberOfMissedVisits != null) { return String.format(I18nProperties.getCaption(Captions.formatNumberOfVisitsFormat), numberOfVisits, numberOfMissedVisits); } else { return "-"; @@ -200,6 +200,10 @@ protected void initColumns() { LocationDto.I18N_PREFIX)); column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId())); } + + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + getColumn(CaseIndexDto.RESPONSIBLE_DISTRICT_NAME).setHidden(true); + } } protected Stream getGridColumns() { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java index 6310bfda226..b078fba6b9c 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java @@ -69,6 +69,7 @@ import de.symeda.sormas.api.user.JurisdictionLevel; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.location.LocationEditForm; import de.symeda.sormas.ui.person.PersonCreateForm; @@ -714,7 +715,7 @@ public void setValue(CaseDataDto caseDataDto) throws com.vaadin.v7.data.Property PersonDto personByUuid = personUuid == null ? null : FacadeProvider.getPersonFacade().getByUuid(personUuid); personCreateForm.setPerson(personByUuid); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideAndFillJurisdictionFields(); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java index ccf33b15aeb..66ecd8e441f 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java @@ -127,6 +127,7 @@ import de.symeda.sormas.api.utils.fieldvisibility.checkers.CountryFieldVisibilityChecker; import de.symeda.sormas.api.utils.fieldvisibility.checkers.UserRightFieldVisibilityChecker; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.caze.surveillancereport.CaseReinfectionCheckBoxTree; import de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm; @@ -1416,7 +1417,7 @@ public String getFormattedHtmlMessage() { } }); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideJurisdictionFields(); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseFilterForm.java index 6807f3fab63..781d752af25 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseFilterForm.java @@ -118,7 +118,11 @@ public class CaseFilterForm extends AbstractFilterForm { + loc(WEEK_AND_DATE_FILTER); protected CaseFilterForm() { - super(CaseCriteria.class, CaseDataDto.I18N_PREFIX, FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale())); + super( + CaseCriteria.class, + CaseDataDto.I18N_PREFIX, + FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()), + JurisdictionFieldConfig.withPrefillOnHide(CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY)); } @Override @@ -345,7 +349,8 @@ public void addMoreFilters(CustomLayout moreFiltersContainer) { CaseCriteria.ONLY_CASES_WITH_EVENTS, I18nProperties.getCaption(Captions.caseFilterRelatedToEvent), I18nProperties.getDescription(Descriptions.descCaseFilterRelatedToEvent), - CssStyles.CHECKBOX_FILTER_INLINE)).setVisible(UiUtil.permitted(UserRight.EVENT_VIEW)); + CssStyles.CHECKBOX_FILTER_INLINE)) + .setVisible(UiUtil.permitted(UserRight.EVENT_VIEW)); addField( moreFiltersContainer, @@ -436,9 +441,6 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC final CaseCriteria criteria = getValue(); - final ComboBox regionField = getField(CaseDataDto.REGION); - final ComboBox districtField = getField(CaseDataDto.DISTRICT); - final ComboBox communityField = getField(CaseDataDto.COMMUNITY); final ComboBox facilityTypeGroupField = getField(CaseCriteria.FACILITY_TYPE_GROUP); final ComboBox facilityTypeField = getField(CaseCriteria.FACILITY_TYPE); final ComboBox facilityField = getField(CaseDataDto.HEALTH_FACILITY); @@ -447,7 +449,7 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC final UserDto user = currentUserDto(); final DistrictReferenceDto currentDistrict = - user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtField.getValue(); + user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtFilter.getValue(); final CaseOrigin currentCaseOrigin = caseOriginField != null ? (CaseOrigin) getField(CaseDataDto.CASE_ORIGIN).getValue() : CaseOrigin.POINT_OF_ENTRY; @@ -459,15 +461,15 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER); officerField.removeAllItems(); if (region != null) { - enableFields(districtField); - FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid())); + enableFields(districtFilter); + FieldHelper.updateItems(districtFilter, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid())); disableFields(pointOfEntryField); - clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField); + clearAndDisableFields(communityFilter, facilityField, facilityTypeField, facilityTypeGroupField); addOfficers(officerField, region); } else { - clearAndDisableFields(districtField, communityField, facilityField, facilityTypeField, facilityTypeGroupField); + clearAndDisableFields(districtFilter, communityFilter, facilityField, facilityTypeField, facilityTypeGroupField); disableFields(pointOfEntryField); addOfficers(officerField, user.getRegion()); } @@ -482,7 +484,7 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER); officerField.removeAllItems(); if (newDistrict != null) { - enableFields(communityField, facilityTypeGroupField); + enableFields(communityFilter, facilityTypeGroupField); clearAndDisableFields(facilityField); if (facilityTypeGroupField != null) { @@ -497,7 +499,7 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC } } - FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(newDistrict.getUuid())); + FieldHelper.updateItems(communityFilter, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(newDistrict.getUuid())); if (pointOfEntryField != null && currentCaseOrigin == CaseOrigin.POINT_OF_ENTRY) { pointOfEntryField.setEnabled(true); @@ -509,9 +511,9 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC officerField .addItems(FacadeProvider.getUserFacade().getUserRefsByDistrict(newDistrict, selectedDisease, UserRight.CASE_RESPONSIBLE)); } else { - clearAndDisableFields(communityField, pointOfEntryField, facilityField, facilityTypeField, facilityTypeGroupField); + clearAndDisableFields(communityFilter, pointOfEntryField, facilityField, facilityTypeField, facilityTypeGroupField); - final RegionReferenceDto region = regionField != null ? (RegionReferenceDto) regionField.getValue() : null; + final RegionReferenceDto region = regionFilter != null ? (RegionReferenceDto) regionFilter.getValue() : null; addOfficers(officerField, region != null ? region : user.getRegion()); } } @@ -566,7 +568,7 @@ protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueC enableFields(facilityField); facilityField.setValue(null); - CommunityReferenceDto community = (CommunityReferenceDto) communityField.getValue(); + CommunityReferenceDto community = (CommunityReferenceDto) communityFilter.getValue(); if (community != null) { FieldHelper.updateItems( facilityField, diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseGridDetailed.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseGridDetailed.java index 3e90c264d55..52a23ebdbcb 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseGridDetailed.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseGridDetailed.java @@ -13,6 +13,7 @@ import de.symeda.sormas.api.caze.CaseCriteria; import de.symeda.sormas.api.caze.CaseIndexDetailedDto; import de.symeda.sormas.api.caze.CaseIndexDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.person.PersonHelper; import de.symeda.sormas.api.symptoms.SymptomsDto; @@ -153,5 +154,10 @@ protected void initColumns() { .setRenderer(new DateRenderer(DateFormatHelper.getDateFormat())) .setCaption(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)) .setWidth(80); + + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + getColumn(CaseIndexDetailedDto.RESPONSIBLE_REGION).setHidden(true); + getColumn(CaseIndexDetailedDto.RESPONSIBLE_COMMUNITY).setHidden(true); + } } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/components/linelisting/LineListingLayout.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/components/linelisting/LineListingLayout.java index 178a0d481f0..e5a34e0b13d 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/components/linelisting/LineListingLayout.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/components/linelisting/LineListingLayout.java @@ -26,6 +26,7 @@ import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.caze.CaseDataDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; @@ -41,6 +42,7 @@ import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.api.utils.UtilDate; import de.symeda.sormas.api.utils.ValidationRuntimeException; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.utils.ButtonHelper; import de.symeda.sormas.ui.utils.CssStyles; @@ -101,7 +103,6 @@ public LineListingLayout(Window window) { district = new ComboBox<>(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_DISTRICT)); district.setItemCaptionGenerator(item -> item.buildCaption()); district.setId("lineListingDistrict"); - district.addValueChangeListener(e -> setEpidNumberPrefixes()); sharedInformationBar.addComponent(district); typeGroup = new ComboBox<>(I18nProperties.getCaption(Captions.Facility_typeGroup)); @@ -160,6 +161,13 @@ public LineListingLayout(Window window) { region.setItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry()); } + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + region.setVisible(false); + region.setValue(FacadeProvider.getRegionFacade().getDefaultInfrastructureReference()); + district.setVisible(false); + district.setValue(FacadeProvider.getDistrictFacade().getDefaultInfrastructureReference()); + } + HorizontalLayout actionBar = new HorizontalLayout(); Button addLine = ButtonHelper.createIconButton(Captions.lineListingAddLine, VaadinIcons.PLUS, e -> { CaseLineLayout newLine = buildNewLine(lineComponent); @@ -488,6 +496,11 @@ public CaseLineLayout(int lineIndex) { } else { formatAsOtherLine(); } + + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + community.setVisible(false); + community.setValue(FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference()); + } } public void setBean(CaseLineDto bean) { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java index f8662a1efff..62a3d4bffbc 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java @@ -25,6 +25,7 @@ import de.symeda.sormas.api.infrastructure.community.CommunityDto; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; import de.symeda.sormas.ui.utils.BooleanRenderer; @@ -56,7 +57,7 @@ public CommunitiesGrid(CommunityCriteria criteria) { CommunityDto.REGION, CommunityDto.DISTRICT, CommunityDto.EXTERNAL_ID }; - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { columns = ArrayUtils.add(columns, CommunityDto.DEFAULT_INFRASTRUCTURE); } setColumns(columns); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java index 4eb083ab5da..85f012a93fa 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java @@ -32,6 +32,7 @@ import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; import de.symeda.sormas.api.infrastructure.region.RegionDto; import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.utils.AbstractEditForm; import de.symeda.sormas.ui.utils.FieldHelper; @@ -67,7 +68,7 @@ protected void addFields() { ComboBox district = addInfrastructureField(CommunityDto.DISTRICT); addField(RegionDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java index 15c1957524c..3e3bd9ea099 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java @@ -28,6 +28,7 @@ import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault; import de.symeda.sormas.api.infrastructure.district.DistrictDto; import de.symeda.sormas.api.infrastructure.region.RegionDto; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.utils.AbstractEditForm; public class DistrictEditForm extends AbstractEditForm { @@ -62,7 +63,7 @@ protected void addFields() { ComboBox region = addInfrastructureField(DistrictDto.REGION); addField(RegionDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java index c7393ef9279..b9964c80ad2 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java @@ -25,6 +25,7 @@ import de.symeda.sormas.api.infrastructure.district.DistrictIndexDto; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; import de.symeda.sormas.ui.utils.BooleanRenderer; @@ -58,7 +59,7 @@ public DistrictsGrid(DistrictCriteria criteria) { DistrictIndexDto.EXTERNAL_ID, DistrictIndexDto.POPULATION, DistrictIndexDto.GROWTH_RATE }; - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { columns = ArrayUtils.add(columns, DistrictIndexDto.DEFAULT_INFRASTRUCTURE); } setColumns(columns); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java index 01487aab81f..c44e4c8ad6c 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java @@ -33,6 +33,7 @@ import de.symeda.sormas.api.infrastructure.region.RegionDto; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.utils.AbstractEditForm; import de.symeda.sormas.ui.utils.FieldHelper; @@ -83,7 +84,7 @@ protected void addFields() { ComboBox area = addInfrastructureField(RegionDto.AREA); addField(RegionDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java index 5f1d447f1d7..e3972d0690d 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java @@ -25,6 +25,7 @@ import de.symeda.sormas.api.infrastructure.region.RegionIndexDto; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; import de.symeda.sormas.ui.utils.BooleanRenderer; @@ -63,7 +64,7 @@ public RegionsGrid(RegionCriteria criteria) { RegionIndexDto.EXTERNAL_ID, RegionIndexDto.POPULATION, RegionIndexDto.GROWTH_RATE); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { columns = ArrayUtils.add(columns, RegionIndexDto.DEFAULT_INFRASTRUCTURE); } setColumns(columns); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactsFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactsFilterForm.java index 5ebb67ffeb7..ea930b79e76 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactsFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactsFilterForm.java @@ -99,7 +99,8 @@ protected ContactsFilterForm() { super( ContactCriteria.class, ContactIndexDto.I18N_PREFIX, - FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale())); + FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()), + JurisdictionFieldConfig.of(ContactCriteria.REGION, ContactCriteria.DISTRICT, ContactCriteria.COMMUNITY)); } @Override @@ -320,7 +321,8 @@ public void addMoreFilters(CustomLayout moreFiltersContainer) { ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE, I18nProperties.getCaption(Captions.contactOnlyWithSharedEventWithSourceCase), null, - CHECKBOX_STYLE)).setVisible(UiUtil.permitted(UserRight.EVENT_VIEW)); + CHECKBOX_STYLE)) + .setVisible(UiUtil.permitted(UserRight.EVENT_VIEW)); addField( moreFiltersContainer, diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/campaigns/CampaignDashboardFilterLayout.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/campaigns/CampaignDashboardFilterLayout.java index 325ac7b102e..fc7d36c78cf 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/campaigns/CampaignDashboardFilterLayout.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/campaigns/CampaignDashboardFilterLayout.java @@ -20,6 +20,7 @@ import de.symeda.sormas.api.campaign.CampaignJurisdictionLevel; import de.symeda.sormas.api.campaign.CampaignPhase; import de.symeda.sormas.api.campaign.CampaignReferenceDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; @@ -27,6 +28,7 @@ import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; import de.symeda.sormas.api.user.UserDto; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.utils.ComboBoxHelper; import de.symeda.sormas.ui.utils.CssStyles; @@ -151,17 +153,6 @@ private void createJurisdictionFilters(CampaignJurisdictionLevel campaignJurisdi addComponent(districtFilter); dashboardDataProvider.setDistrict((DistrictReferenceDto) districtFilter.getValue()); - if (userRegion != null) { - areaFilter.setValue(userArea); - regionFilter.setValue(userRegion); - areaFilter.setEnabled(false); - regionFilter.setEnabled(false); - if (userDistrict != null) { - districtFilter.setValue(userDistrict); - districtFilter.setEnabled(false); - } - } - campaignJurisdictionGroupByFilter.setCaption(I18nProperties.getCaption(Captions.campaignDiagramGroupBy)); campaignJurisdictionGroupByFilter.setWidth(200, Unit.PIXELS); @@ -188,6 +179,22 @@ private void createJurisdictionFilters(CampaignJurisdictionLevel campaignJurisdi dashboardView.refreshDashboard(); }); addComponent(campaignJurisdictionGroupByFilter); + + if (userRegion != null) { + areaFilter.setValue(userArea); + regionFilter.setValue(userRegion); + areaFilter.setEnabled(false); + regionFilter.setEnabled(false); + if (userDistrict != null) { + districtFilter.setValue(userDistrict); + districtFilter.setEnabled(false); + } + } else if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + areaFilter.setVisible(false); + regionFilter.setVisible(false); + districtFilter.setVisible(false); + campaignJurisdictionGroupByFilter.setVisible(false); + } } private CampaignJurisdictionLevel getJurisdictionBelow(CampaignJurisdictionLevel campaignJurisdictionLevel) { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/components/DashboardFilterLayout.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/components/DashboardFilterLayout.java index 0c80494e7c2..6a71345c4e5 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/components/DashboardFilterLayout.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/components/DashboardFilterLayout.java @@ -44,6 +44,7 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.Language; import de.symeda.sormas.api.caze.NewCaseDateType; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; @@ -52,6 +53,7 @@ import de.symeda.sormas.api.utils.DateFilterOption; import de.symeda.sormas.api.utils.DateHelper; import de.symeda.sormas.api.utils.EpiWeek; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.dashboard.AbstractDashboardDataProvider; import de.symeda.sormas.ui.dashboard.AbstractDashboardView; @@ -135,7 +137,7 @@ protected void createRegionAndDistrictFilter() { } protected void createRegionFilter(String description) { - if (UserProvider.getCurrent().getUser().getRegion() == null) { + if (UserProvider.getCurrent().getUser().getRegion() == null && UiUtil.disabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { regionFilter.setWidth(200, Unit.PIXELS); regionFilter.setInputPrompt(I18nProperties.getString(Strings.promptRegion)); regionFilter.setDescription(description); @@ -151,7 +153,9 @@ protected void createRegionFilter(String description) { } protected void createDistrictFilter(String description) { - if (UserProvider.getCurrent().getUser().getRegion() != null && UserProvider.getCurrent().getUser().getDistrict() == null) { + if (UserProvider.getCurrent().getUser().getRegion() != null + && UserProvider.getCurrent().getUser().getDistrict() == null + && UiUtil.disabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { districtFilter.setWidth(200, Unit.PIXELS); districtFilter.setInputPrompt(I18nProperties.getString(Strings.promptDistrict)); districtFilter.setDescription(description); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/surveillance/components/statistics/summary/DiseaseSummaryComponent.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/surveillance/components/statistics/summary/DiseaseSummaryComponent.java index 6ecf759e214..7990f7ebbaf 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/surveillance/components/statistics/summary/DiseaseSummaryComponent.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/surveillance/components/statistics/summary/DiseaseSummaryComponent.java @@ -6,6 +6,7 @@ import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; import de.symeda.sormas.api.utils.DataHelper; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.dashboard.DashboardDataProvider; import de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent; import de.symeda.sormas.ui.utils.CssStyles; @@ -16,7 +17,7 @@ public class DiseaseSummaryComponent extends DashboardStatisticsSubComponent { private final FatalitiesSummaryElementComponent fatalitiesSummaryElementComponent; // "Outbreak Districts" elements - private final DiseaseSummaryElementComponent lastReportedDistrict; + private DiseaseSummaryElementComponent lastReportedDistrict; private DiseaseSummaryElementComponent outbreakDistrictCount; //"cases in quarantine" elements @@ -33,11 +34,14 @@ public DiseaseSummaryComponent() { fatalitiesSummaryElementComponent = new FatalitiesSummaryElementComponent(); addComponent(fatalitiesSummaryElementComponent); - lastReportedDistrict = - new DiseaseSummaryElementComponent(Strings.headingLastReportedDistrict, I18nProperties.getString(Strings.none).toUpperCase()); - addComponent(lastReportedDistrict); + boolean jurisdictionFieldsVisible = UiUtil.disabled(FeatureType.HIDE_JURISDICTION_FIELDS); + if (jurisdictionFieldsVisible) { + lastReportedDistrict = + new DiseaseSummaryElementComponent(Strings.headingLastReportedDistrict, I18nProperties.getString(Strings.none).toUpperCase()); + addComponent(lastReportedDistrict); + } - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.OUTBREAKS)) { + if (UiUtil.enabled(FeatureType.OUTBREAKS) && jurisdictionFieldsVisible) { outbreakDistrictCount = new DiseaseSummaryElementComponent(Strings.headingOutbreakDistricts); addComponent(outbreakDistrictCount); } @@ -62,10 +66,13 @@ public DiseaseSummaryComponent() { public void update(DashboardDataProvider dashboardDataProvider) { fatalitiesSummaryElementComponent.update(dashboardDataProvider.getCases(), dashboardDataProvider.getPreviousCases()); - String district = dashboardDataProvider.getLastReportedDistrict(); - lastReportedDistrict.updateTotalLabel(DataHelper.isNullOrEmpty(district) ? I18nProperties.getString(Strings.none).toUpperCase() : district); + if (lastReportedDistrict != null) { + String district = dashboardDataProvider.getLastReportedDistrict(); + lastReportedDistrict + .updateTotalLabel(DataHelper.isNullOrEmpty(district) ? I18nProperties.getString(Strings.none).toUpperCase() : district); + } - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.OUTBREAKS)) { + if (outbreakDistrictCount != null) { outbreakDistrictCount.updateTotalLabel(dashboardDataProvider.getOutbreakDistrictCount().toString()); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/environment/EnvironmentFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/environment/EnvironmentFilterForm.java index c2171137191..a7db3ada7e6 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/environment/EnvironmentFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/environment/EnvironmentFilterForm.java @@ -61,7 +61,10 @@ public class EnvironmentFilterForm extends AbstractFilterForm(EnvironmentIndexDto.UUID, e -> ControllerProvider.getEnvironmentController().navigateToEnvironment(e.getUuid()))); + new ShowDetailsListener<>( + EnvironmentIndexDto.UUID, + e -> ControllerProvider.getEnvironmentController().navigateToEnvironment(e.getUuid()))); + + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + getColumn(EnvironmentIndexDto.REGION).setHidden(true); + getColumn(EnvironmentIndexDto.DISTRICT).setHidden(true); + getColumn(EnvironmentIndexDto.COMMUNITY).setHidden(true); + } } public void reload() { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventActionFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventActionFilterForm.java index 878e1abaa12..20c82bd3797 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventActionFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventActionFilterForm.java @@ -30,7 +30,7 @@ public class EventActionFilterForm extends AbstractFilterForm { private static final long serialVersionUID = -8661345403078183132L; protected EventActionFilterForm() { - super(ActionCriteria.class, ActionDto.I18N_PREFIX); + super(ActionCriteria.class, ActionDto.I18N_PREFIX, null); } @Override diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventGroupsFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventGroupsFilterForm.java index 1d35b7c6cae..32e79cd7440 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventGroupsFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventGroupsFilterForm.java @@ -10,9 +10,9 @@ import de.symeda.sormas.api.i18n.Descriptions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; -import de.symeda.sormas.api.location.LocationDto; import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; +import de.symeda.sormas.api.location.LocationDto; import de.symeda.sormas.ui.utils.AbstractFilterForm; import de.symeda.sormas.ui.utils.FieldConfiguration; import de.symeda.sormas.ui.utils.FieldHelper; @@ -22,7 +22,10 @@ public class EventGroupsFilterForm extends AbstractFilterForm { protected EventParticipantsFilterForm() { - super(EventParticipantCriteria.class, EventParticipantIndexDto.I18N_PREFIX); + super(EventParticipantCriteria.class, EventParticipantIndexDto.I18N_PREFIX, null); } @Override @@ -39,7 +39,11 @@ protected String[] getMainFilterLocators() { @Override protected void addFields() { - addBirthDateFields(getContent(), EventParticipantCriteria.BIRTHDATE_YYYY, EventParticipantCriteria.BIRTHDATE_MM, EventParticipantCriteria.BIRTHDATE_DD); + addBirthDateFields( + getContent(), + EventParticipantCriteria.BIRTHDATE_YYYY, + EventParticipantCriteria.BIRTHDATE_MM, + EventParticipantCriteria.BIRTHDATE_DD); addField( FieldConfiguration.withCaptionAndPixelSized( diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventsFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventsFilterForm.java index 75523aa2e99..b64dce534d3 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventsFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventsFilterForm.java @@ -125,7 +125,8 @@ protected EventsFilterForm(boolean hideEventStatusFilter, boolean hideActionFilt super( EventCriteria.class, EventIndexDto.I18N_PREFIX, - FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale())); + FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()), + JurisdictionFieldConfig.of(LocationDto.REGION, LocationDto.DISTRICT, LocationDto.COMMUNITY)); this.hideEventStatusFilter = hideEventStatusFilter; this.hideActionFilters = hideActionFilters; diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/ExternalMessageGridFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/ExternalMessageGridFilterForm.java index a9b327ba818..587d2adae04 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/ExternalMessageGridFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/ExternalMessageGridFilterForm.java @@ -57,7 +57,7 @@ public class ExternalMessageGridFilterForm extends AbstractFilterForm we weekAndDateFilter.setNotificationsForMissingFilters(); } } - - private void hideAndFillJurisdictionFilters() { - - regionFilter.setVisible(false); - regionFilter.setValue(FacadeProvider.getRegionFacade().getDefaultInfrastructureReference()); - districtFilter.setVisible(false); - districtFilter.setValue(FacadeProvider.getDistrictFacade().getDefaultInfrastructureReference()); - communityFilter.setVisible(false); - communityFilter.setValue(FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference()); - } - - @Override - public void setValue(ImmunizationCriteria newFieldValue) throws ReadOnlyException, Converter.ConversionException { - super.setValue(newFieldValue); - - if (newFieldValue != null - && (regionFilter.isVisible() || districtFilter.isVisible() || communityFilter.isVisible()) - && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { - hideAndFillJurisdictionFilters(); - } - } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationCreationForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationCreationForm.java index 6607b9ad7a0..f8d955c3ee1 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationCreationForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationCreationForm.java @@ -54,6 +54,7 @@ import de.symeda.sormas.api.person.PersonReferenceDto; import de.symeda.sormas.api.travelentry.TravelEntryDto; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.person.PersonCreateForm; import de.symeda.sormas.ui.utils.AbstractEditForm; import de.symeda.sormas.ui.utils.ComboBoxHelper; @@ -401,7 +402,7 @@ public ImmunizationDto getValue() { protected void setInternalValue(ImmunizationDto newValue) { super.setInternalValue(newValue); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideAndFillJurisdictionFields(); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationDataForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationDataForm.java index 671e3ec0384..62d0d46af49 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationDataForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/form/ImmunizationDataForm.java @@ -71,6 +71,7 @@ import de.symeda.sormas.ui.ControllerProvider; import de.symeda.sormas.ui.SearchSpecificLayout; import de.symeda.sormas.ui.SormasUI; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.utils.AbstractEditForm; import de.symeda.sormas.ui.utils.ButtonHelper; @@ -605,7 +606,7 @@ public void setValue(ImmunizationDto newFieldValue) throws ReadOnlyException, Co ignoreMeansOfImmunizationChange = false; previousMeansOfImmunization = newFieldValue.getMeansOfImmunization(); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideAndFillJurisdictionFields(); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/grid/ImmunizationGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/grid/ImmunizationGrid.java index b5df129dd7d..9b54d3fa3b8 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/grid/ImmunizationGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/immunization/components/grid/ImmunizationGrid.java @@ -15,6 +15,7 @@ import de.symeda.sormas.api.person.PersonDto; import de.symeda.sormas.api.person.PersonHelper; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.immunization.ImmunizationPersonView; import de.symeda.sormas.ui.utils.DateFormatHelper; import de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator; @@ -106,7 +107,7 @@ private void initColumns() { column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId())); } - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { getColumn(ImmunizationIndexDto.DISTRICT).setHidden(true); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/location/LocationEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/location/LocationEditForm.java index de4e1b88f28..cff65110501 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/location/LocationEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/location/LocationEditForm.java @@ -75,6 +75,7 @@ import de.symeda.sormas.api.person.PersonAddressType; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.map.LeafletMap; import de.symeda.sormas.ui.map.LeafletMarker; import de.symeda.sormas.ui.map.MarkerIcon; @@ -370,7 +371,7 @@ protected void addFields() { FieldHelper.removeItems(facility); // Add a visual indictator reminding the user to select a district - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.disabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { facility.setComponentError(new ErrorMessage() { @Override @@ -602,7 +603,7 @@ public void setValue(LocationDto newFieldValue) throws ReadOnlyException, Conver protected void setInternalValue(LocationDto newValue) { super.setInternalValue(newValue); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideAndFillJurisdictionFields(); } } @@ -622,7 +623,7 @@ public void discard() throws SourceException { facility.setComponentError(null); facilityDetails.setValue(locationDto.getFacilityDetails()); - if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { hideAndFillJurisdictionFields(); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonFilterForm.java index 915ac8ae71b..cb752ab11a6 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonFilterForm.java @@ -24,7 +24,10 @@ public class PersonFilterForm extends AbstractFilterForm { protected PersonFilterForm() { - super(PersonCriteria.class, PersonDto.I18N_PREFIX); + super( + PersonCriteria.class, + PersonDto.I18N_PREFIX, + JurisdictionFieldConfig.of(PersonCriteria.REGION, PersonCriteria.DISTRICT, PersonCriteria.COMMUNITY)); } @Override diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonGrid.java index 2e789d67947..e8b68d493ad 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonGrid.java @@ -6,6 +6,7 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.caze.AgeAndBirthDateDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.location.LocationDto; import de.symeda.sormas.api.person.PersonCriteria; @@ -14,6 +15,7 @@ import de.symeda.sormas.api.person.PersonIndexDto; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.ui.ControllerProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.utils.FieldAccessColumnStyleGenerator; import de.symeda.sormas.ui.utils.FilteredGrid; @@ -80,6 +82,10 @@ private void initColumns() { LocationDto.I18N_PREFIX)); column.setStyleGenerator(FieldAccessColumnStyleGenerator.getDefault(getBeanType(), column.getId())); } + + if (UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + getColumn(PersonIndexDto.DISTRICT).setHidden(true); + } } public void setLazyDataProvider() { diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonSelectionFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonSelectionFilterForm.java index 39751b48d8c..80f261360e4 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonSelectionFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonSelectionFilterForm.java @@ -38,7 +38,7 @@ public class PersonSelectionFilterForm extends AbstractFilterForm( EnvironmentSampleIndexDto.UUID, diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/environmentsample/EnvironmentSampleGridFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/environmentsample/EnvironmentSampleGridFilterForm.java index b922e1f68f9..70efc7be26f 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/environmentsample/EnvironmentSampleGridFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/environmentsample/EnvironmentSampleGridFilterForm.java @@ -55,7 +55,10 @@ public class EnvironmentSampleGridFilterForm extends AbstractFilterForm { private static final long serialVersionUID = 829016959284536683L; public SampleGridFilterForm() { - super(SampleCriteria.class, SampleIndexDto.I18N_PREFIX); + super(SampleCriteria.class, SampleIndexDto.I18N_PREFIX, JurisdictionFieldConfig.of(SampleCriteria.REGION, SampleCriteria.DISTRICT, null)); } private static final String WEEK_AND_DATE_FILTER = "moreFilters"; diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/sormastosormas/ShareRequestFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/sormastosormas/ShareRequestFilterForm.java index 7ae693f9ed2..d4422100589 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/sormastosormas/ShareRequestFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/sormastosormas/ShareRequestFilterForm.java @@ -29,7 +29,7 @@ public class ShareRequestFilterForm extends AbstractFilterForm(task -> { boolean isInJurisdiction = task.getTaskJurisdictionFlagsDto().getInJurisdiction(); return UiFieldAccessCheckers.getDefault(!isInJurisdiction).hasRight(); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/task/TaskGridFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/task/TaskGridFilterForm.java index c921ff9b47c..9baa42ac126 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/task/TaskGridFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/task/TaskGridFilterForm.java @@ -48,7 +48,8 @@ protected TaskGridFilterForm() { super( TaskCriteria.class, TaskIndexDto.I18N_PREFIX, - FieldVisibilityCheckers.withCheckers(new UserRightFieldVisibilityChecker(UserProvider.getCurrent()::hasUserRight))); + FieldVisibilityCheckers.withCheckers(new UserRightFieldVisibilityChecker(UserProvider.getCurrent()::hasUserRight)), + JurisdictionFieldConfig.of(TaskIndexDto.REGION, TaskIndexDto.DISTRICT, null)); } @Override diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/travelentry/TravelEntryFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/travelentry/TravelEntryFilterForm.java index 1a7555bc848..3f1eb858167 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/travelentry/TravelEntryFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/travelentry/TravelEntryFilterForm.java @@ -12,7 +12,6 @@ import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.caze.NewCaseDateType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; @@ -38,7 +37,8 @@ protected TravelEntryFilterForm() { super( TravelEntryCriteria.class, TravelEntryDto.I18N_PREFIX, - FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale())); + FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()), + null); } @Override diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractFilterForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractFilterForm.java index fedd2d368bd..1fcd2e10007 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractFilterForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractFilterForm.java @@ -2,11 +2,14 @@ import static de.symeda.sormas.ui.utils.LayoutUtil.div; import static de.symeda.sormas.ui.utils.LayoutUtil.filterLocs; -import static de.symeda.sormas.ui.utils.LayoutUtil.loc; import static de.symeda.sormas.ui.utils.LayoutUtil.locCss; +import java.util.Objects; +import java.util.function.Supplier; import java.util.stream.Stream; +import javax.annotation.Nullable; + import org.apache.commons.lang3.ArrayUtils; import com.vaadin.ui.Button; @@ -20,12 +23,15 @@ import com.vaadin.v7.ui.PopupDateField; import de.symeda.sormas.api.FacadeProvider; +import de.symeda.sormas.api.ReferenceDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; import de.symeda.sormas.api.user.UserDto; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.utils.components.FormActionButtonsComponent; @@ -44,16 +50,33 @@ public abstract class AbstractFilterForm extends AbstractForm { protected FormActionButtonsComponent formActionButtonsComponent; - protected AbstractFilterForm(Class type, String propertyI18nPrefix) { - this(type, propertyI18nPrefix, null); + private JurisdictionFieldConfig jurisdictionFieldConfig; + + protected ComboBox regionFilter; + protected ComboBox districtFilter; + protected ComboBox communityFilter; + + protected AbstractFilterForm(Class type, String propertyI18nPrefix, JurisdictionFieldConfig jurisdictionFieldConfig) { + this(type, propertyI18nPrefix, null, jurisdictionFieldConfig); } - protected AbstractFilterForm(Class type, String propertyI18nPrefix, boolean addFields) { - this(type, propertyI18nPrefix, null, Captions.actionApplyFilters, Captions.actionResetFilters, addFields); + protected AbstractFilterForm(Class type, String propertyI18nPrefix, JurisdictionFieldConfig jurisdictionFieldConfig, boolean addFields) { + this(type, propertyI18nPrefix, null, Captions.actionApplyFilters, Captions.actionResetFilters, jurisdictionFieldConfig, addFields); } - protected AbstractFilterForm(Class type, String propertyI18nPrefix, FieldVisibilityCheckers fieldVisibilityCheckers) { - this(type, propertyI18nPrefix, fieldVisibilityCheckers, Captions.actionApplyFilters, Captions.actionResetFilters, true); + protected AbstractFilterForm( + Class type, + String propertyI18nPrefix, + FieldVisibilityCheckers fieldVisibilityCheckers, + JurisdictionFieldConfig jurisdictionFieldConfig) { + this( + type, + propertyI18nPrefix, + fieldVisibilityCheckers, + Captions.actionApplyFilters, + Captions.actionResetFilters, + jurisdictionFieldConfig, + true); } protected AbstractFilterForm( @@ -62,9 +85,11 @@ protected AbstractFilterForm( FieldVisibilityCheckers fieldVisibilityCheckers, String applyCaptionTag, String resetCaptionTag, + JurisdictionFieldConfig jurisdictionFieldConfig, boolean addFields) { super(type, propertyI18nPrefix, new SormasFieldGroupFieldFactory(fieldVisibilityCheckers, null), addFields); + this.jurisdictionFieldConfig = jurisdictionFieldConfig; String moreFiltersHtmlLayout = createMoreFiltersHtmlLayout(); boolean hasMoreFilters = moreFiltersHtmlLayout != null && moreFiltersHtmlLayout.length() > 0; @@ -88,6 +113,22 @@ protected AbstractFilterForm( }); addStyleName(CssStyles.FILTER_FORM); + + if (addFields) { + initJurisdictionFields(jurisdictionFieldConfig); + } + } + + protected void initJurisdictionFields(JurisdictionFieldConfig jurisdictionFieldConfig) { + if (jurisdictionFieldConfig != null) { + regionFilter = jurisdictionFieldConfig.region != null ? getField(jurisdictionFieldConfig.region) : null; + districtFilter = jurisdictionFieldConfig.district != null ? getField(jurisdictionFieldConfig.district) : null; + communityFilter = jurisdictionFieldConfig.community != null ? getField(jurisdictionFieldConfig.community) : null; + } else { + regionFilter = null; + districtFilter = null; + communityFilter = null; + } } public void onChange() { @@ -167,6 +208,29 @@ public void setValue(T newFieldValue) throws ReadOnlyException, Converter.Conver formActionButtonsComponent.toggleMoreFilters(hasExpandedFilter); } }); + + if (newFieldValue != null && getJurisdictionFields().anyMatch(Field::isVisible) && UiUtil.enabled(FeatureType.HIDE_JURISDICTION_FIELDS)) { + hideAndFillJurisdictionFilters(); + } + } + + protected Stream getJurisdictionFields() { + return Stream.of(regionFilter, districtFilter, communityFilter).filter(Objects::nonNull); + } + + private void hideAndFillJurisdictionFilters() { + hideAndFillJurisdictionField(regionFilter, () -> FacadeProvider.getRegionFacade().getDefaultInfrastructureReference()); + hideAndFillJurisdictionField(districtFilter, () -> FacadeProvider.getDistrictFacade().getDefaultInfrastructureReference()); + hideAndFillJurisdictionField(communityFilter, () -> FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference()); + } + + private void hideAndFillJurisdictionField(@Nullable ComboBox field, Supplier defaultValueGetter) { + if (field != null) { + field.setVisible(false); + if (jurisdictionFieldConfig.prefillOnHide) { + field.setValue(defaultValueGetter.get()); + } + } } @SuppressWarnings("rawtypes") @@ -314,4 +378,30 @@ interface Callable { void call(); } + + protected static class JurisdictionFieldConfig { + + private String region; + private String district; + private String community; + + private boolean prefillOnHide; + + public static JurisdictionFieldConfig of(String region, String district, String community) { + JurisdictionFieldConfig names = new JurisdictionFieldConfig(); + names.region = region; + names.district = district; + names.community = community; + return names; + } + + public static JurisdictionFieldConfig withPrefillOnHide(String region, String district, String community) { + JurisdictionFieldConfig names = new JurisdictionFieldConfig(); + names.region = region; + names.district = district; + names.community = community; + names.prefillOnHide = true; + return names; + } + } }