diff --git a/client/components/pages/templates/TemplateTags.vue b/client/components/pages/templates/TemplateTags.vue index 6ed0b3a8..02cceb5a 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 d8aa6887..b335a5a9 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 00000000..8e5adcfa --- /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 b394dab3..a3958ae6 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