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