added new panel where admin should write a comment for the authors when refusing a project idea
This commit is contained in:
parent
c684abaabf
commit
2ad03a4761
src/main/java/se/su/dsv/scipro
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="main"></div>
|
||||
<wicket:fragment wicket:id="buttonFragment">
|
||||
<button wicket:id="manualRefuseButton">Refuse project idea</button>
|
||||
</wicket:fragment>
|
||||
<wicket:fragment wicket:id="refuseFragment">
|
||||
<form wicket:id="refuseForm">
|
||||
<div wicket:id="localFeedback"></div>
|
||||
<div>
|
||||
Comment for author(s): <br /><textarea wicket:id="commentArea"></textarea><br />
|
||||
<a href="#" wicket:id="saveButton"><input type="button" value="Save"/></a>
|
||||
<button wicket:id="cancelButton">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</wicket:fragment>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,148 @@
|
||||
package se.su.dsv.scipro.admin.panels;
|
||||
|
||||
import com.visural.wicket.component.confirmer.ConfirmerAjaxSubmitLink;
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.Session;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Fragment;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.admin.pages.match.AdminManageProjectIdeaPage;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.MatchDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Match;
|
||||
|
||||
public class ManualRefuseIdeaPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private MatchDao matchDao;
|
||||
|
||||
private Fragment currentFragment;
|
||||
private Fragment alternateFragment;
|
||||
private final ConfirmerAjaxSubmitLink saveButton;
|
||||
|
||||
public ManualRefuseIdeaPanel(String id, IModel<Match> matchModel, Component feedbackPanel) {
|
||||
super(id);
|
||||
setOutputMarkupPlaceholderTag(true);
|
||||
Component localFeedback = new FeedbackPanel("localFeedback");
|
||||
TextArea<String> commentArea = new TextArea<String>("commentArea", new PropertyModel<String>(matchModel, "commentForStudent"));
|
||||
commentArea.setOutputMarkupId(true);
|
||||
saveButton = createSubmitLink(matchModel, feedbackPanel, localFeedback, commentArea);
|
||||
saveButton.setOutputMarkupId(true);
|
||||
saveButton.setMessageContentHTML("Are you sure you want to refuse the project idea "+matchModel.getObject().getProjectIdea().getTitle()+"?");
|
||||
Form<Employee> refuseForm = new Form<Employee>("refuseForm");
|
||||
currentFragment = createButtonFragment(refuseForm, commentArea);
|
||||
alternateFragment = createRefuseFragment(refuseForm, localFeedback, commentArea );
|
||||
add(currentFragment);
|
||||
}
|
||||
|
||||
private ConfirmerAjaxSubmitLink createSubmitLink(final IModel<Match> matchModel, final Component feedbackPanel,
|
||||
final Component localFeedback, final TextArea<String> commentArea) {
|
||||
return new ConfirmerAjaxSubmitLink("saveButton") {
|
||||
|
||||
private static final long serialVersionUID = -1852298712407811714L;
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
if(commentArea.getInput().length() < 5) {
|
||||
Session.get().error("You need to write at least 5 characters in the comment field.");
|
||||
target.addComponent(localFeedback);
|
||||
} else {
|
||||
Match matchToChange = matchModel.getObject();
|
||||
matchToChange.setCommentForStudent(commentArea.getInput());
|
||||
matchDao.changeStatus(SciProSession.get().getUser(), matchToChange, Match.Status.REFUSED);
|
||||
Session.get().info("The status was set to refused for the project idea "+matchToChange.getProjectIdea().getTitle());
|
||||
setResponsePage(AdminManageProjectIdeaPage.class);
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override //Listener method invoked on form submit with errors
|
||||
protected void onError(AjaxRequestTarget target, Form<?> form) {
|
||||
Session.get().error("An error occurred when trying to change status to refused on the project idea "+matchModel.getObject().getProjectIdea().getTitle());
|
||||
super.onError(target, form);
|
||||
setResponsePage(AdminManageProjectIdeaPage.class);
|
||||
target.addComponent(feedbackPanel); // is only activated on "this"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Fragment createButtonFragment(final Form<Employee> refuseForm, final TextArea<String> commentArea) {
|
||||
Fragment buttonFragment = new Fragment("main", "buttonFragment", this) {
|
||||
private static final long serialVersionUID = 2383077895140299047L;
|
||||
|
||||
@Override
|
||||
protected void onBeforeRender() {
|
||||
refuseForm.setEnabled(false);
|
||||
super.onBeforeRender();
|
||||
}
|
||||
};
|
||||
buttonFragment.add(new AjaxFallbackLink<Object>("manualRefuseButton") {
|
||||
private static final long serialVersionUID = 5843396419011530582L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
swapFragment();
|
||||
clearInputAndAddToTarget(target, commentArea);
|
||||
}
|
||||
});
|
||||
buttonFragment.setOutputMarkupPlaceholderTag(true);
|
||||
return buttonFragment;
|
||||
}
|
||||
|
||||
private void clearInputAndAddToTarget(AjaxRequestTarget target, final TextArea<String> commentArea) {
|
||||
//noinspection unchecked
|
||||
commentArea.setModelObject(null);
|
||||
commentArea.clearInput();
|
||||
target.addComponent(currentFragment);
|
||||
target.addComponent(commentArea);
|
||||
target.addComponent(saveButton);
|
||||
}
|
||||
|
||||
private Fragment createRefuseFragment(final Form<Employee> refuseForm, Component localFeedback, final TextArea<String> commentArea) {
|
||||
Fragment reviewerFragment = new Fragment("main", "refuseFragment", this) {
|
||||
|
||||
private static final long serialVersionUID = -1831632235479216987L;
|
||||
|
||||
@Override
|
||||
protected void onBeforeRender() {
|
||||
refuseForm.setEnabled(true);
|
||||
super.onBeforeRender();
|
||||
}
|
||||
};
|
||||
commentArea.setModelObject(null);
|
||||
refuseForm.add(commentArea);
|
||||
saveButton.setOutputMarkupId(true);
|
||||
localFeedback.setOutputMarkupId(true);
|
||||
refuseForm.add(localFeedback);
|
||||
refuseForm.add(saveButton);
|
||||
refuseForm.add(new AjaxFallbackLink<Object>("cancelButton") {
|
||||
private static final long serialVersionUID = 5413209640805412939L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
swapFragment();
|
||||
clearInputAndAddToTarget(target, commentArea);
|
||||
}
|
||||
});
|
||||
reviewerFragment.add(refuseForm);
|
||||
reviewerFragment.setOutputMarkupPlaceholderTag(true);
|
||||
return reviewerFragment;
|
||||
}
|
||||
|
||||
private void swapFragment() {
|
||||
Fragment tempFragment = currentFragment;
|
||||
currentFragment.replaceWith(alternateFragment);
|
||||
currentFragment = alternateFragment;
|
||||
alternateFragment = tempFragment;
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<wicket:panel>
|
||||
<div wicket:id="removeAuthorPanel"></div>
|
||||
<form wicket:id="form">
|
||||
|
||||
<div class="span-16">
|
||||
<div class="prepend-top">If you want to match (CONFIRM) this
|
||||
idea to a supervisor manually, you can do so.</div>
|
||||
<div><span wicket:id="manualMatchPanel"></span></div>
|
||||
@ -15,7 +15,7 @@
|
||||
<div class="prepend-top">If this project idea is poorly
|
||||
written, it should be refused, which means it will be sent back to the
|
||||
authors for rewriting.</div>
|
||||
<button wicket:id="sendBackButton">Refuse project idea</button>
|
||||
<div><span wicket:id="manualRefuseIdeaPanel"></span></div>
|
||||
<div class="prepend-top">If this project idea has been
|
||||
suggested to a supervisor that has not answered for very long, it
|
||||
can be unmatched and then suggested to some other supervisor.</div>
|
||||
@ -26,6 +26,7 @@
|
||||
<div class="prepend-top">If you want to suggest a reviewer (NOT supervisor) for this
|
||||
idea manually, you can do so.</div>
|
||||
<div> <span wicket:id="manualSetReviewerPanel"></span></div>
|
||||
</div>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
|
@ -14,6 +14,7 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.admin.pages.match.AdminManageProjectIdeaPage;
|
||||
import se.su.dsv.scipro.admin.panels.ManualMatchPanel;
|
||||
import se.su.dsv.scipro.admin.panels.ManualRefuseIdeaPanel;
|
||||
import se.su.dsv.scipro.admin.panels.ManualSetReviewerPanel;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.MatchDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Match;
|
||||
@ -37,16 +38,7 @@ public class ProjectIdeaActionPanel extends Panel {
|
||||
form.add(new ManualMatchPanel("manualMatchPanel", matchModel, feedbackPanel, Match.Status.CONFIRMED));
|
||||
form.add(new ManualMatchPanel("manualSuggestionPanel", matchModel, feedbackPanel, Match.Status.PUBLISHED));
|
||||
form.add(new ManualSetReviewerPanel("manualSetReviewerPanel", projectIdeaModel, feedbackPanel));
|
||||
|
||||
form.add(new AjaxSubmitLink("sendBackButton") {
|
||||
private static final long serialVersionUID = -1152454202773560729L;
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> f) {
|
||||
changeStatusAndQuit(target, Match.Status.REFUSED, matchModel, feedbackPanel);
|
||||
}
|
||||
});
|
||||
|
||||
form.add(new ManualRefuseIdeaPanel("manualRefuseIdeaPanel", matchModel, feedbackPanel));
|
||||
form.add(new AjaxSubmitLink("rematchButton") {
|
||||
|
||||
private static final long serialVersionUID = 2586530227803716442L;
|
||||
|
@ -70,6 +70,9 @@ public class MatchDaoJPAImp extends AbstractDaoJPAImp<Match> implements
|
||||
newMatch.setRejectedBy(changer);
|
||||
newMatch.setCommentForAdmin(match.getCommentForAdmin());
|
||||
}
|
||||
if(status != null && status.equals(Match.Status.REFUSED)){
|
||||
newMatch.setCommentForStudent(match.getCommentForStudent());
|
||||
}
|
||||
newMatch.setProjectIdea(match.getProjectIdea());
|
||||
return save(newMatch);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user