Allow changes to the reflection to be made after it's been submitted #13
@ -19,6 +19,17 @@
|
||||
[Authors submitted reflection]
|
||||
</wicket:container>
|
||||
|
||||
<button class="btn btn-outline-secondary" wicket:id="show_edit_reflection_form">
|
||||
<wicket:message key="edit_reflection">
|
||||
Edit reflection
|
||||
</wicket:message>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" wicket:id="show_request_improvements_form">
|
||||
<wicket:message key="request_improvements">
|
||||
Request improvements
|
||||
</wicket:message>
|
||||
</button>
|
||||
|
||||
<form wicket:id="request_improvements_form">
|
||||
<hr>
|
||||
<p>
|
||||
@ -39,6 +50,32 @@
|
||||
Request improvements
|
||||
</wicket:message>
|
||||
</button>
|
||||
<button class="btn btn-link" wicket:id="cancel">
|
||||
<wicket:message key="cancel">
|
||||
Cancel
|
||||
</wicket:message>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form wicket:id="edit_reflection_form">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">
|
||||
<wicket:message key="reflection">
|
||||
Reflection
|
||||
</wicket:message>
|
||||
</label>
|
||||
<textarea class="form-control" wicket:id="reflection" rows="10"></textarea>
|
||||
</div>
|
||||
<button class="btn btn-primary" wicket:id="submit">
|
||||
<wicket:message key="save">
|
||||
Save
|
||||
</wicket:message>
|
||||
</button>
|
||||
<button class="btn btn-link" wicket:id="cancel">
|
||||
<wicket:message key="cancel">
|
||||
Cancel
|
||||
</wicket:message>
|
||||
</button>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
|
@ -2,8 +2,8 @@ package se.su.dsv.scipro.grading;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
@ -27,6 +27,10 @@ class ReflectionModalBodyPanel extends Panel {
|
||||
private final IModel<Project> projectModel;
|
||||
private final IModel<User> authorModel;
|
||||
|
||||
private enum State { VIEWING, REQUESTING_IMPROVEMENTS, EDITING }
|
||||
|
||||
private State state = State.VIEWING;
|
||||
|
||||
ReflectionModalBodyPanel(String id, IModel<Project> projectModel, IModel<User> authorModel) {
|
||||
super(id);
|
||||
this.projectModel = projectModel;
|
||||
@ -36,7 +40,13 @@ class ReflectionModalBodyPanel extends Panel {
|
||||
|
||||
IModel<Reflection> reflectionModel = projectModel.combineWith(authorModel, reflectionService::getReflection);
|
||||
|
||||
add(new MultiLineLabel("reflection_text", reflectionModel.map(this::getReflectionText)));
|
||||
add(new MultiLineLabel("reflection_text", reflectionModel.map(this::getReflectionText)) {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(state != State.EDITING);
|
||||
}
|
||||
});
|
||||
|
||||
add(new MultiLineLabel("improvements_needed_supervisor_feedback", reflectionModel
|
||||
.as(Reflection.ImprovementsNeeded.class)
|
||||
@ -49,6 +59,39 @@ class ReflectionModalBodyPanel extends Panel {
|
||||
});
|
||||
|
||||
add(new RequestImprovementsForm("request_improvements_form", reflectionModel));
|
||||
add(new SupervisorEditReflectionForm("edit_reflection_form", reflectionModel));
|
||||
|
||||
add(new AjaxLink<>("show_request_improvements_form", reflectionModel) {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
ReflectionModalBodyPanel.this.state = State.REQUESTING_IMPROVEMENTS;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
Reflection reflection = getModelObject();
|
||||
boolean canRequestImprovements = reflection instanceof Reflection.Submitted;
|
||||
setVisible(state == State.VIEWING && canRequestImprovements);
|
||||
}
|
||||
});
|
||||
|
||||
add(new AjaxLink<>("show_edit_reflection_form", reflectionModel) {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
ReflectionModalBodyPanel.this.state = State.EDITING;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
Reflection reflection = getModelObject();
|
||||
boolean canEditReflection = reflection instanceof Reflection.Submitted || reflection instanceof Reflection.ImprovementsNeeded;
|
||||
setVisible(state == State.VIEWING && canEditReflection);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getReflectionText(Reflection reflection) {
|
||||
@ -88,6 +131,14 @@ class ReflectionModalBodyPanel extends Panel {
|
||||
authorModel.getObject(),
|
||||
commentModel.getObject());
|
||||
|
||||
ReflectionModalBodyPanel.this.state = State.VIEWING;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
});
|
||||
add(new AjaxLink<>("cancel") {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
ReflectionModalBodyPanel.this.state = State.VIEWING;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
});
|
||||
@ -96,7 +147,45 @@ class ReflectionModalBodyPanel extends Panel {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(getModelObject() instanceof Reflection.Submitted);
|
||||
setVisible(state == State.REQUESTING_IMPROVEMENTS && getModelObject() instanceof Reflection.Submitted);
|
||||
}
|
||||
}
|
||||
|
||||
private class SupervisorEditReflectionForm extends Form<Reflection> {
|
||||
public SupervisorEditReflectionForm(String id, IModel<Reflection> reflectionModel) {
|
||||
super(id, reflectionModel);
|
||||
|
||||
IModel<String> reflectionTextModel = new Model<>(getReflectionText(reflectionModel.getObject()));
|
||||
|
||||
TextArea<String> reflectionTextArea = new TextArea<>("reflection", reflectionTextModel);
|
||||
reflectionTextArea.setRequired(true);
|
||||
add(reflectionTextArea);
|
||||
|
||||
add(new AjaxSubmitLink("submit") {
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target) {
|
||||
reflectionService.submitReflection(
|
||||
projectModel.getObject(),
|
||||
authorModel.getObject(),
|
||||
reflectionTextModel.getObject());
|
||||
|
||||
ReflectionModalBodyPanel.this.state = State.VIEWING;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
});
|
||||
add(new AjaxLink<>("cancel") {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
ReflectionModalBodyPanel.this.state = State.VIEWING;
|
||||
target.add(ReflectionModalBodyPanel.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(state == State.EDITING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,6 @@ reflection_not_submitted=Reflection not submitted yet
|
||||
request_improvements_text=If the submitted reflection does not meet the minimum requirements \
|
||||
you can request improvements from the student. The student will be notified and can submit a new reflection. \
|
||||
Use the comment field to provide feedback to the student.
|
||||
edit_reflection=Edit reflection
|
||||
reflection=Reflection
|
||||
cancel=Cancel
|
||||
|
Loading…
x
Reference in New Issue
Block a user