Changeset 4991


Ignore:
Timestamp:
04/16/14 13:20:32 (10 years ago)
Author:
Twan Goosen
Message:

Limited number of resources shown in expanded search result item; it exceeded, a link to the record page is shown with a label telling the number of resources not shown

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main
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/SearchResultItemExpandedPanel.html

    r4880 r4991  
    3838                            </a>
    3939                        </li>
     40                        <wicket:enclosure child="more">
     41                            <li class="moreresources">
     42                                <a wicket:id="more"><wicket:container wicket:id="moreLabel">99 more resources...</wicket:container></a>
     43                            </li>
     44                        </wicket:enclosure>
    4045                    </ul>
    4146                </wicket:container>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.java

    r4982 r4991  
    3232import java.util.List;
    3333import org.apache.solr.common.SolrDocument;
    34 import org.apache.wicket.Component;
    3534import org.apache.wicket.ajax.AjaxRequestTarget;
    3635import org.apache.wicket.behavior.AttributeAppender;
     
    3938import org.apache.wicket.markup.html.link.ExternalLink;
    4039import org.apache.wicket.markup.html.list.ListItem;
    41 import org.apache.wicket.markup.html.list.ListView;
     40import org.apache.wicket.markup.html.list.PageableListView;
    4241import org.apache.wicket.markup.html.panel.GenericPanel;
     42import org.apache.wicket.model.AbstractReadOnlyModel;
    4343import org.apache.wicket.model.IModel;
    4444import org.apache.wicket.model.PropertyModel;
     
    5252public class SearchResultItemExpandedPanel extends GenericPanel<SolrDocument> {
    5353
     54    private static final int MAX_RESOURCES_TO_SHOW = 10;
     55   
    5456    @SpringBean(name = "searchResultPropertiesFilter")
    5557    private FieldFilter propertiesFilter;
     
    5961    ResourceStringConverter resolvingResourceStringConverter;
    6062
    61     public SearchResultItemExpandedPanel(String id, IModel<SolrDocument> documentModel, IModel<SearchContext> selectionModel) {
     63    public SearchResultItemExpandedPanel(String id, final IModel<SolrDocument> documentModel, final IModel<SearchContext> selectionModel) {
    6264        super(id, documentModel);
    6365
     
    6971        add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(documentModel, propertiesFilter)));
    7072
     73        // add a container for the resources (only visible if there are actual resources)
     74        add(createResourcesView("resources", documentModel, selectionModel));
     75    }
     76
     77    private WebMarkupContainer createResourcesView(String id, final IModel<SolrDocument> documentModel, final IModel<SearchContext> selectionModel) {
    7178        final SolrFieldModel<String> resourceModel = new SolrFieldModel<String>(getModel(), FacetConstants.FIELD_RESOURCE);
    72 
    73         // add a container for the resources (only visible if there are actual resources)
    74         add(new WebMarkupContainer("resources") {
    75             {
    76                 add(createResourcesList("resource", resourceModel));
    77             }
    78 
     79        // create a container for the list view that is only visible if there actually are resources
     80        final WebMarkupContainer container = new WebMarkupContainer(id) {
    7981            @Override
    8082            protected void onConfigure() {
     
    8385            }
    8486
    85         });
     87        };
     88
     89        final PageableListView resourcesView = createResourcesList("resource", resourceModel);
     90        container.add(resourcesView);
     91
     92        // create a link to the record page that is only visible when there are more resources than shown
     93        final RecordPageLink moreLink = new RecordPageLink("more", documentModel, selectionModel) {
     94
     95            @Override
     96            protected void onConfigure() {
     97                super.onConfigure();
     98                setVisible(resourcesView.getPageCount() > 1);
     99            }
     100
     101        };
     102        // add a record page link that shows the number of resources not shown
     103        moreLink.add(new Label("moreLabel", new StringResourceModel("resources.more", new AbstractReadOnlyModel<Integer>() {
     104
     105            @Override
     106            public Integer getObject() {
     107                return resourceModel.getObject().size() - MAX_RESOURCES_TO_SHOW;
     108            }
     109
     110        }, "more...")));
     111        container.add(moreLink);
     112       
     113        return container;
    86114    }
    87115
    88     private Component createResourcesList(String id, SolrFieldModel<String> resourceModel) {
     116    private PageableListView createResourcesList(String id, SolrFieldModel<String> resourceModel) {
    89117        // list of resources in this record
    90         // TODO: limit number of resources shown here?
    91118        final IModel<List<String>> resourceListModel = new CollectionListModel<String>(resourceModel);
    92         return new ListView<String>(id, resourceListModel) {
     119        // use a a pageable view so that the number of resources actually shown is limited
     120        return new PageableListView<String>(id, resourceListModel, MAX_RESOURCES_TO_SHOW) {
    93121
    94122            @Override
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/SearchResultItemExpandedPanel.properties

    r4881 r4991  
    1414# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1515
     16# ${} = number of additional resources
     17resources.more=${} more resources...
    1618# {0} = resource type, {1} = mime type
    1719resource.tooltip={0} ({1})
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/resources/eu/clarin/cmdi/vlo/wicket/pages/vlo-search.css

    r4937 r4991  
    175175}
    176176
     177.searchresultresources li.moreresources {
     178    /* 'N more resources' link (has no icon) */
     179    padding-left: .5em;
     180}
     181
    177182.searchresultresources li.writtenresource {
    178183    background-image: url('document-256.png'); /* icon from icons8.com */
Note: See TracChangeset for help on using the changeset viewer.