Skip to content

Commit

Permalink
blr: landing page fixes
Browse files Browse the repository at this point in the history
* search for related records only within BLR community
* adjust empty search results to absence of search bar
* add a new loader placeholder
  • Loading branch information
anikachurilova committed Jan 19, 2024
1 parent 23f1e3a commit d4d71c7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { RecordGridItem, RecordListItem } from "./components/RecordItem";
import { FilterContainer, Filter, FilterValues } from "./components/Filter";
import { LayoutSwitchButtons } from "./components/LayoutSwitchButtons";
import { NoResults } from "./components/NoResults";
import { BlrResultsLoader } from "./components/BlrResultsLoader";

const blrSearchAppID = "blrSearch";

Expand All @@ -54,16 +55,17 @@ const overriddenComponents = {
[`${blrSearchAppID}.BucketAggregationValues.element`]: FilterValues,
[`${blrSearchAppID}.LayoutSwitcher.element`]: LayoutSwitchButtons,
[`${blrSearchAppID}.EmptyResults.element`]: NoResults,
[`${blrSearchAppID}.ResultsLoader.element`]: BlrResultsLoader,
};

export const BlrSearch = ({ endpoint, recordDOI, resourceType }) => {
export const BlrSearch = ({ endpoint, recordDOI, resourceType, blrId }) => {
const relationType = (resourceType) =>
resourceType === "Journal article" || resourceType === "Book chapter"
? "ispartof"
: "haspart";

const queryString = (relationType, identifier) =>
`metadata.related_identifiers.relation_type.id:${relationType} AND metadata.related_identifiers.identifier:"${identifier}"`;
`parent.communities.ids:${blrId} AND metadata.related_identifiers.relation_type.id:${relationType} AND metadata.related_identifiers.identifier:"${identifier}"`;

const searchApi = new InvenioSearchApi(apiConfig(endpoint));

Expand Down Expand Up @@ -115,4 +117,5 @@ BlrSearch.propTypes = {
endpoint: PropTypes.string.isRequired,
recordDOI: PropTypes.string.isRequired,
resourceType: PropTypes.string.isRequired,
blrId: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { Placeholder } from "semantic-ui-react";

export const BlrResultsLoader = (children, loading) => {
return loading ? (
<Placeholder fluid className="rel-mt-3">
<Placeholder.Header image>
<Placeholder.Line length="full" />
<Placeholder.Line length="medium" />
</Placeholder.Header>
<Placeholder.Header image>
<Placeholder.Line length="full" />
<Placeholder.Line length="medium" />
</Placeholder.Header>
</Placeholder>
) : (
children
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,14 @@
// as an Intergovernmental Organization or submit itself to any jurisdiction.

import React from "react";
import { PropTypes } from "prop-types";
import { Container, Icon } from "semantic-ui-react";
import { Container } from "semantic-ui-react";

export const NoResults = ({ queryString }) => {
export const NoResults = () => {
return (
<Container align={(!queryString && "left") || "center"}>
{(queryString && (
<div className="text-muted rel-p-1">
<Icon name="search" size="huge" />
<p className="rel-mt-1">
<strong>No results found for '{queryString}'</strong>
</p>
</div>
)) || (
<p>
<Icon name="folder open outline" />
<em>No related content for this record.</em>
</p>
)}
<Container align="left">
<p>
<em>No related content for this record</em>
</p>
</Container>
);
};

NoResults.propTypes = {
queryString: PropTypes.string,
};

NoResults.defaultProps = {
queryString: "",
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const blrContainer = document.getElementById("blr-search");
const endpoint = blrContainer.dataset.blrEndpoint;
const recordDOI = JSON.parse(blrContainer.dataset.recordDoi);
const resourceType = JSON.parse(blrContainer.dataset.resourceType);
const blrId = JSON.parse(blrContainer.dataset.blrId);

const validTypes = [
"Figure",
Expand All @@ -44,6 +45,7 @@ if (validTypes.includes(resourceType)) {
endpoint={endpoint}
recordDOI={recordDOI}
resourceType={resourceType}
blrId={blrId}
/>,
blrContainer
);
Expand Down
6 changes: 3 additions & 3 deletions templates/semantic-ui/zenodo_rdm/records/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ <h4 class="inline">{{ record.ui.access_status.title_l10n }}</h4>
{# Additional details #}
{%- block record_details -%}

{% if record.expanded.parent.communities.default.slug == "biosyslit" %}
{% if record.expanded and record.expanded.parent.communities.default.slug == "biosyslit" %}
{# BLR Related works #}
<section
id="blr-search"
class="rel-mt-2"
data-blr-endpoint="/api/records"
data-record-doi='{{ record.pids.doi.identifier | tojson }}'
data-resource-type='{{ record.metadata.resource_type.title.en | tojson }}'
data-communities='{{ record.expanded.parent.communities | tojson }}'
data-blr-id='{{ record.expanded.parent.communities.default.id | tojson }}'
>
</section>
{% endif %}
Expand Down Expand Up @@ -103,7 +103,7 @@ <h4 class="inline">{{ record.ui.access_status.title_l10n }}</h4>
{{super()}}
{{ webpack['zenodo-rdm-citations.js'] }}

{% if record.expanded.parent.communities.default.slug == "biosyslit" %}
{% if record.expanded and record.expanded.parent.communities.default.slug == "biosyslit" %}
{{ webpack['zenodo-rdm-blr-search.js'] }}
{% endif %}
{% endblock javascript %}

0 comments on commit d4d71c7

Please sign in to comment.