The partner field disappears after submit. + It is not possible to edit the partner field after a submit.
This commit is contained in:
parent
c305509e34
commit
73c02f6e0e
src/main/java/se/su/dsv/scipro/project/panels
@ -37,9 +37,7 @@ public class PartnerAdditionPanel extends Panel {
|
||||
coAuthor = authorList.get(1);
|
||||
partnerLong = new Model<Long>(roleDao.findStudentRole(coAuthor.getUser()).getId());
|
||||
}
|
||||
|
||||
if(!authorList.isEmpty())
|
||||
setEnabled(false);
|
||||
|
||||
addProjectPartner();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
}
|
||||
|
||||
private void dialogSetup(){
|
||||
dialog = new Dialog("dialog");
|
||||
dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.setWidth(600);
|
||||
@ -155,7 +155,6 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
//there may be other higher levels later, thats why i check for bachelor, cus we know bachelor will always require partners.
|
||||
if (!projectClassModel.getObject().getName().equalsIgnoreCase("bachelor")){
|
||||
partnerAdditionPanel.setPartnerRequired(false);
|
||||
partnerContainer.setVisible(false);
|
||||
}
|
||||
|
||||
target.addComponent(partnerContainer);
|
||||
@ -187,10 +186,8 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
container.add(keywordPanel);
|
||||
|
||||
partnerContainer = new WebMarkupContainer("partnerContainer");
|
||||
// partnerContainer.setOutputMarkupId(true);
|
||||
partnerContainer.setOutputMarkupPlaceholderTag(true);
|
||||
container.add(partnerContainer);
|
||||
partnerContainer.setVisible(false);
|
||||
|
||||
|
||||
partnerAdditionPanel = new PartnerAdditionPanel("partnerPanel", ideaModel.getObject().getAuthors());
|
||||
@ -203,8 +200,6 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
createInfoLinks();
|
||||
addInfoLinksToForm();
|
||||
setEnabled(isEditable());
|
||||
|
||||
|
||||
submitButton = new Button("submitButton") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -212,48 +207,43 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
public void onSubmit() {
|
||||
ProjectIdea idea = ideaModel.getObject();
|
||||
boolean validated = true;
|
||||
if (partnerAdditionPanel.coAuthorExists()) {
|
||||
//Check to see if the submitter tries to add himself.
|
||||
if(!partnerAdditionPanel.getCoAuthor().equals(signedInAuthor)) {
|
||||
idea.getAuthors().clear();
|
||||
idea.getAuthors().add(signedInAuthor);
|
||||
idea.getAuthors().add(partnerAdditionPanel.getCoAuthor());
|
||||
} else {
|
||||
error("You can't add yourself as project partner");
|
||||
validated = false;
|
||||
}
|
||||
} else {
|
||||
if (isExemptionGranted() || !projectClassModel.getObject().getName().equalsIgnoreCase("bachelor")) {
|
||||
idea.getAuthors().add(signedInAuthor);
|
||||
//Exemption is granted, no co-author needed OR not bachelor level, no co-author needed
|
||||
} else {
|
||||
error("You need to choose a project partner");
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(idea.getAuthors().isEmpty()) {
|
||||
if (partnerAdditionPanel.coAuthorExists()) {
|
||||
//Check to see if the submitter tries to add himself.
|
||||
if(!partnerAdditionPanel.getCoAuthor().equals(signedInAuthor)) {
|
||||
idea.getAuthors().add(signedInAuthor);
|
||||
idea.getAuthors().add(partnerAdditionPanel.getCoAuthor());
|
||||
} else {
|
||||
error("You can't add yourself as project partner");
|
||||
validated = false;
|
||||
}
|
||||
} else {
|
||||
if (isExemptionGranted() || !projectClassModel.getObject().getName().equalsIgnoreCase("bachelor")) {
|
||||
idea.getAuthors().add(signedInAuthor);
|
||||
//Exemption is granted, no co-author needed OR not bachelor level, no co-author needed
|
||||
} else {
|
||||
error("You need to choose a project partner");
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!validated)
|
||||
error("Submission failed, please try again");
|
||||
else {
|
||||
if (preferredSupervisorSelector.getModelObject() != null && agreedSupervisorSelector.getModelObject() == null) {
|
||||
Employee s = supervisorDao.load(preferredSupervisorSelector.getModelObject());
|
||||
idea.setPreferredSupervisor(s);
|
||||
}
|
||||
|
||||
idea.getKeywords().setKeywords(keywordPanel.getSelectedKeywords());
|
||||
idea.setLanguages(languageSelectionPanel.getSelectedLanguages());
|
||||
|
||||
projectIdeaFacade.saveIdea(idea, loggedInUser, agreedSupervisorSelector.getModelObject());
|
||||
setResponsePage(ProjectIdeaPage.class);
|
||||
getSession().info("Project idea successfully submitted");
|
||||
if (!validated) {
|
||||
error("Submission failed, please try again");
|
||||
} else {
|
||||
if (preferredSupervisorSelector.getModelObject() != null && agreedSupervisorSelector.getModelObject() == null) {
|
||||
Employee s = supervisorDao.load(preferredSupervisorSelector.getModelObject());
|
||||
idea.setPreferredSupervisor(s);
|
||||
}
|
||||
idea.getKeywords().setKeywords(keywordPanel.getSelectedKeywords());
|
||||
idea.setLanguages(languageSelectionPanel.getSelectedLanguages());
|
||||
projectIdeaFacade.saveIdea(idea, loggedInUser, agreedSupervisorSelector.getModelObject());
|
||||
setResponsePage(ProjectIdeaPage.class);
|
||||
getSession().info("Project idea successfully submitted");
|
||||
}
|
||||
}
|
||||
};
|
||||
container.add(submitButton);
|
||||
add(container);
|
||||
|
||||
}
|
||||
|
||||
//Creation of Watson fields
|
||||
|
Loading…
x
Reference in New Issue
Block a user