Changeset 4786


Ignore:
Timestamp:
03/20/14 08:56:58 (11 years ago)
Author:
Twan Goosen
Message:

added links to expand or collapse all facets

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/FacetsPanel.html

    r4661 r4786  
    3434                    <div wicket:id="facet">[facet]</div>
    3535                </wicket:container>
     36                <div id="expandcollapseall">
     37                    <a wicket:id="expandAll" href="">Expand all</a>
     38                    <a wicket:id="collapseAll" href="">Collapse all</a>
     39                </div>
    3640                <!-- rounded corners - bottom **** -->
    3741                <div class="rbottom"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/FacetsPanel.java

    r4782 r4786  
    2828import org.apache.solr.client.solrj.response.FacetField;
    2929import org.apache.wicket.ajax.AjaxRequestTarget;
     30import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
    3031import org.apache.wicket.markup.html.list.ListItem;
    3132import org.apache.wicket.markup.html.list.ListView;
    32 import org.apache.wicket.markup.html.panel.Panel;
     33import org.apache.wicket.markup.html.panel.GenericPanel;
    3334import org.apache.wicket.model.IModel;
    3435import org.apache.wicket.model.util.MapModel;
     
    4344 * @author twagoo
    4445 */
    45 public abstract class FacetsPanel extends Panel {
     46public abstract class FacetsPanel extends GenericPanel<List<FacetField>> {
    4647
    4748    @SpringBean
    4849    private FacetFieldsService facetFieldsService;
     50
     51    private MapModel<String, ExpansionState> expansionModel;
    4952
    5053    /**
     
    5760     */
    5861    public FacetsPanel(final String id, final IModel<List<FacetField>> facetsModel, final IModel<QueryFacetsSelection> selectionModel) {
    59         super(id);
     62        super(id, facetsModel);
    6063
    6164        final Map<String, ExpansionState> expansionStateMap = new HashMap<String, ExpansionState>();
    62         final MapModel<String, ExpansionState> expansionModel = new MapModel<String, ExpansionState>(expansionStateMap);
     65        expansionModel = new MapModel<String, ExpansionState>(expansionStateMap);
    6366
    6467        final ListView<FacetField> facetsView = new ListView<FacetField>("facets", facetsModel) {
     
    8689        facetsView.setReuseItems(true);
    8790        add(facetsView);
     91
     92        add(new AjaxFallbackLink("expandAll") {
     93
     94            @Override
     95            public void onClick(AjaxRequestTarget target) {
     96                setAllFacetsExpansionState(ExpansionState.EXPANDED);
     97                selectionChanged(target);
     98            }
     99        });
     100        add(new AjaxFallbackLink("collapseAll") {
     101
     102            @Override
     103            public void onClick(AjaxRequestTarget target) {
     104                setAllFacetsExpansionState(ExpansionState.COLLAPSED);
     105                selectionChanged(target);
     106            }
     107        });
     108    }
     109
     110    private void setAllFacetsExpansionState(final ExpansionState state) {
     111        final Map<String, ExpansionState> expansionMap = expansionModel.getObject();
     112        for (FacetField facet : getModelObject()) {
     113            expansionMap.put(facet.getName(), state);
     114        }
     115    }
     116
     117    @Override
     118    public void detachModels() {
     119        super.detachModels();
     120        expansionModel.detach();
    88121    }
    89122
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/webapp/style/vlo-facets.css

    r4785 r4786  
    213213    margin: 0em 1em;
    214214}
     215
     216div#expandcollapseall {
     217    text-align: right;
     218}
     219
     220div#expandcollapseall a {
     221    display: block;
     222    font-size: smaller;
     223    padding-right: 1em;
     224}
Note: See TracChangeset for help on using the changeset viewer.