SEBSERV-142 fixed
This commit is contained in:
parent
c5008ad5c2
commit
a7e0dded7f
3 changed files with 75 additions and 38 deletions
|
@ -33,6 +33,7 @@ import ch.ethz.seb.sebserver.gbl.model.EntityDependency;
|
|||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
||||
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
||||
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
||||
|
@ -69,6 +70,8 @@ public class UserAccountDeletePopup {
|
|||
new LocTextKey("sebserver.useraccount.delete.form.title");
|
||||
private final static LocTextKey FORM_INFO =
|
||||
new LocTextKey("sebserver.useraccount.delete.form.info");
|
||||
private final static LocTextKey FORM_INFO_NO_DEPS =
|
||||
new LocTextKey("sebserver.useraccount.delete.form.info.noDeps");
|
||||
private final static LocTextKey FORM_REPORT_INFO =
|
||||
new LocTextKey("sebserver.useraccount.delete.form.report.info");
|
||||
private final static LocTextKey FORM_REPORT_LIST_TYPE =
|
||||
|
@ -109,16 +112,32 @@ public class UserAccountDeletePopup {
|
|||
this.pageService.getWidgetFactory())
|
||||
.setVeryLargeDialogWidth();
|
||||
|
||||
final EntityKey entityKey = pageContext.getEntityKey();
|
||||
final UserInfo userInfo = this.pageService.getRestService()
|
||||
.getBuilder(GetUserAccount.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||
.call()
|
||||
.get();
|
||||
|
||||
final Set<String> roles = userInfo.getRoles();
|
||||
final boolean showDeps = roles.contains(UserRole.EXAM_ADMIN.name())
|
||||
|| roles.contains(UserRole.INSTITUTIONAL_ADMIN.name())
|
||||
|| roles.contains(UserRole.SEB_SERVER_ADMIN.name());
|
||||
|
||||
final String page1Id = "DELETE_PAGE";
|
||||
final String page2Id = "REPORT_PAGE";
|
||||
final Predicate<PageContext> callback = pc -> doDelete(this.pageService, pc);
|
||||
final BiFunction<PageContext, Composite, Supplier<PageContext>> composePage1 =
|
||||
(prefPageContext, content) -> composeDeleteDialog(content,
|
||||
(prefPageContext != null) ? prefPageContext : pageContext);
|
||||
(prefPageContext, content) -> composeDeleteDialog(
|
||||
content,
|
||||
(prefPageContext != null) ? prefPageContext : pageContext,
|
||||
userInfo,
|
||||
showDeps);
|
||||
final BiFunction<PageContext, Composite, Supplier<PageContext>> composePage2 =
|
||||
(prefPageContext, content) -> composeReportDialog(content,
|
||||
(prefPageContext != null) ? prefPageContext : pageContext);
|
||||
|
||||
if (showDeps) {
|
||||
final WizardPage<PageContext> page1 = new WizardPage<>(
|
||||
page1Id,
|
||||
true,
|
||||
|
@ -133,6 +152,15 @@ public class UserAccountDeletePopup {
|
|||
new WizardAction<>(ACTION_DELETE, callback));
|
||||
|
||||
wizard.open(FORM_TITLE, Utils.EMPTY_EXECUTION, page1, page2);
|
||||
} else {
|
||||
final WizardPage<PageContext> page1 = new WizardPage<>(
|
||||
page1Id,
|
||||
true,
|
||||
composePage1,
|
||||
new WizardAction<>(ACTION_DELETE, callback));
|
||||
|
||||
wizard.open(FORM_TITLE, Utils.EMPTY_EXECUTION, page1);
|
||||
}
|
||||
|
||||
return action;
|
||||
};
|
||||
|
@ -188,6 +216,8 @@ public class UserAccountDeletePopup {
|
|||
final List<EntityKey> dependencies = report.results.stream()
|
||||
.filter(key -> !key.equals(entityKey))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (dependencies.size() > 0) {
|
||||
pageContext.publishPageMessage(
|
||||
DELETE_CONFIRM_TITLE,
|
||||
new LocTextKey(
|
||||
|
@ -195,6 +225,13 @@ public class UserAccountDeletePopup {
|
|||
userName,
|
||||
dependencies.size(),
|
||||
(report.errors.isEmpty()) ? "no" : String.valueOf((report.errors.size()))));
|
||||
} else {
|
||||
pageContext.publishPageMessage(
|
||||
DELETE_CONFIRM_TITLE,
|
||||
new LocTextKey(
|
||||
"sebserver.useraccount.delete.confirm.message.noDeps",
|
||||
userName));
|
||||
}
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
log.error("Unexpected error while trying to delete User Account:", e);
|
||||
|
@ -205,25 +242,20 @@ public class UserAccountDeletePopup {
|
|||
|
||||
private Supplier<PageContext> composeDeleteDialog(
|
||||
final Composite parent,
|
||||
final PageContext pageContext) {
|
||||
final PageContext pageContext,
|
||||
final UserInfo userInfo,
|
||||
final boolean showDeps) {
|
||||
|
||||
final Composite grid = this.pageService.getWidgetFactory()
|
||||
.createPopupScrollComposite(parent);
|
||||
|
||||
final Label title = this.pageService.getWidgetFactory()
|
||||
.labelLocalized(grid, CustomVariant.TEXT_H3, FORM_INFO);
|
||||
.labelLocalized(grid, CustomVariant.TEXT_H3, (showDeps) ? FORM_INFO : FORM_INFO_NO_DEPS);
|
||||
final GridData gridData = new GridData();
|
||||
gridData.horizontalIndent = 10;
|
||||
gridData.verticalIndent = 10;
|
||||
title.setLayoutData(gridData);
|
||||
|
||||
final EntityKey entityKey = pageContext.getEntityKey();
|
||||
final UserInfo userInfo = this.pageService.getRestService()
|
||||
.getBuilder(GetUserAccount.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||
.call()
|
||||
.get();
|
||||
|
||||
final FormHandle<?> formHandle = this.pageService.formBuilder(
|
||||
pageContext.copyOf(grid))
|
||||
.readonly(false)
|
||||
|
@ -235,11 +267,15 @@ public class UserAccountDeletePopup {
|
|||
userInfo.toName().name)
|
||||
.readonly(true))
|
||||
|
||||
.addField(FormBuilder.checkbox(
|
||||
.addFieldIf(
|
||||
() -> showDeps,
|
||||
() -> FormBuilder.checkbox(
|
||||
ARG_WITH_CONFIGS,
|
||||
FORM_CONFIGS))
|
||||
|
||||
.addField(FormBuilder.checkbox(
|
||||
.addFieldIf(
|
||||
() -> showDeps,
|
||||
() -> FormBuilder.checkbox(
|
||||
ARG_WITH_EXAMS,
|
||||
FORM_EXAMS))
|
||||
.build();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
.withInstitutionalPrivilege(PrivilegeType.READ)
|
||||
.withOwnerPrivilege(PrivilegeType.MODIFY)
|
||||
.andForRole(UserRole.EXAM_SUPPORTER)
|
||||
.withOwnerPrivilege(PrivilegeType.MODIFY)
|
||||
.withOwnerPrivilege(PrivilegeType.WRITE)
|
||||
.create();
|
||||
|
||||
// grants for seb client config
|
||||
|
|
|
@ -257,6 +257,7 @@ sebserver.useraccount.form.password.new.confirm.tooltip=Please confirm the passw
|
|||
|
||||
sebserver.useraccount.delete.form.title=Delete User Account
|
||||
sebserver.useraccount.delete.form.info=Please Note:<br/> This deletes the particular User Account with all selected dependencies.<br/> The User Account and selected dependent exams and exam configurations, will be lost after deletion.<br/> Please use the "Show Report" action below to see a report of all objects that will be<br/> deleted and check them carefully.
|
||||
sebserver.useraccount.delete.form.info.noDeps=Please Note:<br/> This deletes the particular User Account<br/> The User Account will be lost after deletion.
|
||||
sebserver.useraccount.delete.form.report.info=The following objects will be deleted within this User Account deletion.<br/>Please check them carefully before delete.
|
||||
sebserver.useraccount.delete.form.report.empty=No dependencies will be deleted.
|
||||
sebserver.useraccount.delete.form.report.list.type=Type
|
||||
|
@ -271,7 +272,7 @@ sebserver.useraccount.delete.form.action.delete=Delete
|
|||
sebserver.useraccount.delete.form.action.report=Show Report
|
||||
sebserver.useraccount.delete.confirm.title=Deletion Successful
|
||||
sebserver.useraccount.delete.confirm.message=The User Account ({0}) was successfully deleted.<br/>Also the following number dependencies where successfully deleted: {1}.<br/><br/>And there where {2} errors.
|
||||
|
||||
sebserver.useraccount.delete.confirm.message.noDeps=The User Account ({0}) was successfully deleted.
|
||||
################################
|
||||
# LMS Setup
|
||||
################################
|
||||
|
|
Loading…
Reference in a new issue