indication is removed if the user is the one who makes a change in the checklist
This commit is contained in:
parent
d50681c2b7
commit
ce82fe1bb9
src/main/java/se/su/dsv/scipro/checklists/panels
@ -7,23 +7,23 @@ import org.apache.wicket.model.Model;
|
|||||||
import org.apache.wicket.model.PropertyModel;
|
import org.apache.wicket.model.PropertyModel;
|
||||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||||
|
import se.su.dsv.scipro.SciProSession;
|
||||||
import se.su.dsv.scipro.checklists.panels.AnswerDialogPanel.AnswerDialog;
|
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListAnswerDao;
|
import se.su.dsv.scipro.data.dao.interfaces.CheckListAnswerDao;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao;
|
import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao;
|
||||||
import se.su.dsv.scipro.data.dataobjects.CheckListAnswer;
|
import se.su.dsv.scipro.data.dataobjects.CheckListAnswer;
|
||||||
import se.su.dsv.scipro.data.dataobjects.CheckListQuestion;
|
import se.su.dsv.scipro.data.dataobjects.CheckListQuestion;
|
||||||
import se.su.dsv.scipro.data.dataobjects.User;
|
import se.su.dsv.scipro.data.dataobjects.User;
|
||||||
import se.su.dsv.scipro.data.enums.CheckListQuestionAnswer;
|
import se.su.dsv.scipro.data.enums.CheckListQuestionAnswer;
|
||||||
|
import se.su.dsv.scipro.springdata.services.ChecklistService;
|
||||||
|
|
||||||
public class AnswerDialogPanel extends Panel {
|
public class AnswerDialogPanel extends Panel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private AnswerDialog dialog;
|
private AnswerDialog dialog;
|
||||||
|
|
||||||
public AnswerDialogPanel(String id, User currentUser) {
|
public AnswerDialogPanel(String id, User currentUser, Long checklistId) {
|
||||||
super(id);
|
super(id);
|
||||||
dialog = new AnswerDialog("answerDialog", currentUser);
|
dialog = new AnswerDialog("answerDialog", currentUser, checklistId);
|
||||||
add(dialog);
|
add(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,35 +32,42 @@ public class AnswerDialogPanel extends Panel {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@SpringBean
|
@SpringBean
|
||||||
private CheckListAnswerDao checkListAnswerDao;
|
private CheckListAnswerDao checkListAnswerDao;
|
||||||
|
private Long checklistId;
|
||||||
|
|
||||||
|
|
||||||
@SpringBean
|
@SpringBean
|
||||||
private CheckListQuestionDao checkListQuestionDao;
|
private CheckListQuestionDao checkListQuestionDao;
|
||||||
private final User currentUser;
|
private final User currentUser;
|
||||||
|
|
||||||
public AnswerDialog(String id, User currentUser) {
|
public AnswerDialog(String id, User currentUser, Long checklistId) {
|
||||||
super(id);
|
super(id);
|
||||||
|
this.checklistId = checklistId;
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setAutoOpen(false);
|
setAutoOpen(false);
|
||||||
setWidth(400);
|
setWidth(400);
|
||||||
setHeight(400);
|
setHeight(400);
|
||||||
add(new AnswerForm("answerForm"));
|
add(new AnswerForm("answerForm", checklistId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dialogContent(CheckListQuestion clq) {
|
public void dialogContent(CheckListQuestion clq) {
|
||||||
setTitle(clq.getQuestion());
|
setTitle(clq.getQuestion());
|
||||||
replace(new AnswerForm("answerForm", clq));
|
replace(new AnswerForm("answerForm", clq, checklistId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AnswerForm extends Form<Void> {
|
private class AnswerForm extends Form<Void> {
|
||||||
|
|
||||||
|
@SpringBean
|
||||||
|
private ChecklistService checklistService;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private TrafficLightPanel trafficLights;
|
private TrafficLightPanel trafficLights;
|
||||||
private CheckListQuestion clq;
|
private CheckListQuestion clq;
|
||||||
private CheckListAnswer answer;
|
private CheckListAnswer answer;
|
||||||
private TextArea<String> commentArea;
|
private TextArea<String> commentArea;
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
public AnswerForm(String id, CheckListQuestion clq) {
|
public AnswerForm(String id, CheckListQuestion clq, Long checklistId) {
|
||||||
super(id);
|
super(id);
|
||||||
setMultiPart(true);
|
setMultiPart(true);
|
||||||
answer = clq.getAnswerFromUser(currentUser);
|
answer = clq.getAnswerFromUser(currentUser);
|
||||||
@ -81,7 +88,7 @@ public class AnswerDialogPanel extends Panel {
|
|||||||
add(commentArea);
|
add(commentArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnswerForm(String id) {
|
public AnswerForm(String id, Long checklistId) {
|
||||||
super(id);
|
super(id);
|
||||||
add(new TrafficLightPanel("trafficLights"));
|
add(new TrafficLightPanel("trafficLights"));
|
||||||
add(new TextArea<String>("commentArea"));
|
add(new TextArea<String>("commentArea"));
|
||||||
@ -96,6 +103,7 @@ public class AnswerDialogPanel extends Panel {
|
|||||||
clq = checkListQuestionDao.reLoad(clq);
|
clq = checkListQuestionDao.reLoad(clq);
|
||||||
clq.addAnswer(checkListAnswerDao.save(clAnswer));
|
clq.addAnswer(checkListAnswerDao.save(clAnswer));
|
||||||
clq = checkListQuestionDao.save(clq);
|
clq = checkListQuestionDao.save(clq);
|
||||||
|
checklistService.updateUserLastOpenDate(checklistService.findOne(checklistId), SciProSession.get().getUser());
|
||||||
setResponsePage(getPage());
|
setResponsePage(getPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public class ViewCheckListPanel extends Panel {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private AnswerDialogPanel answerDialog;
|
private AnswerDialogPanel answerDialog;
|
||||||
|
private Long checklistId;
|
||||||
|
|
||||||
@SpringBean
|
@SpringBean
|
||||||
private CheckListDao checkListDao;
|
private CheckListDao checkListDao;
|
||||||
@ -55,6 +56,7 @@ public class ViewCheckListPanel extends Panel {
|
|||||||
|
|
||||||
public ViewCheckListPanel(final String id, final Long checkListId) {
|
public ViewCheckListPanel(final String id, final Long checkListId) {
|
||||||
super(id);
|
super(id);
|
||||||
|
this.checklistId = checkListId;
|
||||||
checklistService.updateUserLastOpenDate(checklistService.findOne(checkListId), SciProSession.get().getUser());
|
checklistService.updateUserLastOpenDate(checklistService.findOne(checkListId), SciProSession.get().getUser());
|
||||||
LoadableDetachableModel<CheckListModel> checkListModel =
|
LoadableDetachableModel<CheckListModel> checkListModel =
|
||||||
new LoadableDetachableModel<CheckListModel>() {
|
new LoadableDetachableModel<CheckListModel>() {
|
||||||
@ -82,7 +84,7 @@ public class ViewCheckListPanel extends Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents(final IModel<CheckListModel> checkListModel) {
|
private void initComponents(final IModel<CheckListModel> checkListModel) {
|
||||||
answerDialog = new AnswerDialogPanel("answerDialog", getCurrentUser());
|
answerDialog = new AnswerDialogPanel("answerDialog", getCurrentUser(), checklistId);
|
||||||
add(answerDialog);
|
add(answerDialog);
|
||||||
|
|
||||||
ListView<CheckListQuestion> checkListQuestions =
|
ListView<CheckListQuestion> checkListQuestions =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user