From 8e70d6be98c1dd07f711a4902407905b81f767f0 Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Tue, 19 Dec 2023 15:24:54 +0100 Subject: [PATCH] Finishing the templates pages --- .../pages/templates/TemplateTags.vue | 113 ++++----- .../pages/templates/TemplatesList.vue | 26 +- client/pages/templates/[slug].vue | 9 +- client/pages/templates/index.vue | 1 + .../{industries.vue => industries/[slug].vue} | 12 +- client/pages/templates/types.vue | 238 ------------------ client/pages/templates/types/[slug].vue | 200 +++++++++++++++ client/stores/templates.js | 48 ++-- .../{industries-show.vue => industries.vue} | 0 .../templates/{types-show.vue => types.vue} | 0 10 files changed, 295 insertions(+), 352 deletions(-) rename client/pages/templates/{industries.vue => industries/[slug].vue} (95%) delete mode 100644 client/pages/templates/types.vue create mode 100644 client/pages/templates/types/[slug].vue rename resources/js/pages/templates/{industries-show.vue => industries.vue} (100%) rename resources/js/pages/templates/{types-show.vue => types.vue} (100%) diff --git a/client/components/pages/templates/TemplateTags.vue b/client/components/pages/templates/TemplateTags.vue index 6ed0b3a..02cceb5 100644 --- a/client/components/pages/templates/TemplateTags.vue +++ b/client/components/pages/templates/TemplateTags.vue @@ -1,51 +1,48 @@ - diff --git a/client/components/pages/templates/TemplatesList.vue b/client/components/pages/templates/TemplatesList.vue index d8aa688..b335a5a 100644 --- a/client/components/pages/templates/TemplatesList.vue +++ b/client/components/pages/templates/TemplatesList.vue @@ -16,7 +16,7 @@
- +
@@ -45,7 +45,7 @@
@@ -65,7 +65,7 @@
@@ -79,9 +79,9 @@ - - - diff --git a/client/pages/templates/types/[slug].vue b/client/pages/templates/types/[slug].vue new file mode 100644 index 0000000..8e5adcf --- /dev/null +++ b/client/pages/templates/types/[slug].vue @@ -0,0 +1,200 @@ + + + + + + diff --git a/client/stores/templates.js b/client/stores/templates.js index b394dab..a3958ae 100644 --- a/client/stores/templates.js +++ b/client/stores/templates.js @@ -1,5 +1,7 @@ import {defineStore} from 'pinia' import {useContentStore} from "~/composables/stores/useContentStore.js"; +import templateTypes from "~/data/forms/templates/types.json" +import industryTypes from "~/data/forms/templates/industries.json" const templatesEndpoint = 'templates' export const useTemplatesStore = defineStore('templates', () => { @@ -7,29 +9,26 @@ export const useTemplatesStore = defineStore('templates', () => { const contentStore = useContentStore('slug') const allLoaded = ref(false) - const industries = ref({}) - const types = ref({}) + const industries = ref(new Map) + const types = ref(new Map) - const getTemplateTypes = computed((state) => (slugs) => { - if (state.types.length === 0) return null - return Object.values(state.types).filter((val) => slugs.includes(val.slug)).map((item) => { - return item.name - }) - // todo: use map - }) - const getTemplateIndustries = computed((state) => (slugs) => { - if (state.industries.length === 0) return null - return Object.values(state.industries).filter((val) => slugs.includes(val.slug)).map((item) => { - return item.name - }) - }) + const getTemplateTypes = (slugs) => { + return slugs.map((slug) => { + return types.value.get(slug) + }).filter((item) => item !== undefined) + } + const getTemplateIndustries =(slugs) => { + return slugs.map((slug) => { + return industries.value.get(slug) + }).filter((item) => item !== undefined) + } - const loadTypesAndIndustries = function() { - if (Object.keys(this.industries).length === 0 || Object.keys(this.types).length === 0) { - // const files = import.meta.glob('~/data/forms/templates/*.json') - // console.log(await files['/data/forms/templates/industries.json']()) - // this.industries = await files['/data/forms/templates/industries.json']() - // this.types = await files['/data/forms/templates/types.json']() + const initTypesAndIndustries = () => { + if (types.value.size === 0) { + types.value = new Map(Object.entries(templateTypes)) + } + if (industries.value.size === 0) { + industries.value = new Map(Object.entries(industryTypes)) } } @@ -39,7 +38,7 @@ export const useTemplatesStore = defineStore('templates', () => { types, getTemplateTypes, getTemplateIndustries, - loadTypesAndIndustries, + initTypesAndIndustries } }) @@ -51,3 +50,8 @@ export const fetchAllTemplates = () => { return useOpnApi(templatesEndpoint) } +export const loadTypesAndIndustries = () => { + // Load the json files + +} + diff --git a/resources/js/pages/templates/industries-show.vue b/resources/js/pages/templates/industries.vue similarity index 100% rename from resources/js/pages/templates/industries-show.vue rename to resources/js/pages/templates/industries.vue diff --git a/resources/js/pages/templates/types-show.vue b/resources/js/pages/templates/types.vue similarity index 100% rename from resources/js/pages/templates/types-show.vue rename to resources/js/pages/templates/types.vue