removed old list checklist template panel
This commit is contained in:
parent
3c45bac2ee
commit
462071780f
src/main/java/se/su/dsv/scipro
admin/pages
checklists/panels
@ -7,7 +7,6 @@ import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
import se.su.dsv.scipro.checklists.panels.FunctionalEditChecklistTemplatePanel;
|
||||
import se.su.dsv.scipro.checklists.panels.FunctionalListCheckListTemplatePanel;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
||||
import se.su.dsv.scipro.datatables.checklist.CheckListTemplateDataPanel;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
|
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="span-24 append-bottom last" wicket:id="settingsContainer">
|
||||
<div wicket:id="filterStringPanel"></div>
|
||||
<div wicket:id="listView">
|
||||
<div wicket:id="filterCategoryPanel"></div>
|
||||
</div>
|
||||
<!-- <div wicket:id="filterSupervisorPanel"></div> -->
|
||||
<!-- <div wicket:id="filterPeerPanel"></div> -->
|
||||
<!-- <div wicket:id="filterBachelorPanel"></div> -->
|
||||
<!-- <div wicket:id="filterMasterPanel"></div> -->
|
||||
<div wicket:id="filterMinePanel"></div>
|
||||
</div>
|
||||
|
||||
<div><button wicket:id="newLink">Create new checklist template</button></div>
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="panel"></div>
|
||||
</div>
|
||||
|
||||
<div class="span-24 last" wicket:id="dataViewContainer">
|
||||
<table class="rounded-corner" >
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th><a href="#" wicket:id="nameSort">Title</a></th>
|
||||
<!-- <th><a href="#" wicket:id="creatorSort">Creator</a></th> -->
|
||||
<th>Creator</th>
|
||||
<th>Category</th>
|
||||
<th><a href="#" wicket:id="numberOfQuestionsSort">Questions</a></th>
|
||||
<th>Delete</th>
|
||||
|
||||
<!-- <th class="rounded-left-top"><a href="#" wicket:id="nameSort"><span wicket:id="nameLabel">Title</span></a></th> -->
|
||||
<!-- <th><a href="#" wicket:id="creatorSort"><span wicket:id="creatorLabel">Title</span></a></th> -->
|
||||
<!-- <th class="rounded-right-top"><a href="#" wicket:id="numberOfQuestionsSort"><span wicket:id="numberOfQuestionsLabel">Title</span></a></th> -->
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5" class="rounded-foot"> </td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody wicket:id="checklistTemplateDataView">
|
||||
<tr>
|
||||
<!-- <td wicket:id="nameLabel"></td> -->
|
||||
<td><a href="#" wicket:id="testLink"><span wicket:id="nameLabel"></span></a></td>
|
||||
<!-- <td><a href="#" wicket:id="superLink"><span wicket:id="nameLabel"></span></a></td> -->
|
||||
<td wicket:id="userLabel">Other role</td>
|
||||
<td wicket:id="categoryLabel">Other role</td>
|
||||
<td wicket:id="questionLabel">Other role</td>
|
||||
<td><a href="#" wicket:id="delete"><img wicket:id="deleteIcon" alt="Delete" title="Delete" /></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td wicket:id="emptyLabel" colspan="5"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div wicket:id="nav"></div>
|
||||
</div>
|
||||
|
||||
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,362 +0,0 @@
|
||||
package se.su.dsv.scipro.checklists.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.IAjaxCallDecorator;
|
||||
import org.apache.wicket.ajax.calldecorator.AjaxCallDecorator;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.admin.pages.AdminCheckListPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CategoryDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ChecklistCategoryDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao.SortableParams.Sort;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
||||
import se.su.dsv.scipro.data.dataobjects.ChecklistCategory;
|
||||
import se.su.dsv.scipro.dataproviders.CheckListTemplateDataProvider;
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
import se.su.dsv.scipro.reusable.FilterBooleanPanel;
|
||||
import se.su.dsv.scipro.reusable.FilterStringPanel;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fred
|
||||
*/
|
||||
|
||||
public class FunctionalListCheckListTemplatePanel extends Panel{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SpringBean
|
||||
private CheckListTemplateDao checklistTemplateDao;
|
||||
@SpringBean
|
||||
private ChecklistCategoryDao checklistCategoryDao;
|
||||
|
||||
//settings stuff
|
||||
private WebMarkupContainer settingsContainer; //contains settings for the dataview (e.g. filtering and such)
|
||||
private HashSet<ChecklistCategory> filterSet; //needed for filtering on different categories
|
||||
|
||||
//dataview stuff
|
||||
private CheckListTemplateDao.Params params; //controls what the dataview should display
|
||||
private CheckListTemplateDataProvider dataProvider; //provides data to the dataview.
|
||||
private DataView<CheckListTemplate> checklistTemplateDataView;
|
||||
private Label emptyLabel; //informs user that there are no templates to show
|
||||
private WebMarkupContainer dataViewContainer; //the container for the list (dataview)
|
||||
private PagingNavigator nav;
|
||||
|
||||
//create new stuff.
|
||||
private AjaxLink<Void> newLink;
|
||||
private Dialog dialog;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param id
|
||||
*/
|
||||
public FunctionalListCheckListTemplatePanel(String id) {
|
||||
super(id);
|
||||
setOutputMarkupId(true); //make the whole panel AJAX-targetable
|
||||
|
||||
settingsSetup(); //setup and add panel with settings
|
||||
listSetup(); //setup and add panel with dataview
|
||||
|
||||
sortSetup();
|
||||
createSetup();
|
||||
}
|
||||
|
||||
private void ajaxRefresh(AjaxRequestTarget target){
|
||||
target.addComponent(dataViewContainer); //refresh the container containing the list
|
||||
nav.setVisible(dataProvider.size()!=0);
|
||||
target.addComponent(nav);
|
||||
emptyLabel.setVisible(dataProvider.size()==0);
|
||||
target.addComponent(emptyLabel);
|
||||
}
|
||||
|
||||
private void settingsSetup(){
|
||||
|
||||
settingsContainer = new WebMarkupContainer("settingsContainer"); //container for the settings stuff
|
||||
settingsContainer.setOutputMarkupId(true); //make it ajax targetable
|
||||
add(settingsContainer); //add it
|
||||
|
||||
filterSet = new HashSet<ChecklistCategory>();
|
||||
|
||||
params = new CheckListTemplateDao.Params();
|
||||
params.setSortOn("name", Sort.DESCENDING);
|
||||
params.setCategories(filterSet);
|
||||
|
||||
dataProvider = new CheckListTemplateDataProvider(params);
|
||||
|
||||
//under here are the filtering components: beginning with the filter on string
|
||||
settingsContainer.add(new FilterStringPanel("filterStringPanel"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onUpdateFilter(AjaxRequestTarget target) {
|
||||
params.setFilterString(getFilterString());
|
||||
ajaxRefresh(target);
|
||||
}
|
||||
});
|
||||
|
||||
//the listview below adds checkboxes for categories that would otherwise have been added one by one like this:
|
||||
|
||||
// settingsContainer.add(new FilterBooleanPanel("filterSupervisorPanel", "Supervisor"){
|
||||
// private static final long serialVersionUID = 1L;
|
||||
// @Override
|
||||
// public void onUpdateFilter(AjaxRequestTarget target) {
|
||||
// if (isFilter()){
|
||||
// filterSet.add(checklistCategoryDao.findCategoryByName("Supervisor"));
|
||||
// }
|
||||
// else if (!isFilter()){
|
||||
// filterSet.remove(checklistCategoryDao.findCategoryByName("Supervisor"));
|
||||
// }
|
||||
// params.setCategories(filterSet);
|
||||
// ajaxRefresh(target);
|
||||
// }
|
||||
// });
|
||||
|
||||
settingsContainer.add(new ListView<ChecklistCategory>("listView", checklistCategoryDao.findAll()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void populateItem(ListItem<ChecklistCategory> item) {
|
||||
final ChecklistCategory clc = item.getModelObject();
|
||||
item.add(new FilterBooleanPanel("filterCategoryPanel", clc.getCategoryName()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onUpdateFilter(AjaxRequestTarget target) {
|
||||
if (isFilter()){
|
||||
filterSet.add(clc);
|
||||
}
|
||||
else if (!isFilter()){
|
||||
filterSet.remove(clc);
|
||||
}
|
||||
params.setCategories(filterSet);
|
||||
ajaxRefresh(target);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
settingsContainer.add(new FilterBooleanPanel("filterMinePanel", "Show only my checklist templates"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onUpdateFilter(AjaxRequestTarget target) {
|
||||
if (isFilter()){
|
||||
params.setCreator(SciProSession.get().getUser());
|
||||
}
|
||||
else if (!isFilter()){
|
||||
params.setCreator(null);
|
||||
}
|
||||
target.addComponent(dataViewContainer); //refresh the container containing the list
|
||||
ajaxRefresh(target);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void listSetup(){//as in, dataview setup
|
||||
dataViewContainer = new WebMarkupContainer("dataViewContainer"); //container for the dataview
|
||||
dataViewContainer.setOutputMarkupId(true); //make it ajax-targetable
|
||||
add(dataViewContainer); //add the container
|
||||
|
||||
checklistTemplateDataView = new DataView<CheckListTemplate>("checklistTemplateDataView", dataProvider, 20) { //add stuff to it
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void populateItem(final Item item) {
|
||||
final CheckListTemplate clt = (CheckListTemplate) item.getModelObject();
|
||||
// item.add(new Label("nameLabel", clt.getName())); replaced by testlink
|
||||
item.add(new Label("userLabel", clt.getCreator().toString()));
|
||||
|
||||
String categoryString = new String("");
|
||||
for (ChecklistCategory cc : clt.getCategories()){
|
||||
categoryString += cc.getCategoryName();
|
||||
categoryString += " ";
|
||||
}
|
||||
|
||||
item.add(new Label("categoryLabel", categoryString));
|
||||
item.add(new Label("questionLabel", Integer.toString(clt.getNumberOfQuestions())));
|
||||
|
||||
//edit link. this is ugly and is taken straight out of the old panel. should be done using facades.
|
||||
AjaxLink testLink = new AjaxLink<Void>("testLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
System.out.println(clt.getName());
|
||||
|
||||
|
||||
dialog.replace(new FunctionalEditChecklistTemplatePanel("panel", clt){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onUpdate(AjaxRequestTarget target) {
|
||||
// dialog.close();
|
||||
// ajaxRefresh(target);
|
||||
setResponsePage(AdminCheckListPage.class);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// dialog.replace(new FunctionalEditChecklistTemplatePanel("panel", clt));
|
||||
target.addComponent(dialog);
|
||||
dialog.open(target);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
item.add(testLink);
|
||||
testLink.add(new Label("nameLabel", clt.getName()));
|
||||
|
||||
//delete link. this is ugly and is taken straight out of the old panel. should be done using facades.
|
||||
AjaxLink<Void> deleteLink = new AjaxLink<Void>("delete") {
|
||||
private static final long serialVersionUID = 1529565679210978293L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
CheckListTemplate clt2 = checklistTemplateDao.reLoad(clt);
|
||||
checklistTemplateDao.delete(clt2);
|
||||
ajaxRefresh(target);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected IAjaxCallDecorator getAjaxCallDecorator() {
|
||||
return new AjaxCallDecorator() {
|
||||
private static final long serialVersionUID = 8989126586010432130L;
|
||||
@Override
|
||||
public CharSequence decorateScript(CharSequence script) {
|
||||
String ret = "if(!confirm('Are you sure you want to remove the template?')) return false; "
|
||||
+ script;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
};
|
||||
item.add(deleteLink);
|
||||
deleteLink.add(new ImageObject("deleteIcon", ImageObject.SIXTEEN + ImageObject.DELETE));
|
||||
deleteLink.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to remove this template?"));
|
||||
item.setOutputMarkupId(true);
|
||||
}
|
||||
}; //finish adding stuff to the rows inside the list
|
||||
dataViewContainer.add(checklistTemplateDataView); //add the dataview to the container
|
||||
|
||||
// checklistTemplateDataView.setOutputMarkupId(true); dont target repeaters
|
||||
|
||||
nav = new PagingNavigator("nav", checklistTemplateDataView); //we need a navigator
|
||||
nav.setOutputMarkupId(true); //make it ajax-targetable
|
||||
nav.setVisible(dataProvider.size()!=0);
|
||||
dataViewContainer.add(nav); //add it
|
||||
|
||||
emptyLabel = new Label("emptyLabel", "No templates to show"); //informs the user that the list is emty
|
||||
emptyLabel.setOutputMarkupId(true); //make it ajax-targetable
|
||||
emptyLabel.setVisible(dataProvider.size()==0);
|
||||
dataViewContainer.add(emptyLabel); //add it
|
||||
}
|
||||
|
||||
private void sortSetup(){
|
||||
// Robins sortmetod om man använder en dataprovider som extendar hans SortableDataProviderklass
|
||||
// final Set<String> sortFields = new HashSet<String>(); //begin setting up sorting
|
||||
// sortFields.add("name");
|
||||
// sortFields.add("creator");
|
||||
// sortFields.add("numberOfQuestions");
|
||||
// final HashMap<String, String> headerMap = new HashMap<String,String>();
|
||||
// headerMap.put("name", "Name");
|
||||
// headerMap.put("creator","Creator");
|
||||
// headerMap.put("numberOfQuestions", "Questions");
|
||||
// for(final SortSpecifier spec : dataProvider.getAvailableSortSpecifiers(sortFields)){
|
||||
// final String fieldBaseName = spec.getFieldName();
|
||||
// final Link<Void> link = new Link<Void>(fieldBaseName+"Sort"){
|
||||
// private static final long serialVersionUID = 1L;
|
||||
// @Override
|
||||
// public void onClick(){
|
||||
// SortSpecifier current = dataProvider.getSortSpecifier();
|
||||
// if(!spec.equals(current)){
|
||||
// dataProvider.setSortSpecifier(spec);
|
||||
// dataProvider.setAscendingOrder(false);
|
||||
// }else{
|
||||
// dataProvider.setAscendingOrder(!dataProvider.isAscendingOrder());
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// link.add(new Label(fieldBaseName+"Label",headerMap.get(fieldBaseName)));
|
||||
// dataViewContainer.add(link); //add sorting
|
||||
// }
|
||||
|
||||
//min lite imiterande metod. lite tokigt är att ints i ascending visar lägst värden högst och vice versa fast det oftast är tvärtom.
|
||||
//och sorterar man på creator (ett "främmande fält" för checklisttemplateentityn) så sorterar den på creators (users) id och inte namn.
|
||||
final Set<String> sortString = new HashSet<String>(); //make a set with columns you want to be sortable
|
||||
sortString.add(new String("name"));
|
||||
// sortString.add(new String("creator")); //this doesnt work because it sorts on user id, not name
|
||||
sortString.add(new String("numberOfQuestions"));
|
||||
|
||||
for (final String s : sortString){ //create links for sorting using the set
|
||||
Link<Void> link = new Link<Void>(s + "Sort"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onClick() {
|
||||
if (params.getSortField().equals(s) && params.getDirection().equals(Sort.ASCENDING))
|
||||
params.setSortOn(s, Sort.DESCENDING);
|
||||
else params.setSortOn(s, Sort.ASCENDING);
|
||||
}
|
||||
};
|
||||
dataViewContainer.add(link); //add the links
|
||||
}
|
||||
}
|
||||
|
||||
private void createSetup(){
|
||||
dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.setWidth(550);
|
||||
dialog.setHeight(700);
|
||||
add(dialog);
|
||||
dialog.add(new EmptyPanel("panel"));
|
||||
//create new link.
|
||||
newLink = new AjaxLink<Void>("newLink") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
CheckListTemplate dummy = new CheckListTemplate();
|
||||
dummy.setCategories(new ArrayList<ChecklistCategory>());
|
||||
dummy.setCreator(SciProSession.get().getUser());
|
||||
dummy.setName("New checklisttemplate (change this to a real name)");
|
||||
dummy.setQuestions(new ArrayList<String>());
|
||||
dummy.setTemplateNumber(checklistTemplateDao.findTemplates().size()-1);
|
||||
|
||||
// dialog.replace(new FunctionalEditChecklistTemplatePanel("panel", dummy));
|
||||
|
||||
dialog.replace(new FunctionalEditChecklistTemplatePanel("panel", dummy){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void onUpdate(AjaxRequestTarget target) {
|
||||
// target.addComponent(dialog);
|
||||
// dialog.close();
|
||||
// ajaxRefresh(target);
|
||||
setResponsePage(AdminCheckListPage.class);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
target.addComponent(dialog);
|
||||
dialog.open(target);
|
||||
}
|
||||
};
|
||||
add(newLink);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user