From 9cc998e0bf1e3bf1a41930b5782ef26e6dbb3060 Mon Sep 17 00:00:00 2001 From: nguyen van thai Date: Tue, 16 Jul 2024 09:23:44 +0700 Subject: [PATCH] Fix --- .../page-component/AssignComponent.vue | 21 +++++++++++++------ .../layouts/articles/details/Default.vue | 9 ++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/components/dynamic-page/page-component/AssignComponent.vue b/components/dynamic-page/page-component/AssignComponent.vue index d0f39bb..a65fc97 100644 --- a/components/dynamic-page/page-component/AssignComponent.vue +++ b/components/dynamic-page/page-component/AssignComponent.vue @@ -7,6 +7,7 @@ const props = defineProps<{ type?: any; // [TOP_NAVIGATION, BOTTOM_NAVIGATION] }>(); +const contentParse = computed(() => (currentPage.value.content ? JSON.parse(currentPage.value.content) : {})); const defineTypeRecusive = { TOP_NAVIGATION: enumPageComponentLayouts[`${enumPageComponentTemplate[enumPageComponentKey.NAVIGATION]['TOP']}`]['NAVIGATION_TOP_DEFAULT'], BOTTOM_NAVIGATION: enumPageComponentLayouts[`${enumPageComponentTemplate[enumPageComponentKey.NAVIGATION]['BOTTOM']}`]['NAVIGATION_BOTTOM_DEFAULT'], @@ -16,14 +17,22 @@ const findDataPosition = computed(() => { let result = {}; switch (props.type) { case defineTypeRecusive.TOP_NAVIGATION: - result = currentPage.value.components && currentPage.value.components.find((component: any) => { - return component.taxonomy === enumPageComponentKey.NAVIGATION && component.settings?.layout === defineTypeRecusive.TOP_NAVIGATION - }); + if (contentParse.value.navigationTop) { + result = + currentPage.value.components && + currentPage.value.components.find((component: any) => { + return component.id === contentParse.value.navigationTop; + }); + } break; case defineTypeRecusive.BOTTOM_NAVIGATION: - result = currentPage.value.components && currentPage.value.components.find((component: any) => { - return component.taxonomy === enumPageComponentKey.NAVIGATION && component.settings?.layout === defineTypeRecusive.BOTTOM_NAVIGATION - }); + if (contentParse.value.navigationBottom) { + result = + currentPage.value.components && + currentPage.value.components.find((component: any) => { + return component.id === contentParse.value.navigationBottom; + }); + } break; default: result = {}; diff --git a/components/dynamic-page/page-section/layouts/articles/details/Default.vue b/components/dynamic-page/page-section/layouts/articles/details/Default.vue index 1099f95..fb9ee03 100644 --- a/components/dynamic-page/page-section/layouts/articles/details/Default.vue +++ b/components/dynamic-page/page-section/layouts/articles/details/Default.vue @@ -83,7 +83,10 @@ const mapActivesToItems = (index: number) => { return {}; }; -const currentCategoryTree = findElementPathById(categoryTree.value, currentArticle.value.categoryId); +const currentCategoryTree = ref([]); +if(currentArticle.value?.categoryId) { + currentCategoryTree.value = findElementPathById(categoryTree.value, currentArticle.value.categoryId) +} function findElementPathById(categories: any[], targetId: number, path: any[] = []) { for (const category of categories) { const currentPath = [...path, { title: category.title, code: category.code }]; @@ -99,8 +102,6 @@ function findElementPathById(categories: any[], targetId: number, path: any[] = } return null; } - -console.log(currentArticle.value ,'currentArticle')