Changeset 4880


Ignore:
Timestamp:
04/02/14 13:19:44 (11 years ago)
Author:
Twan Goosen
Message:

Resources are hidden in search results (both collapsed and expanded) unless there actually are resources

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search
Files:
4 edited

Legend:

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

    r4875 r4880  
    2727                [DESCRIPTION]
    2828            </p>
    29             <div class="searchresultresources">
     29            <div wicket:id="resources" class="searchresultresources">
    3030                Resources:
    3131                <ul>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemCollapsedPanel.java

    r4873 r4880  
    2727import java.util.Locale;
    2828import org.apache.solr.common.SolrDocument;
     29import org.apache.wicket.markup.html.WebMarkupContainer;
    2930import org.apache.wicket.markup.html.basic.Label;
    3031import org.apache.wicket.markup.html.link.Link;
     
    6465        // wrap with a count provider
    6566        final ResouceTypeCountDataProvider countProvider = new ResouceTypeCountDataProvider(resourcesModel, countingService);
    66         // view that shows provided counts
    67         // TODO: hide if no resources
    68         add(new ResourceCountDataView("resourceCount", countProvider));
     67
     68        // add a container for the resource type counts (only visible if there are actual resources)
     69        add(new WebMarkupContainer("resources") {
     70            {
     71                // view that shows provided counts
     72                add(new ResourceCountDataView("resourceCount", countProvider));
     73            }
     74
     75            @Override
     76            protected void onConfigure() {
     77                super.onConfigure();
     78                setVisible(countProvider.size() > 0);
     79            }
     80        });
    6981    }
    7082
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.html

    r4879 r4880  
    3030                <wicket:container wicket:id="documentProperties">[PROPERTIES TABLE]</wicket:container>
    3131                <p class="moredocumentproperties"><a wicket:id="recordLink">More</a></p>
    32                 <h3>Resources</h3>
    33                 <ul class="searchresultresources">
    34                     <li wicket:id="resource">
    35                         <a wicket:id="resourceLink" href="">
    36                             <wicket:container wicket:id="resourceName"></wicket:container>
    37                         </a>
    38                     </li>
    39                 </ul>
     32                <wicket:container wicket:id="resources">
     33                    <h3>Resources</h3>
     34                    <ul class="searchresultresources">
     35                        <li wicket:id="resource">
     36                            <a wicket:id="resourceLink" href="">
     37                                <wicket:container wicket:id="resourceName"></wicket:container>
     38                            </a>
     39                        </li>
     40                    </ul>
     41                </wicket:container>
    4042            </div>
    4143        </wicket:panel>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.java

    r4879 r4880  
    3131import java.util.List;
    3232import org.apache.solr.common.SolrDocument;
     33import org.apache.wicket.Component;
    3334import org.apache.wicket.behavior.AttributeAppender;
     35import org.apache.wicket.markup.html.WebMarkupContainer;
    3436import org.apache.wicket.markup.html.basic.Label;
    3537import org.apache.wicket.markup.html.link.ExternalLink;
     
    3739import org.apache.wicket.markup.html.list.ListView;
    3840import org.apache.wicket.markup.html.panel.GenericPanel;
     41import org.apache.wicket.markup.html.panel.Panel;
    3942import org.apache.wicket.model.IModel;
    4043import org.apache.wicket.model.PropertyModel;
     
    6366        add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(documentModel, basicPropertiesFilter)));
    6467
    65         createResourcesList("resource");
     68        final SolrFieldModel<String> resourceModel = new SolrFieldModel<String>(getModel(), FacetConstants.FIELD_RESOURCE);
     69
     70        // add a container for the resources (only visible if there are actual resources)
     71        add(new WebMarkupContainer("resources") {
     72            {
     73                add(createResourcesList("resource", resourceModel));
     74            }
     75
     76            @Override
     77            protected void onConfigure() {
     78                super.onConfigure();
     79                setVisible(resourceModel.getObject() != null);
     80            }
     81
     82        });
    6683    }
    6784
    68     private void createResourcesList(String id) {
     85    private Component createResourcesList(String id, SolrFieldModel<String> resourceModel) {
    6986        // list of resources in this record
    7087        // TODO: limit number of resources shown here?
    71         final SolrFieldModel<String> resourceModel = new SolrFieldModel<String>(getModel(), FacetConstants.FIELD_RESOURCE);
    7288        final IModel<List<String>> resourceListModel = new CollectionListModel<String>(resourceModel);
    73         add(new ListView<String>(id, resourceListModel) {
     89        return new ListView<String>(id, resourceListModel) {
    7490
    7591            @Override
     
    84100                // add a tooltip showing resource type and mime type
    85101                final StringResourceModel tooltipModel
    86                         = new StringResourceModel("resource.tooltip", SearchResultItemExpandedPanel.this, resourceModel,
     102                        = new StringResourceModel("resource.tooltip", SearchResultItemExpandedPanel.this, null,
    87103                                new Object[]{
    88104                                    new PropertyModel(resourceInfoModel, "resourceType"),
     
    96112                item.add(resourceLink);
    97113            }
    98         });
     114        };
    99115    }
    100116
Note: See TracChangeset for help on using the changeset viewer.