Finish reworking most templates pages
This commit is contained in:
parent
eda1af9b1b
commit
aac4d1da04
|
@ -5,12 +5,12 @@
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 sm:gap-6 relative z-20">
|
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 sm:gap-6 relative z-20">
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<div class="flex-1 sm:flex-none">
|
<div class="flex-1 sm:flex-none">
|
||||||
<select-input v-model="selectedType" name="type"
|
<select-input v-model="selectedType" name="type" v-if="filterTypes"
|
||||||
:options="typesOptions" class="w-full sm:w-auto md:w-56"
|
:options="typesOptions" class="w-full sm:w-auto md:w-56"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 sm:flex-none">
|
<div class="flex-1 sm:flex-none">
|
||||||
<select-input v-model="selectedIndustry" name="industry"
|
<select-input v-model="selectedIndustry" name="industry" v-if="filterIndustries"
|
||||||
:options="industriesOptions" class="w-full sm:w-auto md:w-56"
|
:options="industriesOptions" class="w-full sm:w-auto md:w-56"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,16 +34,20 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<slot name="before-lists"/>
|
||||||
|
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
<section class="py-12 bg-white border-t border-gray-200 sm:py-16" v-if="showTypes">
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
||||||
All Types
|
All Types
|
||||||
</h4>
|
</h4>
|
||||||
|
<v-button :to="{name:'templates'}" color="white" size="small" :arrow="true">
|
||||||
|
View All Templates
|
||||||
|
</v-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-8 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
<div class="grid grid-cols-1 gap-x-8 gap-y-4 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||||
<router-link v-for="row in types" :key="row.slug"
|
<router-link v-for="row in types" :key="row.slug"
|
||||||
:to="{params: {slug:row.slug}, name:'templates-types-slug'}"
|
:to="{params: {slug:row.slug}, name:'templates-types-slug'}"
|
||||||
:title="row.name"
|
:title="row.name"
|
||||||
|
@ -55,15 +59,18 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
<section class="py-12 bg-white border-t border-gray-200 sm:py-16" v-if="showIndustries">
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
||||||
All Industries
|
All Industries
|
||||||
</h4>
|
</h4>
|
||||||
|
<v-button :to="{name:'templates'}" color="white" size="small" :arrow="true">
|
||||||
|
View All Templates
|
||||||
|
</v-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-8 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
<div class="grid grid-cols-1 gap-x-8 gap-y-4 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||||
<router-link v-for="row in industries" :key="row.slug"
|
<router-link v-for="row in industries" :key="row.slug"
|
||||||
:to="{params:{slug:row.slug}, name:'templates-industries-slug'}"
|
:to="{params:{slug:row.slug}, name:'templates-industries-slug'}"
|
||||||
:title="row.name"
|
:title="row.name"
|
||||||
|
@ -94,6 +101,22 @@ export default {
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
showTypes: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
filterTypes: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
showIndustries: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
filterIndustries: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -137,14 +160,14 @@ export default {
|
||||||
let enrichedTemplates = this.templates
|
let enrichedTemplates = this.templates
|
||||||
|
|
||||||
// Filter by Selected Type
|
// Filter by Selected Type
|
||||||
if (this.selectedType && this.selectedType !== 'all') {
|
if (this.filterTypes && this.selectedType && this.selectedType !== 'all') {
|
||||||
enrichedTemplates = enrichedTemplates.filter((item) => {
|
enrichedTemplates = enrichedTemplates.filter((item) => {
|
||||||
return (item.types && item.types.length > 0) ? item.types.includes(this.selectedType) : false
|
return (item.types && item.types.length > 0) ? item.types.includes(this.selectedType) : false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by Selected Industry
|
// Filter by Selected Industry
|
||||||
if (this.selectedIndustry && this.selectedIndustry !== 'all') {
|
if (this.filterIndustries && this.selectedIndustry && this.selectedIndustry !== 'all') {
|
||||||
enrichedTemplates = enrichedTemplates.filter((item) => {
|
enrichedTemplates = enrichedTemplates.filter((item) => {
|
||||||
return (item.industries && item.industries.length > 0) ? item.industries.includes(this.selectedIndustry) : false
|
return (item.industries && item.industries.length > 0) ? item.industries.includes(this.selectedIndustry) : false
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {fetchAllTemplates} from "~/stores/templates.js";
|
import {loadAllTemplates} from "~/stores/templates.js";
|
||||||
|
|
||||||
// props: {
|
// props: {
|
||||||
// metaTitle: { type: String, default: 'Templates' },
|
// metaTitle: { type: String, default: 'Templates' },
|
||||||
|
@ -28,14 +28,7 @@ import {fetchAllTemplates} from "~/stores/templates.js";
|
||||||
// },
|
// },
|
||||||
|
|
||||||
const templatesStore = useTemplatesStore()
|
const templatesStore = useTemplatesStore()
|
||||||
|
loadAllTemplates(templatesStore)
|
||||||
if (!templatesStore.allLoaded) {
|
|
||||||
templatesStore.startLoading()
|
|
||||||
templatesStore.initTypesAndIndustries()
|
|
||||||
const {data} = await fetchAllTemplates()
|
|
||||||
templatesStore.set(data.value)
|
|
||||||
templatesStore.allLoaded = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const templates = computed(() => templatesStore.getAll)
|
const templates = computed(() => templatesStore.getAll)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col min-h-full">
|
<div class="flex flex-col min-h-full">
|
||||||
<breadcrumb :path="breadcrumbs" />
|
<breadcrumb :path="breadcrumbs"/>
|
||||||
|
|
||||||
<div v-if="templatesLoading" class="text-center my-4">
|
<p v-if="industry === null || !industry" class="text-center my-4">
|
||||||
<Loader class="h-6 w-6 text-nt-blue mx-auto" />
|
We could not find this type.
|
||||||
</div>
|
|
||||||
<p v-else-if="industry === null || !industry" class="text-center my-4">
|
|
||||||
We could not find this industry.
|
|
||||||
</p>
|
</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<section class="py-12 sm:py-16 bg-gray-50 border-b border-gray-200">
|
<section class="py-12 sm:py-16 bg-gray-50 border-b border-gray-200">
|
||||||
|
@ -25,35 +22,9 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="bg-white py-12 sm:py-16">
|
|
||||||
<div class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 sm:gap-6 relative z-20">
|
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<div class="flex-1 sm:flex-none">
|
|
||||||
<select-input v-model="selectedType" name="type"
|
|
||||||
:options="typesOptions" class="w-full sm:w-auto md:w-56"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 w-full md:max-w-xs">
|
|
||||||
<text-input name="search" :form="searchTemplate" placeholder="Search..." />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="templatesLoading" class="text-center mt-4">
|
|
||||||
<Loader class="h-6 w-6 text-nt-blue mx-auto" />
|
|
||||||
</div>
|
|
||||||
<p v-else-if="enrichedTemplates.length === 0" class="text-center mt-4">
|
|
||||||
No templates found.
|
|
||||||
</p>
|
|
||||||
<div v-else class="relative z-10">
|
|
||||||
<div class="grid grid-cols-1 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8 sm:gap-y-12">
|
|
||||||
<single-template v-for="template in enrichedTemplates" :key="template.id" :slug="template.slug" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
<templates-list :templates="templates" :filter-industries="false" :show-types="false">
|
||||||
|
<template #before-lists>
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
||||||
<p class="text-gray-600 font-normal">
|
<p class="text-gray-600 font-normal">
|
||||||
|
@ -61,159 +32,41 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</template>
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
</templates-list>
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
|
||||||
Other Industries
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<v-button :to="{name:'templates'}" color="white" size="small" :arrow="true">
|
|
||||||
View All Templates
|
|
||||||
</v-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-8 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
|
||||||
<router-link v-for="row in otherIndustries" :key="row.slug"
|
|
||||||
:to="{params:{slug:row.slug}, name:'templates-industries-slug'}"
|
|
||||||
:title="row.name"
|
|
||||||
class="text-gray-600 dark:text-gray-400 transition-colors duration-300 hover:text-nt-blue"
|
|
||||||
>
|
|
||||||
{{ row.name }}
|
|
||||||
</router-link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<open-form-footer class="mt-8 border-t"/>
|
<open-form-footer class="mt-8 border-t"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import Form from 'vform'
|
import {computed} from 'vue'
|
||||||
import Fuse from 'fuse.js'
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { useAuthStore } from '../../../stores/auth.js'
|
|
||||||
import { useTemplatesStore } from '../../../stores/templates.js'
|
|
||||||
import SeoMeta from '../../../mixins/seo-meta.js'
|
|
||||||
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
|
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
|
||||||
import Breadcrumb from '~/components/global/Breadcrumb.vue'
|
import Breadcrumb from '~/components/global/Breadcrumb.vue'
|
||||||
import SingleTemplate from '../../../components/pages/templates/SingleTemplate.vue'
|
import {loadAllTemplates} from "~/stores/templates.js";
|
||||||
|
|
||||||
const loadTemplates = function () {
|
const route = useRoute()
|
||||||
const templatesStore = useTemplatesStore()
|
const authStore = useAuthStore()
|
||||||
templatesStore.startLoading()
|
const templatesStore = useTemplatesStore()
|
||||||
templatesStore.loadIfEmpty().then(() => {
|
|
||||||
templatesStore.stopLoading()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
loadAllTemplates(templatesStore)
|
||||||
components: { Breadcrumb, OpenFormFooter, SingleTemplate },
|
|
||||||
mixins: [SeoMeta],
|
|
||||||
|
|
||||||
beforeRouteEnter (to, from, next) {
|
// Computed
|
||||||
loadTemplates()
|
const authenticated = computed(() => authStore.check)
|
||||||
next()
|
const user = computed(() => authStore.user)
|
||||||
},
|
const templates = computed(() => templatesStore.getAll.filter((item) => {
|
||||||
|
return (item.industries && item.industries.length > 0) ? item.industries.includes(route.params.slug) : false
|
||||||
setup () {
|
}))
|
||||||
const authStore = useAuthStore()
|
const breadcrumbs = computed(() => {
|
||||||
const templatesStore = useTemplatesStore()
|
if (!industry) {
|
||||||
return {
|
return [{route: {name: 'templates'}, label: 'Templates'}]
|
||||||
authStore,
|
|
||||||
authenticated : computed(() => authStore.check),
|
|
||||||
user : computed(() => authStore.user),
|
|
||||||
templates : computed(() => templatesStore.content),
|
|
||||||
templatesLoading : computed(() => templatesStore.loading),
|
|
||||||
industries : computed(() => templatesStore.industries),
|
|
||||||
types : computed(() => templatesStore.types)
|
|
||||||
}
|
}
|
||||||
},
|
return [{route: {name: 'templates'}, label: 'Templates'}, {label: industry.value.name}]
|
||||||
|
})
|
||||||
|
|
||||||
data () {
|
const industry = computed(() => templatesStore.industries.get(route.params.slug))
|
||||||
return {
|
|
||||||
selectedType: 'all',
|
|
||||||
searchTemplate: new Form({
|
|
||||||
search: ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted () {},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
breadcrumbs () {
|
|
||||||
if (!this.industry) {
|
|
||||||
return [{ route: { name: 'templates' }, label: 'Templates' }]
|
|
||||||
}
|
|
||||||
return [{ route: { name: 'templates' }, label: 'Templates' }, { label: this.industry.name }]
|
|
||||||
},
|
|
||||||
industry () {
|
|
||||||
return Object.values(this.industries).find((industry) => {
|
|
||||||
return industry.slug === this.$route.params.slug
|
|
||||||
})
|
|
||||||
},
|
|
||||||
typesOptions () {
|
|
||||||
return [{ name: 'All Types', value: 'all' }].concat(Object.values(this.types).map((type) => {
|
|
||||||
return {
|
|
||||||
name: type.name,
|
|
||||||
value: type.slug
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
},
|
|
||||||
otherIndustries() {
|
|
||||||
return Object.values(this.industries).filter((industry) => {
|
|
||||||
return industry.slug !== this.$route.params.slug
|
|
||||||
})
|
|
||||||
},
|
|
||||||
enrichedTemplates () {
|
|
||||||
let enrichedTemplates = this.templates
|
|
||||||
|
|
||||||
// Filter by current Industry only
|
|
||||||
enrichedTemplates = enrichedTemplates.filter((item) => {
|
|
||||||
return (item.industries && item.industries.length > 0) ? item.industries.includes(this.$route.params.slug) : false
|
|
||||||
})
|
|
||||||
|
|
||||||
// Filter by Selected Type
|
|
||||||
if (this.selectedType && this.selectedType !== 'all') {
|
|
||||||
enrichedTemplates = enrichedTemplates.filter((item) => {
|
|
||||||
return (item.types && item.types.length > 0) ? item.types.includes(this.selectedType) : false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.searchTemplate.search === '' || this.searchTemplate.search === null) {
|
|
||||||
return enrichedTemplates
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fuze search
|
|
||||||
const fuzeOptions = {
|
|
||||||
keys: [
|
|
||||||
'name',
|
|
||||||
'slug',
|
|
||||||
'description',
|
|
||||||
'short_description'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
const fuse = new Fuse(enrichedTemplates, fuzeOptions)
|
|
||||||
return fuse.search(this.searchTemplate.search).map((res) => {
|
|
||||||
return res.item
|
|
||||||
})
|
|
||||||
},
|
|
||||||
metaTitle () {
|
|
||||||
return this.industry ? this.industry.meta_title : 'Form Template Industry'
|
|
||||||
},
|
|
||||||
metaDescription () {
|
|
||||||
if (!this.industry) return null
|
|
||||||
return this.industry.meta_description.substring(0, 140)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
|
@ -236,3 +89,4 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
<div class="flex flex-col min-h-full">
|
<div class="flex flex-col min-h-full">
|
||||||
<breadcrumb :path="breadcrumbs"/>
|
<breadcrumb :path="breadcrumbs"/>
|
||||||
|
|
||||||
<div v-if="templatesLoading" class="text-center my-4">
|
<p v-if="type === null || !type" class="text-center my-4">
|
||||||
<Loader class="h-6 w-6 text-nt-blue mx-auto"/>
|
|
||||||
</div>
|
|
||||||
<p v-else-if="type === null || !type" class="text-center my-4">
|
|
||||||
We could not find this type.
|
We could not find this type.
|
||||||
</p>
|
</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
@ -25,35 +22,9 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="bg-white py-12 sm:py-16">
|
|
||||||
<div class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 sm:gap-6 relative z-20">
|
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<div class="flex-1 sm:flex-none">
|
|
||||||
<select-input v-model="selectedIndustry" name="industry"
|
|
||||||
:options="industriesOptions" class="w-full sm:w-auto md:w-56"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 w-full md:max-w-xs">
|
|
||||||
<text-input name="search" :form="searchTemplate" placeholder="Search..."/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="templatesLoading" class="text-center mt-4">
|
|
||||||
<Loader class="h-6 w-6 text-nt-blue mx-auto"/>
|
|
||||||
</div>
|
|
||||||
<p v-else-if="enrichedTemplates.length === 0" class="text-center mt-4">
|
|
||||||
No templates found.
|
|
||||||
</p>
|
|
||||||
<div v-else class="relative z-10">
|
|
||||||
<div class="grid grid-cols-1 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8 sm:gap-y-12">
|
|
||||||
<single-template v-for="template in enrichedTemplates" :key="template.id" :slug="template.slug"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
<templates-list :templates="templates" :filter-types="false" :show-industries="false">
|
||||||
|
<template #before-lists>
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
||||||
<p class="text-gray-600 font-normal">
|
<p class="text-gray-600 font-normal">
|
||||||
|
@ -61,120 +32,41 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</template>
|
||||||
<section class="py-12 bg-white border-t border-gray-200 sm:py-16">
|
</templates-list>
|
||||||
<div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl">
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h4 class="text-xl font-bold tracking-tight text-gray-900 sm:text-2xl">
|
|
||||||
Other Types
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<v-button :to="{name:'templates'}" color="white" size="small" :arrow="true">
|
|
||||||
View All Templates
|
|
||||||
</v-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-8 mt-8 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
|
||||||
<router-link v-for="row in otherTypes" :key="row.slug"
|
|
||||||
:to="{params:{slug:row.slug}, name:'templates-types-slug'}"
|
|
||||||
:title="row.name"
|
|
||||||
class="text-gray-600 dark:text-gray-400 transition-colors duration-300 hover:text-nt-blue"
|
|
||||||
>
|
|
||||||
{{ row.name }}
|
|
||||||
</router-link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<open-form-footer class="mt-8 border-t"/>
|
<open-form-footer class="mt-8 border-t"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
import SeoMeta from '../../../mixins/seo-meta.js'
|
|
||||||
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
|
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
|
||||||
import Breadcrumb from '~/components/global/Breadcrumb.vue'
|
import Breadcrumb from '~/components/global/Breadcrumb.vue'
|
||||||
import SingleTemplate from '../../../components/pages/templates/SingleTemplate.vue'
|
import {loadAllTemplates} from "~/stores/templates.js";
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const templatesStore = useTemplatesStore()
|
const templatesStore = useTemplatesStore()
|
||||||
|
|
||||||
const route = useRoute()
|
loadAllTemplates(templatesStore)
|
||||||
|
|
||||||
// State
|
|
||||||
const selectedIndustry = ref('all')
|
|
||||||
const searchTemplate = useForm({
|
|
||||||
search: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
// Computed
|
// Computed
|
||||||
const authenticated = computed(() => authStore.check)
|
const authenticated = computed(() => authStore.check)
|
||||||
const user = computed(() => authStore.user)
|
const user = computed(() => authStore.user)
|
||||||
const templates = computed(() => templatesStore.getAll)
|
const templates = computed(() => templatesStore.getAll.filter((item) => {
|
||||||
|
return (item.types && item.types.length > 0) ? item.types.includes(route.params.slug) : false
|
||||||
|
}))
|
||||||
const breadcrumbs = computed(() => {
|
const breadcrumbs = computed(() => {
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return [{route: {name: 'templates'}, label: 'Templates'}]
|
return [{route: {name: 'templates'}, label: 'Templates'}]
|
||||||
}
|
}
|
||||||
return [{route: {name: 'templates'}, label: 'Templates'}, {label: type.name}]
|
return [{route: {name: 'templates'}, label: 'Templates'}, {label: type.value.name}]
|
||||||
})
|
})
|
||||||
const type = computed(() => templatesStore.types.value.get(route.params.slug))
|
|
||||||
const types = computed(() => [...templatesStore.types.value.values()])
|
|
||||||
const industriesOptions = computed(() => [{name: 'All Industries', value: 'all'}].concat(
|
|
||||||
[...templatesStore.types.values.values()].map((industry) => {
|
|
||||||
return {
|
|
||||||
name: industry.name,
|
|
||||||
value: industry.slug
|
|
||||||
}
|
|
||||||
})))
|
|
||||||
|
|
||||||
// enrichedTemplates()
|
const type = computed(() => templatesStore.types.get(route.params.slug))
|
||||||
// {
|
|
||||||
// let enrichedTemplates = this.templates
|
|
||||||
//
|
|
||||||
// // Filter by current Type only
|
|
||||||
// enrichedTemplates = enrichedTemplates.filter((item) => {
|
|
||||||
// return (item.types && item.types.length > 0) ? item.types.includes(this.$route.params.slug) : false
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// // Filter by Selected Industry
|
|
||||||
// if (this.selectedIndustry && this.selectedIndustry !== 'all') {
|
|
||||||
// enrichedTemplates = enrichedTemplates.filter((item) => {
|
|
||||||
// return (item.industries && item.industries.length > 0) ? item.industries.includes(this.selectedIndustry) : false
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (this.searchTemplate.search === '' || this.searchTemplate.search === null) {
|
|
||||||
// return enrichedTemplates
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Fuze search
|
|
||||||
// const fuzeOptions = {
|
|
||||||
// keys: [
|
|
||||||
// 'name',
|
|
||||||
// 'slug',
|
|
||||||
// 'description',
|
|
||||||
// 'short_description'
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// const fuse = new Fuse(enrichedTemplates, fuzeOptions)
|
|
||||||
// return fuse.search(this.searchTemplate.search).map((res) => {
|
|
||||||
// return res.item
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// ,
|
|
||||||
// metaTitle()
|
|
||||||
// {
|
|
||||||
// return this.type ? this.type.meta_title : 'Form Template Type'
|
|
||||||
// }
|
|
||||||
// ,
|
|
||||||
// metaDescription()
|
|
||||||
// {
|
|
||||||
// if (!this.type) return null
|
|
||||||
// return this.type.meta_description.substring(0, 140)
|
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const useTemplatesStore = defineStore('templates', () => {
|
||||||
return types.value.get(slug)
|
return types.value.get(slug)
|
||||||
}).filter((item) => item !== undefined)
|
}).filter((item) => item !== undefined)
|
||||||
}
|
}
|
||||||
const getTemplateIndustries =(slugs) => {
|
const getTemplateIndustries = (slugs) => {
|
||||||
return slugs.map((slug) => {
|
return slugs.map((slug) => {
|
||||||
return industries.value.get(slug)
|
return industries.value.get(slug)
|
||||||
}).filter((item) => item !== undefined)
|
}).filter((item) => item !== undefined)
|
||||||
|
@ -50,8 +50,12 @@ export const fetchAllTemplates = () => {
|
||||||
return useOpnApi(templatesEndpoint)
|
return useOpnApi(templatesEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadTypesAndIndustries = () => {
|
export const loadAllTemplates = async (store) => {
|
||||||
// Load the json files
|
if (!store.allLoaded) {
|
||||||
|
store.startLoading()
|
||||||
|
store.initTypesAndIndustries()
|
||||||
|
const {data} = await fetchAllTemplates()
|
||||||
|
store.set(data.value)
|
||||||
|
store.allLoaded = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue