fixed some saves, changed a panel to use models instead of entity
This commit is contained in:
parent
50ab4aadc3
commit
b4df30b748
src/main/java/se/su/dsv/scipro
checklists/panels
project/pages
supervisor/pages
@ -14,6 +14,7 @@ import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
@ -56,19 +57,19 @@ public class ListCheckListPanel extends Panel {
|
||||
@SpringBean
|
||||
CheckListController checkListController;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Project project;
|
||||
private Model<Project> projectModel;
|
||||
private final ListView<CheckList> checkLists;
|
||||
private Label emptyLabel;
|
||||
|
||||
public ListCheckListPanel(String id, final CheckListRole role, final Project project) {
|
||||
public ListCheckListPanel(String id, final CheckListRole role, final Model<Project> projectModel) {
|
||||
super(id);
|
||||
assert(project != null);
|
||||
this.project = project;
|
||||
assert(projectModel.getObject() != null);
|
||||
this.projectModel = projectModel;
|
||||
final IModel<List<CheckList>> checkListModel = new LoadableDetachableModel<List<CheckList>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected List<CheckList> load() {
|
||||
return project.getCheckLists();
|
||||
return projectModel.getObject().getCheckLists();
|
||||
}
|
||||
};
|
||||
final WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
@ -76,7 +77,7 @@ public class ListCheckListPanel extends Panel {
|
||||
|
||||
emptyLabel = new Label("emptyLabel", "No checklists has been added to this project yet.");
|
||||
emptyLabel.setOutputMarkupId(true);
|
||||
emptyLabel.setVisible(project.getCheckLists().isEmpty());
|
||||
emptyLabel.setVisible(projectModel.getObject().getCheckLists().isEmpty());
|
||||
container.add(emptyLabel);
|
||||
|
||||
container.add(new WebMarkupContainer("removeHeader"){
|
||||
@ -94,7 +95,7 @@ public class ListCheckListPanel extends Panel {
|
||||
final CheckList cl = item.getModelObject();
|
||||
final PageParameters pp = new PageParameters();
|
||||
pp.put("checklist", cl.getId());
|
||||
pp.put(Project.PP_PROJECT_ID, project.getId());
|
||||
pp.put(Project.PP_PROJECT_ID, projectModel.getObject().getId());
|
||||
//Check for answered questions on this checklist
|
||||
boolean isAnswered=false;
|
||||
for(CheckListQuestion question :cl.getQuestions()){
|
||||
@ -105,8 +106,8 @@ public class ListCheckListPanel extends Panel {
|
||||
}
|
||||
//Check for links from project schedule events
|
||||
boolean isLinked=false;
|
||||
if(project != null && project.getProjectSchedule() != null){
|
||||
for(final ProjectScheduleEvent event : project.getProjectSchedule().getEvents()){
|
||||
if(projectModel.getObject() != null && projectModel.getObject().getProjectSchedule() != null){
|
||||
for(final ProjectScheduleEvent event : projectModel.getObject().getProjectSchedule().getEvents()){
|
||||
if(event.getCheckList() != null && event.getCheckList().equals(cl)){
|
||||
isLinked = true;
|
||||
break;
|
||||
@ -123,7 +124,7 @@ public class ListCheckListPanel extends Panel {
|
||||
assert(canDeleteChecklist(role));
|
||||
// if(checklistCanBeRemoved){
|
||||
|
||||
for (ProjectScheduleEvent pse : project.getProjectSchedule().getEvents()){
|
||||
for (ProjectScheduleEvent pse : projectModel.getObject().getProjectSchedule().getEvents()){
|
||||
if (pse.getCheckList()!=null && pse.getCheckList().equals(item.getModelObject())){
|
||||
pse.setCheckList(null);
|
||||
pseDao.save(pse);
|
||||
@ -131,8 +132,11 @@ public class ListCheckListPanel extends Panel {
|
||||
}
|
||||
|
||||
checkListDao.reLoad(item.getModel().getObject());
|
||||
project.removeCheckList(item.getModelObject());
|
||||
projectDao.save(project);
|
||||
projectModel.getObject().removeCheckList(item.getModelObject());
|
||||
|
||||
|
||||
|
||||
projectModel.setObject(projectDao.save(projectModel.getObject()));
|
||||
setResponsePage(SupervisorChecklistPage.class, pp);
|
||||
// }
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.checklists.panels.CheckListModel;
|
||||
import se.su.dsv.scipro.checklists.panels.ListCheckListPanel;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||
import se.su.dsv.scipro.data.dataobjects.Member;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
@ -28,7 +22,7 @@ public class ProjectChecklistPage extends ProjectPage {
|
||||
super(pp);
|
||||
|
||||
pp.put(Project.PP_PROJECT_ID, SciProSession.get().getActiveProject().getId());
|
||||
add(new ListCheckListPanel("listCheckListPanel", CheckListRole.AUTHOR,getActiveProject()));
|
||||
add(new ListCheckListPanel("listCheckListPanel", CheckListRole.AUTHOR, new Model<Project>(getActiveProject())));
|
||||
//add(new TrafficLightPanel("trafficLightPanel"));
|
||||
//add(new CreateCheckListTemplatePanel("createCheckList"));
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package se.su.dsv.scipro.supervisor.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.checklists.panels.ListCheckListPanel;
|
||||
import se.su.dsv.scipro.checklists.panels.SupervisorAddChecklistPanel;
|
||||
import se.su.dsv.scipro.components.menuhighlighting.MenuHighlightSupervisorMyProjects;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
@ -18,7 +20,7 @@ import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
public class SupervisorChecklistPage extends AbstractSupervisorProjectDetailsPage implements MenuHighlightSupervisorMyProjects {
|
||||
public SupervisorChecklistPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new ListCheckListPanel("listCheckListPanel", CheckListRole.SUPERVISOR, projectModel.getObject()));
|
||||
add(new ListCheckListPanel("listCheckListPanel", CheckListRole.SUPERVISOR, new Model<Project>(projectModel.getObject())));
|
||||
add(new SupervisorAddChecklistPanel("addChecklistPanel", pp, projectModel.getObject()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user