Skip to content

Commit

Permalink
add custom field
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jun 3, 2021
1 parent 31c92c7 commit 166cbf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/theme/View/CollectionView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const CollectionView = (props) => {

const items = listingBlockItems[listingBlockid]?.data?.items;

const listingBlockProps = content[blocksFieldname]?.[listingBlockid] || {};

useEffect(() => {
//This is only done to get full expanded content along with metadata fields which is,
// not possible with listing block's @querystring-search default action
Expand All @@ -73,7 +75,7 @@ const CollectionView = (props) => {
fullobjects: true,
};
dispatch(getContentWithData(path, null, listingBlockid, options));
}, [dispatch, path, listingBlockid]);
}, [dispatch, path, listingBlockid, listingBlockProps]);

const handleSelectFilter = (ev, { name }) => {
const filtered = filterResults(items, name, content.filter);
Expand All @@ -83,8 +85,6 @@ const CollectionView = (props) => {
}
};

const listingBlockProps = content[blocksFieldname]?.[listingBlockid] || {};

return (
<Container>
<Helmet title={content.title} />
Expand Down
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ export default function applyConfig(config) {
...config.views.layoutViews,
topics_view: TopicsView,
topic_tab_view: TopicsTabView,
listing_view: CollectionView,
},
contentTypesViews: {
...config.views.contentTypesViews,
Collection: CollectionView,
//Collection: CollectionView,
},
};

Expand Down Expand Up @@ -139,6 +140,15 @@ export default function applyConfig(config) {
isDefault: false,
title: 'List',
template: ListingBlockTemplate,
schemaEnhancer: ({ formData, schema, intl }) => {
schema.properties.metadata_fields = {
type: 'array',
title: 'Metadata fields',
choices: [['_all', '_all']],
};
schema.fieldsets[0].fields.push('metadata_fields');
return schema;
},
},
];

Expand Down

0 comments on commit 166cbf7

Please sign in to comment.