diff --git a/invenio_administration/assets/semantic-ui/js/invenio_administration/src/search/SearchComponents.js b/invenio_administration/assets/semantic-ui/js/invenio_administration/src/search/SearchComponents.js index 96d1ffb..337689b 100644 --- a/invenio_administration/assets/semantic-ui/js/invenio_administration/src/search/SearchComponents.js +++ b/invenio_administration/assets/semantic-ui/js/invenio_administration/src/search/SearchComponents.js @@ -20,8 +20,9 @@ import { ContribBucketAggregationValuesElement, } from "@js/invenio_search_ui/components"; import { SearchBar } from "./SearchBar"; +import _mapKeys from "lodash/mapKeys"; -export const initDefaultSearchComponents = (domContainer) => { +export const initDefaultSearchComponents = (domContainer, appId = null) => { const sortColumns = (columns) => Object.entries(columns).sort((a, b) => a[1].order - b[1].order); const title = JSON.parse(domContainer.dataset.title); @@ -63,11 +64,11 @@ export const initDefaultSearchComponents = (domContainer) => { resourceSchema: resourceSchema, }); - return { + const components = { "ResultsList.item": SearchResultItemWithConfig, "BucketAggregation.element": ContribBucketAggregationElement, "BucketAggregationValues.element": ContribBucketAggregationValuesElement, - "ResultsGrid.item": () => {}, + "ResultsGrid.item": () => null, "SearchApp.results": SearchResultsWithConfig, "ResultsList.container": ResultsContainerWithConfig, "EmptyResults.element": SearchEmptyResults, @@ -77,4 +78,13 @@ export const initDefaultSearchComponents = (domContainer) => { "SearchApp.resultOptions": () => null, "SearchBar.element": displaySearch ? SearchBarElement : () => null, }; + + if (appId) { + const nameSpacedComponents = _mapKeys(components, function (value, key) { + return `${appId}.${key}`; + }); + return nameSpacedComponents; + } + + return components; }; diff --git a/invenio_administration/templates/semantic-ui/invenio_administration/search.html b/invenio_administration/templates/semantic-ui/invenio_administration/search.html index 04bde36..8004fe1 100644 --- a/invenio_administration/templates/semantic-ui/invenio_administration/search.html +++ b/invenio_administration/templates/semantic-ui/invenio_administration/search.html @@ -38,7 +38,7 @@

{{ title or name }}

id="invenio-search-config" data-title='{{ title | tojson }}' data-resource-name='{{ resource_name | tojson }}' - data-invenio-search-config='{{ search_config() | tojson }}' + data-invenio-search-config='{{ search_config(app_id=app_id) | tojson }}' data-fields='{{ fields | tojson }}' data-display-search='{{ display_search | tojson }}' data-display-read='{{ display_read | tojson }}' diff --git a/invenio_administration/views/base.py b/invenio_administration/views/base.py index c6d6c13..ec03a6a 100644 --- a/invenio_administration/views/base.py +++ b/invenio_administration/views/base.py @@ -331,6 +331,7 @@ class AdminResourceListView(AdminResourceBaseView): display_search = True search_config_name = None + app_id = None search_facets_config_name = None search_sort_config_name = None sort_options = {} @@ -387,6 +388,7 @@ def get(self): "api_endpoint": self.get_api_endpoint(), "title": self.title, "name": self.name, + "app_id": self.app_id, "resource_schema": serialized_schema, "fields": self.item_field_list, "display_search": self.display_search,