Skip to content

Commit

Permalink
Set group of search pages to page id
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Feb 7, 2025
1 parent cc461e6 commit 8ace26f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ config.settings.bookmarks = {
bookmarkgroupmapping: {
manual: 'Manuals and HowTos',
releasenote: 'Release Notes',
default_search: 'Search',
search: 'Search', // id of search page
'search-in-news': 'Search in News', // id of another search page
default_nogroup: 'Miscellaneous',
},
bookmarkgroupfield: 'type_title',
Expand Down
21 changes: 1 addition & 20 deletions packages/volto-bookmarks/src/components/ToggleBookmarkButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ const ToggleBookmarkButton = ({ item = null }) => {
const [bookmarked, setBookmarked] = React.useState(false);

React.useEffect(() => {
console.debug('Check if content is bookmarked', searchkitQuery);
// Check if page is bookmarked
setBookmarked(false);
const doLoSearch = sortQuerystring(document.location.search);
// console.debug('* doLoSearch', doLoSearch);
bookmarks.items?.forEach((element) => {
// console.debug('element.queryparams', element.queryparams);
if (
item
? element.uid === item?.UID
Expand All @@ -67,13 +64,8 @@ const ToggleBookmarkButton = ({ item = null }) => {
});

// group
console.debug(
'item, config.settings?.bookmarks?.bookmarkgroupfield',
item,
config.settings?.bookmarks?.bookmarkgroupfield,
);
if (document.location.search && !item) {
setGroup('default_search');
setGroup(content.id);
} else {
let grp_token = get(
item || content,
Expand All @@ -85,13 +77,6 @@ const ToggleBookmarkButton = ({ item = null }) => {
? grp_token[0].token || grp_token
: 'default_nogroup',
);
console.debug(
'grp_token',
grp_token,
grp_token && grp_token.length > 0
? grp_token[0].token || grp_token
: 'definitif: default_nogroup',
);
}
}, [
content,
Expand All @@ -112,10 +97,6 @@ const ToggleBookmarkButton = ({ item = null }) => {
if (response.ok) {
setBookmarked(false);
fetchBookmarks();
} else {
console.debug('response', response);
let responsejson = await response.json();
console.debug('response.json()', responsejson);
}
} else {
const response = await addBookmark(
Expand Down
3 changes: 2 additions & 1 deletion packages/volto-bookmarks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const applyConfig = (config) => {
config.settings.bookmarks = {
...(config.settings.bookmarks ?? {}),
bookmarkgroupmapping: {
default_search: 'Search results',
search: 'Search results', // id of search page
'search-in-news': 'Search in News', // id of another search page
default_nogroup: 'Miscellaneous',
},
bookmarkgroupfield: 'type_title',
Expand Down

0 comments on commit 8ace26f

Please sign in to comment.