Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
18297d5
#11509 - Delete should be possible without edit right (CaseController…
carina29 Feb 22, 2023
a06483f
#11509 - Delete should be possible without edit right (ContactControl…
carina29 Feb 22, 2023
6310408
#11509 - Delete should be possible without edit right (EventController)
carina29 Feb 22, 2023
d05516f
#11509 - Delete should be possible without edit right (ImmunizationCo…
carina29 Feb 22, 2023
d9944ab
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 24, 2023
40442cb
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 24, 2023
b6c3ec1
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 24, 2023
9f4a122
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 27, 2023
5fa78fa
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 27, 2023
3a28939
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 27, 2023
7a8f84c
#11509 - Users with delete right but without edit right should be abl…
carina29 Feb 28, 2023
fe8818e
#11509 - A user without edit but with delete right should be able to …
carina29 Mar 3, 2023
42a7589
#11509 - A user without edit but with delete right should be able to …
carina29 Mar 6, 2023
9e44da0
Merge branch 'development' into #11509-users-without-edit-but-with-de…
carina29 Mar 6, 2023
13aadf5
#11509 - A user without edit but with delete right should be able to …
carina29 Mar 6, 2023
ba87a2c
#11509 - Refactoring
carina29 Mar 6, 2023
10d3aa5
#11509 - Bugfixes
carina29 Mar 6, 2023
957ca5c
#11509 - Fixes
carina29 Mar 6, 2023
49d980d
Merge branch 'development' into #11509-users-without-edit-but-with-de…
carina29 Mar 6, 2023
ceebee3
#11509 - Some fixes after the review comments
carina29 Mar 7, 2023
ca0932d
#11509 - refactor isEditAllowed method
carina29 Mar 7, 2023
a90c2e2
#11509 - Refactoring
carina29 Mar 7, 2023
732ae6a
#11509 - Refactorings
carina29 Mar 8, 2023
3f013e1
#11509 - Refactorings
carina29 Mar 8, 2023
f1a5004
Merge branch 'development' into #11509-users-without-edit-but-with-de…
carina29 Mar 8, 2023
ab0c945
#11509 - delete getActiveButtons()
carina29 Mar 8, 2023
830cfb1
#11509 - delete unused method
carina29 Mar 8, 2023
b9b7789
#11509 - delete unused method
carina29 Mar 8, 2023
e69a7f1
Merge branch 'development' into #11509-users-without-edit-but-with-de…
carina29 Mar 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import de.symeda.sormas.api.immunization.ImmunizationStatus;
import de.symeda.sormas.api.immunization.MeansOfImmunization;
import de.symeda.sormas.api.sormastosormas.share.incoming.ShareRequestStatus;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.backend.caze.Case;
import de.symeda.sormas.backend.common.AbstractCoreAdoService;
import de.symeda.sormas.backend.common.AbstractDomainObject;
Expand Down Expand Up @@ -571,10 +570,6 @@ private Predicate buildCriteriaFilter(Long personId, Disease disease, Immunizati
@Override
public EditPermissionType getEditPermissionType(Immunization immunization) {

if (!userService.hasRight(UserRight.IMMUNIZATION_EDIT)) {
return EditPermissionType.REFUSED;
}

if (immunization.getSormasToSormasOriginInfo() != null && !immunization.getSormasToSormasOriginInfo().isOwnershipHandedOver()) {
return EditPermissionType.REFUSED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import de.symeda.sormas.api.travelentry.TravelEntryCriteria;
import de.symeda.sormas.api.travelentry.TravelEntryIndexDto;
import de.symeda.sormas.api.travelentry.TravelEntryReferenceDto;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.SortProperty;
import de.symeda.sormas.backend.caze.Case;
Expand Down Expand Up @@ -267,7 +266,7 @@ public List<TravelEntry> getAllByResultingCase(Case caze, boolean includeDeleted
@Override
public EditPermissionType getEditPermissionType(TravelEntry travelEntry) {

if (!userService.hasRight(UserRight.TRAVEL_ENTRY_EDIT) || !inJurisdictionOrOwned(travelEntry)) {
if (!inJurisdictionOrOwned(travelEntry)) {
return EditPermissionType.REFUSED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void edit(ActionDto dto, Runnable callback) {
ActionEditForm form = new ActionEditForm(false);
form.setValue(newDto);
final CommitDiscardWrapperComponent<ActionEditForm> editView =
new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.ACTION_EDIT), form.getFieldGroup());
new CommitDiscardWrapperComponent<>(form, true, form.getFieldGroup());

Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditAction));

Expand All @@ -101,6 +101,7 @@ public void edit(ActionDto dto, Runnable callback) {
}

editView.addDiscardListener(popupWindow::close);
editView.restrictEditableComponentsOnEditView(UserRight.ACTION_EDIT, UserRight.ACTION_DELETE, null);
}

private ActionDto createNewAction(ActionContext context, ReferenceDto entityRef) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import de.symeda.sormas.api.action.ActionDto;
import de.symeda.sormas.api.i18n.Captions;
import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.ui.ControllerProvider;
import de.symeda.sormas.ui.UserProvider;
import de.symeda.sormas.ui.utils.PaginationList;

@SuppressWarnings("serial")
Expand Down Expand Up @@ -66,11 +64,9 @@ protected void drawDisplayedEntries() {
for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
ActionDto action = displayedEntries.get(i);
ActionListEntry listEntry = new ActionListEntry(action);
if (UserProvider.getCurrent().hasUserRight(UserRight.ACTION_EDIT)) {
listEntry.addEditListener(
i,
(ClickListener) event -> ControllerProvider.getActionController().edit(listEntry.getAction(), ActionList.this::reload));
}
listLayout.addComponent(listEntry);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ public void createCampaignDataForm(CampaignReferenceDto campaign, CampaignFormMe
getCampaignFormDataComponent(null, campaign, campaignForm, false, false, () -> {
window.close();
SormasUI.refreshView();
Notification
.show(String.format(I18nProperties.getString(Strings.messageCampaignFormSaved), campaignForm.buildCaption()), Type.TRAY_NOTIFICATION);
Notification.show(
String.format(I18nProperties.getString(Strings.messageCampaignFormSaved), campaignForm.buildCaption()),
Type.TRAY_NOTIFICATION);
}, window::close);

window.setCaption(String.format(I18nProperties.getString(Strings.headingCreateCampaignDataForm), campaignForm.buildCaption()));
Expand All @@ -124,17 +125,15 @@ public CommitDiscardWrapperComponent<CampaignEditForm> getCampaignComponent(Camp
}
campaignEditForm.setValue(campaignDto);

final CommitDiscardWrapperComponent<CampaignEditForm> campaignComponent = new CommitDiscardWrapperComponent<CampaignEditForm>(
campaignEditForm,
UserProvider.getCurrent().hasUserRight(UserRight.CAMPAIGN_EDIT),
campaignEditForm.getFieldGroup()) {
final CommitDiscardWrapperComponent<CampaignEditForm> campaignComponent =
new CommitDiscardWrapperComponent<CampaignEditForm>(campaignEditForm, true, campaignEditForm.getFieldGroup()) {

@Override
public void discard() {
super.discard();
campaignEditForm.discard();
}
};
@Override
public void discard() {
super.discard();
campaignEditForm.discard();
}
};

if (UserProvider.getCurrent().hasUserRight(UserRight.CAMPAIGN_DELETE) && !isCreate) {
CampaignDto finalCampaignDto = campaignDto;
Expand Down Expand Up @@ -170,6 +169,8 @@ public void discard() {
}
}

campaignComponent.restrictEditableComponentsOnEditView(UserRight.CAMPAIGN_EDIT, UserRight.CAMPAIGN_DELETE, null);

return campaignComponent;
}

Expand All @@ -192,7 +193,8 @@ public CommitDiscardWrapperComponent<CampaignFormDataEditForm> getCampaignFormDa
}
form.setValue(campaignFormData);

final CommitDiscardWrapperComponent<CampaignFormDataEditForm> component = new CommitDiscardWrapperComponent<>(form, form.getFieldGroup());
final CommitDiscardWrapperComponent<CampaignFormDataEditForm> component =
new CommitDiscardWrapperComponent<>(form, true, form.getFieldGroup());

component.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
Expand Down Expand Up @@ -232,6 +234,7 @@ public CommitDiscardWrapperComponent<CampaignFormDataEditForm> getCampaignFormDa
}, I18nProperties.getString(Strings.entityCampaignDataForm));
}

component.restrictEditableComponentsOnEditView(UserRight.CAMPAIGN_FORM_DATA_EDIT, UserRight.CAMPAIGN_FORM_DATA_DELETE, null);
return component;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import de.symeda.sormas.ui.ControllerProvider;
import de.symeda.sormas.ui.SubMenu;
import de.symeda.sormas.ui.utils.AbstractDetailView;
import de.symeda.sormas.ui.utils.ArchivingController;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
import de.symeda.sormas.ui.utils.DetailSubComponentWrapper;
import de.symeda.sormas.ui.utils.LayoutWithSidePanel;

public class CampaignView extends AbstractDetailView<CampaignReferenceDto> {

Expand Down Expand Up @@ -70,20 +70,15 @@ protected void initView(String params) {
editComponent.addStyleName(CssStyles.ROOT_COMPONENT);
editComponent.setWidth(100, Unit.PERCENTAGE);

container.addComponent(editComponent);
LayoutWithSidePanel layout = new LayoutWithSidePanel(editComponent);
container.addComponent(layout);

getViewTitleLabel().setValue(campaignDto.getName());

final EditPermissionType campaignEditAllowed = FacadeProvider.getCampaignFacade().getEditPermissionType(campaignDto.getUuid());
final boolean deleted = FacadeProvider.getCampaignFacade().isDeleted(campaignDto.getUuid());
layout.disableIfNecessary(deleted, campaignEditAllowed);

if (deleted) {
editComponent.setEditable(false, CommitDiscardWrapperComponent.DELETE_UNDELETE);
} else if (campaignEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
editComponent.setEditable(false, ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
} else if (campaignEditAllowed.equals(EditPermissionType.REFUSED)) {
editComponent.setEditable(false, "");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ public CommitDiscardWrapperComponent<CaseDataForm> getCaseDataEditComponent(fina

CommitDiscardWrapperComponent<CaseDataForm> editView = new CommitDiscardWrapperComponent<CaseDataForm>(
caseEditForm,
UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT),
true,
caseEditForm.getFieldGroup());

editView.getButtonsPanel()
Expand Down Expand Up @@ -957,6 +957,7 @@ public CommitDiscardWrapperComponent<CaseDataForm> getCaseDataEditComponent(fina

appendSpecialCommands(caze, editView);

editView.restrictEditableComponentsOnEditView(UserRight.CASE_EDIT, UserRight.CASE_DELETE, null);
return editView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout;
import de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent;
import de.symeda.sormas.ui.task.TaskListComponent;
import de.symeda.sormas.ui.utils.ArchivingController;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
import de.symeda.sormas.ui.utils.DetailSubComponentWrapper;
Expand Down Expand Up @@ -219,15 +218,6 @@ protected void initView(String params) {
QuarantineOrderDocumentsComponent.addComponentToLayout(layout, caze, documentList);

final boolean deleted = FacadeProvider.getCaseFacade().isDeleted(uuid);

if (deleted) {
layout.disable(CommitDiscardWrapperComponent.DELETE_UNDELETE);
} else if (caseEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
layout.disableWithViewAllow(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
} else if (caseEditAllowed.equals(EditPermissionType.REFUSED)) {
layout.disableWithViewAllow();
} else if (caseEditAllowed.equals(EditPermissionType.WITHOUT_OWNERSHIP)) {
layout.disableWithViewAllow(CommitDiscardWrapperComponent.DELETE_UNDELETE);
}
layout.disableIfNecessary(deleted, caseEditAllowed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public CommitDiscardWrapperComponent<ContactDataForm> getContactDataEditComponen
editForm.setValue(contact);
final CommitDiscardWrapperComponent<ContactDataForm> editComponent = new CommitDiscardWrapperComponent<ContactDataForm>(
editForm,
UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EDIT),
true,
editForm.getFieldGroup());

editComponent.getButtonsPanel()
Expand Down Expand Up @@ -698,6 +698,8 @@ public CommitDiscardWrapperComponent<ContactDataForm> getContactDataEditComponen
() -> navigateToView(ContactDataView.VIEW_NAME, contact.getUuid(), false));
}

editComponent.restrictEditableComponentsOnEditView(UserRight.CONTACT_EDIT, UserRight.CONTACT_DELETE, null);

return editComponent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import de.symeda.sormas.ui.samples.sampleLink.SampleListComponentLayout;
import de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent;
import de.symeda.sormas.ui.task.TaskListComponent;
import de.symeda.sormas.ui.utils.ArchivingController;
import de.symeda.sormas.ui.utils.ButtonHelper;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
Expand Down Expand Up @@ -286,16 +285,7 @@ protected void initView(String params) {
QuarantineOrderDocumentsComponent.addComponentToLayout(layout, contactDto, documentList);

final boolean deleted = FacadeProvider.getContactFacade().isDeleted(uuid);

if (deleted) {
layout.disable(CommitDiscardWrapperComponent.DELETE_UNDELETE);
} else if (contactEditAllowed.equals(EditPermissionType.ARCHIVING_STATUS_ONLY)) {
layout.disableWithViewAllow(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
} else if (contactEditAllowed.equals(EditPermissionType.REFUSED)) {
layout.disableWithViewAllow();
} else if (contactEditAllowed.equals(EditPermissionType.WITHOUT_OWNERSHIP)) {
layout.disableWithViewAllow(CommitDiscardWrapperComponent.DELETE_UNDELETE);
}
layout.disableIfNecessary(deleted, contactEditAllowed);
}

private void addCreateFromCaseButtonLogic() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,24 @@ protected void initView(String params) {
listLayout.setSizeFull();
listLayout.setMargin(true);
listLayout.setSpacing(false);
listLayout.addComponent(createTopBar());
listLayout.addComponent(createFilterBar());

HorizontalLayout topBar = createTopBar();
listLayout.addComponent(topBar);

HorizontalLayout filterBar = createFilterBar();
listLayout.addComponent(filterBar);

listLayout.addComponent(list);
listLayout.setExpandRatio(list, 1);
setSubComponent(listLayout);
listLayout.setEnabled(UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT) && isEditAllowed() && !isEventDeleted());

boolean hasEventEditRight = UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT);
if (hasEventEditRight) {
listLayout.setEnabled(isEditAllowed() && !isEventDeleted());
} else {
topBar.setEnabled(false);
filterBar.setEnabled(false);
}
}

updateFilterComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(fi
eventEditForm.setValue(event);
final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(
eventEditForm,
UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT),
true,
eventEditForm.getFieldGroup());

editView.getButtonsPanel()
Expand Down Expand Up @@ -909,6 +909,8 @@ public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(fi
.addArchivingButton(event, FacadeProvider.getEventFacade(), CoreEntityArchiveMessages.EVENT, editView, () -> navigateToData(uuid));
}

editView.restrictEditableComponentsOnEditView(UserRight.EVENT_EDIT, UserRight.EVENT_DELETE, null);

return editView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import de.symeda.sormas.ui.externalsurveillanceservice.ExternalSurveillanceShareComponent;
import de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent;
import de.symeda.sormas.ui.task.TaskListComponent;
import de.symeda.sormas.ui.utils.ArchivingController;
import de.symeda.sormas.ui.utils.ButtonHelper;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
Expand Down Expand Up @@ -220,20 +219,11 @@ protected void initView(String params) {
layout.addSidePanelComponent(shortcutLinksLayout, SHORTCUT_LINKS_LOC);

if (!UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
layout.setEnabled(false);
layout.getSidePanelComponent().setEnabled(false);
}

final boolean deleted = FacadeProvider.getEventFacade().isDeleted(uuid);

if (deleted) {
layout.disable(CommitDiscardWrapperComponent.DELETE_UNDELETE);
} else if (eventEditAllowed == EditPermissionType.ARCHIVING_STATUS_ONLY) {
layout.disable(ArchivingController.ARCHIVE_DEARCHIVE_BUTTON_ID);
} else if (eventEditAllowed == EditPermissionType.REFUSED) {
layout.disable();
} else if (eventEditAllowed == EditPermissionType.WITHOUT_OWNERSHIP) {
layout.disableWithViewAllow(CommitDiscardWrapperComponent.DELETE_UNDELETE);
}
layout.disableIfNecessary(deleted, eventEditAllowed);
}

private void setExternalSurvToolLayoutVisibility(EventStatus eventStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public CommitDiscardWrapperComponent<?> getEventGroupEditComponent(String uuid)
eventGroupEditForm.setValue(eventGroup);
UserProvider user = UserProvider.getCurrent();
final CommitDiscardWrapperComponent<EventGroupDataForm> editView =
new CommitDiscardWrapperComponent<>(eventGroupEditForm, user.hasUserRight(UserRight.EVENTGROUP_EDIT), eventGroupEditForm.getFieldGroup());
new CommitDiscardWrapperComponent<>(eventGroupEditForm, true, eventGroupEditForm.getFieldGroup());

List<RegionReferenceDto> regions = FacadeProvider.getEventGroupFacade().getEventGroupRelatedRegions(uuid);
boolean hasRegion = user.hasNationJurisdictionLevel() || regions.stream().allMatch(user::hasRegion);
Expand Down Expand Up @@ -265,6 +265,7 @@ public CommitDiscardWrapperComponent<?> getEventGroupEditComponent(String uuid)
}

editView.addDiscardListener(SormasUI::refreshView);
editView.restrictEditableComponentsOnEditView(UserRight.EVENTGROUP_EDIT, UserRight.EVENTGROUP_DELETE, null);

return editView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
*/
package de.symeda.sormas.ui.events;

import static de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc;
import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRow;

import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.CustomLayout;

import de.symeda.sormas.api.FacadeProvider;
import de.symeda.sormas.api.event.EventCriteria;
import de.symeda.sormas.api.event.EventGroupDto;
import de.symeda.sormas.api.event.EventGroupReferenceDto;
import de.symeda.sormas.api.i18n.Captions;
Expand All @@ -27,16 +29,11 @@
import de.symeda.sormas.ui.ControllerProvider;
import de.symeda.sormas.ui.SubMenu;
import de.symeda.sormas.ui.UserProvider;
import de.symeda.sormas.ui.events.groups.EventGroupMemberList;
import de.symeda.sormas.ui.events.groups.EventGroupMemberListComponent;
import de.symeda.sormas.ui.utils.AbstractDetailView;
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
import de.symeda.sormas.ui.utils.CssStyles;
import de.symeda.sormas.ui.utils.DetailSubComponentWrapper;
import de.symeda.sormas.ui.utils.LayoutUtil;

import static de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc;
import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRow;

public class EventGroupDataView extends AbstractDetailView<EventGroupReferenceDto> {

Expand Down Expand Up @@ -93,7 +90,7 @@ protected void initView(String params) {
CssStyles.style(eventGroupMemberListComponent, CssStyles.VSPACE_TOP_2);

if(!UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_EDIT)){
layout.setEnabled(false);
layout.getComponent(EVENTS_LOC).setEnabled(false);
}
}

Expand Down
Loading