Added a feedback panel to give users information when a supervisor has reported interest to supervise a project idea + removed text area which we not should use.
This commit is contained in:
parent
1065fd4131
commit
08e5a59e4e
src/main/java/se/su/dsv/scipro/supervisor/panels
@ -9,8 +9,6 @@
|
||||
<form wicket:id="form">
|
||||
<div wicket:id="wmc1">
|
||||
<div class="append-bottom"><button wicket:id="acceptButton">Report interest to supervise</button></div>
|
||||
<div class="append-top">Enter a reason for your interest: (at least 5 characters)</div>
|
||||
<textarea wicket:id="reason" rows="5" style="width: 100%;"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package se.su.dsv.scipro.supervisor.panels;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
@ -39,7 +40,7 @@ public abstract class SupervisorInterestPanel extends Panel {
|
||||
|
||||
public abstract void onUpdate(AjaxRequestTarget target);
|
||||
|
||||
public SupervisorInterestPanel(String id, final IModel<ProjectIdea> projectIdeaIModel) {
|
||||
public SupervisorInterestPanel(String id, final IModel<ProjectIdea> projectIdeaIModel, final Component feedbackPanel) {
|
||||
super(id);
|
||||
final LoadableDetachableModel<ProjectIdea> projectIdeaModel = new LoadableDetachableModel<ProjectIdea>() {
|
||||
private static final long serialVersionUID = 5696857658828934865L;
|
||||
@ -48,15 +49,13 @@ public abstract class SupervisorInterestPanel extends Panel {
|
||||
return projectIdeaDao.load(projectIdeaIModel.getObject().getId());
|
||||
}
|
||||
};
|
||||
add(new SupervisorAcceptDeclineForm(projectIdeaModel));
|
||||
add(new SupervisorAcceptDeclineForm(projectIdeaModel, feedbackPanel));
|
||||
}
|
||||
|
||||
private class SupervisorAcceptDeclineForm extends Form<Void> {
|
||||
private static final long serialVersionUID = -3157033328235572033L;
|
||||
private final TextArea<String> reason;
|
||||
private String reasonString;
|
||||
|
||||
public SupervisorAcceptDeclineForm(final LoadableDetachableModel<ProjectIdea> projectIdeaModel) {
|
||||
public SupervisorAcceptDeclineForm(final LoadableDetachableModel<ProjectIdea> projectIdeaModel, final Component feedbackPanel) {
|
||||
super("form");
|
||||
WebMarkupContainer wmc1 = new WebMarkupContainer("wmc1");
|
||||
add(wmc1);
|
||||
@ -65,9 +64,6 @@ public abstract class SupervisorInterestPanel extends Panel {
|
||||
private static final long serialVersionUID = -2591216055201410154L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
//if (reason.getModelObject() != null && reason.getModelObject().length() > 4) {
|
||||
//here we should save the reason for the interest in some table
|
||||
//}
|
||||
Employee employee = supervisorDao.getFrom(SciProSession.get().getUser());
|
||||
if(isInterestAlreadyAdded(projectIdeaModel.getObject(), employee)) {
|
||||
SupervisorInterest supervisorInterest = new SupervisorInterest();
|
||||
@ -77,17 +73,16 @@ public abstract class SupervisorInterestPanel extends Panel {
|
||||
projectIdeaModel.getObject().setSupervisorInterest(supervisorInterest);
|
||||
projectIdeaDao.save(projectIdeaModel.getObject());
|
||||
onUpdate(target);
|
||||
logger.info("Added interest for the supervisor" + employee.getNameAsString() + " to supervise the project idea " + projectIdeaModel.getObject().getTitle());
|
||||
String infoText = "Added supervisor interest to " + employee.getNameAsString() + " for the project idea " + projectIdeaModel.getObject().getTitle();
|
||||
SciProSession.get().info(infoText);
|
||||
target.addComponent(feedbackPanel);
|
||||
logger.info(infoText);
|
||||
} else {
|
||||
// the link is disabled when interest already is added for the supervisor so there is no need for a feedback message
|
||||
logger.info("Interest already added for the supervisor " + employee.getNameAsString() + " to supervise the project idea " + projectIdeaModel.getObject().getTitle());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reason = new TextArea<String>("reason", new PropertyModel<String>(this, "reasonString"));
|
||||
reason.setRequired(true);
|
||||
reason.add(StringValidator.minimumLength(5));
|
||||
wmc1.add(reason);
|
||||
}
|
||||
|
||||
private boolean isInterestAlreadyAdded(ProjectIdea projectIdea, Employee employee ) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package se.su.dsv.scipro.supervisor.panels;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
@ -15,11 +16,11 @@ public abstract class SupervisorInterestProjectIdeaDialogPanel extends Panel {
|
||||
|
||||
public abstract void onUpdateUpdate(AjaxRequestTarget target);
|
||||
|
||||
public SupervisorInterestProjectIdeaDialogPanel(String id, final IModel<ProjectIdea> projectIdea) {
|
||||
public SupervisorInterestProjectIdeaDialogPanel(String id, final IModel<ProjectIdea> projectIdea, final Component feedbackPanel) {
|
||||
super(id);
|
||||
add(new WatsonInfoPanel("watsonPanel", projectIdea.getObject()));
|
||||
|
||||
add(new SupervisorInterestPanel("acceptDeclinePanel", projectIdea){
|
||||
add(new SupervisorInterestPanel("acceptDeclinePanel", projectIdea, feedbackPanel){
|
||||
private static final long serialVersionUID = 2192277777696201317L;
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,6 @@ import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
@ -78,7 +77,7 @@ public class SupervisorUnmatchedThesisPanel extends Panel {
|
||||
Label emptyLabel = new Label("emptyLabel", "No project ideas to show.");
|
||||
|
||||
setOutputMarkupId(totalProjectIdeas, emptyLabel, allContainer);
|
||||
allDataViewSetup(totalProjectIdeas, allContainer, allProvider, emptyLabel);
|
||||
allDataViewSetup(totalProjectIdeas, allContainer, allProvider, emptyLabel, feedBackPanel);
|
||||
FilterForm form = new FilterForm(totalProjectIdeas, allContainer, allProvider, emptyLabel, params, feedBackPanel);
|
||||
addSortingLinks(allContainer, params);
|
||||
add(form);
|
||||
@ -138,7 +137,8 @@ public class SupervisorUnmatchedThesisPanel extends Panel {
|
||||
}
|
||||
|
||||
|
||||
private void allDataViewSetup(final Label totalProjectIdeas, final WebMarkupContainer allContainer, final ProjectIdeaDataProvider allProvider, final Label emptyLabel) {
|
||||
private void allDataViewSetup(final Label totalProjectIdeas, final WebMarkupContainer allContainer, final ProjectIdeaDataProvider allProvider, final Label emptyLabel,
|
||||
final Component feedBackPanel) {
|
||||
final Dialog dialog = createDialog();
|
||||
add(dialog.setOutputMarkupId(true));
|
||||
allContainer.add(emptyLabel.setOutputMarkupId(true));
|
||||
@ -157,7 +157,7 @@ public class SupervisorUnmatchedThesisPanel extends Panel {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
|
||||
dialog.replace(new SupervisorInterestProjectIdeaDialogPanel("dialogContent", new Model<ProjectIdea>(idea)) {
|
||||
dialog.replace(new SupervisorInterestProjectIdeaDialogPanel("dialogContent", new Model<ProjectIdea>(idea), feedBackPanel) {
|
||||
private static final long serialVersionUID = 5108807012237992330L;
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user