Skip to content

Commit

Permalink
base: enables namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Jan 23, 2023
1 parent f1f10fc commit 6cd94cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1 class="ui header">{{ title or name }}</h1>
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 }}'
Expand Down
2 changes: 2 additions & 0 deletions invenio_administration/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6cd94cc

Please sign in to comment.