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

Commit 8a1f223

Browse files
Allow regional users to assign tasks to national ones SORMAS-Foundation#4048 (SORMAS-Foundation#4123)
1 parent c92038c commit 8a1f223

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public enum FeatureType {
5454
OTHER_NOTIFICATIONS(true, true, null),
5555
DOCUMENTS(true, false, null),
5656
OUTBREAKS(true, true, null),
57-
LAB_MESSAGES(true, false, null);
57+
LAB_MESSAGES(true, false, null),
58+
ASSIGN_TASKS_TO_HIGHER_LEVEL(true, true, null);
5859

5960
/**
6061
* Server feature means that the feature only needs to be configured once per server since they define the way the system

sormas-ui/src/main/java/de/symeda/sormas/ui/task/TaskEditForm.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import de.symeda.sormas.api.task.TaskContext;
5353
import de.symeda.sormas.api.task.TaskDto;
5454
import de.symeda.sormas.api.task.TaskType;
55+
import de.symeda.sormas.api.user.JurisdictionLevel;
5556
import de.symeda.sormas.api.user.UserDto;
5657
import de.symeda.sormas.api.user.UserReferenceDto;
5758
import de.symeda.sormas.api.user.UserRight;
@@ -166,6 +167,7 @@ protected void addFields() {
166167
}
167168
}
168169

170+
UserDto userDto = UserProvider.getCurrent().getUser();
169171
DistrictReferenceDto district = null;
170172
RegionReferenceDto region = null;
171173
if (taskDto.getCaze() != null) {
@@ -187,19 +189,27 @@ protected void addFields() {
187189
district = eventDto.getEventLocation().getDistrict();
188190
region = eventDto.getEventLocation().getRegion();
189191
} else {
190-
UserDto userDto = UserProvider.getCurrent().getUser();
191192
district = userDto.getDistrict();
192193
region = userDto.getRegion();
193194
}
194195

195-
List<UserReferenceDto> users = new ArrayList<>();
196+
final List<UserReferenceDto> users = new ArrayList<>();
196197
if (district != null) {
197-
users = FacadeProvider.getUserFacade().getUserRefsByDistrict(district, true);
198+
users.addAll(FacadeProvider.getUserFacade().getUserRefsByDistrict(district, true));
198199
} else if (region != null) {
199-
users = FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region);
200+
users.addAll(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region));
200201
} else {
201202
// fallback - just show all users
202-
users = FacadeProvider.getUserFacade().getAllUserRefs(false);
203+
users.addAll(FacadeProvider.getUserFacade().getAllUserRefs(false));
204+
}
205+
206+
// Allow regional users to assign the task to national ones
207+
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ASSIGN_TASKS_TO_HIGHER_LEVEL)
208+
&& userDto.getDistrict() == null
209+
&& userDto.getRegion() != null) {
210+
users.addAll(
211+
FacadeProvider.getUserFacade()
212+
.getUsersByRegionAndRoles(null, UserRole.getWithJurisdictionLevels(JurisdictionLevel.NATION).toArray(new UserRole[0])));
203213
}
204214

205215
// Validation

0 commit comments

Comments
 (0)