From c01a7ec49c1080ddd7a91e03d2e27f740e65f26d Mon Sep 17 00:00:00 2001 From: aydawka Date: Tue, 22 Apr 2025 19:16:27 -0700 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20validation=20st?= =?UTF-8?q?yle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/Dataset.d.ts | 10 +++ .../study/dataset/publish/new/NewVersion.vue | 65 ++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/types/Dataset.d.ts b/src/types/Dataset.d.ts index 3a7f7bf0..dc79e8e7 100644 --- a/src/types/Dataset.d.ts +++ b/src/types/Dataset.d.ts @@ -238,6 +238,16 @@ export interface DatasetRelatedIdentifiers { related_identifiers: DatasetRelatedIdentifier[]; } +export interface FieldValidation { + name: string; + identifier: string; +} + +export interface DatasetMetadataValidation { + message: string; + metadata: FieldValidation[]; +} + export interface DatasetHealthsheetRecord { id: number; question: string; diff --git a/src/views/study/dataset/publish/new/NewVersion.vue b/src/views/study/dataset/publish/new/NewVersion.vue index 755178f9..7444c302 100644 --- a/src/views/study/dataset/publish/new/NewVersion.vue +++ b/src/views/study/dataset/publish/new/NewVersion.vue @@ -2,6 +2,7 @@ import { faker } from "@faker-js/faker"; import { useSidebarStore } from "@/stores/sidebar"; +import { DatasetMetadataValidation } from "@/types/Dataset"; import { baseURL } from "@/utils/constants"; const route = useRoute(); @@ -17,6 +18,7 @@ const routeParams = { const studyId = routeParams.studyId as string; const datasetId = routeParams.datasetId as string; +const responseLoading = ref(false); const loading = ref(false); @@ -26,6 +28,8 @@ const version = ref({ title: faker.commerce.productName(), }); +const moduleData = reactive([]); + const rules: FormRules = { title: [ { @@ -38,6 +42,31 @@ const rules: FormRules = { onBeforeMount(async () => { sidebarStore.setAppSidebarCollapsed(true); + responseLoading.value = true; + + const response = await fetch( + `${baseURL}/study/${studyId}/dataset/${datasetId}/metadata-validation`, + { + method: "GET", + } + ); + responseLoading.value = false; + + if (!response.ok) { + push.error("Something went wrong."); + + throw new Error("Network response was not ok"); + } + + const data = await response.json(); + + console.log(data); + + moduleData.splice(0, moduleData.length, ...(data ?? []).map((item: any) => ({ ...item }))); + + // + // aboutList = moduleData.map((item: any) => item.about); + // datasetSubjects = moduleData.map((item: any) => item.dataset_subjects); }); const createVersion = (e: MouseEvent) => { @@ -96,7 +125,41 @@ const createVersion = (e: MouseEvent) => { +
+ + + + +
+ + + Add missing {{ field.identifier }} {{ field.name }} + + + + + + +
+
+
+ + + {
- + From 539d1949cb8de4eccb40ed05ffb9b6c97e81306a Mon Sep 17 00:00:00 2001 From: aydawka Date: Fri, 25 Apr 2025 09:55:53 -0700 Subject: [PATCH 02/11] =?UTF-8?q?add:=20=E2=9E=95=20alerts=20for=20metadat?= =?UTF-8?q?a=20to=20publish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/dataset/publish/new/NewVersion.vue | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/views/study/dataset/publish/new/NewVersion.vue b/src/views/study/dataset/publish/new/NewVersion.vue index 7444c302..e6cb9e4b 100644 --- a/src/views/study/dataset/publish/new/NewVersion.vue +++ b/src/views/study/dataset/publish/new/NewVersion.vue @@ -2,7 +2,7 @@ import { faker } from "@faker-js/faker"; import { useSidebarStore } from "@/stores/sidebar"; -import { DatasetMetadataValidation } from "@/types/Dataset"; +import type { DatasetMetadataValidation } from "@/types/Dataset"; import { baseURL } from "@/utils/constants"; const route = useRoute(); @@ -112,6 +112,21 @@ const createVersion = (e: MouseEvent) => { } }); }; + +function uniqueMetadataIdentifiers(fullMetadata: any) { + const uniqueIdentifier = new Set(); + + const uniqueFields = fullMetadata.filter((field: any) => { + const key = field.identifier; // or field.field if that's your unique identifier + if (!uniqueIdentifier.has(key)) { + uniqueIdentifier.add(key); + return true; + } + return false; + }); + + return uniqueFields; +}