Changeset 6228


Ignore:
Timestamp:
05/19/15 12:10:09 (9 years ago)
Author:
Twan Goosen
Message:

Added removal link for the query to the breadcrumbs panel
Fixes #619

Location:
vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java

    r6210 r6228  
    4747    private Component collectionsPanel;
    4848    private Component navigation;
     49    private Component searchForm;
    4950
    5051    public FacetedSearchPage(IModel<QueryFacetsSelection> queryModel) {
     
    6566        navigation = createNavigation("navigation");
    6667        add(navigation);
    67 
    68         add(createSearchForm("search"));
     68       
     69        searchForm = createSearchForm("search");
     70        add(searchForm);
    6971
    7072        collectionsPanel = createCollectionsPanel("collections");
     
    118120
    119121    private SearchForm createSearchForm(String id) {
    120         final SearchForm searchForm = new SearchForm(id, getModel()) {
     122        final SearchForm form = new SearchForm(id, getModel()) {
    121123
    122124            @Override
     
    128130
    129131        };
    130         return searchForm;
     132        form.setOutputMarkupId(true);
     133        return form;
    131134    }
    132135
     
    172175        if (target != null) { // null if JavaScript disabled
    173176            target.add(navigation);
     177            target.add(searchForm);
    174178            target.add(searchResultsPanel);
    175179            target.add(facetsPanel);
  • vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.html

    r5224 r6228  
    3030            <wicket:container wicket:id="query">
    3131                &gt; <a wicket:id="leavequery">Search: &quot;<span wicket:id="content"></span>&quot;</a>
     32                <a wicket:id="removal" title="Remove query" class="breadcrumbunselect"><span>[Remove]</span></a>
    3233            </wicket:container>
    3334            <wicket:container wicket:id="facets">
    3435                &gt; <a wicket:id="leaveselection">Selections</a>:
    3536                <wicket:container wicket:id="facet">
    36                     <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container> <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span>
     37                    <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container>
     38                        <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span>
    3739                </wicket:container>
    3840            </wicket:container>
  • vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.java

    r6012 r6228  
    5353 */
    5454public class BreadCrumbPanel extends GenericPanel<QueryFacetsSelection> {
    55    
     55
    5656    @SpringBean(name = "queryParametersConverter")
    5757    private PageParametersConverter<QueryFacetsSelection> paramsConverter;
    5858    @SpringBean
    5959    private FieldValueConverterProvider fieldValueConverterProvider;
    60    
     60
    6161    private final WebMarkupContainer query;
    6262    private final WebMarkupContainer facets;
    63    
     63
    6464    public BreadCrumbPanel(String id, IModel<QueryFacetsSelection> model) {
    6565        super(id, model);
     
    6868        add(facets = createFacets(model, "facets"));
    6969    }
    70    
     70
    7171    private WebMarkupContainer createQuery(final IModel<QueryFacetsSelection> selectionModel, String id) {
    7272        final WebMarkupContainer queryContainer = new WebMarkupContainer(id);
    7373        final Link link = new AjaxFallbackLink("leavequery") {
    74            
     74
    7575            @Override
    7676            public void onClick(AjaxRequestTarget target) {
     
    8282        link.add(new Label("content", new PropertyModel(selectionModel, "query")));
    8383        queryContainer.add(link);
     84
     85        queryContainer.add(new AjaxFallbackLink("removal") {
     86
     87            @Override
     88            public void onClick(AjaxRequestTarget target) {
     89                // get a copy of the current selection
     90                final QueryFacetsSelection newSelection = selectionModel.getObject().getCopy();
     91                newSelection.setQuery(null);
     92                onSelectionChanged(newSelection, target);
     93            }
     94        });
    8495        return queryContainer;
    8596    }
    86    
     97
    8798    private WebMarkupContainer createFacets(final IModel<QueryFacetsSelection> model, String id) {
    8899        final WebMarkupContainer facetsContainer = new WebMarkupContainer(id);
    89100        facetsContainer.add(new AjaxFallbackLink("leaveselection") {
    90            
     101
    91102            @Override
    92103            public void onClick(AjaxRequestTarget target) {
     
    98109        final FacetSelectionProvider facetSelectionProvider = new FacetSelectionProvider(model);
    99110        facetsContainer.add(new DataView<Map.Entry<String, FacetSelection>>("facet", facetSelectionProvider) {
    100            
     111
    101112            @Override
    102113            protected void populateItem(final Item<Map.Entry<String, FacetSelection>> item) {
     
    104115                // add a label for the selected facet value(s)
    105116                final Label valueLabel = new Label("value", new PropertyModel(selectionModel, "value")) {
    106                    
     117
    107118                    @Override
    108119                    public <C> IConverter<C> getConverter(Class<C> type) {
     
    111122                        return (IConverter<C>) new SelectionConverter(facet, fieldValueConverterProvider.getConverter(facet));
    112123                    }
    113                    
     124
    114125                };
    115126                // add facet name as title attribute so that it becomes available through a tooltip
     
    120131                // add a link for removal of the facet value selection
    121132                item.add(new AjaxFallbackLink("removal") {
    122                    
     133
    123134                    @Override
    124135                    public void onClick(AjaxRequestTarget target) {
     
    133144            }
    134145        });
    135        
     146
    136147        return facetsContainer;
    137148    }
     
    148159        setResponsePage(FacetedSearchPage.class, paramsConverter.toParameters(selection));
    149160    }
    150    
     161
    151162    @Override
    152163    protected void onConfigure() {
    153164        super.onConfigure();
    154        
     165
    155166        final String queryString = getModelObject().getQuery();
    156167        final Map<String, FacetSelection> selection = getModelObject().getSelection();
    157        
     168
    158169        query.setVisible(queryString != null && !queryString.isEmpty());
    159170        facets.setVisible(selection != null && !selection.isEmpty());
     
    165176     */
    166177    private class SelectionConverter implements IConverter<FacetSelection> {
    167        
     178
    168179        private final String facet;
    169180        private final IConverter<String> valueConverter;
    170        
     181
    171182        public SelectionConverter(String facet, IConverter<String> valueConverter) {
    172183            this.facet = facet;
    173184            this.valueConverter = valueConverter;
    174185        }
    175        
     186
    176187        @Override
    177188        public FacetSelection convertToObject(String value, Locale locale) throws ConversionException {
    178189            throw new UnsupportedOperationException("Not supported yet.");
    179190        }
    180        
     191
    181192        @Override
    182193        public String convertToString(FacetSelection selection, Locale locale) {
     
    193204                    return facet;
    194205            }
    195            
    196         }
    197        
     206
     207        }
     208
    198209        private String getAnyValueString() {
    199210            if (FacetConstants.FIELD_SEARCH_SERVICE.equals(facet)) {
     
    202213            return "any " + facet;
    203214        }
    204        
     215
    205216        public String getCollectionString(FacetSelection selection, String valueSeparator, Locale locale) {
    206217            final Collection<String> value = selection.getValues();
     
    219230            }
    220231        }
    221        
     232
    222233        private String getConvertedValue(String string, Locale locale) {
    223234            if (valueConverter != null) {
     
    229240            return string;
    230241        }
    231        
     242
    232243    };
    233244}
Note: See TracChangeset for help on using the changeset viewer.