From 7bb84b2eb4cbdf01b67c305861c251e4edfd94f7 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 4 Feb 2025 12:23:10 +0000 Subject: [PATCH 1/7] mark parent task as incomplete if task is marked --- .../frontend/site/features/canvas/CanvasTaskProgress.tsx | 7 ++++++- services/madoc-ts/translations/en/madoc.json | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx b/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx index 252490774..68842656b 100644 --- a/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx +++ b/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx @@ -68,6 +68,11 @@ export const CanvasTaskProgress: React.FC = () => { status: 2, status_text: 'in progress', }); + // mark parent as incomplete + await api.updateRevisionTask(canvasTask.parent_task, { + status: 2, + status_text: 'in progress', + }); await refetch(); } }); @@ -123,7 +128,7 @@ export const CanvasTaskProgress: React.FC = () => { - {t('Mark as complete')} + {t('Mark as complete 1')} {isAdmin && canvasTask?.state.approvalsRequired && ( diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 48a15f4c0..d894424ef 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -45,6 +45,7 @@ "All contributions": "All contributions", "All locales": "All locales", "All manifests": "All manifests", + "All of the contributions to this Manifest will be deleted": "All of the contributions to this Manifest will be deleted", "All of the contributions to this canvas will be deleted": "All of the contributions to this canvas will be deleted", "All of your work on these images will be lost if you continue and you will be taken back to the project homepage": "All of your work on these images will be lost if you continue and you will be taken back to the project homepage", "All projects": "All projects", @@ -218,6 +219,7 @@ "Continue where you left off?": "Continue where you left off?", "Continue working": "Continue working", "Contribute": "Contribute", + "Contribute to another manifest": "Contribute to another manifest", "Contribute to random canvas": "Contribute to random canvas", "Contribute to the next image": "Contribute to the next image", "Contribution Panel": "Contribution Panel", @@ -286,6 +288,7 @@ "Delete Manifest": "Delete Manifest", "Delete Project": "Delete Project", "Delete all contributions": "Delete all contributions", + "Delete all contributions 1": "Delete all contributions 1", "Delete feedback": "Delete feedback", "Delete field": "Delete field", "Delete page": "Delete page", @@ -595,6 +598,7 @@ "Manually put into review": "Manually put into review", "Margin left and right": "Margin left and right", "Mark as complete": "Mark as complete", + "Mark as complete 1": "Mark as complete 1", "Mark as incomplete": "Mark as incomplete", "Mark as too difficult": "Mark as too difficult", "Max number of instances (used when referring to lists of this document)": "Max number of instances (used when referring to lists of this document)", @@ -943,6 +947,9 @@ "This is the current style": "This is the current style", "This is the type of search to use in constructing the query.": "This is the type of search to use in constructing the query.", "This manifest is complete": "This manifest is complete", + "This manifest is complete 1": "This manifest is complete 1", + "This manifest is complete 2": "This manifest is complete 2", + "This manifest is complete 3": "This manifest is complete 3", "This manifest is currently in review": "This manifest is currently in review", "This manifest is not available to browse": "This manifest is not available to browse", "This means this task has been assigned or is in progress, but nothing has been submitted": "This means this task has been assigned or is in progress, but nothing has been submitted", From 6120211e8b6af679668aa94408bd40ec1e64d7d5 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 4 Feb 2025 12:24:25 +0000 Subject: [PATCH 2/7] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced1e9042..598191264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed block editor button 'saved' instead of 'save' (MAD-1475) +- Fixed marking canvas as incomplete not marking manifest as incomplete (MAD-1516) ## [v2.2.6](https://github.com/digirati-co-uk/madoc-platform/compare/v2.2.5...v2.2.6) From 0d0380d015b9049aa59c8a3a22d50fe2e702de82 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 4 Feb 2025 12:26:07 +0000 Subject: [PATCH 3/7] remove test texts --- .../src/frontend/site/features/canvas/CanvasTaskProgress.tsx | 2 +- services/madoc-ts/translations/en/madoc.json | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx b/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx index 68842656b..9acf2bbf2 100644 --- a/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx +++ b/services/madoc-ts/src/frontend/site/features/canvas/CanvasTaskProgress.tsx @@ -128,7 +128,7 @@ export const CanvasTaskProgress: React.FC = () => { - {t('Mark as complete 1')} + {t('Mark as complete')} {isAdmin && canvasTask?.state.approvalsRequired && ( diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index d894424ef..f7537da11 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -288,7 +288,6 @@ "Delete Manifest": "Delete Manifest", "Delete Project": "Delete Project", "Delete all contributions": "Delete all contributions", - "Delete all contributions 1": "Delete all contributions 1", "Delete feedback": "Delete feedback", "Delete field": "Delete field", "Delete page": "Delete page", @@ -598,7 +597,6 @@ "Manually put into review": "Manually put into review", "Margin left and right": "Margin left and right", "Mark as complete": "Mark as complete", - "Mark as complete 1": "Mark as complete 1", "Mark as incomplete": "Mark as incomplete", "Mark as too difficult": "Mark as too difficult", "Max number of instances (used when referring to lists of this document)": "Max number of instances (used when referring to lists of this document)", @@ -947,9 +945,6 @@ "This is the current style": "This is the current style", "This is the type of search to use in constructing the query.": "This is the type of search to use in constructing the query.", "This manifest is complete": "This manifest is complete", - "This manifest is complete 1": "This manifest is complete 1", - "This manifest is complete 2": "This manifest is complete 2", - "This manifest is complete 3": "This manifest is complete 3", "This manifest is currently in review": "This manifest is currently in review", "This manifest is not available to browse": "This manifest is not available to browse", "This means this task has been assigned or is in progress, but nothing has been submitted": "This means this task has been assigned or is in progress, but nothing has been submitted", From b8e85a3ab75b1de502c36e1409fb53d25f40de20 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Tue, 4 Feb 2025 16:04:58 +0000 Subject: [PATCH 4/7] WIP --- .../export-configs/project/project-csv-simple-export.ts | 8 +++++++- services/madoc-ts/translations/en/madoc.json | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts index 02598f8e7..2e00a1026 100644 --- a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts +++ b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts @@ -1,6 +1,7 @@ import { parseModelTarget } from '../../../../utility/parse-model-target'; import { ExportFile } from '../../server-export'; import { ExportConfig, ExportDataOptions, ExportFileDefinition, SupportedExportResource } from '../../types'; +import { api } from '../../../../gateway/api.server'; export const projectCsvSimpleExport: ExportConfig = { type: 'project-csv-simple-export', @@ -77,11 +78,12 @@ export const projectCsvSimpleExport: ExportConfig = { } const mappedList = Object.entries(rowRecord) - .map(([key, record]) => { + .map(async ([key, record]) => { const newRecord: any = {}; newRecord.model_id = record.model_id; newRecord.doc_id = record.doc_id; + // newRecord.canvas_label = record.canvas.label; if (record.__fields) { for (const field of record.__fields) { @@ -90,10 +92,14 @@ export const projectCsvSimpleExport: ExportConfig = { const target = parseModelTarget(record.target); if (target.manifest) { + const manifest = await api.getManifestById(target.manifest.id); newRecord.manifest = target.manifest.id; + newRecord.manifest_label = manifest.manifest.label.toLocaleString(); } if (target.canvas) { + const canvas = await api.getCanvasById(target.canvas.id); newRecord.canvas = target.canvas.id; + newRecord.canvas_label = canvas.canvas.label.toLocaleString(); } return newRecord; } diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index f7537da11..1b015c4d9 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -519,6 +519,8 @@ "Importing canvases": "Importing canvases", "In progress": "In progress", "In review": "In review", + "Include reviews": "Include reviews", + "Include submissions being reviewed in the export.": "Include submissions being reviewed in the export.", "Indexing resource into search": "Indexing resource into search", "Inline label": "Inline label", "Installation title": "Installation title", @@ -696,6 +698,7 @@ "Panel alignment": "Panel alignment", "Part of this page crashed": "Part of this page crashed", "Password": "Password", + "Paste Measurement Id ": "Paste Measurement Id ", "Pending": "Pending", "Permissions": "Permissions", "Personal notes": "Personal notes", @@ -882,6 +885,7 @@ "Structure": "Structure", "Style": "Style", "Submission approvals required": "Submission approvals required", + "Submission filter": "Submission filter", "Submission process": "Submission process", "Submit": "Submit", "Submit feedback": "Submit feedback", From 29c1a2bbd4f42523ff291212251fdba060406391 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Thu, 6 Feb 2025 09:54:03 +0000 Subject: [PATCH 5/7] Show canvas and manifes IDs on CSv --- .../project/project-csv-simple-export.ts | 77 +++++++++++++++---- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts index 2e00a1026..91300bb2b 100644 --- a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts +++ b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts @@ -1,7 +1,46 @@ import { parseModelTarget } from '../../../../utility/parse-model-target'; import { ExportFile } from '../../server-export'; import { ExportConfig, ExportDataOptions, ExportFileDefinition, SupportedExportResource } from '../../types'; -import { api } from '../../../../gateway/api.server'; + +const labelCache: { manifestLabels: Record; canvasLabels: Record } = { + manifestLabels: {}, + canvasLabels: {}, +}; + +type InternationalString = { + [locale: string]: string[]; +}; + +function getLocaleString(internationalString: InternationalString, locale: string = 'none'): string { + return internationalString[locale] ? internationalString[locale][0] : Object.values(internationalString)[0][0]; +} + +async function fetchLabels(api: any, manifestIds: number[], canvasIds: number[]) { + const newManifestIds = manifestIds.filter(id => id !== undefined && !labelCache.manifestLabels[id.toString()]); + const newCanvasIds = canvasIds.filter(id => id !== undefined && !labelCache.canvasLabels[id.toString()]); + + if (newManifestIds.length > 0) { + const manifests = await Promise.all(newManifestIds.map(id => api.getManifestById(id))); + manifests.forEach(response => { + const manifest = response.manifest; + if (manifest && manifest.id !== undefined) { + labelCache.manifestLabels[manifest.id.toString()] = getLocaleString(manifest.label); + } + }); + } + + if (newCanvasIds.length > 0) { + const canvases = await Promise.all(newCanvasIds.map(id => api.getCanvasById(id))); + canvases.forEach(response => { + const canvas = response.canvas; + if (canvas && canvas.id !== undefined) { + labelCache.canvasLabels[canvas.id.toString()] = getLocaleString(canvas.label); + } + }); + } + + return { manifestLabels: labelCache.manifestLabels, canvasLabels: labelCache.canvasLabels }; +} export const projectCsvSimpleExport: ExportConfig = { type: 'project-csv-simple-export', @@ -48,14 +87,15 @@ export const projectCsvSimpleExport: ExportConfig = { subject: SupportedExportResource, options: ExportDataOptions ): Promise { - // This will probably be a pretty long-running task. - const allPublished = await options.api.getProjectFieldsRaw(subject.id, { status: options.config.reviews ? 'all' : 'approved', entity: options.config.entity, }); const rowRecord: Record = {}; + const manifestIds: number[] = []; + const canvasIds: number[] = []; + for (const item of allPublished) { rowRecord[item.doc_id] = rowRecord[item.doc_id] || { target: item.target, @@ -70,20 +110,29 @@ export const projectCsvSimpleExport: ExportConfig = { rowRecord[item.doc_id][item.key] = rowRecord[item.doc_id][item.key] || []; rowRecord[item.doc_id][item.key].push({ value: item.value, id: item.id, revises: item.revises }); + + const target = parseModelTarget(item.target); + if (target.manifest && target.manifest.id !== undefined) { + manifestIds.push(target.manifest.id); + } + if (target.canvas && target.canvas.id !== undefined) { + canvasIds.push(target.canvas.id); + } } + const { manifestLabels, canvasLabels } = await fetchLabels(options.api, manifestIds, canvasIds); + function findBest(fields: any[]) { const revises = fields.map(r => r.revises); return fields.filter(r => !revises.includes(r.id)).pop() || fields[0]; } const mappedList = Object.entries(rowRecord) - .map(async ([key, record]) => { - const newRecord: any = {}; - - newRecord.model_id = record.model_id; - newRecord.doc_id = record.doc_id; - // newRecord.canvas_label = record.canvas.label; + .map(([key, record]) => { + const newRecord: any = { + model_id: record.model_id, + doc_id: record.doc_id, + }; if (record.__fields) { for (const field of record.__fields) { @@ -91,15 +140,13 @@ export const projectCsvSimpleExport: ExportConfig = { } const target = parseModelTarget(record.target); - if (target.manifest) { - const manifest = await api.getManifestById(target.manifest.id); + if (target.manifest && target.manifest.id !== undefined) { newRecord.manifest = target.manifest.id; - newRecord.manifest_label = manifest.manifest.label.toLocaleString(); + newRecord.manifest_label = manifestLabels[target.manifest.id.toString()]; } - if (target.canvas) { - const canvas = await api.getCanvasById(target.canvas.id); + if (target.canvas && target.canvas.id !== undefined) { newRecord.canvas = target.canvas.id; - newRecord.canvas_label = canvas.canvas.label.toLocaleString(); + newRecord.canvas_label = canvasLabels[target.canvas.id.toString()]; } return newRecord; } From 110a7e04ca09a5a6952a5a64fd50602411e5ccd4 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Thu, 6 Feb 2025 09:57:46 +0000 Subject: [PATCH 6/7] changelog --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 598191264..6b0509a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added back in the Basic Google Analytics page block (NS-45) (NS-54) - Added config option to continue contributions to another manifest after submission (MAD-1514) +- Added manifest and canvas labels on CSV export (MAD-1420) + +### Fixed +- Fixed block editor button 'saved' instead of 'save' (MAD-1475) +- Fixed marking canvas as incomplete not marking manifest as incomplete (MAD-1516) ## [v2.2.7](https://github.com/digirati-co-uk/madoc-platform/compare/v2.2.6...v2.2.7) @@ -23,10 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Disables server-side rendering on the 2 review/task pages. -### Fixed -- Fixed block editor button 'saved' instead of 'save' (MAD-1475) -- Fixed marking canvas as incomplete not marking manifest as incomplete (MAD-1516) - ## [v2.2.6](https://github.com/digirati-co-uk/madoc-platform/compare/v2.2.5...v2.2.6) ### Added From 896ae8b1a4260eb90181179d1440be4d6b54091c Mon Sep 17 00:00:00 2001 From: Heather0K Date: Mon, 10 Feb 2025 13:33:14 +0000 Subject: [PATCH 7/7] use getValue --- .../project/project-csv-simple-export.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts index 91300bb2b..d1928802e 100644 --- a/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts +++ b/services/madoc-ts/src/extensions/project-export/export-configs/project/project-csv-simple-export.ts @@ -1,20 +1,13 @@ import { parseModelTarget } from '../../../../utility/parse-model-target'; import { ExportFile } from '../../server-export'; import { ExportConfig, ExportDataOptions, ExportFileDefinition, SupportedExportResource } from '../../types'; +import { getValue } from '@iiif/helpers/i18n'; const labelCache: { manifestLabels: Record; canvasLabels: Record } = { manifestLabels: {}, canvasLabels: {}, }; -type InternationalString = { - [locale: string]: string[]; -}; - -function getLocaleString(internationalString: InternationalString, locale: string = 'none'): string { - return internationalString[locale] ? internationalString[locale][0] : Object.values(internationalString)[0][0]; -} - async function fetchLabels(api: any, manifestIds: number[], canvasIds: number[]) { const newManifestIds = manifestIds.filter(id => id !== undefined && !labelCache.manifestLabels[id.toString()]); const newCanvasIds = canvasIds.filter(id => id !== undefined && !labelCache.canvasLabels[id.toString()]); @@ -24,7 +17,7 @@ async function fetchLabels(api: any, manifestIds: number[], canvasIds: number[]) manifests.forEach(response => { const manifest = response.manifest; if (manifest && manifest.id !== undefined) { - labelCache.manifestLabels[manifest.id.toString()] = getLocaleString(manifest.label); + labelCache.manifestLabels[manifest.id.toString()] = getValue(manifest.label); } }); } @@ -34,7 +27,7 @@ async function fetchLabels(api: any, manifestIds: number[], canvasIds: number[]) canvases.forEach(response => { const canvas = response.canvas; if (canvas && canvas.id !== undefined) { - labelCache.canvasLabels[canvas.id.toString()] = getLocaleString(canvas.label); + labelCache.canvasLabels[canvas.id.toString()] = getValue(canvas.label); } }); }