diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java index 3a7f80ac..8400c59d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java @@ -869,7 +869,7 @@ public enum ActionDefinition { SEB_EXAM_CONFIG_TEMPLATE_ATTR_FORM_SET_DEFAULT( new LocTextKey("sebserver.configtemplate.attr.action.setdefault"), - ImageIcon.UNDO, + ImageIcon.RESET, PageStateDefinitionImpl.SEB_EXAM_CONFIG_TEMPLATE_ATTRIBUTE_EDIT, ActionCategory.FORM), SEB_EXAM_CONFIG_TEMPLATE_ATTR_FORM_EDIT_TEMPLATE( diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/ConfigTemplateAttributeForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/ConfigTemplateAttributeForm.java index 09d3a31e..4addce83 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/ConfigTemplateAttributeForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/ConfigTemplateAttributeForm.java @@ -69,6 +69,8 @@ public class ConfigTemplateAttributeForm implements TemplateComposer { new LocTextKey("sebserver.configtemplate.attr.form.value"); private static final LocTextKey FORM_VALUE_TOOLTIP_TEXT_KEY = new LocTextKey("sebserver.configtemplate.attr.form.value" + Constants.TOOLTIP_TEXT_KEY_SUFFIX); + public static final LocTextKey CONF_TEXT_RESET_VALUES = + new LocTextKey("sebserver.configtemplate.attr.list.actions.setdefault.confirm"); private final PageService pageService; private final RestService restService; @@ -137,7 +139,7 @@ public class ConfigTemplateAttributeForm implements TemplateComposer { final boolean _hasView = hasView; this.pageService.formBuilder(formContext) - .readonly(true) // TODO change this for next version + .readonly(true) .addField(FormBuilder.text( Domain.CONFIGURATION_ATTRIBUTE.ATTR_NAME, FORM_NAME_TEXT_KEY, @@ -183,7 +185,7 @@ public class ConfigTemplateAttributeForm implements TemplateComposer { final ViewContext viewContext = this.examConfigurationService.createViewContext( valueContext, configuration, - new View(-1L, "template", 10, 0, templateId), + new View(-1L, ViewContext.TEMPLATE_VIEW_NAME, 10, 0, templateId), viewName -> null, attributeMapping, 1, false, null); @@ -211,9 +213,15 @@ public class ConfigTemplateAttributeForm implements TemplateComposer { final boolean _hasView = hasView; this.pageService.pageActionBuilder(pageContext.clearEntityKeys()) + .newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_ATTR_FORM_EDIT_TEMPLATE) + .withEntityKey(templateKey) + .ignoreMoveAwayFromEdit() + .publish() + .newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_ATTR_FORM_SET_DEFAULT) .withEntityKey(attributeKey) .withParentEntityKey(templateKey) + .withConfirm(() -> CONF_TEXT_RESET_VALUES) .withExec(this.examConfigurationService::resetToDefaults) .ignoreMoveAwayFromEdit() .publishIf(() -> _modifyGrant) @@ -231,11 +239,8 @@ public class ConfigTemplateAttributeForm implements TemplateComposer { .withExec(this.examConfigurationService::attachToDefaultView) .ignoreMoveAwayFromEdit() .publishIf(() -> _modifyGrant && !_hasView) + ; - .newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_ATTR_FORM_EDIT_TEMPLATE) - .withEntityKey(templateKey) - .ignoreMoveAwayFromEdit() - .publish(); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java index e999fba7..b38d9ffe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java @@ -71,7 +71,7 @@ public class CheckBoxBuilder implements InputFieldBuilder { final Button checkbox = this.widgetFactory.buttonLocalized( innerGrid, SWT.CHECK, - (orientation.title == TitleOrientation.NONE) + (orientation.title == TitleOrientation.NONE || viewContext.isTemplateView()) ? ExamConfigurationService.attributeNameLocKey(attribute) : null, ExamConfigurationService.getToolTipKey(attribute, i18nSupport), diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ExamConfigurationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ExamConfigurationServiceImpl.java index 095a0089..6a477e0a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ExamConfigurationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ExamConfigurationServiceImpl.java @@ -233,7 +233,7 @@ public class ExamConfigurationServiceImpl implements ExamConfigurationService { final Long configurationId, final Collection viewContexts) { - if (viewContexts == null || viewContexts.size() < 1) { + if (viewContexts == null || viewContexts.isEmpty()) { log.warn("No viewContexts available"); return; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java index 29681987..16702505 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java @@ -36,6 +36,7 @@ public final class ViewContext { /** Defines a list of checkbox fields that are inverted on the display of SEB settings */ public static final Set INVERTED_CHECKBOX_SETTINGS = new HashSet<>(Arrays.asList( "enableSebBrowser")); + public static final String TEMPLATE_VIEW_NAME = "template"; private final Configuration configuration; private final View view; @@ -115,6 +116,10 @@ public final class ViewContext { return this.view; } + public boolean isTemplateView() { + return TEMPLATE_VIEW_NAME.equals(this.view.name); + } + public Collection getChildAttributes(final Long id) { return this.attributeMapping.childAttributeMapping.get(id); } @@ -127,6 +132,8 @@ public final class ViewContext { return this.attributeMapping.getAttribute(attributeId); } + + public Long getAttributeIdByName(final String name) { return this.attributeMapping.attributeNameIdMapping.get(name); } @@ -338,4 +345,5 @@ public final class ViewContext { values.forEach(this.inputFieldMapping::remove); } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java index e39d0ed1..f1364f33 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java @@ -128,6 +128,7 @@ public class WidgetFactory { ARCHIVE("archive.png"), SEARCH("lens.png"), UNDO("undo.png"), + RESET("reset.png"), COLOR("color.png"), USER("user.png"), INSTITUTION("institution.png"), diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index dbc1f8ce..0ab58a0a 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -2013,10 +2013,11 @@ sebserver.configtemplate.action.error.title=Action Failed sebserver.configtemplate.action.error.noview.message=This setting has no default view
and cannot be attached/detached from a view sebserver.configtemplate.attr.list.actions= sebserver.configtemplate.attr.list.actions.modify=Edit Attribute -sebserver.configtemplate.attr.list.actions.setdefault=Set Default Values +sebserver.configtemplate.attr.list.actions.setdefault=Reset to default values sebserver.configtemplate.attr.list.actions.removeview=Remove From View sebserver.configtemplate.attr.list.actions.attach-default-view=Attach To View sebserver.configtemplate.attr.info.pleaseSelect=At first please select an Attribute from the list +sebserver.configtemplate.attr.list.actions.setdefault.confirm=Are you sure you want to reset this setting to overall default value? sebserver.configtemplate.attr.form.title=Configuration Template Attribute @@ -2032,7 +2033,7 @@ sebserver.configtemplate.attr.form.group.tooltip=The group on the view/tab where sebserver.configtemplate.attr.form.value=Configuration Template Attribute Value sebserver.configtemplate.attr.form.value.tooltip=The SEB exam configuration attribute value that can be set as default for this template -sebserver.configtemplate.attr.action.setdefault=Set Default Values +sebserver.configtemplate.attr.action.setdefault=Reset to default values sebserver.configtemplate.attr.action.template=View Configuration Template sebserver.configtemplate.action.delete=Delete Configuration Template diff --git a/src/main/resources/static/images/reset.png b/src/main/resources/static/images/reset.png new file mode 100644 index 00000000..d257f3c1 Binary files /dev/null and b/src/main/resources/static/images/reset.png differ