Skip to content

Commit

Permalink
show metadata children count + hierarchy icon in search result badges…
Browse files Browse the repository at this point in the history
…. Refs #330
  • Loading branch information
twagoo committed Jan 28, 2022
1 parent 34ca0b7 commit 5a7579e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,27 @@ <h3>
<li wicket:id="collectionRecord">
<a wicket:id="recordLink" href="record1.html" title="Collection record">
<span class="badge">
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
</span>
</a>
<span wicket:id="hierarchyChildrenCountLabel">1</span>
<i class="fa fa-sitemap" aria-hidden="true"></i>
</span></a>
</li>
<li wicket:id="resourceCount">
<a wicket:id="recordLink" href="record1.html">
<span class="badge">
<span wicket:id="resourceCountLabel">1</span>
<span wicket:id="resourceTypeIcon" class="glyphicon" aria-hidden="true"></span>
</span>
</a>
</span></a>
</li>
<li wicket:id="noResources">
<a wicket:id="recordLink" href="record1.html" title="Record without resource links">
<span class="badge">
<span>0</span>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
</span>
</a>
</span></a>
</li>
<li wicket:id="availabilityWarning">
<a wicket:id="recordLink" href="record1.html" title="Some linked resources may not be available or have restricted access">
<span wicket:id="warningBadge"></span>
</a>
<span wicket:id="warningBadge"></span></a>
</li>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import eu.clarin.cmdi.vlo.wicket.model.SolrFieldStringModel;
import eu.clarin.cmdi.vlo.wicket.pages.RecordPage;
import eu.clarin.cmdi.vlo.wicket.model.IsPidModel;
import eu.clarin.cmdi.vlo.wicket.model.RecordMetadataLinksCountModel;
import eu.clarin.cmdi.vlo.wicket.model.ResourceInfoModel;
import eu.clarin.cmdi.vlo.wicket.provider.ResouceTypeCountDataProvider;
import java.util.Collection;
Expand Down Expand Up @@ -140,7 +141,7 @@ public void onConfigure(Component component) {
// wrap with a count provider
final ResouceTypeCountDataProvider countProvider = new ResouceTypeCountDataProvider(resourcesModel, countingService);
// part count model to determine whether a record is a collection record
final SolrFieldModel<String> partCountModel = new SolrFieldModel<>(documentModel, fieldNameService.getFieldName(FieldKey.HAS_PART_COUNT));
final RecordMetadataLinksCountModel recordMetadataLinksCountModel = new RecordMetadataLinksCountModel(documentModel);

final SolrFieldModel<Integer> resourceAvailabilityScoreModel = new SolrFieldModel<>(documentModel, fieldNameService.getFieldName(FieldKey.RESOURCE_AVAILABILITY_SCORE));
final IModel<Boolean> resourceAvailabilityWarningModel = new LoadableDetachableModel<Boolean>() {
Expand Down Expand Up @@ -183,27 +184,17 @@ protected IModel<String> getResourceRestrictedTooltip() {
.add(new ResourceCountDataView("resourceCount", countProvider))
//badge for collection records
.add(new WebMarkupContainer("collectionRecord")
.add(new RecordPageLink("recordLink", documentModel, selectionModel, RecordPage.HIERARCHY_SECTION))
// collection, go to hierarchy instead of records
.add(new RecordPageLink("recordLink", documentModel, selectionModel, RecordPage.HIERARCHY_SECTION)
.add(new Label("hierarchyChildrenCountLabel", recordMetadataLinksCountModel))
.add(new AttributeModifier("title", new StringResourceModel("searchresult.hierarchy.badgetitle", recordMetadataLinksCountModel))))
//badge for records without resources (resource count data view will not yield any badges)
.add(new Behavior() {
@Override
public void onConfigure(Component component) {
component.setVisible(partCountModel.getObject() != null);
}

})
.add(BooleanVisibilityBehavior.visibleOnTrue(() -> recordMetadataLinksCountModel.getObject() > 0))
)
//badge for record with no resources
.add(new WebMarkupContainer("noResources")
.add(new RecordPageLink("recordLink", documentModel, selectionModel)) //initial tab *not* resources as there are none...
.add(new Behavior() {
@Override
public void onConfigure(Component component) {
component.setVisible(countProvider.size() == 0 && partCountModel.getObject() == null);
}

})
.add(BooleanVisibilityBehavior.visibleOnTrue(()->countProvider.size() == 0 && recordMetadataLinksCountModel.getObject() <= 0))
)
//badge for availability warning
.add(new WebMarkupContainer("availabilityWarning")
Expand Down Expand Up @@ -345,7 +336,7 @@ protected void populateItem(Item<ResourceTypeCount> item) {
final Link resourceLink = new RecordPageLink("recordLink", documentModel, selectionModel, RecordPage.RESOURCES_SECTION);
item.add(resourceLink
.add(new Label("resourceCountLabel", new PropertyModel<String>(item.getModel(), "count")))
.add(new ResourceTypeIcon("resourceTypeIcon", new PropertyModel<String>(item.getModel(), "resourceType")))
.add(new ResourceTypeIcon("resourceTypeIcon", new PropertyModel<>(item.getModel(), "resourceType")))
.add(new AttributeModifier("title", getResourceCountModel(item.getModel())))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ searchresult.nodescription=No description
searchresult.partof=Part of
searchresult.landingpage.recordlandingpage=Landing page for this record
searchresult.landingpage.recordlandingpageat=Landing page for this record at
searchresult.hierarchy.badgetitle=${} child metadata record links

0 comments on commit 5a7579e

Please sign in to comment.