SEBSERV-67 fixed
This commit is contained in:
parent
800399f83b
commit
a1a9c482e3
5 changed files with 56 additions and 6 deletions
src/main/java/ch/ethz/seb/sebserver/gui
|
@ -192,14 +192,14 @@ public class SebExamConfigPropForm implements TemplateComposer {
|
|||
FORM_DESCRIPTION_TEXT_KEY,
|
||||
examConfig.description)
|
||||
.asArea()
|
||||
.withInputSpan(3))
|
||||
.withInputSpan((isReadonly) ? 3 : 2))
|
||||
|
||||
.addField(FormBuilder.singleSelection(
|
||||
Domain.CONFIGURATION_NODE.ATTR_STATUS,
|
||||
FORM_STATUS_TEXT_KEY,
|
||||
examConfig.status.name(),
|
||||
() -> resourceService.examConfigStatusResources(isAttachedToExam))
|
||||
.withEmptyCellSeparation(false))
|
||||
.withEmptyCellSeparation((isReadonly) ? false : true))
|
||||
.buildFor((isNew)
|
||||
? this.restService.getRestCall(NewExamConfig.class)
|
||||
: this.restService.getRestCall(SaveExamConfig.class));
|
||||
|
|
|
@ -11,6 +11,7 @@ package ch.ethz.seb.sebserver.gui.content;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -144,6 +145,16 @@ public class SebExamConfigSettingsForm implements TemplateComposer {
|
|||
tabItem.setControl(viewGrid);
|
||||
}
|
||||
|
||||
// set selection if available
|
||||
final String viewIndex = pageContext.getAttribute("VIEW_INDEX");
|
||||
if (StringUtils.isNotBlank(viewIndex)) {
|
||||
try {
|
||||
tabFolder.setSelection(Integer.parseInt(viewIndex));
|
||||
} catch (final NumberFormatException e) {
|
||||
log.warn("Failed to initialize view selection");
|
||||
}
|
||||
}
|
||||
|
||||
this.examConfigurationService.initInputFieldValues(configuration.id, viewContexts);
|
||||
|
||||
final GrantCheck examConfigGrant = this.currentUser.grantCheck(EntityType.CONFIGURATION_NODE);
|
||||
|
@ -156,7 +167,9 @@ public class SebExamConfigSettingsForm implements TemplateComposer {
|
|||
.withURIVariable(API.PARAM_MODEL_ID, configuration.getModelId())
|
||||
.call()
|
||||
.onError(t -> notifyErrorOnSave(t, pageContext));
|
||||
return action;
|
||||
return action.withAttribute(
|
||||
"VIEW_INDEX",
|
||||
String.valueOf(tabFolder.getSelectionIndex()));
|
||||
})
|
||||
.withSuccess(KEY_SAVE_TO_HISTORY_SUCCESS)
|
||||
.ignoreMoveAwayFromEdit()
|
||||
|
@ -169,7 +182,9 @@ public class SebExamConfigSettingsForm implements TemplateComposer {
|
|||
.withURIVariable(API.PARAM_MODEL_ID, configuration.getModelId())
|
||||
.call()
|
||||
.getOrThrow();
|
||||
return action;
|
||||
return action.withAttribute(
|
||||
"VIEW_INDEX",
|
||||
String.valueOf(tabFolder.getSelectionIndex()));
|
||||
})
|
||||
.withSuccess(KEY_UNDO_SUCCESS)
|
||||
.ignoreMoveAwayFromEdit()
|
||||
|
|
|
@ -294,7 +294,7 @@ public class ResourceService {
|
|||
if (type == null) {
|
||||
return Constants.EMPTY_NOTE;
|
||||
}
|
||||
return this.i18nSupport.getText(ENTITY_TYPE_PREFIX + type.name());
|
||||
return this.i18nSupport.getText(getEntityTypeNameKey(type));
|
||||
}
|
||||
|
||||
public String getEntityTypeName(final UserActivityLog userLog) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.service.page;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
|
||||
public class MultiPageMessageException extends PageMessageException {
|
||||
|
||||
private static final long serialVersionUID = -501071029069528332L;
|
||||
|
||||
private final Collection<Exception> errors;
|
||||
|
||||
public MultiPageMessageException(final LocTextKey message, final Collection<Exception> errors) {
|
||||
super(message, (errors != null && !errors.isEmpty()) ? errors.iterator().next() : null);
|
||||
this.errors = Utils.immutableCollectionOf(errors);
|
||||
}
|
||||
|
||||
public Collection<Exception> getErrors() {
|
||||
return this.errors;
|
||||
}
|
||||
|
||||
}
|
|
@ -43,6 +43,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
|||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.ComposerService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.MultiPageMessageException;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
|
@ -268,7 +269,10 @@ public class PageServiceImpl implements PageService {
|
|||
}
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
// TODO notify message for user
|
||||
final String entityTypeName = this.resourceService.getEntityTypeName(entityType);
|
||||
throw new MultiPageMessageException(
|
||||
new LocTextKey(PageContext.GENERIC_ACTIVATE_ERROR_TEXT_KEY, entityTypeName),
|
||||
errors);
|
||||
}
|
||||
|
||||
return action;
|
||||
|
|
Loading…
Add table
Reference in a new issue