added feedback panel to project idea start page for authors and some submission logic that disallow bachelor students to accept ideas without partner. exemptions still needs to be implemented

This commit is contained in:
Emil Siverhall 2012-07-24 14:10:55 +02:00
parent 5b5c5cb7f2
commit 468739997b
5 changed files with 30 additions and 10 deletions

@ -3,6 +3,7 @@
<body>
<wicket:extend>
<div class="prepend-top span-24 last">
<div wicket:id="feedback"></div>
<div wicket:id="dialog">
<div wicket:id="dialogPanel"></div>
</div>

@ -9,6 +9,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;
@ -34,15 +35,22 @@ public class ProjectIdeaStartPage extends AbstractProjectIdeaPage {
@SpringBean
private StudentService studentService;
private Dialog dialog;
private FeedbackPanel feedbackPanel;
private GenericDataPanel<SupervisorIdea> genericDataPanel;
public ProjectIdeaStartPage(PageParameters pp) {
super(pp);
addFeedback();
addDialog();
addDataTable();
checkForUnconfirmedIdeas();
}
private void addFeedback() {
add(feedbackPanel = new FeedbackPanel("feedback"));
feedbackPanel.setOutputMarkupId(true);
}
private void checkForUnconfirmedIdeas() {
boolean hasUnconfirmed = ideaService.hasUnconfirmedIdea(getUser());
if(hasUnconfirmed) {

@ -74,6 +74,7 @@ public class AcceptIdeaDialogPanel extends Panel {
@Override
public void onSubmit(){
ideaService.partnerAcceptIdea(model, loggedInUser);
getSession().info("You have accepted to be a part of the project: "+ model.getObject().getTitle());
}
};
acceptButton.add(new JavascriptEventConfirmation("onClick", "Are you sure you want to be a part of this project?"));
@ -82,8 +83,8 @@ public class AcceptIdeaDialogPanel extends Panel {
@Override
public void onSubmit(){
System.out.println("DECLINED?!?!?");
ideaService.partnerDeclineIdea(model);
getSession().info("You have declined to be a part of the project: "+ model.getObject().getTitle());
}
};
declineButton.add(new JavascriptEventConfirmation("onClick", "Are you sure you want to decline this project idea?"));
@ -147,9 +148,9 @@ public class AcceptIdeaDialogPanel extends Panel {
@Override
public void onSubmit() {
if(ideaService.acceptIdea(model, loggedInUser, partnerPanel.getStudentSet())){
System.out.println("COOL");
getSession().info("You have successfully accepted this project idea");
} else {
System.out.println("ERROR");
getSession().error("Something went wrong while trying to accept the project idea");
}

@ -94,9 +94,12 @@ public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorId
public boolean acceptIdea(IModel<SupervisorIdea> model, User mainAuthor,
SortedSet<Student> studentSet) {
if(studentSet.size()> MAX_PARTNERS){
return false;
return false; //You may not add more than a specified number of partners.
} else {
SupervisorIdea idea = supervisorIdeaRepo.findOne(model.getObject().getId());
if(idea.getProjectClass().getCode().equals(ProjectClass.BACHELOR)&&studentSet.isEmpty()){
return false; //You need to select a partner if the idea is on bachelor level.
}
Student author = studentService.findByUser(mainAuthor);
IdeaParticipation mainParticipation = new IdeaParticipation();
mainParticipation.setStudent(author);

@ -58,9 +58,9 @@ public class SupervisorEditIdeaPanel extends Panel {
@SpringBean
private SupervisorService supervisorService;
public SupervisorEditIdeaPanel(String id, User creator, boolean readOnly,IModel<SupervisorIdea> model) {
public SupervisorEditIdeaPanel(String id, User currentUser, boolean readOnly,IModel<SupervisorIdea> model) {
super(id, model);
add(new IdeaForm("form", model, creator).setEnabled(!readOnly));
add(new IdeaForm("form", model, currentUser, readOnly).setEnabled(!readOnly));
}
private class IdeaForm extends Form<SupervisorIdea> {
@ -76,10 +76,9 @@ public class SupervisorEditIdeaPanel extends Panel {
private KeywordContainer regularKwc;
private FeedbackPanel feedbackPanel;
public IdeaForm(String id, final IModel<SupervisorIdea> model, final User creator) {
public IdeaForm(String id, final IModel<SupervisorIdea> model, final User currentUser, final boolean readOnly) {
super(id, model);
final Employee supervisor = supervisorService.findByUser(creator);
add(wmc = new WebMarkupContainer("wmc"));
@ -97,7 +96,15 @@ public class SupervisorEditIdeaPanel extends Panel {
descriptionField.setRequired(true);
descriptionField.add(StringValidator.minimumLength(10)); // Description needs to be at least 10 characters
final Set<ResearchArea> areas = supervisor.getResearchAreas();
final Employee ideaCreator = supervisorService.findByUser(currentUser);
Employee ideaSupervisor = model.getObject().getCreator();
Set<ResearchArea> areas;
if(readOnly)
areas = ideaSupervisor.getActiveResearchAreas();
else
areas = ideaCreator.getActiveResearchAreas();
ListView<ResearchArea> areaList = new ListView<ResearchArea>("researchAreas", new ArrayList<ResearchArea>(areas)) {
private static final long serialVersionUID = 1745649109195334927L;
@ -148,7 +155,7 @@ public class SupervisorEditIdeaPanel extends Panel {
target.addComponent(feedbackPanel);
try {
ideaService.saveSupervisorCreatedIdea(model, supervisor, studentsPanel.getStudentSet());
ideaService.saveSupervisorCreatedIdea(model, ideaCreator, studentsPanel.getStudentSet());
setResponsePage(SupervisorProjectIdeaStartPage.class);
getSession().info("Idea successfully submitted");
} catch (Exception e) {