Skip to content
Snippets Groups Projects
Commit 67ba4fa9 authored by srosse's avatar srosse
Browse files

OO-4095: enable dirty check in survey with quick save

parent c10ef08b
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ import org.olat.core.gui.components.form.flexible.FormItemContainer; ...@@ -33,6 +33,7 @@ import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.FormLink; import org.olat.core.gui.components.form.flexible.elements.FormLink;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent; import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit;
import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event; import org.olat.core.gui.control.Event;
...@@ -80,7 +81,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -80,7 +81,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple
private final Map<String, EvaluationFormElementHandler> handlerMap = new HashMap<>(); private final Map<String, EvaluationFormElementHandler> handlerMap = new HashMap<>();
private final List<ExecutionFragment> fragments = new ArrayList<>(); private final List<ExecutionFragment> fragments = new ArrayList<>();
private FormLink saveLink; private FormLink saveLink;
private FormLink doneLink; private FormSubmit doneLink;
private DialogBoxController confirmDoneCtrl; private DialogBoxController confirmDoneCtrl;
private PageFragmentsElementImpl fragmentsEl; private PageFragmentsElementImpl fragmentsEl;
...@@ -91,8 +92,6 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -91,8 +92,6 @@ public class EvaluationFormExecutionController extends FormBasicController imple
private boolean readOnly; private boolean readOnly;
private boolean showDoneButton; private boolean showDoneButton;
private boolean immediateSave = false;
private EvaluationFormSession session; private EvaluationFormSession session;
private final EvaluationFormResponses responses; private final EvaluationFormResponses responses;
...@@ -196,9 +195,11 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -196,9 +195,11 @@ public class EvaluationFormExecutionController extends FormBasicController imple
&& !session.getParticipation().isAnonymous(); && !session.getParticipation().isAnonymous();
boolean anonymous = !notAnonymous; boolean anonymous = !notAnonymous;
flc.contextPut("anonymous", Boolean.valueOf(showDoneButton && anonymous)); flc.contextPut("anonymous", Boolean.valueOf(showDoneButton && anonymous));
// force it to have always the same settings
mainForm.setMultipartEnabled(true);
doneLink = uifactory.addFormLink("save.as.done", "save.as.done", null, flc, Link.BUTTON); doneLink = uifactory.addFormSubmitButton("save.as.done", "save.as.done", formLayout);
doneLink.setPrimary(true);
saveLink = uifactory.addFormLink("save.intermediate", "save.intermediate", null, flc, Link.BUTTON); saveLink = uifactory.addFormLink("save.intermediate", "save.intermediate", null, flc, Link.BUTTON);
showHideButtons(); showHideButtons();
} }
...@@ -270,11 +271,10 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -270,11 +271,10 @@ public class EvaluationFormExecutionController extends FormBasicController imple
@Override @Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (saveLink == source) { if (saveLink == source) {
immediateSave = true; if(mainForm.validate(ureq)) {
mainForm.submit(ureq); mainForm.forceSubmittedAndValid();
} else if (doneLink == source) { doSaveResponses();
immediateSave = false; }
mainForm.submit(ureq);
} }
super.formInnerEvent(ureq, source, event); super.formInnerEvent(ureq, source, event);
} }
...@@ -292,7 +292,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -292,7 +292,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple
@Override @Override
protected void formOK(UserRequest ureq) { protected void formOK(UserRequest ureq) {
boolean responsesSaved = doSaveResponses(); boolean responsesSaved = doSaveResponses();
if (!immediateSave && responsesSaved) { if (responsesSaved) {
doConfirmDone(ureq); doConfirmDone(ureq);
} }
} }
...@@ -342,7 +342,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple ...@@ -342,7 +342,7 @@ public class EvaluationFormExecutionController extends FormBasicController imple
List<ValidationMessage> messages = new ArrayList<>(); List<ValidationMessage> messages = new ArrayList<>();
validate(ureq, messages); validate(ureq, messages);
if (messages.size() > 0) { if (!messages.isEmpty()) {
for (ValidationMessage message : messages) { for (ValidationMessage message : messages) {
sb.append("<p class='o_warning'>").append(message.getMessage()).append("</p>"); sb.append("<p class='o_warning'>").append(message.getMessage()).append("</p>");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment