Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 69aba83

Browse files
author
Martin Wahnschaffe
authored
SORMAS-Foundation#3572 hide views based on features (SORMAS-Foundation#3651)
countries, line listing, statistics
1 parent 9b2d2a4 commit 69aba83

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/MainScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public View getView(String viewName) {
216216
if (permitted(FeatureType.WEEKLY_REPORTING, UserRight.WEEKLYREPORT_VIEW)) {
217217
menu.addView(ReportsView.class, ReportsView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuReports), VaadinIcons.FILE_TEXT);
218218
}
219-
if (permitted(UserRight.STATISTICS_ACCESS)) {
219+
if (permitted(FeatureType.CASE_SURVEILANCE, UserRight.STATISTICS_ACCESS)) {
220220
ControllerProvider.getStatisticsController().registerViews(navigator);
221221
menu.addView(
222222
StatisticsView.class,
@@ -230,7 +230,7 @@ public View getView(String viewName) {
230230
if (permitted(UserRight.CONFIGURATION_ACCESS)) {
231231
AbstractConfigurationView.registerViews(navigator);
232232
menu.addView(
233-
FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.OUTBREAKS) ? OutbreaksView.class : CountriesView.class,
233+
FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.OUTBREAKS) ? OutbreaksView.class : RegionsView.class,
234234
AbstractConfigurationView.ROOT_VIEW_NAME,
235235
I18nProperties.getCaption(Captions.mainMenuConfiguration),
236236
VaadinIcons.COGS);

sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/AbstractConfigurationView.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, Strin
6666
params);
6767
}
6868

69+
boolean isCaseSurveillanceEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE);
70+
boolean isAnySurveillanceEnabled = isCaseSurveillanceEnabled
71+
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)
72+
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AGGREGATE_REPORTING);
73+
6974
if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
70-
menu.addView(
71-
CountriesView.VIEW_NAME,
72-
I18nProperties.getPrefixCaption("View", CountriesView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
73-
null,
74-
false);
75+
if (isAnySurveillanceEnabled) {
76+
menu.addView(
77+
CountriesView.VIEW_NAME,
78+
I18nProperties.getPrefixCaption("View", CountriesView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
79+
null,
80+
false);
81+
}
7582
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.INFRASTRUCTURE_TYPE_AREA)) {
7683
menu.addView(
7784
AreasView.VIEW_NAME,
@@ -94,16 +101,14 @@ public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, Strin
94101
I18nProperties.getPrefixCaption("View", CommunitiesView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
95102
null,
96103
false);
97-
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)
98-
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)
99-
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AGGREGATE_REPORTING)) {
104+
if (isAnySurveillanceEnabled) {
100105
menu.addView(
101106
FacilitiesView.VIEW_NAME,
102107
I18nProperties.getPrefixCaption("View", FacilitiesView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
103108
null,
104109
false);
105110
}
106-
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)) {
111+
if (isCaseSurveillanceEnabled) {
107112
menu.addView(
108113
PointsOfEntryView.VIEW_NAME,
109114
I18nProperties.getPrefixCaption("View", PointsOfEntryView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
@@ -125,16 +130,15 @@ public void refreshMenu(SubMenu menu, Label infoLabel, Label infoLabelSub, Strin
125130
// UserRightsView.VIEW_NAME.replaceAll("/", ".") + ".short", ""), params);
126131
// }
127132

128-
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.LINE_LISTING)
129-
&& UserProvider.getCurrent().hasUserRight(UserRight.LINE_LISTING_CONFIGURE)) {
133+
if (isCaseSurveillanceEnabled && UserProvider.getCurrent().hasUserRight(UserRight.LINE_LISTING_CONFIGURE)) {
130134
RegionReferenceDto region = UserProvider.getCurrent().getUser().getRegion();
131135
menu.addView(
132136
LineListingConfigurationView.VIEW_NAME,
133137
I18nProperties.getPrefixCaption("View", LineListingConfigurationView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
134138
region != null ? region.getUuid() : null,
135139
false);
136140
}
137-
if (UserProvider.getCurrent().hasUserRight(UserRight.DOCUMENT_TEMPLATE_MANAGEMENT)) {
141+
if (isAnySurveillanceEnabled && UserProvider.getCurrent().hasUserRight(UserRight.DOCUMENT_TEMPLATE_MANAGEMENT)) {
138142
menu.addView(
139143
DocumentTemplatesView.VIEW_NAME,
140144
I18nProperties.getPrefixCaption("View", DocumentTemplatesView.VIEW_NAME.replaceAll("/", ".") + ".short", ""),
@@ -156,20 +160,25 @@ public static void registerViews(Navigator navigator) {
156160
navigator.addView(OutbreaksView.VIEW_NAME, OutbreaksView.class);
157161
}
158162

163+
boolean isCaseSurveillanceEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE);
164+
boolean isAnySurveillanceEnabled = isCaseSurveillanceEnabled
165+
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)
166+
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AGGREGATE_REPORTING);
167+
159168
if (UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_VIEW)) {
160169
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.INFRASTRUCTURE_TYPE_AREA)) {
161170
navigator.addView(AreasView.VIEW_NAME, AreasView.class);
162171
}
163-
navigator.addView(CountriesView.VIEW_NAME, CountriesView.class);
172+
if (isAnySurveillanceEnabled) {
173+
navigator.addView(CountriesView.VIEW_NAME, CountriesView.class);
174+
}
164175
navigator.addView(RegionsView.VIEW_NAME, RegionsView.class);
165176
navigator.addView(DistrictsView.VIEW_NAME, DistrictsView.class);
166177
navigator.addView(CommunitiesView.VIEW_NAME, CommunitiesView.class);
167-
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)
168-
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)
169-
|| FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AGGREGATE_REPORTING)) {
178+
if (isAnySurveillanceEnabled) {
170179
navigator.addView(FacilitiesView.VIEW_NAME, FacilitiesView.class);
171180
}
172-
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)) {
181+
if (isCaseSurveillanceEnabled) {
173182
navigator.addView(PointsOfEntryView.VIEW_NAME, PointsOfEntryView.class);
174183
}
175184

@@ -182,11 +191,11 @@ public static void registerViews(Navigator navigator) {
182191
// navigator.addView(UserRightsView.VIEW_NAME, UserRightsView.class);
183192
// }
184193

185-
if (UserProvider.getCurrent().hasUserRight(UserRight.LINE_LISTING_CONFIGURE)) {
194+
if (isCaseSurveillanceEnabled && UserProvider.getCurrent().hasUserRight(UserRight.LINE_LISTING_CONFIGURE)) {
186195
navigator.addView(LineListingConfigurationView.VIEW_NAME, LineListingConfigurationView.class);
187196
}
188197

189-
if (UserProvider.getCurrent().hasUserRight(UserRight.DOCUMENT_TEMPLATE_MANAGEMENT)) {
198+
if (isAnySurveillanceEnabled && UserProvider.getCurrent().hasUserRight(UserRight.DOCUMENT_TEMPLATE_MANAGEMENT)) {
190199
navigator.addView(DocumentTemplatesView.VIEW_NAME, DocumentTemplatesView.class);
191200
}
192201

0 commit comments

Comments
 (0)