started to work on new component for keyword filtering used in supervisor settings tab. using dropdown to save space and render list of choices underneath
This commit is contained in:
parent
ee1f668baf
commit
621d163b37
src/main/java/se/su/dsv/scipro/match/panel
@ -190,7 +190,8 @@ public class AdminManageSupervisorPanel extends Panel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TextField<String> supervisorField, keywordField;
|
||||
private FilterFormKeywordPanel unitPanel, researchAreaPanel;
|
||||
private FilterFormKeywordPanel unitPanel;
|
||||
private FilterKeywordDropdownPanel researchAreaPanel;
|
||||
|
||||
public FilterForm(String id) {
|
||||
super(id);
|
||||
@ -232,7 +233,9 @@ public class AdminManageSupervisorPanel extends Panel {
|
||||
};
|
||||
|
||||
unitPanel = new FilterFormKeywordPanel("unitPanel", KeywordTypeDao.TYPE.UNIT);
|
||||
researchAreaPanel = new FilterFormKeywordPanel("researchAreaPanel", KeywordTypeDao.TYPE.RESEARCH_AREA);
|
||||
//researchAreaPanel = new FilterFormKeywordPanel("researchAreaPanel", KeywordTypeDao.TYPE.RESEARCH_AREA);
|
||||
researchAreaPanel = new FilterKeywordDropdownPanel("researchAreaPanel", KeywordTypeDao.TYPE.RESEARCH_AREA);
|
||||
|
||||
add(unitPanel);
|
||||
add(researchAreaPanel);
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
<!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 wicket:id="container">
|
||||
<select wicket:id="dropdown"></select>
|
||||
<div wicket:id="listView">
|
||||
<span wicket:id="name"></span><a href="#" wicket:id="removeLink"><img wicket:id="removeIcon" /></a>
|
||||
</div>
|
||||
<!-- <div wicket:id="selectedChoices"></div> -->
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,98 @@
|
||||
package se.su.dsv.scipro.match.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
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.form.DropDownChoice;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordTypeDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public class FilterKeywordDropdownPanel extends Panel {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 8862892008428526067L;
|
||||
|
||||
@SpringBean
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
@SpringBean
|
||||
private KeywordTypeDao keywordTypeDao;
|
||||
|
||||
private List<Keyword> keywords;
|
||||
|
||||
private final DropDownChoice<Keyword> dropdown;
|
||||
|
||||
public FilterKeywordDropdownPanel(String id, KeywordTypeDao.TYPE type) {
|
||||
super(id);
|
||||
final WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
container.setOutputMarkupId(true);
|
||||
|
||||
KeywordType kwType = keywordTypeDao.findByType(type);
|
||||
KeywordDao.Params params = new KeywordDao.Params();
|
||||
params.setType(kwType);
|
||||
params.setIncludeDeleted(true);
|
||||
keywords = keywordDao.getKeywordList(params);
|
||||
final List<Keyword> selected = new ArrayList<Keyword>();
|
||||
IModel<Keyword> model = new Model<Keyword>();
|
||||
dropdown = new DropDownChoice<Keyword>("dropdown",model, keywords);
|
||||
//dropdown.setModel(Model.of(keywords.get(0)));
|
||||
dropdown.add(new AjaxFormComponentUpdatingBehavior("onchange"){
|
||||
|
||||
private static final long serialVersionUID = 1027524203735088565L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
selected.add(dropdown.getModelObject());
|
||||
System.out.println(selected);
|
||||
target.addComponent(container);
|
||||
}
|
||||
|
||||
});
|
||||
ListView<Keyword> listView = new ListView<Keyword>("listView", selected) {
|
||||
|
||||
private static final long serialVersionUID = -1999361159123892309L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<Keyword> item) {
|
||||
item.add(new Label("name", item.getModelObject().getKeyword()));
|
||||
final ImageObject removeIcon = new ImageObject("removeIcon", ImageObject.SIXTEEN + ImageObject.DELETE);
|
||||
final AjaxLink<Void> remove = new AjaxLink<Void>("removeLink") {
|
||||
|
||||
private static final long serialVersionUID = -5129451036772812285L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
selected.remove(item.getModelObject());
|
||||
target.addComponent(container);
|
||||
}
|
||||
};
|
||||
remove.add(removeIcon);
|
||||
item.add(remove);
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
;
|
||||
container.add(dropdown);
|
||||
container.add(listView);
|
||||
add(container);
|
||||
}
|
||||
|
||||
public List<Keyword> getSelectedKeywords(){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
dropdown.nullValid=Choose research area(s)
|
||||
dropdown.null=Choose research area(s)
|
Loading…
x
Reference in New Issue
Block a user