diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamSignatureKeyForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamSignatureKeyForm.java index 3bd48ea6..043902a8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamSignatureKeyForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamSignatureKeyForm.java @@ -186,18 +186,31 @@ public class ExamSignatureKeyForm implements TemplateComposer { table -> actionBuilder .newAction(ActionDefinition.EXAM_SECURITY_KEY_SHOW_ADD_GRANT_POPUP) .withParentEntityKey(entityKey) - .withExec(action -> this.addSecurityKeyGrantPopup.showGrantPopup( - action, - table.getSingleSelectedROWData())) + .withSelect( + table::getMultiSelection, + this.addGrant(table), + APP_SIG_KEY_LIST_EMPTY_SELECTION_TEXT_KEY) + .noEventPropagation() + .ignoreMoveAwayFromEdit() + .create()) + .withDefaultActionIf( + () -> readonly, + table -> actionBuilder + .newAction(ActionDefinition.EXAM_SECURITY_KEY_SHOW_ASK_POPUP) + .withParentEntityKey(entityKey) + .withSelect( + table::getMultiSelection, + this.showASK(table), + APP_SIG_KEY_LIST_EMPTY_SELECTION_TEXT_KEY) .noEventPropagation() .ignoreMoveAwayFromEdit() .create()) - .withSelectionListenerIf( - () -> !readonly, + .withSelectionListener( this.pageService.getSelectionPublisher( pageContext, - ActionDefinition.EXAM_SECURITY_KEY_SHOW_ADD_GRANT_POPUP)) + ActionDefinition.EXAM_SECURITY_KEY_SHOW_ADD_GRANT_POPUP, + ActionDefinition.EXAM_SECURITY_KEY_SHOW_ASK_POPUP)) .compose(pageContext.copyOf(content)); @@ -225,14 +238,14 @@ public class ExamSignatureKeyForm implements TemplateComposer { GRANT_LIST_TAG, SecurityKey::getTag).widthProportion(1)) - .withDefaultActionIf( - () -> !readonly, + .withDefaultAction( table -> actionBuilder .newAction(ActionDefinition.EXAM_SECURITY_KEY_SHOW_GRANT_POPUP) .withParentEntityKey(entityKey) - .withExec(action -> this.securityKeyGrantPopup.showGrantPopup( - action, - table.getSingleSelectedROWData())) + .withSelect( + table::getMultiSelection, + this.showGrant(table), + GRANT_LIST_EMPTY_SELECTION_TEXT_KEY) .noEventPropagation() .ignoreMoveAwayFromEdit() .create()) @@ -330,6 +343,7 @@ public class ExamSignatureKeyForm implements TemplateComposer { return action -> { final EntityKey singleSelection = action.getSingleSelection(); if (singleSelection != null) { + action.setReadonly(); this.addSecurityKeyGrantPopup.showGrantPopup(action, connectionInfoTable.getSingleSelectedROWData()); } return action; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageAction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageAction.java index 6f6cd2eb..ae6b335b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageAction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageAction.java @@ -86,6 +86,10 @@ public final class PageAction { } } + public void setReadonly() { + this.pageContext = this.pageContext.withAttribute(AttributeKeys.READ_ONLY, Constants.TRUE_STRING); + } + public String getName() { if (this.definition != null) { return this.definition.name();