checklists can now be removed even though they are started and linked to activities
This commit is contained in:
parent
55d52cbce0
commit
1bd44a6c90
@ -21,6 +21,7 @@ import se.su.dsv.scipro.data.controllers.CheckListController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ChecklistCategoryDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectScheduleEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckListAnswer;
|
||||
@ -48,7 +49,9 @@ public class ListCheckListPanel extends Panel {
|
||||
private ChecklistCategoryDao categoryDao;
|
||||
@SpringBean
|
||||
private RoleDao roleDao;
|
||||
|
||||
@SpringBean
|
||||
private ProjectScheduleEventDao pseDao;
|
||||
|
||||
@SpringBean
|
||||
CheckListController checkListController;
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -110,32 +113,40 @@ public class ListCheckListPanel extends Panel {
|
||||
}
|
||||
}
|
||||
//Final value of calculations
|
||||
final boolean checklistCanBeRemoved = !(isAnswered||isLinked);
|
||||
// final boolean checklistCanBeRemoved = !(isAnswered||isLinked);
|
||||
|
||||
AjaxLink<Void> deleteLink = new AjaxLink<Void>("deleteLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
assert(canDeleteChecklist(role));
|
||||
if(checklistCanBeRemoved){
|
||||
checkListDao.reLoad(item.getModel().getObject());
|
||||
project.removeCheckList(item.getModelObject());
|
||||
projectDao.save(project);
|
||||
setResponsePage(SupervisorChecklistPage.class, pp);
|
||||
// if(checklistCanBeRemoved){
|
||||
|
||||
for (ProjectScheduleEvent pse : project.getProjectSchedule().getEvents()){
|
||||
if (pse.getCheckList()!=null && pse.getCheckList().equals(item.getModelObject())){
|
||||
pse.setCheckList(null);
|
||||
pseDao.save(pse);
|
||||
}
|
||||
}
|
||||
|
||||
checkListDao.reLoad(item.getModel().getObject());
|
||||
project.removeCheckList(item.getModelObject());
|
||||
projectDao.save(project);
|
||||
setResponsePage(SupervisorChecklistPage.class, pp);
|
||||
// }
|
||||
}
|
||||
};
|
||||
BookmarkablePageLink<Void> checkListLink = null;
|
||||
|
||||
|
||||
item.add(new EmptyPanel("deleteLabel"));
|
||||
|
||||
if(canDeleteChecklist(role)){
|
||||
checkListLink = new BookmarkablePageLink<Void>("checkListLink", SupervisorViewCheckListPage.class, pp);
|
||||
|
||||
if(!checklistCanBeRemoved){
|
||||
deleteLink.setVisible(false);
|
||||
item.replace(new Label("deleteLabel", "Already active"));
|
||||
}
|
||||
|
||||
// if(!checklistCanBeRemoved){
|
||||
// deleteLink.setVisible(false);
|
||||
// item.replace(new Label("deleteLabel", "Already active"));
|
||||
// }
|
||||
}else{
|
||||
checkListLink = new BookmarkablePageLink<Void>("checkListLink", ProjectViewCheckListPage.class, pp);
|
||||
item.replace(new Label("deleteLabel", "Not owner"));
|
||||
@ -144,22 +155,22 @@ public class ListCheckListPanel extends Panel {
|
||||
checkListLink.add(listName);
|
||||
item.add(checkListLink);
|
||||
item.add(deleteLink);
|
||||
|
||||
|
||||
boolean green = false;
|
||||
boolean yellow = false;
|
||||
boolean red = false;
|
||||
boolean noanswer = false;
|
||||
|
||||
|
||||
|
||||
|
||||
if (cl.getCategories().contains(categoryDao.findCategoryByName("Supervisor")) && !roleDao.isEmployee(SciProSession.get().getUser())){
|
||||
item.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
item.add(new EmptyPanel("image"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (CheckListQuestion clq : cl.getQuestions()){
|
||||
for (CheckListAnswer cla : clq.getAnswers()){
|
||||
if (cla.getAnswer() == CheckListQuestionAnswer.GREEN){
|
||||
@ -176,7 +187,7 @@ public class ListCheckListPanel extends Panel {
|
||||
noanswer = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!noanswer){
|
||||
if (red){
|
||||
item.replace(new ImageObject("image", ImageObject.TWENTYFOUR + ImageObject.LIGHT_RED));
|
||||
@ -188,8 +199,8 @@ public class ListCheckListPanel extends Panel {
|
||||
item.replace(new ImageObject("image", ImageObject.TWENTYFOUR + ImageObject.LIGHT_GREEN));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
container.add(checkLists);
|
||||
|
Loading…
x
Reference in New Issue
Block a user