fixed Test And Save on LMS Setup edit view
This commit is contained in:
		
							parent
							
								
									db29818ecd
								
							
						
					
					
						commit
						09b326fdfe
					
				
					 3 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
					@ -202,7 +202,7 @@ public class LmsSetupForm implements TemplateComposer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                .newAction(ActionDefinition.LMS_SETUP_SAVE_AND_TEST)
 | 
					                .newAction(ActionDefinition.LMS_SETUP_SAVE_AND_TEST)
 | 
				
			||||||
                .withEntityKey(entityKey)
 | 
					                .withEntityKey(entityKey)
 | 
				
			||||||
                .withExec(action -> this.testLmsSetup(action, formHandle))
 | 
					                .withExec(action -> this.testLmsSetup(action, formHandle, true))
 | 
				
			||||||
                .ignoreMoveAwayFromEdit()
 | 
					                .ignoreMoveAwayFromEdit()
 | 
				
			||||||
                .publishIf(() -> modifyGrant && isNotNew.getAsBoolean() && !readonly)
 | 
					                .publishIf(() -> modifyGrant && isNotNew.getAsBoolean() && !readonly)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -238,7 +238,7 @@ public class LmsSetupForm implements TemplateComposer {
 | 
				
			||||||
    /** Save and test connection before activation */
 | 
					    /** Save and test connection before activation */
 | 
				
			||||||
    private PageAction activate(final PageAction action, final FormHandle<LmsSetup> formHandle) {
 | 
					    private PageAction activate(final PageAction action, final FormHandle<LmsSetup> formHandle) {
 | 
				
			||||||
        // first test the LMS Setup. If this fails the action execution will stops
 | 
					        // first test the LMS Setup. If this fails the action execution will stops
 | 
				
			||||||
        final PageAction testLmsSetup = this.testLmsSetup(action, formHandle);
 | 
					        final PageAction testLmsSetup = this.testLmsSetup(action, formHandle, false);
 | 
				
			||||||
        // if LMS Setup test was successful, the activation action applies
 | 
					        // if LMS Setup test was successful, the activation action applies
 | 
				
			||||||
        this.resourceService.getRestService().getBuilder(ActivateLmsSetup.class)
 | 
					        this.resourceService.getRestService().getBuilder(ActivateLmsSetup.class)
 | 
				
			||||||
                .withURIVariable(
 | 
					                .withURIVariable(
 | 
				
			||||||
| 
						 | 
					@ -285,9 +285,11 @@ public class LmsSetupForm implements TemplateComposer {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** LmsSetup test action implementation */
 | 
					    /** LmsSetup test action implementation */
 | 
				
			||||||
    private PageAction testLmsSetup(final PageAction action, final FormHandle<LmsSetup> formHandle) {
 | 
					    private PageAction testLmsSetup(
 | 
				
			||||||
        // If we are in edit-mode we have to save the form before testing
 | 
					            final PageAction action,
 | 
				
			||||||
        if (!action.pageContext().isReadonly()) {
 | 
					            final FormHandle<LmsSetup> formHandle, final boolean saveFirst) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (saveFirst) {
 | 
				
			||||||
            final Result<LmsSetup> postResult = formHandle.doAPIPost();
 | 
					            final Result<LmsSetup> postResult = formHandle.doAPIPost();
 | 
				
			||||||
            if (postResult.hasError()) {
 | 
					            if (postResult.hasError()) {
 | 
				
			||||||
                formHandle.handleError(postResult.getError());
 | 
					                formHandle.handleError(postResult.getError());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,7 @@ public interface PageContext {
 | 
				
			||||||
        public static final String PAGE_TEMPLATE_COMPOSER_NAME = "ATTR_PAGE_TEMPLATE_COMPOSER_NAME";
 | 
					        public static final String PAGE_TEMPLATE_COMPOSER_NAME = "ATTR_PAGE_TEMPLATE_COMPOSER_NAME";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static final String READ_ONLY = "READ_ONLY";
 | 
					        public static final String READ_ONLY = "READ_ONLY";
 | 
				
			||||||
 | 
					        public static final String READ_ONLY_FROM = "READ_ONLY_FROM";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static final String ENTITY_ID = "ENTITY_ID";
 | 
					        public static final String ENTITY_ID = "ENTITY_ID";
 | 
				
			||||||
        public static final String PARENT_ENTITY_ID = "PARENT_ENTITY_ID";
 | 
					        public static final String PARENT_ENTITY_ID = "PARENT_ENTITY_ID";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,11 +59,12 @@ public final class PageAction {
 | 
				
			||||||
        this.successMessage = successMessage;
 | 
					        this.successMessage = successMessage;
 | 
				
			||||||
        this.selectionSupplier = selectionSupplier;
 | 
					        this.selectionSupplier = selectionSupplier;
 | 
				
			||||||
        this.noSelectionMessage = noSelectionMessage;
 | 
					        this.noSelectionMessage = noSelectionMessage;
 | 
				
			||||||
        this.pageContext = pageContext;
 | 
					        this.pageContext = (pageContext != null) ? pageContext.copy() : null;
 | 
				
			||||||
        this.exec = (exec != null) ? exec : Function.identity();
 | 
					        this.exec = (exec != null) ? exec : Function.identity();
 | 
				
			||||||
        this.fireActionEvent = fireActionEvent;
 | 
					        this.fireActionEvent = fireActionEvent;
 | 
				
			||||||
        this.ignoreMoveAwayFromEdit = ignoreMoveAwayFromEdit;
 | 
					        this.ignoreMoveAwayFromEdit = ignoreMoveAwayFromEdit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (this.pageContext != null) {
 | 
				
			||||||
            this.pageContext = pageContext.withAttribute(AttributeKeys.READ_ONLY, Constants.TRUE_STRING);
 | 
					            this.pageContext = pageContext.withAttribute(AttributeKeys.READ_ONLY, Constants.TRUE_STRING);
 | 
				
			||||||
            if (definition.targetState != null) {
 | 
					            if (definition.targetState != null) {
 | 
				
			||||||
                final Type type = definition.targetState.type();
 | 
					                final Type type = definition.targetState.type();
 | 
				
			||||||
| 
						 | 
					@ -72,6 +73,7 @@ public final class PageAction {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public EntityKey getEntityKey() {
 | 
					    public EntityKey getEntityKey() {
 | 
				
			||||||
        return this.pageContext.getEntityKey();
 | 
					        return this.pageContext.getEntityKey();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue