From f6849bd4a2e863963432d5ade43fa2e7070c0e09 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 16 Feb 2024 10:38:02 +0000 Subject: [PATCH 01/55] innit --- .github/workflows/madoc-ts-docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/madoc-ts-docker.yaml b/.github/workflows/madoc-ts-docker.yaml index 8416f366b..434e8b424 100644 --- a/.github/workflows/madoc-ts-docker.yaml +++ b/.github/workflows/madoc-ts-docker.yaml @@ -5,7 +5,7 @@ on: branches: ['main'] tags: ['v*'] pull_request: - branches: ['main', 'feature/v2.1', 'feature/IDA-893-enrichment-integration'] + branches: ['main', 'feature/v2.1', 'feature/IDA-893-enrichment-integration', 'feature/IDA-madoc-develop'] paths: - ".github/workflows/madoc-ts-docker.yaml" - "services/madoc-ts/src/**" From c35346775e36a4082d3cf51051db1c2a89585c4d Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 23 Feb 2024 12:13:12 +0000 Subject: [PATCH 02/55] use topic from slug for search --- .../site/features/SearchPageResults.tsx | 1 - .../src/frontend/site/hooks/use-search.ts | 18 +++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/SearchPageResults.tsx b/services/madoc-ts/src/frontend/site/features/SearchPageResults.tsx index 75ea8400b..ff80987c7 100644 --- a/services/madoc-ts/src/frontend/site/features/SearchPageResults.tsx +++ b/services/madoc-ts/src/frontend/site/features/SearchPageResults.tsx @@ -11,7 +11,6 @@ import { SimpleDropdown } from '../../shared/atoms/SimpleDropdown'; import { Button, ButtonIcon } from '../../shared/navigation/Button'; import { GridIcon } from '../../shared/icons/GridIcon'; import { ListIcon } from '../../shared/icons/ListIcon'; -import useDropdownMenu from 'react-accessible-dropdown-menu-hook'; interface SearchPageResultsProps { background?: string; diff --git a/services/madoc-ts/src/frontend/site/hooks/use-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-search.ts index 42fb93863..5d11d014c 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-search.ts @@ -5,17 +5,13 @@ import { apiHooks, paginatedApiHooks } from '../../shared/hooks/use-api-query'; import { useSiteConfiguration } from '../features/SiteConfigurationContext'; import { useRouteContext } from './use-route-context'; import { useSearchQuery } from './use-search-query'; -import { useBreadcrumbs } from '../../shared/components/Breadcrumbs'; function normalizeDotKey(key: string) { return key.startsWith('metadata.') ? key.slice('metadata.'.length).toLowerCase() : key.toLowerCase(); } export function useSearch() { - const { topic } = useBreadcrumbs(); - const topicId = topic?.id; - - const { projectId, collectionId, manifestId } = useRouteContext(); + const { projectId, collectionId, manifestId, topic } = useRouteContext(); const { fulltext, appliedFacets, page, rscType } = useSearchQuery(); const { project: { searchStrategy, claimGranularity, searchOptions }, @@ -24,14 +20,14 @@ export function useSearch() { const searchFacetConfig = apiHooks.getSiteSearchFacetConfiguration(() => []); useEffect(() => { - if (topicId) { - appliedFacets.push({ k: 'entity', v: topicId, t: 'entity' }); + if (topic) { + appliedFacets.push({ k: 'entity', v: topic, t: 'entity' }); } return; - }, [appliedFacets, topicId, topic]); + }, [appliedFacets, topic]); const [facetsToRequest, facetDisplayOrder, facetIdMap] = useMemo(() => { - const facets = !topicId && searchFacetConfig.data ? searchFacetConfig.data.facets : []; + const facets = !topic && searchFacetConfig.data ? searchFacetConfig.data.facets : []; const returnList: string[] = []; const idMap: { [id: string]: { config: FacetConfig; keys: string[] } } = {}; const displayOrder: string[] = []; @@ -50,7 +46,7 @@ export function useSearch() { } } return [returnList, displayOrder, idMap]; - }, [searchFacetConfig.data, topicId]); + }, [searchFacetConfig.data, topic]); const topicFacets = appliedFacets.map(facet => { return facet.k === 'entity' @@ -103,7 +99,7 @@ export function useSearch() { collectionId || manifestId || projectId || - topicId), + topic), } ); From 960fef766ad8b3e1771350e1001ee3f2bdb7840c Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 23 Feb 2024 13:07:38 +0000 Subject: [PATCH 03/55] 0 resources instead of 0 --- .../src/frontend/shared/components/TopicCard.tsx | 9 ++++----- .../src/frontend/site/features/SearchPageFilters.tsx | 2 +- services/madoc-ts/translations/en/madoc.json | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx b/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx index 6ce78d0af..70de2d52a 100644 --- a/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx +++ b/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx @@ -54,11 +54,10 @@ export const TopicCard: React.FC<{ {topic.title} - {topic.tagged_resource_count && ( - - {topic.tagged_resource_count} {t('Resources')} - - )} + + {topic.tagged_resource_count || 0} {t('Resources')} + + {t('PART OF')} {topic.type_title.length ? ( {topic.type_title} diff --git a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx index 03856862f..b58ac9e39 100644 --- a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx +++ b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx @@ -113,7 +113,7 @@ export const SearchPageFilters: React.FC = ({ checkBoxCo onChange={(e: { target: { checked: any } }) => e.target.checked ? queueSingleFacet(item.key, item.values, item.type) - : dequeueSingleFacet(item.key, item.values) + : dequeueSingleFacet(item.key, item.values, item.type) } /> diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index e03e3732c..9299e83ee 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -633,6 +633,7 @@ "Override the hero title": "Override the hero title", "Overview": "Overview", "PART OF": "PART OF", + "PART OFs": "PART OFs", "Padding around logo": "Padding around logo", "Padding size": "Padding size", "Page blocks": "Page blocks", From 7ab78cd43e04096d86b7ae9a7bc83b4c6905cf6d Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 26 Feb 2024 16:48:53 +0000 Subject: [PATCH 04/55] fix errors when editing and images hasnt changed --- .../madoc-ts/src/extensions/enrichment/models.ts | 8 ++++++-- .../pages/topics/topic-type/edit-topic-type.tsx | 16 ++++++++++++---- services/madoc-ts/translations/en/madoc.json | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/services/madoc-ts/src/extensions/enrichment/models.ts b/services/madoc-ts/src/extensions/enrichment/models.ts index 1c68a31cb..6bdba9c8a 100644 --- a/services/madoc-ts/src/extensions/enrichment/models.ts +++ b/services/madoc-ts/src/extensions/enrichment/models.ts @@ -19,9 +19,13 @@ export const entityTypeModel: CaptureModelShorthand = { }, // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore + thumbnail: { type: 'madoc-media-explorer', label: 'Thumbnail' }, + hero: { type: 'madoc-media-explorer', label: 'Hero image' }, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore 'featured_topics.slug': { type: 'topic-explorer', label: 'featured topics' }, - 'other_data.main_image': { type: 'madoc-media-explorer', label: 'Hero image' }, - 'other_data.thumbnail': { type: 'madoc-media-explorer', label: 'Thumbnail' }, + // 'other_data.main_image': { type: 'madoc-media-explorer', label: 'Hero image' }, + // 'other_data.thumbnail': { type: 'madoc-media-explorer', label: 'Thumbnail' }, }; export const entityModel: CaptureModelShorthand = { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx index f52ce23cd..0d19eba17 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx @@ -19,8 +19,12 @@ export function EditTopicType() { const [createNewEntityType, status] = useMutation(async (updatedData: any) => { if (!data) return; - updatedData.other_data.main_image = ParseEntityMedia(updatedData.other_data.main_image); - updatedData.other_data.thumbnail = ParseEntityMedia(updatedData.other_data.thumbnail); + if (data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { + updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); + } + if (data.other_data?.main_image?.id !== updatedData.hero.id) { + updatedData.hero = ParseEntityMedia(updatedData.hero); + } if (data.topic_count > 0) { if (updatedData.featured_topics) { @@ -41,6 +45,10 @@ export function EditTopicType() { const resp = api.enrichment.upsertEntityType({ id: data.id, label: data.label, + other_data: { + thumbnail: updatedData.thumbnail, + main_image: updatedData.hero, + }, ...updatedData, }); @@ -56,7 +64,7 @@ export function EditTopicType() { // dont allow editing featured if not enough to chose from // backend automatically picks first 3 if (data && data.topic_count < 4) { - delete copy.featured_topics; + delete copy['featured_topics.slug']; } return copy; }, [data]); @@ -83,7 +91,7 @@ export function EditTopicType() { { await createNewEntityType(d); }} diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 9299e83ee..d42bcfe5c 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -1063,6 +1063,7 @@ "migrate-capture-model-task": "migrate-capture-model-task", "not found": "not found", "not started": "not started", + "other_data": "other_data", "paused": "paused", "pending": "pending", "preview": "preview", From adcbf32a0ed845e93aa63bd0899c303e0485bf2b Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 26 Feb 2024 17:00:44 +0000 Subject: [PATCH 05/55] admin header use title not label --- .../frontend/admin/pages/topics/topic-type/edit-topic-type.tsx | 2 +- .../src/frontend/admin/pages/topics/topic-type/manage-type.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx index 0d19eba17..c59de206d 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx @@ -60,7 +60,7 @@ export function EditTopicType() { const copy: any = { ...entityTypeModel, }; - delete copy.label; + // delete copy.label; // dont allow editing featured if not enough to chose from // backend automatically picks first 3 if (data && data.topic_count < 4) { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/manage-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/manage-type.tsx index 375d6b69d..b69c124fc 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/manage-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/manage-type.tsx @@ -17,7 +17,7 @@ export function ManageType() { const site = useSite(); const { deleted } = useLocationQuery(); - const label = {data?.label || { none: ['...'] }}; + const label = {data?.title || { none: ['...'] }}; return ( <> From baedd923c62355177df3568edf026dc5ca52cf46 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 26 Feb 2024 17:30:25 +0000 Subject: [PATCH 06/55] reflect same changed on topic editing --- .../src/extensions/enrichment/models.ts | 14 +++-------- .../topics/topic-type/edit-topic-type.tsx | 2 +- .../admin/pages/topics/topic/edit-topic.tsx | 25 +++++++++++++++---- .../admin/pages/topics/topic/manage-topic.tsx | 4 +-- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/services/madoc-ts/src/extensions/enrichment/models.ts b/services/madoc-ts/src/extensions/enrichment/models.ts index 6bdba9c8a..e7e2b9b5b 100644 --- a/services/madoc-ts/src/extensions/enrichment/models.ts +++ b/services/madoc-ts/src/extensions/enrichment/models.ts @@ -11,21 +11,13 @@ export const entityTypeModel: CaptureModelShorthand = { label: 'Featured topic', pluralLabel: 'Featured topics', }, - other_data: { - allowMultiple: false, - label: 'Images', - labelledBy: 'id', - }, }, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore thumbnail: { type: 'madoc-media-explorer', label: 'Thumbnail' }, hero: { type: 'madoc-media-explorer', label: 'Hero image' }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore 'featured_topics.slug': { type: 'topic-explorer', label: 'featured topics' }, - // 'other_data.main_image': { type: 'madoc-media-explorer', label: 'Hero image' }, - // 'other_data.thumbnail': { type: 'madoc-media-explorer', label: 'Thumbnail' }, }; export const entityModel: CaptureModelShorthand = { @@ -55,10 +47,10 @@ export const entityModel: CaptureModelShorthand = { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore + thumbnail: { type: 'madoc-media-explorer', label: 'Thumbnail' }, + hero: { type: 'madoc-media-explorer', label: 'Hero image' }, 'featured_resources.madoc_id': { type: 'topic-item-explorer', label: 'featured resources' }, 'other_data.topic_summary': { type: 'international-field', label: 'Summary' }, 'other_data.secondary_heading': { type: 'international-field', label: 'Secondary heading' }, 'other_data.aliases': { type: 'international-field', label: 'Aliases', allowMultiple: true }, - 'other_data.main_image': { type: 'madoc-media-explorer', label: 'Hero image' }, - 'other_data.thumbnail': { type: 'madoc-media-explorer', label: 'Thumbnail' }, }; diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx index c59de206d..0d19eba17 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx @@ -60,7 +60,7 @@ export function EditTopicType() { const copy: any = { ...entityTypeModel, }; - // delete copy.label; + delete copy.label; // dont allow editing featured if not enough to chose from // backend automatically picks first 3 if (data && data.topic_count < 4) { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx index 622dee0f1..be91115bd 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx @@ -18,8 +18,16 @@ export function EditTopic() { const [createNewEntity, status] = useMutation(async (updatedData: any) => { if (!data) return; - updatedData.other_data.main_image = ParseEntityMedia(updatedData.other_data.main_image); - updatedData.other_data.thumbnail = ParseEntityMedia(updatedData.other_data.thumbnail); + console.log(data.other_data); + + if (updatedData.thumbnail.id && data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { + console.log('1'); + updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); + } + if (updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { + console.log('2'); + updatedData.hero = ParseEntityMedia(updatedData.hero); + } if (updatedData.featured_resources) { const ftRes = updatedData.featured_resources; @@ -34,12 +42,18 @@ export function EditTopic() { updatedData.featured_resources = Object.values(ftRes); } } - const resp = api.enrichment.upsertEntity({ id: data.id, ...updatedData }); - await refetch(); + updatedData.other_data.thumbnail = updatedData.thumbnail; + updatedData.other_data.main_image = updatedData.hero; + const resp = api.enrichment.upsertEntity({ + id: data.id, + ...updatedData, + }); + await refetch(); return resp; }); + const model = useMemo(() => { const copy: any = { ...entityModel, @@ -54,6 +68,7 @@ export function EditTopic() { return copy; }, [data]); + if (!data) { return
{t('Loading...')}
; } @@ -76,7 +91,7 @@ export function EditTopic() { { await createNewEntity(input); }} diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/manage-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/manage-topic.tsx index 2a5db0276..80df54d2b 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/manage-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/manage-topic.tsx @@ -16,8 +16,8 @@ export function ManageTopic() { const { data: topicTypeData } = useTopicType(); const site = useSite(); - const label = {data?.label || { none: ['...'] }}; - const topicTypeLabel = {topicTypeData?.label || { none: ['...'] }}; + const label = {data?.title || { none: ['...'] }}; + const topicTypeLabel = {topicTypeData?.title || { none: ['...'] }}; return ( <> From 370ed03b44a22f12d13ab3c1999121f8601cd834 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 26 Feb 2024 17:36:13 +0000 Subject: [PATCH 07/55] fix console log --- .../admin/pages/topics/topic-type/edit-topic-type.tsx | 4 ++-- .../src/frontend/admin/pages/topics/topic/edit-topic.tsx | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx index 0d19eba17..1f54d4200 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx @@ -19,10 +19,10 @@ export function EditTopicType() { const [createNewEntityType, status] = useMutation(async (updatedData: any) => { if (!data) return; - if (data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { + if (updatedData.thumbnail.id && data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); } - if (data.other_data?.main_image?.id !== updatedData.hero.id) { + if (updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { updatedData.hero = ParseEntityMedia(updatedData.hero); } diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx index be91115bd..99b0fe2ee 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx @@ -18,14 +18,10 @@ export function EditTopic() { const [createNewEntity, status] = useMutation(async (updatedData: any) => { if (!data) return; - console.log(data.other_data); - if (updatedData.thumbnail.id && data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { - console.log('1'); updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); } if (updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { - console.log('2'); updatedData.hero = ParseEntityMedia(updatedData.hero); } From fd2ea207dcb191c29daacd1383423d718d157300 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 27 Feb 2024 12:51:42 +0000 Subject: [PATCH 08/55] update search pages to reflect new designs --- .../src/frontend/shared/atoms/SearchBox.tsx | 19 +++-- .../shared/components/SearchFilters.tsx | 2 +- .../site/features/SearchPageFilters.tsx | 40 ++-------- .../site/features/SearchPageSearch.tsx | 73 +++++++++++++++++++ .../src/frontend/site/pages/search.tsx | 7 +- .../src/frontend/site/pages/view-topic.tsx | 2 + services/madoc-ts/translations/en/madoc.json | 5 ++ 7 files changed, 107 insertions(+), 41 deletions(-) create mode 100644 services/madoc-ts/src/frontend/site/features/SearchPageSearch.tsx diff --git a/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx b/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx index 1748e687f..252e544df 100644 --- a/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx +++ b/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx @@ -1,9 +1,11 @@ import React, { useState } from 'react'; import styled, { css } from 'styled-components'; - import { InputBorderless } from '../form/Input'; -import { LinkButton } from '../navigation/Button'; -import { SearchIcon } from '../icons/SearchIcon'; +import { Button, LinkButton } from '../navigation/Button'; +import { CloseIcon } from '../icons/CloseIcon'; +import { useTranslation } from 'react-i18next'; +import { Simulate } from 'react-dom/test-utils'; +import submit = Simulate.submit; const SearchContainer = styled.div<{ $isFocus?: boolean; $isAdmin?: boolean }>` padding: 0.2em 0.4em; @@ -15,6 +17,7 @@ const SearchContainer = styled.div<{ $isFocus?: boolean; $isAdmin?: boolean }>` line-height: 1.3em; width: 100%; max-width: 700px; + min-width: 500px; box-shadow: none; &:focus { border-color: #333; @@ -56,9 +59,10 @@ export const SearchBox: React.FC<{ }> = ({ isAdmin, onSearch, placeholder = 'Search', large = false, value = '' }) => { const [isFocus, setIsFocus] = useState(false); const [searchValue, setSearchValue] = useState(value); + const { t } = useTranslation(); return (
{ ev.preventDefault(); onSearch(searchValue); @@ -74,10 +78,13 @@ export const SearchBox: React.FC<{ onChange={(e: any) => setSearchValue(e.target.value)} placeholder={placeholder} /> - - + setSearchValue('')} style={{ display: 'flex', alignItems: 'center' }}> + + ); }; diff --git a/services/madoc-ts/src/frontend/shared/components/SearchFilters.tsx b/services/madoc-ts/src/frontend/shared/components/SearchFilters.tsx index ba72462d2..fa226fbf2 100644 --- a/services/madoc-ts/src/frontend/shared/components/SearchFilters.tsx +++ b/services/madoc-ts/src/frontend/shared/components/SearchFilters.tsx @@ -2,7 +2,7 @@ import styled, { css } from 'styled-components'; export const SearchFilterContainer = styled.div` width: 100%; - padding-right: 1em; + padding-right: 2em; `; export const SearchFilterCheckbox = styled.div` diff --git a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx index b58ac9e39..8b6829bae 100644 --- a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx +++ b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx @@ -9,7 +9,7 @@ import { SearchFilterLabel, SearchFilterTitle, } from '../../shared/components/SearchFilters'; -import { ButtonRow, TinyButton } from '../../shared/navigation/Button'; +import { Button, ButtonRow, TextButton, TinyButton } from '../../shared/navigation/Button'; import { LocaleString } from '../../shared/components/LocaleString'; import { useSearchQuery } from '../hooks/use-search-query'; import { useSearchFacets } from '../hooks/use-search-facets'; @@ -58,39 +58,13 @@ export const SearchPageFilters: React.FC = ({ checkBoxCo {filterHeader} - - - - { - setResourceType(val || ''); - }} - options={[ - { - value: '', - text: 'All', - }, - { - value: 'manifest', - text: 'Documents', - }, - { - value: 'canvas', - text: 'Pages', - }, - ]} - /> - - - applyAllFacets()}> - {t('Apply')} - - clearAllFacets()}> + + + {displayFacets?.map(facet => { diff --git a/services/madoc-ts/src/frontend/site/features/SearchPageSearch.tsx b/services/madoc-ts/src/frontend/site/features/SearchPageSearch.tsx new file mode 100644 index 000000000..a96c63289 --- /dev/null +++ b/services/madoc-ts/src/frontend/site/features/SearchPageSearch.tsx @@ -0,0 +1,73 @@ +import React from 'react'; +import styled from 'styled-components'; +import { useTranslation } from 'react-i18next'; +import { useSearchQuery } from '../hooks/use-search-query'; +import { useSearchFacets } from '../hooks/use-search-facets'; +import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; +import { SearchBox } from '../../shared/atoms/SearchBox'; +import { Dropdown } from '../../shared/capture-models/editor/atoms/Dropdown'; + +const SearchBoxContainer = styled.div` + display: flex; + justify-content: space-between; + align-items: center; +`; + +const DropdownContainer = styled.div` + margin: 1em 1em 1em 0; + font-size: 0.9em; + font-weight: 400; + min-width: 250px; + + & strong { + font-size: 0.9em; + font-weight: 400; + } +`; + +export const SearchPageSearch: React.FC = () => { + const { t } = useTranslation(); + const { fulltext, rscType } = useSearchQuery(); + + const { setFullTextQuery, setResourceType } = useSearchFacets(); + + return ( + + + + + { + setResourceType(val || ''); + }} + options={[ + { + value: '', + text: 'All results', + }, + { + value: 'manifest', + text: 'Documents', + }, + { + value: 'canvas', + text: 'Pages', + }, + ]} + /> + + + ); +}; + +blockEditorFor(SearchPageSearch, { + label: 'Search Page Search', + type: 'default.SearchPageSearch', + anyContext: ['collection', 'manifest', 'canvas', 'project', 'topic', 'topicType'], + requiredContext: ['page'], + defaultProps: {}, + editor: {}, +}); diff --git a/services/madoc-ts/src/frontend/site/pages/search.tsx b/services/madoc-ts/src/frontend/site/pages/search.tsx index 5bd77bb16..f4d764b0d 100644 --- a/services/madoc-ts/src/frontend/site/pages/search.tsx +++ b/services/madoc-ts/src/frontend/site/pages/search.tsx @@ -7,6 +7,7 @@ import { SearchPageResults } from '../features/SearchPageResults'; import { DisplayBreadcrumbs } from '../../shared/components/Breadcrumbs'; import { SearchHeading } from '../features/SearchPageHeading'; import { AutoSlotLoader } from '../../shared/page-blocks/auto-slot-loader'; +import { SearchPageSearch } from '../features/SearchPageSearch'; export const Search = () => { return ( @@ -27,12 +28,16 @@ export const Search = () => {
+ + + + + - diff --git a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx index edc9e76a9..2c8b6b5aa 100644 --- a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx +++ b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx @@ -11,6 +11,7 @@ import { TopicActions } from '../features/TopicActions'; import { TopicAuthorities } from '../features/TopicAuthorities'; import { TopicHeroImage } from '../features/TopicHeroImage'; import { SearchPageResults } from '../features/SearchPageResults'; +import { SearchPageSearch } from '../features/SearchPageSearch'; import { useTopic } from './loaders/topic-loader'; export const ViewTopic = () => { const { data } = useTopic(); @@ -52,6 +53,7 @@ export const ViewTopic = () => {
+ diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index d42bcfe5c..767fa193b 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -80,6 +80,7 @@ "Annotations": "Annotations", "Appearance of the container": "Appearance of the container", "Apply": "Apply", + "Apply filters": "Apply filters", "Approvals required": "Approvals required", "Approve": "Approve", "Approve submission": "Approve submission", @@ -155,6 +156,7 @@ "Change the background of the deep zoom viewer": "Change the background of the deep zoom viewer", "Changes requested on your submission": "Changes requested on your submission", "Changes saved": "Changes saved", + "Check box color": "Check box color", "Checkbox options (value,label one per line)": "Checkbox options (value,label one per line)", "Choice": "Choice", "Choose": "Choose", @@ -643,6 +645,7 @@ "Page {{page}} of {{count}}": "Page {{page}} of {{count}}", "Page {{page}} of {{count}}_plural": "Page {{page}} of {{count}}", "Pagination Numbered": "Pagination Numbered", + "Pagination as Numbered?": "Pagination as Numbered?", "Panel alignment": "Panel alignment", "Part of this page crashed": "Part of this page crashed", "Password": "Password", @@ -1029,6 +1032,7 @@ "featured resource": "featured resource", "featured resources": "featured resources", "featured topics": "featured topics", + "filter header": "filter header", "generate pdf": "generate pdf", "height (px)": "height (px)", "help__flat_collection": "This shows all of the collections and manifests in your project. When you add a collection you will see all off the manifests inside of the collection are added to this view. When you remove a collection you will have to also manually remove any manifests you want to remove.", @@ -1072,6 +1076,7 @@ "remove": "remove", "requiredStatement": "requiredStatement", "resources tagged": "resources tagged", + "s": "s", "search index": "search index", "size": "size", "slug": "slug", From 6460c65a3550e48e2d97288ea10fef352a1df495 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Thu, 29 Feb 2024 11:43:55 +0000 Subject: [PATCH 09/55] use title plurals for listing --- .../madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx index 9c8fba4b1..145b267d2 100644 --- a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx +++ b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx @@ -79,7 +79,7 @@ export function AllTopicTypeItems(props: AllTopicTypeItemsProps) { {type.label || { en: ['...'] }} - {type.topic_count} {t('Objects')} + {type.topic_count} {type.title} From b3d229f7ec2225ab2b5481ac04dec8f010440db1 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Thu, 29 Feb 2024 13:28:33 +0000 Subject: [PATCH 11/55] 2 types in a row --- .../frontend/site/features/AllTopicTypeItems.tsx | 14 +++++++++++--- .../site/pages/loaders/topic-type-list-loader.tsx | 4 ++-- services/madoc-ts/translations/en/madoc.json | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx index 8e707f20a..d37e4e7d3 100644 --- a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx +++ b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx @@ -10,6 +10,13 @@ import { useRelativeLinks } from '../hooks/use-relative-links'; import styled from 'styled-components'; import { CroppedImage } from '../../shared/atoms/Images'; +const ListWrapper = styled.div` + padding-top: 1em; + display: grid; + grid-template-columns: 1fr 1fr; + gap: 2em; +`; + const TypeCard = styled.div` display: flex; border: 1px solid #002d4b; @@ -17,6 +24,7 @@ const TypeCard = styled.div` margin-bottom: 20px; justify-content: space-evenly; max-height: 250px; + min-width: 45%; `; const TypeText = styled.div` @@ -73,13 +81,13 @@ export function AllTopicTypeItems(props: AllTopicTypeItemsProps) { const createLink = useRelativeLinks(); return ( -
+ {data?.results.map(type => ( {type.label || { en: ['...'] }} - {type.topic_count} {type.title} + {type.topic_count} {type.label || { en: ['...'] }}
+ ); } diff --git a/services/madoc-ts/src/frontend/site/pages/loaders/topic-type-list-loader.tsx b/services/madoc-ts/src/frontend/site/pages/loaders/topic-type-list-loader.tsx index d3baaeace..c742e9772 100644 --- a/services/madoc-ts/src/frontend/site/pages/loaders/topic-type-list-loader.tsx +++ b/services/madoc-ts/src/frontend/site/pages/loaders/topic-type-list-loader.tsx @@ -28,8 +28,8 @@ export const TopicTypeListLoader: UniversalComponent = getKey: (params, query) => { return ['site-topic-types-list', { page: Number(query.page) || 1 }]; }, - getData: async (key, vars, api) => { - return await api.getSiteTopicTypes(vars.page); + getData: (key, vars, api) => { + return api.getSiteTopicTypes(vars.page); }, } ); diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 767fa193b..f9f7db07b 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -348,6 +348,7 @@ "Exit edit": "Exit edit", "Exit edit mode": "Exit edit mode", "Explore all resources": "Explore all resources", + "Explore documents by language": "Explore documents by language", "Export": "Export", "Extra Nav item display text": "Extra Nav item display text", "Extra Nav item slug": "Extra Nav item slug", From 40bb4cc9a7448f05ef83a4f095277339503b1f59 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 1 Mar 2024 13:16:49 +0000 Subject: [PATCH 12/55] single topic block --- .gitignore | 1 + docker-compose.yml | 14 +- .../TopicExplorer/TopicExplorer.tsx | 38 ++-- .../src/extensions/enrichment/extension.ts | 6 +- .../page-blocks/default-definitions.ts | 2 + .../pages/topics/tags/ListManifestTags.tsx | 4 +- .../pages/topics/topic/create-new-topic.tsx | 2 +- .../admin/pages/topics/topic/edit-topic.tsx | 2 +- .../topics/topic/list-topic-resources.tsx | 2 +- .../shared/components/SingleCollection.tsx | 1 - .../shared/components/SingleTopic.tsx | 203 ++++++++++++++++++ .../shared/components/TopicSnippet.tsx | 1 + .../frontend/shared/hooks/use-api-topic.ts | 1 + .../frontend/shared/hooks/use-topic-items.ts | 2 +- .../plugins/external/block-config-for.ts | 4 +- .../site/features/AllTopicTypeItems.tsx | 2 +- services/madoc-ts/translations/en/madoc.json | 4 + 17 files changed, 259 insertions(+), 30 deletions(-) create mode 100644 services/madoc-ts/src/frontend/shared/components/SingleTopic.tsx diff --git a/.gitignore b/.gitignore index 5c9bc915e..06687b84c 100755 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ services/madoc-remix services/madoc-ts/service-jwts/madoc-remix.json e2e/test-fixtures/postgres/default/default.sql .DS_Store +/spotlight-model diff --git a/docker-compose.yml b/docker-compose.yml index 1dab915e8..873b6662e 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -205,7 +205,7 @@ services: condition: service_healthy search: - image: digirati/madoc-enrichment:qa-deploy + image: digirati/madoc-enrichment:latest # build: # context: services/enrichment # dockerfile: Dockerfile @@ -231,9 +231,11 @@ services: - INLINE_WORKER=True - GOOGLE_APPLICATION_CREDENTIALS=/app/starsky_google_credentials - OCR_ENGINE=Google + - DEFAULT_DBPEDIA_URL=http://dbpedia-spotlight/rest links: - shared-postgres - gateway-redis + - spotlight.en # volumes: # - ./services/enrichment/app:/app:delegated ports: @@ -243,3 +245,13 @@ services: sysctls: - net.core.somaxconn=1024 - net.ipv4.tcp_syncookies=0 + + spotlight.en: + image: digirati/spotlight-alpine:multi-platform + container_name: dbpedia-spotlight + volumes: + - ./spotlight-model:/opt/spotlight/models + restart: unless-stopped + ports: + - "2222:80" + command: spotlight.sh en \ No newline at end of file diff --git a/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx b/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx index e33995a43..c55c821b3 100644 --- a/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx +++ b/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx @@ -20,6 +20,7 @@ export type TopicExplorerProps = { value: { slug?: string; id?: string; + type: string; } | null; }; @@ -34,7 +35,6 @@ export const TopicExplorer: FieldComponent = ({ value, updat return api.enrichment.entityAutoComplete(topicType, '', page); }, { - enabled: !!topicType, getFetchMore: lastPage => { if (lastPage.pagination.totalPages === lastPage.pagination.page) { return undefined; @@ -69,19 +69,21 @@ export const TopicExplorer: FieldComponent = ({ value, updat {pages?.map((page, key) => { return ( - {page.results.map(item => ( - { - updateValue({ slug: item.slug, id: item.id }); - }} - > - {item.title} - {item.label} - - ))} + {page.results.map(item => { + return ( + { + updateValue({ slug: item.slug, id: item.id, type: item.type_slug }); + }} + > + {item.title} + {item.label} + + ); + })} ); })} @@ -98,16 +100,18 @@ export const GetTopic: React.FC<{ value: | { slug?: string; + type?: string; id?: string; } | string; }> = ({ value }) => { - const { topicType } = useParams>(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const slug = !value.slug && typeof value === 'string' ? value : value.slug; - const { data } = useApiTopic(topicType, slug); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const type = !value.type && typeof value === 'string' ? value : value.type; + const { data } = useApiTopic(type, slug); if (data) { return ; diff --git a/services/madoc-ts/src/extensions/enrichment/extension.ts b/services/madoc-ts/src/extensions/enrichment/extension.ts index e3e76e1b0..512e99ced 100644 --- a/services/madoc-ts/src/extensions/enrichment/extension.ts +++ b/services/madoc-ts/src/extensions/enrichment/extension.ts @@ -149,12 +149,12 @@ export class EnrichmentExtension extends BaseDjangoExtension { // Entity - List, filtered by chosen Entity Type getEntities(slug: string, page?: number) { - return this.api.request(`/api/enrichment/entity/${slug}/?page=${page}`); + return this.api.request(`/api/enrichment/entity/${slug}/?page=${page}`); } // Entity - Retrieve getEntity(entity_type_slug: string, slug: string) { - return this.api.request(`/api/enrichment/entity/${entity_type_slug}/${slug}/`); + return this.api.request(`/api/enrichment/entity/${entity_type_slug}/${slug}/`); } // Entity - Upsert @@ -175,7 +175,7 @@ export class EnrichmentExtension extends BaseDjangoExtension { } // Entity - Autocomplete Search - entityAutoComplete(type: string, fullText: string, page = 1) { + entityAutoComplete(type?: string, fullText: string, page = 1) { return this.api.request(`/api/enrichment/entity_autocomplete/?${stringify({ page })}`, { method: 'POST', body: { diff --git a/services/madoc-ts/src/extensions/page-blocks/default-definitions.ts b/services/madoc-ts/src/extensions/page-blocks/default-definitions.ts index 424dfe98c..6fe84c5ed 100644 --- a/services/madoc-ts/src/extensions/page-blocks/default-definitions.ts +++ b/services/madoc-ts/src/extensions/page-blocks/default-definitions.ts @@ -11,6 +11,7 @@ import simpleMarkdownBlock from './simple-markdown-block/simple-markdown-block'; import { EmbedItem } from '../../frontend/site/features/EmbedItem'; import { SiteLogoNavItem } from '../../frontend/shared/components/SiteLogoNavItem'; import { DropDownMenu } from '../../frontend/site/features/DropdownMenu'; +import { SingleTopic } from '../../frontend/shared/components/SingleTopic'; export function getDefaultPageBlockDefinitions(): PageBlockDefinition[] { return [ @@ -27,5 +28,6 @@ export function getDefaultPageBlockDefinitions(): PageBlockDefinition(); const [selectedId, setSelectedId] = useState(undefined); - const onSelect = (id: string | undefined) => { - setSelectedId(id); + const onSelect = (i: string | undefined) => { + setSelectedId(i); }; const [createTag, createTagStatus] = useMutation(async (entityId: string) => { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx index 08eda1bf9..725080fd9 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx @@ -94,7 +94,7 @@ export function CreateNewTopic() { } return ( -
+
{t('Create new Topic')} {status.isError && {t('Error...')}} diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx index 99b0fe2ee..c5341b7ea 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx @@ -82,7 +82,7 @@ export function EditTopic() { } return ( -
+
{status.isError && {t('Error...')}} { diff --git a/services/madoc-ts/src/frontend/shared/components/SingleCollection.tsx b/services/madoc-ts/src/frontend/shared/components/SingleCollection.tsx index c53c3d75e..fbf82a812 100644 --- a/services/madoc-ts/src/frontend/shared/components/SingleCollection.tsx +++ b/services/madoc-ts/src/frontend/shared/components/SingleCollection.tsx @@ -2,7 +2,6 @@ import { InternationalString } from '@iiif/presentation-3'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; -import styled from 'styled-components'; import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; import { CollectionFull } from '../../../types/schemas/collection-full'; import { useRelativeLinks } from '../../site/hooks/use-relative-links'; diff --git a/services/madoc-ts/src/frontend/shared/components/SingleTopic.tsx b/services/madoc-ts/src/frontend/shared/components/SingleTopic.tsx new file mode 100644 index 000000000..65d02424b --- /dev/null +++ b/services/madoc-ts/src/frontend/shared/components/SingleTopic.tsx @@ -0,0 +1,203 @@ +import { InternationalString } from '@iiif/presentation-3'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { Link } from 'react-router-dom'; +import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; +import { useRelativeLinks } from '../../site/hooks/use-relative-links'; +import { CroppedImage } from '../atoms/Images'; +import { ImageStrip, ImageStripBox } from '../atoms/ImageStrip'; +import { ObjectContainer } from '../atoms/ObjectContainer'; +import { SnippetLarge } from '../atoms/SnippetLarge'; +import { useAccessibleColor } from '../hooks/use-accessible-color'; +import { Button, ButtonRow } from '../navigation/Button'; +import { MoreContainer, MoreDot, MoreIconContainer, MoreLabel } from '../navigation/MoreButton'; +import { Heading3, Subheading3 } from '../typography/Heading3'; +import { SingleLineHeading5, Subheading5 } from '../typography/Heading5'; +import { HrefLink } from '../utility/href-link'; +import { LocaleString, useCreateLocaleString } from './LocaleString'; +import { Topic } from '../../../types/schemas/topics'; +import { useTopicItems } from '../hooks/use-topic-items'; +import { extractIdFromUrn } from '../../../utility/parse-urn'; + +interface SingleTopicProps { + customButtonLabel?: InternationalString; + topic?: { id: string; slug: string; type: string }; + background?: string; + data?: Topic; + radius?: string; + snippet?: boolean; + imageStyle?: string; + cardBackground?: string; + textColor?: string; + cardBorder?: string; +} +export function SingleTopic(props: SingleTopicProps) { + const { t } = useTranslation(); + const createLink = useRelativeLinks(); + const createLocaleString = useCreateLocaleString(); + const { data, customButtonLabel } = props; + const accessibleTextColor = useAccessibleColor(props.background || '#eeeeee'); + const radius = props.radius ? parseInt(props.radius, 10) : undefined; + const [{ data: topicItems, isLoading }] = useTopicItems(props.topic?.slug); + + if (!props.topic || !data || !topicItems) { + return null; + } + + if (!props.snippet) { + return ( + + + + {data.title} + + + {t('{{count}} items', { count: data.tagged_resource_count })} + {topicItems.pagination.totalResults === 0 ? null : ( + + {topicItems.results.slice(0, 6).map((item: any) => { + return ( + e.includes('canvas'))), + manifestId: extractIdFromUrn(item.contexts.find((e: string) => e.includes('manifest'))), + })} + key={item.id} + > + + + {item.madoc_thumbnail ? ( + {createLocaleString(item.label, + ) : null} + + {item.label} + {item.canvasCount && ( + {t('{{count}} images', { count: item.canvasCount })} + )} + + + ); + })} + {topicItems.results.length > 6 ? ( +
+ + + + + + + + + {t('{{count}} more', { + count: topicItems.pagination.totalResults - 6, + })} + + + +
+ ) : null} +
+ )} + + + +
+ ); + } + + const thumbnail = data.other_data?.thumbnail?.url + ? data.other_data?.thumbnail?.url + : data.other_data?.main_image?.url; + + return ( + {data.label}} + subtitle={t('topic with {{count}} ', { count: data.tagged_resource_count })} + summary={{data.description}} + linkAs={HrefLink} + thumbnail={thumbnail} + buttonText={customButtonLabel ? {customButtonLabel} : t('view topic')} + link={createLink({ topic: data.id })} + {...props} + /> + ); +} + +// @ts-ignore +blockEditorFor(SingleTopic, { + label: 'Single topic', + type: 'SingleTopic', + defaultProps: { + customButtonLabel: '', + topic: null, + background: null, + radius: null, + snippet: false, + cardBackground: '', + textColor: '', + cardBorder: '', + imageStyle: 'fit', + }, + hooks: [ + { + name: 'getSiteTopic', + creator: props => { + return props.topic ? [props.topic.type, props.topic.slug] : undefined; + }, + mapToProps: (props, data) => { + return { ...props, data }; + }, + }, + ], + editor: { + customButtonLabel: { type: 'text-field', label: 'Custom button label' }, + background: { type: 'color-field', label: 'Background color', defaultValue: '#eeeeee' }, + radius: { type: 'text-field', label: 'Border radius', defaultValue: '' }, + topic: { + label: 'Topic', + type: 'topic-explorer', + }, + snippet: { type: 'checkbox-field', label: 'Layout', inlineLabel: 'Show as snippet' }, + cardBackground: { label: 'Card background color', type: 'color-field' }, + textColor: { label: 'Card text color', type: 'color-field' }, + cardBorder: { label: 'Card border', type: 'color-field' }, + imageStyle: { + label: 'Image Style', + type: 'dropdown-field', + options: [ + { value: 'covered', text: 'covered' }, + { value: 'fit', text: 'fit' }, + ], + }, + }, + requiredContext: [], + anyContext: [], +}); diff --git a/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx b/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx index 2e305238b..46b8c58a1 100644 --- a/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx +++ b/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx @@ -52,6 +52,7 @@ export const TopicSnippetCard: React.FC<{ const createLocaleString = useCreateLocaleString(); const { t } = useTranslation(); + console.log('hello?'); return ( { return api.getSearchQuery( { diff --git a/services/madoc-ts/src/frontend/shared/plugins/external/block-config-for.ts b/services/madoc-ts/src/frontend/shared/plugins/external/block-config-for.ts index 9608efa3f..cfd05cdd8 100644 --- a/services/madoc-ts/src/frontend/shared/plugins/external/block-config-for.ts +++ b/services/madoc-ts/src/frontend/shared/plugins/external/block-config-for.ts @@ -22,7 +22,9 @@ export function blockConfigFor(Component: any, model: any) { const query = useQuery( [hook.name, args], async () => { - return (api as any)[hook.name](args) as any; + if (typeof args !== 'undefined') { + return (api as any)[hook.name](...args) as any; + } }, { enabled: typeof args !== 'undefined', diff --git a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx index d37e4e7d3..8c661a991 100644 --- a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx +++ b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx @@ -90,7 +90,7 @@ export function AllTopicTypeItems(props: AllTopicTypeItemsProps) { {type.topic_count} {type.label || { en: ['...'] }} diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index f9f7db07b..c9fa84f32 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -347,6 +347,7 @@ "Errored / Rejected": "Errored / Rejected", "Exit edit": "Exit edit", "Exit edit mode": "Exit edit mode", + "Explore": "Explore", "Explore all resources": "Explore all resources", "Explore documents by language": "Explore documents by language", "Export": "Export", @@ -1091,6 +1092,8 @@ "to make changes": "to make changes", "topic": "topic", "topic types": "topic types", + "topic with {{count}} ": "topic with {{count}} ", + "topic with {{count}} _plural": "topic with {{count}} ", "topics": "topics", "total topic types": "total topic types", "total topics": "total topics", @@ -1102,6 +1105,7 @@ "view canvas": "view canvas", "view collection": "view collection", "view manifest": "view manifest", + "view topic": "view topic", "waiting": "waiting", "waiting for canvases": "waiting for canvases", "width (px)": "width (px)", From 3450589298bd4422db32cd206cce29467824fc04 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 1 Mar 2024 13:28:35 +0000 Subject: [PATCH 13/55] add opacity option to crowdsourcing banner --- .../frontend/shared/components/CrowdSourcingBanner.tsx | 9 +++++++-- services/madoc-ts/translations/en/madoc.json | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx b/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx index 637cec198..1920ea0ae 100644 --- a/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx +++ b/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx @@ -9,6 +9,7 @@ export type CrowdSourcingBannerProps = { buttonLink?: string; buttonLabel?: string; height?: number; + shadowOpacity: string; image: { id: string; image: string; @@ -31,8 +32,9 @@ const MastheadMain = styled.div` position: relative; `; -const MastheadIntro = styled.div<{ $right?: boolean; $height?: string }>` - background-color: rgba(51, 51, 51, 0.8); +const MastheadIntro = styled.div<{ $right?: boolean; $height?: string; $opacity?: string; $width?: string }>` + //background-color: rgba(51, 51, 51, 0.8); + background-color: ${props => (props.$opacity ? ` rgba(0,0,0, ${props.$opacity});` : 'rgba(51, 51, 51,0.8)')}; padding: 20px; width: 33.3333333333%; min-height: ${props => props.$height || '550px'}; @@ -74,6 +76,7 @@ export const CrowdSourcingBanner: React.FC = props => {props.title || props.description || props.buttonLink ? ( @@ -102,6 +105,7 @@ blockEditorFor(CrowdSourcingBanner, { panelAlignment: 'left', buttonLabel: '', buttonLink: '', + shadowOpacity: '', }, svgIcon: props => ( @@ -124,6 +128,7 @@ blockEditorFor(CrowdSourcingBanner, { { value: 'right', text: 'Right aligned' }, ], }, + shadowOpacity: { type: 'text-field', label: 'Shadow opacity', description: 'as decimal eg 0.5 is 50% opacity' }, image: { label: 'Image', type: 'madoc-media-explorer', diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index c9fa84f32..9b2cabd37 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -759,6 +759,7 @@ "Select project": "Select project", "Select user": "Select user", "Selector is required": "Selector is required", + "Shadow opacity": "Shadow opacity", "Short expiry time (minutes)": "Short expiry time (minutes)", "Show IIIF drag and drop logo": "Show IIIF drag and drop logo", "Show all locales": "Show all locales", @@ -984,6 +985,7 @@ "alignment": "alignment", "alt": "alt", "alt text": "alt text", + "as decimal eg 0.5 is 50% opacity": "as decimal eg 0.5 is 50% opacity", "assigned": "assigned", "assigned to": "assigned to", "atlas__annotations": "Annotations", From 72fa027b9f7b957ae6a273aa221b5858ce5f4490 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 1 Mar 2024 13:33:03 +0000 Subject: [PATCH 14/55] change label to title on item list --- .../src/frontend/site/features/AllTopicTypeItems.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx index 8c661a991..ad8682abd 100644 --- a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx +++ b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx @@ -39,8 +39,8 @@ const TypeText = styled.div` border: 1px solid #002d4b; background-color: white; color: #002d4b; - border-radius: 50px; - padding: 1em; + border-radius: 20px; + padding: 0.8em; margin-top: 1em; &:hover { @@ -87,7 +87,7 @@ export function AllTopicTypeItems(props: AllTopicTypeItemsProps) { {type.label || { en: ['...'] }} - {type.topic_count} {type.label || { en: ['...'] }} + {type.topic_count} {type.title || { en: ['...'] }} + + + +
+ + + {searchResults.map((result: SearchResult, index: number) => { + return result ? ( + + ) : null; + })} + + + + ); +}; + +blockEditorFor(TopicPageResults, { + label: 'topic Page Results', + type: 'default.TopicPageResults', + anyContext: ['topic', 'topicType'], + requiredContext: ['page'], + defaultProps: { + background: '', + snippet: '', + textColor: '', + cardBorder: '', + imageStyle: 'fit', + }, + editor: { + snippet: { type: 'checkbox-field', label: 'Snippet', inlineLabel: 'Hide snippet?' }, + background: { label: 'Card background color', type: 'color-field' }, + textColor: { label: 'Card text color', type: 'color-field' }, + cardBorder: { label: 'Card border', type: 'color-field' }, + imageStyle: { + label: 'Image Style', + type: 'dropdown-field', + options: [ + { value: 'covered', text: 'covered' }, + { value: 'fit', text: 'fit' }, + ], + }, + }, +}); diff --git a/services/madoc-ts/src/frontend/site/hooks/use-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-search.ts index 6be0454a5..e36cb5fc8 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-search.ts @@ -19,11 +19,8 @@ export function useSearch() { const { searchMultipleFields, nonLatinFulltext, onlyShowManifests } = searchOptions || {}; const searchFacetConfig = apiHooks.getSiteSearchFacetConfiguration(() => []); - console.log('topic:', topic); - console.log('isLoading', searchFacetConfig.isLoading); - useEffect(() => { - if (topic) { + if ((topic && !appliedFacets.length) || topic) { appliedFacets.push({ k: 'entity', v: topic, t: 'entity' }); } return; diff --git a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts new file mode 100644 index 000000000..f0fff8a89 --- /dev/null +++ b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts @@ -0,0 +1,220 @@ +import { InternationalString } from '@iiif/presentation-3'; +import { useMemo } from 'react'; +import { FacetConfig } from '../../shared/components/MetadataFacetEditor'; +import { apiHooks, paginatedApiHooks } from '../../shared/hooks/use-api-query'; +import { useSiteConfiguration } from '../features/SiteConfigurationContext'; +import { useRouteContext } from './use-route-context'; +import { useSearchQuery } from './use-search-query'; + +function normalizeDotKey(key: string) { + return key.startsWith('metadata.') ? key.slice('metadata.'.length).toLowerCase() : key.toLowerCase(); +} + +export function useTopicSearch() { + const { topic } = useRouteContext(); + const { fulltext, appliedFacets, page, rscType } = useSearchQuery(); + const { + project: { searchStrategy, claimGranularity, searchOptions }, + } = useSiteConfiguration(); + const { searchMultipleFields, nonLatinFulltext, onlyShowManifests } = searchOptions || {}; + const searchFacetConfig = apiHooks.getSiteSearchFacetConfiguration(() => []); + + const [facetsToRequest, facetDisplayOrder, facetIdMap] = useMemo(() => { + const facets = !topic && searchFacetConfig.data ? searchFacetConfig.data.facets : []; + const returnList: string[] = []; + const idMap: { [id: string]: { config: FacetConfig; keys: string[] } } = {}; + const displayOrder: string[] = []; + + for (const facet of facets) { + displayOrder.push(facet.id); + idMap[facet.id] = { config: facet, keys: [] }; + if (facet.keys) { + for (const key of facet.keys) { + const keyToAdd = normalizeDotKey(key); + idMap[facet.id].keys.push(keyToAdd); + if (returnList.indexOf(keyToAdd) === -1) { + returnList.push(keyToAdd); + } + } + } + } + return [returnList, displayOrder, idMap]; + }, [searchFacetConfig.data, topic]); + + const topicFacets = appliedFacets.map(facet => { + return facet.k === 'entity' + ? { + type: 'entity', + group_id: facet.v, + } + : { + type: facet.t, + subtype: facet.k, + value: facet.v, + }; + }); + + const searchResults = paginatedApiHooks.getSiteSearchQuery( + () => [ + { + fulltext: fulltext, + facet_fields: facetsToRequest.length ? facetsToRequest : undefined, + // @todo stringify facets. + facets: [...topicFacets, { type: 'entity', group_id: topic || '' }], + resource_type: rscType, + facet_on_manifests: true, + search_type: searchStrategy as any, + number_of_facets: searchFacetConfig.data?.facets.length ? 100 : undefined, + iiif_type: claimGranularity === 'manifest' || onlyShowManifests ? 'Manifest' : undefined, + non_latin_fulltext: nonLatinFulltext, + search_multiple_fields: searchMultipleFields, + }, + page, + ], + { + enabled: + !searchFacetConfig.isLoading && + (!!facetsToRequest.length || !!fulltext || fulltext === '' || !!topicFacets || !!rscType || !!topic), + staleTime: 0, + } + ); + + const displayFacets = useMemo(() => { + const mappedSearchResponseMetadata: { + [key: string]: Array<{ key: string; value: string; count: number; configuration?: FacetConfig }>; + } = {}; + + const metadataFacets = searchResults.resolvedData?.facets?.metadata || {}; + const entityFacets = searchResults.resolvedData?.facets?.entity || {}; + + for (const mfacet of Object.keys(metadataFacets)) { + const values = Object.keys(metadataFacets[mfacet]); + const normalisedKey = mfacet.toLowerCase(); + + if (metadataFacets) { + facetIdMap[mfacet] = { + config: { + keys: [mfacet], + values: [], + label: { none: [mfacet] }, + id: mfacet, + type: 'metadata', + }, + keys: [mfacet], + }; + facetDisplayOrder.push(mfacet); + } + for (const value of values) { + mappedSearchResponseMetadata[normalisedKey] = mappedSearchResponseMetadata[normalisedKey] + ? mappedSearchResponseMetadata[normalisedKey] + : []; + mappedSearchResponseMetadata[normalisedKey].push({ + value, + count: metadataFacets[mfacet] ? (metadataFacets[mfacet] as any)[value] || 0 : 0, + key: normalisedKey, + }); + } + } + + for (const efacet of Object.keys(entityFacets)) { + const values = Object.keys(entityFacets[efacet]); + const normalisedKey = efacet.toLowerCase(); + + if (entityFacets) { + facetIdMap[efacet] = { + config: { + keys: [efacet], + values: [], + label: { none: [efacet] }, + id: efacet, + type: 'entity', + }, + keys: [efacet], + }; + facetDisplayOrder.push(efacet); + } + for (const value of values) { + mappedSearchResponseMetadata[normalisedKey] = mappedSearchResponseMetadata[normalisedKey] + ? mappedSearchResponseMetadata[normalisedKey] + : []; + mappedSearchResponseMetadata[normalisedKey].push({ + value, + count: entityFacets[efacet] ? (entityFacets[efacet] as any)[value] || 0 : 0, + key: normalisedKey, + }); + } + } + + // Compile the final list. + const displayList: Array<{ + id: string; + label: InternationalString; + items: Array<{ + type?: string; + key: string; + label: InternationalString; + values: string[]; + count: number; + }>; + }> = []; + + for (const id of facetDisplayOrder) { + const fieldsToMap = facetIdMap[id]; + const displayItem: { + id: string; + label: InternationalString; + items: Array<{ + key: string; + label: InternationalString; + values: string[]; + count: number; + type?: string; + }>; + } = { + id: id, + label: fieldsToMap.config.label, + items: [], + }; + + if (fieldsToMap.config.values && fieldsToMap.config.values.length) { + for (const value of fieldsToMap.config.values) { + const key = fieldsToMap.keys[0]; + const mappedCount = (mappedSearchResponseMetadata[key] || []).reduce((count: number, next) => { + if (next.key === key && value.values.indexOf(next.value) !== -1) { + return count + next.count; + } + return count; + }, 0); + displayItem.items.push({ + values: value.values, + key: normalizeDotKey(fieldsToMap.keys[0]), + count: mappedCount, + label: value.label, + type: fieldsToMap.config.type, + }); + } + } else { + for (const field of fieldsToMap.keys) { + const normalisedField = field.toLowerCase(); + const searchResultFacetValues = mappedSearchResponseMetadata[normalisedField]; + if (searchResultFacetValues) { + displayItem.items.push( + ...searchResultFacetValues.map(fieldValue => ({ + label: { none: [fieldValue.value] }, + key: fieldValue.key, + values: [fieldValue.value], + count: fieldValue.count, + type: fieldsToMap.config.type, + })) + ); + } + } + } + // @todo fieldsToMap.config.value + displayList.push(displayItem); + } + + return displayList; + }, [facetDisplayOrder, facetIdMap, searchResults.resolvedData]); + return [searchResults, displayFacets, searchFacetConfig.isLoading || searchResults.isLoading] as const; +} diff --git a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx index 2c8b6b5aa..e74e2d289 100644 --- a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx +++ b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx @@ -13,6 +13,7 @@ import { TopicHeroImage } from '../features/TopicHeroImage'; import { SearchPageResults } from '../features/SearchPageResults'; import { SearchPageSearch } from '../features/SearchPageSearch'; import { useTopic } from './loaders/topic-loader'; +import { TopicPageResults } from '../features/TopicPageResults'; export const ViewTopic = () => { const { data } = useTopic(); return ( @@ -55,7 +56,7 @@ export const ViewTopic = () => { - + From 77d6e806f81f50d41daeec8a5e51080c35c80685 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 4 Mar 2024 17:22:58 +0000 Subject: [PATCH 33/55] padding option crowdsourcing banner --- .../shared/components/CrowdSourcingBanner.tsx | 14 ++++++++++++-- services/madoc-ts/translations/en/madoc.json | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx b/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx index 1920ea0ae..f23b9a387 100644 --- a/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx +++ b/services/madoc-ts/src/frontend/shared/components/CrowdSourcingBanner.tsx @@ -10,6 +10,7 @@ export type CrowdSourcingBannerProps = { buttonLabel?: string; height?: number; shadowOpacity: string; + padding?: string; image: { id: string; image: string; @@ -32,10 +33,16 @@ const MastheadMain = styled.div` position: relative; `; -const MastheadIntro = styled.div<{ $right?: boolean; $height?: string; $opacity?: string; $width?: string }>` +const MastheadIntro = styled.div<{ + $right?: boolean; + $height?: string; + $opacity?: string; + $width?: string; + $padding?: string; +}>` //background-color: rgba(51, 51, 51, 0.8); background-color: ${props => (props.$opacity ? ` rgba(0,0,0, ${props.$opacity});` : 'rgba(51, 51, 51,0.8)')}; - padding: 20px; + padding: ${props => (props.$padding ? props.$padding : '20px')}; width: 33.3333333333%; min-height: ${props => props.$height || '550px'}; ${props => @@ -79,6 +86,7 @@ export const CrowdSourcingBanner: React.FC = props => $opacity={props.shadowOpacity} $height={props.height ? `${props.height}px` : undefined} $right={props.panelAlignment === 'right'} + $padding={props.padding ? `${props.padding}px` : undefined} > {props.title} {props.description} @@ -106,6 +114,7 @@ blockEditorFor(CrowdSourcingBanner, { buttonLabel: '', buttonLink: '', shadowOpacity: '', + padding: '', }, svgIcon: props => ( @@ -134,6 +143,7 @@ blockEditorFor(CrowdSourcingBanner, { type: 'madoc-media-explorer', }, height: { type: 'text-field', label: 'Height (number)' }, + padding: { type: 'text-field', label: 'Padding (number)' }, buttonLabel: { type: 'text-field', label: 'Button label' }, buttonLink: { type: 'text-field', label: 'Button link' }, }, diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 9b2cabd37..d5b29473f 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -638,6 +638,7 @@ "Overview": "Overview", "PART OF": "PART OF", "PART OFs": "PART OFs", + "Padding (number)": "Padding (number)", "Padding around logo": "Padding around logo", "Padding size": "Padding size", "Page blocks": "Page blocks", From cb17aa608391b0f9dc6d040cab8d35f36c1bdfa9 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 5 Mar 2024 11:25:48 +0000 Subject: [PATCH 34/55] tidy up and fix view in search --- .../frontend/shared/hooks/use-topic-items.ts | 1 - .../frontend/site/features/TopicActions.tsx | 6 ++-- .../src/frontend/site/hooks/use-search.ts | 30 ++----------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/hooks/use-topic-items.ts b/services/madoc-ts/src/frontend/shared/hooks/use-topic-items.ts index 0fff86bed..e5e3de618 100644 --- a/services/madoc-ts/src/frontend/shared/hooks/use-topic-items.ts +++ b/services/madoc-ts/src/frontend/shared/hooks/use-topic-items.ts @@ -1,7 +1,6 @@ import { usePaginatedQuery } from 'react-query'; import { useApi } from './use-api'; import { useSearchQuery } from '../../site/hooks/use-search-query'; -import { apiHooks } from './use-api-query'; export function useTopicItems(slug?: string) { const api = useApi(); diff --git a/services/madoc-ts/src/frontend/site/features/TopicActions.tsx b/services/madoc-ts/src/frontend/site/features/TopicActions.tsx index f1ec21a08..4ab9e309d 100644 --- a/services/madoc-ts/src/frontend/site/features/TopicActions.tsx +++ b/services/madoc-ts/src/frontend/site/features/TopicActions.tsx @@ -8,6 +8,7 @@ import { Link } from 'react-router-dom'; import { createLink } from '../../shared/utility/create-link'; import styled from 'styled-components'; import { useTopic } from '../pages/loaders/topic-loader'; +import { useSearchQuery } from '../hooks/use-search-query'; const TopicActionWrapper = styled.div` display: flex; @@ -21,12 +22,14 @@ export const TopicActions: React.FC = ({ alignment }) => { const { t } = useTranslation(); const router = useRouteContext(); const query = useLocationQuery(); + const { appliedFacets } = useSearchQuery(); const { data } = useTopic(); + query.facets = !appliedFacets.length ? JSON.stringify([{ k: 'entity', v: router.topic, t: 'entity' }]) : query.facets; + return (

{t('Explore all resources')}

- {/*might be more to add here in the future */} {data && ( )} diff --git a/services/madoc-ts/src/frontend/site/hooks/use-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-search.ts index e36cb5fc8..c67e72649 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-search.ts @@ -1,5 +1,5 @@ import { InternationalString } from '@iiif/presentation-3'; -import { useEffect, useMemo } from 'react'; +import { useMemo } from 'react'; import { FacetConfig } from '../../shared/components/MetadataFacetEditor'; import { apiHooks, paginatedApiHooks } from '../../shared/hooks/use-api-query'; import { useSiteConfiguration } from '../features/SiteConfigurationContext'; @@ -19,13 +19,6 @@ export function useSearch() { const { searchMultipleFields, nonLatinFulltext, onlyShowManifests } = searchOptions || {}; const searchFacetConfig = apiHooks.getSiteSearchFacetConfiguration(() => []); - useEffect(() => { - if ((topic && !appliedFacets.length) || topic) { - appliedFacets.push({ k: 'entity', v: topic, t: 'entity' }); - } - return; - }, [appliedFacets, topic]); - const [facetsToRequest, facetDisplayOrder, facetIdMap] = useMemo(() => { const facets = !topic && searchFacetConfig.data ? searchFacetConfig.data.facets : []; const returnList: string[] = []; @@ -48,7 +41,7 @@ export function useSearch() { return [returnList, displayOrder, idMap]; }, [searchFacetConfig.data, topic]); - const topicFacets = appliedFacets.map(facet => { + const facets = appliedFacets.map(facet => { return facet.k === 'entity' ? { type: 'entity', @@ -61,14 +54,6 @@ export function useSearch() { }; }); - const searchQFacets = appliedFacets.map(facet => ({ - type: facet.t, - subtype: facet.k, - value: facet.v, - })); - - const facets = topic ? topicFacets : searchQFacets; - const waitForTopic = topic ? !!facets.length : true; const searchResults = paginatedApiHooks.getSiteSearchQuery( () => [ { @@ -92,7 +77,6 @@ export function useSearch() { { enabled: !searchFacetConfig.isLoading && - waitForTopic && (!!facetsToRequest.length || !!fulltext || fulltext === '' || @@ -100,9 +84,7 @@ export function useSearch() { !!rscType || collectionId || manifestId || - projectId || - !!topic), - staleTime: 0, + projectId), } ); @@ -133,12 +115,6 @@ export function useSearch() { const metadataFacets = searchResults.resolvedData?.facets?.metadata || {}; const entityFacets = searchResults.resolvedData?.facets?.entity || {}; - // const facetType = { ...metadataFacets, ...entityFacets }; - const showAllFacets = facetDisplayOrder.length === 0; - // for (const facet of Object.keys(facetType)) { - // const values = Object.keys(facetType[facet]); - // const normalisedKey = facet.toLowerCase(); - for (const mfacet of Object.keys(metadataFacets)) { const values = Object.keys(metadataFacets[mfacet]); const normalisedKey = mfacet.toLowerCase(); From af3f440ea1cf72cbaafe2e68a29e27ff2b6c7bfa Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 5 Mar 2024 11:50:10 +0000 Subject: [PATCH 35/55] fix cant edit featured topics and cant create topic --- .../capture-models/TopicExplorer/TopicExplorer.tsx | 3 ++- .../admin/pages/topics/topic-type/edit-topic-type.tsx | 9 +++++++-- .../admin/pages/topics/topic/create-new-topic.tsx | 2 +- .../src/frontend/admin/pages/topics/topic/edit-topic.tsx | 2 +- services/madoc-ts/translations/en/madoc.json | 3 +++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx b/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx index c55c821b3..cc26a0d9f 100644 --- a/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx +++ b/services/madoc-ts/src/extensions/capture-models/TopicExplorer/TopicExplorer.tsx @@ -105,12 +105,13 @@ export const GetTopic: React.FC<{ } | string; }> = ({ value }) => { + const { topicType } = useParams>(); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const slug = !value.slug && typeof value === 'string' ? value : value.slug; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const type = !value.type && typeof value === 'string' ? value : value.type; + const type = !value.type && typeof value === 'string' ? topicType : value.type; const { data } = useApiTopic(type, slug); if (data) { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx index 1f54d4200..381c70ebb 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic-type/edit-topic-type.tsx @@ -19,10 +19,14 @@ export function EditTopicType() { const [createNewEntityType, status] = useMutation(async (updatedData: any) => { if (!data) return; - if (updatedData.thumbnail.id && data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { + if ( + updatedData.thumbnail && + updatedData.thumbnail.id && + data.other_data?.thumbnail?.id !== updatedData.thumbnail.id + ) { updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); } - if (updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { + if (updatedData.hero && updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { updatedData.hero = ParseEntityMedia(updatedData.hero); } @@ -39,6 +43,7 @@ export function EditTopicType() { .filter((f: string) => f !== undefined); updatedData.featured_topics = ogIds?.concat(newIds); + return; } updatedData.featured_topics = []; } diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx index 725080fd9..c6f289159 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/create-new-topic.tsx @@ -58,7 +58,7 @@ export function CreateNewTopic() { if (!hasTopic) { // input.type_slug = type?.slug; - input.type_slug = input.type_slug.label; + input.type_slug = input.type_slug.label.toLowerCase(); console.log(input.type_slug); } return { diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx index 1f92694f9..c273a0b67 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/edit-topic.tsx @@ -21,7 +21,7 @@ export function EditTopic() { if (updatedData.thumbnail && data.other_data?.thumbnail?.id !== updatedData.thumbnail.id) { updatedData.thumbnail = ParseEntityMedia(updatedData.thumbnail); } - if (updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { + if (updatedData.hero && updatedData.hero.id && data.other_data?.main_image?.id !== updatedData.hero.id) { updatedData.hero = ParseEntityMedia(updatedData.hero); } diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index d5b29473f..04402e364 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -1008,6 +1008,7 @@ "breadcrumbs__Projects": "Projects", "breadcrumbs__Topics": "Topics", "button background color": "button background color", + "c": "c", "cancel": "cancel", "choose": "choose", "collections": "collections", @@ -1039,6 +1040,7 @@ "featured topics": "featured topics", "filter header": "filter header", "generate pdf": "generate pdf", + "great_depression": "great_depression", "height (px)": "height (px)", "help__flat_collection": "This shows all of the collections and manifests in your project. When you add a collection you will see all off the manifests inside of the collection are added to this view. When you remove a collection you will have to also manually remove any manifests you want to remove.", "help__metadata_facet_editor": "When searching for this, search the above fields with all of these values", @@ -1070,6 +1072,7 @@ "manifests": "manifests", "max contributors": "max contributors", "migrate-capture-model-task": "migrate-capture-model-task", + "navajo_people": "navajo_people", "not found": "not found", "not started": "not started", "other_data": "other_data", From a7327d819e5ec433b31cf919ed0da86a6d97eb7f Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 5 Mar 2024 12:06:33 +0000 Subject: [PATCH 36/55] add subtype topicType to search --- .../madoc-ts/src/frontend/site/features/TopicActions.tsx | 4 +++- .../madoc-ts/src/frontend/site/features/TopicPageResults.tsx | 1 - .../madoc-ts/src/frontend/site/hooks/use-topic-search.ts | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/TopicActions.tsx b/services/madoc-ts/src/frontend/site/features/TopicActions.tsx index 4ab9e309d..fe181e9fa 100644 --- a/services/madoc-ts/src/frontend/site/features/TopicActions.tsx +++ b/services/madoc-ts/src/frontend/site/features/TopicActions.tsx @@ -25,7 +25,9 @@ export const TopicActions: React.FC = ({ alignment }) => { const { appliedFacets } = useSearchQuery(); const { data } = useTopic(); - query.facets = !appliedFacets.length ? JSON.stringify([{ k: 'entity', v: router.topic, t: 'entity' }]) : query.facets; + query.facets = !appliedFacets.length + ? JSON.stringify([{ k: router.topicType, v: router.topic, t: 'entity' }]) + : query.facets; return ( diff --git a/services/madoc-ts/src/frontend/site/features/TopicPageResults.tsx b/services/madoc-ts/src/frontend/site/features/TopicPageResults.tsx index bf0585ab1..61fad7811 100644 --- a/services/madoc-ts/src/frontend/site/features/TopicPageResults.tsx +++ b/services/madoc-ts/src/frontend/site/features/TopicPageResults.tsx @@ -12,7 +12,6 @@ import { Button, ButtonIcon } from '../../shared/navigation/Button'; import { GridIcon } from '../../shared/icons/GridIcon'; import { ListIcon } from '../../shared/icons/ListIcon'; import { useTopicSearch } from '../hooks/use-topic-search'; -import { useRouteContext } from '../hooks/use-route-context'; interface TopicPageResultsProps { background?: string; diff --git a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts index f0fff8a89..00c21127e 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts @@ -11,7 +11,7 @@ function normalizeDotKey(key: string) { } export function useTopicSearch() { - const { topic } = useRouteContext(); + const { topic, topicType } = useRouteContext(); const { fulltext, appliedFacets, page, rscType } = useSearchQuery(); const { project: { searchStrategy, claimGranularity, searchOptions }, @@ -46,6 +46,7 @@ export function useTopicSearch() { ? { type: 'entity', group_id: facet.v, + subtype: topicType, } : { type: facet.t, @@ -60,7 +61,7 @@ export function useTopicSearch() { fulltext: fulltext, facet_fields: facetsToRequest.length ? facetsToRequest : undefined, // @todo stringify facets. - facets: [...topicFacets, { type: 'entity', group_id: topic || '' }], + facets: [...topicFacets, { type: 'entity', group_id: topic || '', subtype: topicType || '' }], resource_type: rscType, facet_on_manifests: true, search_type: searchStrategy as any, From 5f32e28257d715d34629edbf8c11e5e7d67737a9 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 5 Mar 2024 12:11:16 +0000 Subject: [PATCH 37/55] fix query enable --- services/madoc-ts/src/frontend/site/hooks/use-search.ts | 6 +++++- .../madoc-ts/src/frontend/site/hooks/use-topic-search.ts | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/hooks/use-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-search.ts index c67e72649..2f2d26061 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-search.ts @@ -11,7 +11,7 @@ function normalizeDotKey(key: string) { } export function useSearch() { - const { projectId, collectionId, manifestId, topic } = useRouteContext(); + const { projectId, collectionId, manifestId, topic, topicType } = useRouteContext(); const { fulltext, appliedFacets, page, rscType } = useSearchQuery(); const { project: { searchStrategy, claimGranularity, searchOptions }, @@ -46,6 +46,7 @@ export function useSearch() { ? { type: 'entity', group_id: facet.v, + subtype: topicType, } : { type: facet.t, @@ -84,7 +85,10 @@ export function useSearch() { !!rscType || collectionId || manifestId || + topic || + topicType || projectId), + staleTime: 0, } ); diff --git a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts index 00c21127e..fd0bc21b5 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts @@ -75,7 +75,13 @@ export function useTopicSearch() { { enabled: !searchFacetConfig.isLoading && - (!!facetsToRequest.length || !!fulltext || fulltext === '' || !!topicFacets || !!rscType || !!topic), + (!!facetsToRequest.length || + !!fulltext || + fulltext === '' || + !!topicFacets || + !!rscType || + !!topic || + topicType), staleTime: 0, } ); From a43d69ad7630d3198a82c200b9979bf5df4ef7c6 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 8 Mar 2024 12:10:36 +0000 Subject: [PATCH 38/55] change resources to apprerances for couns --- .../src/frontend/admin/pages/topics/topic/list-all-topics.tsx | 2 +- services/madoc-ts/src/frontend/shared/components/TopicCard.tsx | 2 +- .../madoc-ts/src/frontend/shared/components/TopicSnippet.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/madoc-ts/src/frontend/admin/pages/topics/topic/list-all-topics.tsx b/services/madoc-ts/src/frontend/admin/pages/topics/topic/list-all-topics.tsx index db35b5584..a058cceb6 100644 --- a/services/madoc-ts/src/frontend/admin/pages/topics/topic/list-all-topics.tsx +++ b/services/madoc-ts/src/frontend/admin/pages/topics/topic/list-all-topics.tsx @@ -23,7 +23,7 @@ export function ListAllTopics() { link={`${topic.type_slug}/${topic.slug}`} buttonText={t('View Topic')} hideButton={!topic.type} - subtitle={`${topic.tagged_resource_count} ${t('resources tagged')}`} + subtitle={`${topic.tagged_resource_count} ${t('appearances')}`} thumbnail={topic.other_data?.thumbnail?.url} margin fluid diff --git a/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx b/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx index 70de2d52a..1c648fd51 100644 --- a/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx +++ b/services/madoc-ts/src/frontend/shared/components/TopicCard.tsx @@ -55,7 +55,7 @@ export const TopicCard: React.FC<{ - {topic.tagged_resource_count || 0} {t('Resources')} + {topic.tagged_resource_count || 0} {t('appearances')} {t('PART OF')} diff --git a/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx b/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx index 2e305238b..8307508c2 100644 --- a/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx +++ b/services/madoc-ts/src/frontend/shared/components/TopicSnippet.tsx @@ -81,7 +81,7 @@ export const TopicSnippetCard: React.FC<{ )} {topic.tagged_resource_count && ( - {topic.tagged_resource_count} {t('Resources')} + {topic.tagged_resource_count} {t('appearances')} )}
From b66c5c7de059795ae26286c82fd6c8fac2233653 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 15 Mar 2024 16:26:16 +0000 Subject: [PATCH 39/55] IDA-1139 enter clears search --- .../madoc-ts/src/frontend/shared/atoms/SearchBox.tsx | 10 ++++++++++ services/madoc-ts/translations/en/madoc.json | 1 + 2 files changed, 11 insertions(+) diff --git a/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx b/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx index 252e544df..c5b8e11a7 100644 --- a/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx +++ b/services/madoc-ts/src/frontend/shared/atoms/SearchBox.tsx @@ -60,6 +60,15 @@ export const SearchBox: React.FC<{ const [isFocus, setIsFocus] = useState(false); const [searchValue, setSearchValue] = useState(value); const { t } = useTranslation(); + + const handleEnter = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + e.preventDefault(); + onSearch(searchValue); + } + return; + }; + return (
setIsFocus(true)} onBlur={() => setIsFocus(false)} + onKeyDown={e => handleEnter(e)} type="text" id={!large ? 'search' : `searchLarge`} value={searchValue} diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 04402e364..636f1d5ce 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -986,6 +986,7 @@ "alignment": "alignment", "alt": "alt", "alt text": "alt text", + "appearances": "appearances", "as decimal eg 0.5 is 50% opacity": "as decimal eg 0.5 is 50% opacity", "assigned": "assigned", "assigned to": "assigned to", From 3dd42140c4deee4cd34b6767d6b9b0f280a155d7 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 15 Mar 2024 17:04:07 +0000 Subject: [PATCH 40/55] IDA-1160 fix duplicating facets --- .../src/frontend/site/features/SearchPageFilters.tsx | 8 ++++---- .../madoc-ts/src/frontend/site/hooks/use-topic-search.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx index 8b6829bae..200f7838a 100644 --- a/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx +++ b/services/madoc-ts/src/frontend/site/features/SearchPageFilters.tsx @@ -16,9 +16,7 @@ import { useSearchFacets } from '../hooks/use-search-facets'; import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; import { CheckboxBtn } from '../../shared/atoms/CheckboxBtn'; import { useSearch } from '../hooks/use-search'; -import { SearchBox } from '../../shared/atoms/SearchBox'; import { Accordion } from '../../shared/atoms/Accordion'; -import { Dropdown } from '../../shared/capture-models/editor/atoms/Dropdown'; const DropdownContainer = styled.div` margin: 1em 1em 1em 0; @@ -51,7 +49,9 @@ export const SearchPageFilters: React.FC = ({ checkBoxCo setResourceType, } = useSearchFacets(); - if (!displayFacets) { + const uniqueFacets = [...new Map(displayFacets.map(v => [v.id, v])).values()]; + + if (!uniqueFacets) { return null; } return ( @@ -67,7 +67,7 @@ export const SearchPageFilters: React.FC = ({ checkBoxCo - {displayFacets?.map(facet => { + {uniqueFacets?.map(facet => { if (facet.items.length === 0) { return null; } diff --git a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts index fd0bc21b5..79c4fe7dd 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts @@ -223,5 +223,6 @@ export function useTopicSearch() { return displayList; }, [facetDisplayOrder, facetIdMap, searchResults.resolvedData]); + console.log(displayFacets); return [searchResults, displayFacets, searchFacetConfig.isLoading || searchResults.isLoading] as const; } From 47c6e758f321c6cb70b0b37d596e98d20b7197dd Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 15 Mar 2024 17:28:16 +0000 Subject: [PATCH 41/55] IDA-1152 change reset to home icon --- .../src/frontend/site/features/CanvasPlaintext.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/CanvasPlaintext.tsx b/services/madoc-ts/src/frontend/site/features/CanvasPlaintext.tsx index fbc4ba4a8..6e3b29692 100644 --- a/services/madoc-ts/src/frontend/site/features/CanvasPlaintext.tsx +++ b/services/madoc-ts/src/frontend/site/features/CanvasPlaintext.tsx @@ -5,6 +5,7 @@ import { Button, ButtonRow } from '../../shared/navigation/Button'; import { useData } from '../../shared/hooks/use-data'; import { useLocalStorage } from '../../shared/hooks/use-local-storage'; import { CanvasLoader } from '../pages/loaders/canvas-loader'; +import { HomeIcon } from '../../shared/icons/HomeIcon'; const PlaintextContainer = styled.div``; @@ -53,8 +54,11 @@ export const CanvasPlaintext: React.FC<{ onSwitch?: () => void; switchLabel?: st - + + ); }; diff --git a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts index 79c4fe7dd..fd0bc21b5 100644 --- a/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts +++ b/services/madoc-ts/src/frontend/site/hooks/use-topic-search.ts @@ -223,6 +223,5 @@ export function useTopicSearch() { return displayList; }, [facetDisplayOrder, facetIdMap, searchResults.resolvedData]); - console.log(displayFacets); return [searchResults, displayFacets, searchFacetConfig.isLoading || searchResults.isLoading] as const; } From f0f877cc2cb3802bf1890fdec55d5d6b0fb78d93 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 22 Mar 2024 13:19:07 +0000 Subject: [PATCH 44/55] IDA-1133 add option to make menu items bold --- .../site/features/GlobalMenuStack.tsx | 33 +++++++++++++++++-- .../site/features/GlobalSiteNavigation.tsx | 29 ++++++++++++---- .../themes/default-madoc-theme/theme.json | 15 --------- services/madoc-ts/translations/en/madoc.json | 4 +++ 4 files changed, 58 insertions(+), 23 deletions(-) delete mode 100644 services/madoc-ts/themes/default-madoc-theme/theme.json diff --git a/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx b/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx index b3a07d1f1..5704ea4c2 100644 --- a/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx +++ b/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx @@ -44,11 +44,21 @@ export const GlobalMenuStack: React.FC<{ hideSiteTitle?: boolean; showHomepageMenu?: boolean; maxWidth?: number; + fontWeight?: 'normal' | 'light' | 'bold'; extraLinks?: { slug?: string; text?: string; }[]; -}> = ({ logo, hideSiteTitle, maxWidth, logoOptions = {}, menuOptions = {}, showHomepageMenu, extraLinks }) => { +}> = ({ + logo, + hideSiteTitle, + maxWidth, + logoOptions = {}, + menuOptions = {}, + showHomepageMenu, + extraLinks, + fontWeight, +}) => { const site = useSite(); const { project } = useSiteConfiguration(); const showSiteTitle = typeof hideSiteTitle === 'undefined' ? !project.headerOptions?.hideSiteTitle : !hideSiteTitle; @@ -71,7 +81,7 @@ export const GlobalMenuStack: React.FC<{ )} - + ); @@ -93,6 +103,7 @@ blockEditorFor(GlobalMenuStack, { menuOptions: { fullWidth: false, }, + fontWeight: 'normal', maxWidth: null, extraLinks: [ { @@ -151,6 +162,24 @@ blockEditorFor(GlobalMenuStack, { type: 'checkbox-field', inlineLabel: 'Show home as menu item', }, + fontWeight: { + label: 'Font weight - Menu items ', + type: 'dropdown-field', + options: [ + { + text: 'Bold', + value: 'bold', + }, + { + text: 'Normal', + value: 'normal', + }, + { + text: 'Light', + value: 'lighter', + }, + ], + }, extraLinks: { allowMultiple: true, label: 'Extra Nav item', diff --git a/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx b/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx index 3c7306064..a1ae6eeb5 100644 --- a/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx +++ b/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx @@ -9,6 +9,7 @@ import { useSiteConfiguration } from './SiteConfigurationContext'; export function GlobalSiteNavigation(props: { showHomepageMenu?: boolean; + fontWeight?: string; extraNavItems?: { slug?: string; text?: string; @@ -30,27 +31,39 @@ export function GlobalSiteNavigation(props: { return ( {props.showHomepageMenu ? ( - + {t('Home')} ) : null} {showProjects ? ( - + {t('Projects')} ) : null} {showCollections ? ( - + {t('Collections')} ) : null} {showTopics ? ( - + {t('Topics')} ) : null} {showDashboard ? ( - + {t('User dashboard')} ) : null} @@ -58,7 +71,11 @@ export function GlobalSiteNavigation(props: { ? props.extraNavItems.map((item, i) => { return ( item.slug && ( - + {item.text ? t(item.text) : item.slug} ) diff --git a/services/madoc-ts/themes/default-madoc-theme/theme.json b/services/madoc-ts/themes/default-madoc-theme/theme.json deleted file mode 100644 index cd03e7975..000000000 --- a/services/madoc-ts/themes/default-madoc-theme/theme.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/digirati-co-uk/madoc-platform/main/services/madoc-ts/schemas/BaseTheme.json", - "name": "Default Madoc Theme", - "version": "1.0.0", - "description": "Example madoc theme with default theme values.", - "thumbnail": "https://user-images.githubusercontent.com/8266711/118507448-25750b80-b726-11eb-9f87-d96f43c0a894.png", - "theme": { - "header": "dark", - "accent": "default", - "siteContainer": "light", - "footer": "dark", - "global": "default", - "fonts": "default" - } -} diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 636f1d5ce..25efbf0ae 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -119,6 +119,7 @@ "Background height": "Background height", "Background image": "Background image", "Below are the enabled activity streams. When you enable them, only new activity will be recorded.": "Below are the enabled activity streams. When you enable them, only new activity will be recorded.", + "Bold": "Bold", "Bookmarks": "Bookmarks", "Border color": "Border color", "Border radius": "Border radius", @@ -376,6 +377,7 @@ "Font (from google)": "Font (from google)", "Font Weight": "Font Weight", "Font size": "Font size", + "Font weight - Menu items ": "Font weight - Menu items ", "Forgot password?": "Forgot password?", "Form description": "Form description", "Form label": "Form label", @@ -504,6 +506,7 @@ "Languages": "Languages", "Layout": "Layout", "Leave feedback": "Leave feedback", + "Light": "Light", "Link": "Link", "Link text": "Link text", "Link to": "Link to", @@ -617,6 +620,7 @@ "No users assigned": "No users assigned", "No values exist for this": "No values exist for this", "Non-latin fulltext": "Non-latin fulltext", + "Normal": "Normal", "Not started": "Not started", "Nothing contributed yet": "Nothing contributed yet", "Nothing tagged yet": "Nothing tagged yet", From ab67f52aa088dbd8743db268f258bf69a5d7af73 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 22 Mar 2024 13:20:28 +0000 Subject: [PATCH 45/55] fix type errors --- .../madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx | 2 +- .../src/frontend/site/features/GlobalSiteNavigation.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx b/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx index 5704ea4c2..1d364e0e2 100644 --- a/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx +++ b/services/madoc-ts/src/frontend/site/features/GlobalMenuStack.tsx @@ -44,7 +44,7 @@ export const GlobalMenuStack: React.FC<{ hideSiteTitle?: boolean; showHomepageMenu?: boolean; maxWidth?: number; - fontWeight?: 'normal' | 'light' | 'bold'; + fontWeight?: 'normal' | 'lighter' | 'bold'; extraLinks?: { slug?: string; text?: string; diff --git a/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx b/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx index a1ae6eeb5..de936d77e 100644 --- a/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx +++ b/services/madoc-ts/src/frontend/site/features/GlobalSiteNavigation.tsx @@ -9,7 +9,7 @@ import { useSiteConfiguration } from './SiteConfigurationContext'; export function GlobalSiteNavigation(props: { showHomepageMenu?: boolean; - fontWeight?: string; + fontWeight?: 'normal' | 'bold' | 'lighter'; extraNavItems?: { slug?: string; text?: string; From b21464f376f766e68657e12b8f7e11afd132e637 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 22 Mar 2024 15:11:18 +0000 Subject: [PATCH 46/55] half width surface --- .../{simple-html-block.ts => simple-html-block.tsx} | 3 ++- .../simple-markdown-block/simple-markdown-block.tsx | 1 + services/madoc-ts/src/frontend/shared/layout/Surface.tsx | 7 +++++++ services/madoc-ts/translations/en/madoc.json | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) rename services/madoc-ts/src/extensions/page-blocks/simple-html-block/{simple-html-block.ts => simple-html-block.tsx} (85%) diff --git a/services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.ts b/services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.tsx similarity index 85% rename from services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.ts rename to services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.tsx index 419c5fcf1..c0fc1d614 100644 --- a/services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.ts +++ b/services/madoc-ts/src/extensions/page-blocks/simple-html-block/simple-html-block.tsx @@ -1,7 +1,7 @@ import { captureModelShorthand } from '../../../frontend/shared/capture-models/helpers/capture-model-shorthand'; import { HTMLPageBlockDefinition } from '../extension'; -const definition: HTMLPageBlockDefinition<{ html: string }> = { +const definition: HTMLPageBlockDefinition<{ html: string; maxWidth?: string }> = { label: 'Simple HTML block', type: 'simple-html-block', renderType: 'html', @@ -14,6 +14,7 @@ const definition: HTMLPageBlockDefinition<{ html: string }> = { defaultData: { html: '', }, + render: data => { return data.html; }, diff --git a/services/madoc-ts/src/extensions/page-blocks/simple-markdown-block/simple-markdown-block.tsx b/services/madoc-ts/src/extensions/page-blocks/simple-markdown-block/simple-markdown-block.tsx index 827637b02..7b6f0be4e 100644 --- a/services/madoc-ts/src/extensions/page-blocks/simple-markdown-block/simple-markdown-block.tsx +++ b/services/madoc-ts/src/extensions/page-blocks/simple-markdown-block/simple-markdown-block.tsx @@ -8,6 +8,7 @@ import { ModalFooter } from '../../../frontend/shared/layout/Modal'; import { blockEditorFor } from '../block-editor-for'; import { PageBlockEditor, ReactPageBlockDefinition } from '../extension'; import { StaticMarkdownBlock } from './static-markdown-block'; +import { maxWidth } from '../../../frontend/site/variables/global'; const MarkdownEditorWrapper = styled.div` padding: 0.6em 0.6em 0.6em 2em; diff --git a/services/madoc-ts/src/frontend/shared/layout/Surface.tsx b/services/madoc-ts/src/frontend/shared/layout/Surface.tsx index 8359f8bac..a62384316 100644 --- a/services/madoc-ts/src/frontend/shared/layout/Surface.tsx +++ b/services/madoc-ts/src/frontend/shared/layout/Surface.tsx @@ -46,6 +46,7 @@ const SurfaceStyled = styled.div<{ $color?: string; $textAlign?: 'left' | 'center' | 'right'; $fullWidth?: boolean; + $halfWidth?: boolean; $padding?: 'none' | 'sm' | 'md' | 'lg'; $marginBottom?: 'none' | 'sm' | 'md' | 'lg'; $fontSize?: 'sm' | 'md' | 'lg'; @@ -63,6 +64,7 @@ const SurfaceStyled = styled.div<{ margin-bottom: ${parseProp('$marginBottom', '0')}; margin-left: ${props => (props.$fullWidth ? '-3em' : '')}; margin-right: ${props => (props.$fullWidth ? '-3em' : '')}; + max-width: ${props => (props.$halfWidth ? '60vw' : '')}; `; export type SurfaceProps = { @@ -70,6 +72,7 @@ export type SurfaceProps = { background?: string; textColor?: string; fullWidth?: boolean; + halfWidth?: boolean; textAlign?: 'left' | 'center' | 'right'; font?: string; padding?: 'none' | 'sm' | 'md' | 'lg'; @@ -83,6 +86,7 @@ export const Surface: React.FC = ({ textAlign, textColor, fullWidth, + halfWidth, background, font, fontSize, @@ -103,6 +107,7 @@ export const Surface: React.FC = ({ $background={background} $textAlign={textAlign} $fullWidth={fullWidth} + $halfWidth={halfWidth} $font={font} $padding={padding} $fontSize={fontSize} @@ -121,6 +126,7 @@ blockEditorFor(Surface, { defaultProps: { textColor: '', fullWidth: false, + halfWidth: false, background: '', font: '', padding: 'none', @@ -134,6 +140,7 @@ blockEditorFor(Surface, { background: { label: 'Background color', type: 'color-field' }, font: { label: 'Font (from google)', type: 'text-field' }, fullWidth: { label: 'Display as full width?', type: 'checkbox-field' }, + halfWidth: { label: 'Display as half width?', type: 'checkbox-field' }, padding: { label: 'Padding size', description: 'How much padding should the surface have. (default: none)', diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 25efbf0ae..fa8034048 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -297,6 +297,7 @@ "Display as": "Display as", "Display as full width?": "Display as full width?", "Display as grid": "Display as grid", + "Display as half width?": "Display as half width?", "Display as list": "Display as list", "Display at half size": "Display at half size", "Display name": "Display name", @@ -332,6 +333,7 @@ "Enable unique submissions": "Enable unique submissions", "Enabled translations": "Enabled translations", "Enrichment": "Enrichment", + "Enter HTML content": "Enter HTML content", "Enter IIIF Manifest Collection URL": "Enter IIIF Manifest Collection URL", "Enter URL": "Enter URL", "Enter a heading": "Enter a heading", @@ -1098,6 +1100,7 @@ "switch to the main revision": "switch to the main revision", "task thumbnail": "task thumbnail", "text": "text", + "text max width": "text max width", "thumbnail": "thumbnail", "thumbnail for": "thumbnail for", "to make changes": "to make changes", From 90e0dc90f1f6e66dd08219459499326cc9169f97 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 22 Mar 2024 15:20:09 +0000 Subject: [PATCH 47/55] make search button use border theme colour --- .../src/frontend/shared/layout/SiteHeader.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/layout/SiteHeader.tsx b/services/madoc-ts/src/frontend/shared/layout/SiteHeader.tsx index beb4f4f7d..8864515fd 100644 --- a/services/madoc-ts/src/frontend/shared/layout/SiteHeader.tsx +++ b/services/madoc-ts/src/frontend/shared/layout/SiteHeader.tsx @@ -15,6 +15,10 @@ const headerText = themeVariable('header', 'headerText', { midnight: '#fff', }); +const accent = themeVariable('accent', 'primary', { + default: '#5b80b2', +}); + export const SiteHeader = styled.div` max-width: ${maxWidth}; width: 100%; @@ -76,9 +80,10 @@ export const GlobalSearchInput = styled.input` export const GlobalSearchButton = styled.button` font-size: 0.9em; padding: 0.2em 1em; - background: #333; - color: #fff; - border: 2px solid #333; + background: ${searchBorder}; + color: #333; + border: 2px solid ${searchBorder}; + &:focus { outline: none; border-color: ${searchBorderFocusColor}; From b1ea89be7db59a7a11da34300ccd5d9e31b9bf13 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 22 Mar 2024 16:40:49 +0000 Subject: [PATCH 48/55] fix margin --- .../src/frontend/site/features/AllTopicTypeItems.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx index ad8682abd..f761ded28 100644 --- a/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx +++ b/services/madoc-ts/src/frontend/site/features/AllTopicTypeItems.tsx @@ -13,18 +13,23 @@ import { CroppedImage } from '../../shared/atoms/Images'; const ListWrapper = styled.div` padding-top: 1em; display: grid; - grid-template-columns: 1fr 1fr; + grid-template-columns: 1fr 1fr 1fr; gap: 2em; `; const TypeCard = styled.div` display: flex; - border: 1px solid #002d4b; + border: 3px solid #002d4b; background-color: white; margin-bottom: 20px; justify-content: space-evenly; max-height: 250px; min-width: 45%; + border-radius: 4px; + + &:hover { + border: 3px solid rgba(4, 102, 166, 0.5) !important; + } `; const TypeText = styled.div` @@ -41,7 +46,6 @@ const TypeText = styled.div` color: #002d4b; border-radius: 20px; padding: 0.8em; - margin-top: 1em; &:hover { background-color: #002d4b; @@ -53,7 +57,7 @@ const TypeText = styled.div` const CountText = styled.div` font-weight: 400; font-size: 1em; - margin: 1em 0 2em 0; + margin: 1em 0; span { color: #707070; From a1753adeb7a2ce0065a8ac3ea20985f97ecd6427 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Wed, 27 Mar 2024 12:07:57 +0000 Subject: [PATCH 49/55] IDA-1158: user feedback and add another button on tagging modal --- .../frontend/site/features/AddTagButton.tsx | 31 +++++++- .../frontend/site/features/AddTopicButton.tsx | 32 +++++++- .../site/features/TaggingFormPannel.tsx | 77 ++++++++++++++----- services/madoc-ts/translations/en/madoc.json | 3 + 4 files changed, 119 insertions(+), 24 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/AddTagButton.tsx b/services/madoc-ts/src/frontend/site/features/AddTagButton.tsx index a116cf6d3..8456d2b29 100644 --- a/services/madoc-ts/src/frontend/site/features/AddTagButton.tsx +++ b/services/madoc-ts/src/frontend/site/features/AddTagButton.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from 'react'; +import React, { useEffect, useRef } from 'react'; import { Button } from '../../shared/navigation/Button'; import { CloseIcon } from '../../shared/icons/CloseIcon'; import { useApi } from '../../shared/hooks/use-api'; @@ -28,7 +28,8 @@ export const AddTagButton: React.FC<{ statusLoading: boolean; onSelected: (id: string | undefined) => void; hideTopic?: boolean; -}> = ({ typeSlug, typeLabel, onSelected, statusLoading, hideTopic }) => { + postSubmission: boolean; +}> = ({ typeSlug, typeLabel, onSelected, statusLoading, hideTopic, postSubmission }) => { const container = useRef(null); const [fullText, setFulltext] = React.useState(''); const [isLoading, setIsLoading] = React.useState(false); @@ -36,6 +37,12 @@ export const AddTagButton: React.FC<{ const api = useApi(); const { t } = useTranslation(); + useEffect(() => { + if (!postSubmission && selected) { + setSelected(null); + } + }, [postSubmission]); + const { data: pages, fetchMore, canFetchMore, isFetchingMore, isLoading: queryLoading } = useInfiniteQuery( ['topic-autocomplete', { fullText, typeSlug }], async (key, _, vars: { page?: number } = { page: 1 }) => { @@ -69,6 +76,26 @@ export const AddTagButton: React.FC<{ // const tags = data?.entity_tags; // const appliedTagIDs = tags?.map(tag => tag.entity.id); + if (selected && postSubmission) { + return ( +
+
+

{t('Canvas tagged with')}:

+ + {selected.title} + +
+
+ ); + } + return (
{selected ? ( diff --git a/services/madoc-ts/src/frontend/site/features/AddTopicButton.tsx b/services/madoc-ts/src/frontend/site/features/AddTopicButton.tsx index 88699f644..26b6ed1df 100644 --- a/services/madoc-ts/src/frontend/site/features/AddTopicButton.tsx +++ b/services/madoc-ts/src/frontend/site/features/AddTopicButton.tsx @@ -12,6 +12,7 @@ import { TagPill } from '../hooks/canvas-menu/tagging-panel'; import { AutoCompleteEntitySnippet } from '../../../extensions/enrichment/types'; import { AddTagButton } from './AddTagButton'; import { useTranslation } from 'react-i18next'; +import { LocaleString } from '../../shared/components/LocaleString'; export const TopicPill = styled(TagPill)` border-color: orange; @@ -19,7 +20,8 @@ export const TopicPill = styled(TagPill)` export const AddTopicButton: React.FC<{ statusLoading: boolean; onSelected: (slug: string | undefined) => void; -}> = ({ onSelected, statusLoading }) => { + postSubmission: boolean; +}> = ({ onSelected, statusLoading, postSubmission }) => { const container = useRef(null); const [fullText, setFulltext] = React.useState(''); const [isLoading, setIsLoading] = React.useState(false); @@ -56,6 +58,33 @@ export const AddTopicButton: React.FC<{ setIsLoading(false); }; + if (selected && postSubmission) { + return ( +
+
+

{t('Canvas tagged with')}:

+ + {t('Topic Type')}: + {selected.label} + + {t('Tag')}: + + {selected.title} + +
+
+ ); + } + return (

{t('Choose a topic type first')}

@@ -78,6 +107,7 @@ export const AddTopicButton: React.FC<{ typeLabel={selected.label} statusLoading={statusLoading} onSelected={onSelected} + postSubmission={false} hideTopic /> diff --git a/services/madoc-ts/src/frontend/site/features/TaggingFormPannel.tsx b/services/madoc-ts/src/frontend/site/features/TaggingFormPannel.tsx index 0e0a8c53b..5e49c1757 100644 --- a/services/madoc-ts/src/frontend/site/features/TaggingFormPannel.tsx +++ b/services/madoc-ts/src/frontend/site/features/TaggingFormPannel.tsx @@ -52,7 +52,7 @@ export const TaggingFormPannel = () => { const { canvasId } = useRouteContext(); const api = useApi(); const ResourceTags = useGetResourceTags(); - + const [postSubmission, setPostSubmission] = useState(false); const [selectedId, setSelectedId] = useState(undefined); const [remove, removeStatus] = useMutation(async (id: string) => { @@ -76,19 +76,33 @@ export const TaggingFormPannel = () => { } + render={() => ( + + )} footerAlignRight renderFooter={({ close }) => ( - + {postSubmission ? ( + + ) : ( + + )} + {ResourceTags.length === 0 ? ( {t('No tags')} @@ -119,20 +140,34 @@ export const TaggingFormPannel = () => { typeLabel={tagType.type} onSelected={onSelect} statusLoading={addStatus.isLoading} + postSubmission={postSubmission} /> )} footerAlignRight renderFooter={({ close }) => ( - + {postSubmission ? ( + + ) : ( + + )} + + + + + {uniqueFacets?.map(facet => { + if (facet.items.length === 0) { + return null; + } + return ( + f.k === facet.id)}> + + {facet.items.map(item => { + const isSelected = isFacetSelected(item.key, item.values); + const itemHash = `item__${facet.id}::${item.key}::${item.values}`; + + return ( + + + e.target.checked + ? queueSingleFacet(item.key, item.values, item.type) + : dequeueSingleFacet(item.key, item.values, item.type) + } + /> + + {item.label} + + ({item.count}) + + ); + })} + + + ); + })} + + + + + + ); +}; + +blockEditorFor(TopicPageFilters, { + label: 'Topic Page Filters', + type: 'default.TopicPageFilters', + anyContext: ['collection', 'manifest', 'canvas', 'project', 'topic', 'topicType'], + requiredContext: ['page'], + defaultProps: { + checkBoxColor: '', + filterHeader: 'Refine search', + }, + editor: { + checkBoxColor: { label: 'Check box color', type: 'color-field' }, + filterHeader: { label: 'filter header', type: 'text-field' }, + }, +}); diff --git a/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx b/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx new file mode 100644 index 000000000..5c3eb61fb --- /dev/null +++ b/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx @@ -0,0 +1,57 @@ +import React from 'react'; +import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; +import { Pagination, PaginationNumbered } from '../../shared/components/Pagination'; +import { useSearchQuery } from '../hooks/use-search-query'; +import { useSearch } from '../hooks/use-search'; + +export const TopicResultsPagination: React.FC<{ + paginationStyle?: boolean; + position?: 'flex-end' | 'flex-start' | 'center'; +}> = ({ paginationStyle, position }) => { + const { rawQuery, page } = useSearchQuery(); + const [{ resolvedData: searchResponse, latestData }, displayFacets, isLoading] = useSearch(); + const PaginationComponent = paginationStyle ? PaginationNumbered : Pagination; + + const pagination = searchResponse?.pagination; + + if (!pagination || !latestData || !searchResponse) { + return null; + } + + return ( + + ); +}; + +blockEditorFor(TopicResultsPagination, { + type: 'default.TopicResultsPagination', + label: 'Topic Results pagination', + anyContext: ['collection', 'manifest', 'canvas', 'project', 'topic', 'topicType'], + requiredContext: ['page'], + defaultProps: { + paginationStyle: true, + position: 'flex-end', + }, + editor: { + paginationStyle: { + type: 'checkbox-field', + inlineLabel: 'Pagination as Numbered?', + label: 'Pagination Numbered', + }, + position: { + label: 'Position', + type: 'dropdown-field', + options: [ + { value: 'flex-start', text: 'Start' }, + { value: 'center', text: 'Center' }, + { value: 'flex-end', text: 'End' }, + ], + }, + }, +}); diff --git a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx index e74e2d289..9f4f230c9 100644 --- a/services/madoc-ts/src/frontend/site/pages/view-topic.tsx +++ b/services/madoc-ts/src/frontend/site/pages/view-topic.tsx @@ -4,16 +4,15 @@ import { Slot } from '../../shared/page-blocks/slot'; import { TopicHero } from '../features/TopicHero'; import { FeaturedTopicItems } from '../features/FeaturedTopicItems'; import { RelatedTopics } from '../features/RelatedTopics'; -import { SearchPagination } from '../features/SearchPagination'; import { AppliedFacets } from '../features/AppliedFacets'; -import { SearchPageFilters } from '../features/SearchPageFilters'; import { TopicActions } from '../features/TopicActions'; import { TopicAuthorities } from '../features/TopicAuthorities'; import { TopicHeroImage } from '../features/TopicHeroImage'; -import { SearchPageResults } from '../features/SearchPageResults'; import { SearchPageSearch } from '../features/SearchPageSearch'; import { useTopic } from './loaders/topic-loader'; import { TopicPageResults } from '../features/TopicPageResults'; +import { TopicPageFilters } from '../features/TopicPageFilters'; +import { TopicResultsPagination } from '../features/TopicResultsPagination'; export const ViewTopic = () => { const { data } = useTopic(); return ( @@ -48,7 +47,7 @@ export const ViewTopic = () => {
- +
@@ -60,7 +59,7 @@ export const ViewTopic = () => { - +
From 2fd6080bc5af190b3048f4aa946e52a9c621ca47 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Thu, 11 Apr 2024 16:28:13 +0100 Subject: [PATCH 54/55] useTopicSearch for pagination --- .../src/frontend/site/features/TopicResultsPagination.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx b/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx index 5c3eb61fb..23350f0c8 100644 --- a/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx +++ b/services/madoc-ts/src/frontend/site/features/TopicResultsPagination.tsx @@ -2,14 +2,14 @@ import React from 'react'; import { blockEditorFor } from '../../../extensions/page-blocks/block-editor-for'; import { Pagination, PaginationNumbered } from '../../shared/components/Pagination'; import { useSearchQuery } from '../hooks/use-search-query'; -import { useSearch } from '../hooks/use-search'; +import { useTopicSearch } from '../hooks/use-topic-search'; export const TopicResultsPagination: React.FC<{ paginationStyle?: boolean; position?: 'flex-end' | 'flex-start' | 'center'; }> = ({ paginationStyle, position }) => { const { rawQuery, page } = useSearchQuery(); - const [{ resolvedData: searchResponse, latestData }, displayFacets, isLoading] = useSearch(); + const [{ resolvedData: searchResponse, latestData }, displayFacets, isLoading] = useTopicSearch(); const PaginationComponent = paginationStyle ? PaginationNumbered : Pagination; const pagination = searchResponse?.pagination; From f7aea4d43e43e0d3bf323994b1ed9dc333f3affd Mon Sep 17 00:00:00 2001 From: Heather0K Date: Fri, 12 Apr 2024 10:30:57 +0100 Subject: [PATCH 55/55] fix window is undefined --- .../madoc-ts/src/frontend/site/features/TopicGrid.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/TopicGrid.tsx b/services/madoc-ts/src/frontend/site/features/TopicGrid.tsx index 2f29d6634..51d07e95f 100644 --- a/services/madoc-ts/src/frontend/site/features/TopicGrid.tsx +++ b/services/madoc-ts/src/frontend/site/features/TopicGrid.tsx @@ -27,11 +27,13 @@ export const TopicGrid: React.FC<{ cardBorder?: string; imageStyle?: string; }> = ({ background, textColor, cardBorder }) => { - const scrollX = window.scrollX; - const scrollY = window.scrollY; - useLayoutEffect(() => { - window.scrollTo(scrollX, scrollY); + if (typeof window !== 'undefined') { + const scrollX = window.scrollX; + const scrollY = window.scrollY; + + window.scrollTo(scrollX, scrollY); + } }); const { data } = useTopicType();