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,6 +49,8 @@ public class ListCheckListPanel extends Panel {
|
||||
private ChecklistCategoryDao categoryDao;
|
||||
@SpringBean
|
||||
private RoleDao roleDao;
|
||||
@SpringBean
|
||||
private ProjectScheduleEventDao pseDao;
|
||||
|
||||
@SpringBean
|
||||
CheckListController checkListController;
|
||||
@ -110,19 +113,27 @@ 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){
|
||||
// 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;
|
||||
@ -132,10 +143,10 @@ public class ListCheckListPanel extends Panel {
|
||||
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"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user