2022-10-02 18:38:41 +00:00
|
|
|
<template>
|
2023-09-08 11:00:28 +00:00
|
|
|
<div class="flex flex-col min-h-full border-t">
|
|
|
|
<section class="py-12 sm:py-16 bg-gray-50 border-b border-gray-200">
|
|
|
|
<div class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
|
|
|
|
<div class="text-center max-w-xl mx-auto">
|
|
|
|
<h1 class="text-3xl sm:text-4xl lg:text-5xl font-bold tracking-tight text-gray-900">
|
|
|
|
Form Templates
|
|
|
|
</h1>
|
|
|
|
<p class="text-gray-600 mt-4 text-lg font-normal">
|
|
|
|
Our collection of beautiful templates to create your own forms!
|
|
|
|
</p>
|
2022-10-02 18:38:41 +00:00
|
|
|
</div>
|
2023-09-08 11:00:28 +00:00
|
|
|
</div>
|
|
|
|
</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 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>
|
2022-10-02 18:38:41 +00:00
|
|
|
</div>
|
2023-09-08 11:00:28 +00:00
|
|
|
|
|
|
|
<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.
|
2022-10-02 18:38:41 +00:00
|
|
|
</p>
|
2023-09-08 11:00:28 +00:00
|
|
|
<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" />
|
2022-10-02 18:38:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-08 11:00:28 +00:00
|
|
|
</section>
|
|
|
|
|
2022-10-02 18:38:41 +00:00
|
|
|
<open-form-footer class="mt-8 border-t"/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import store from '~/store'
|
2023-09-08 11:00:28 +00:00
|
|
|
import { mapGetters, mapState } from 'vuex'
|
|
|
|
import Form from 'vform'
|
2022-10-02 18:38:41 +00:00
|
|
|
import Fuse from 'fuse.js'
|
2023-09-08 11:00:28 +00:00
|
|
|
import SeoMeta from '../../mixins/seo-meta.js'
|
2023-01-21 11:57:37 +00:00
|
|
|
import OpenFormFooter from '../../components/pages/OpenFormFooter.vue'
|
2023-09-08 11:00:28 +00:00
|
|
|
import SingleTemplate from '../../components/pages/templates/SingleTemplate.vue'
|
2022-10-02 18:38:41 +00:00
|
|
|
|
|
|
|
const loadTemplates = function () {
|
|
|
|
store.commit('open/templates/startLoading')
|
2023-09-08 11:00:28 +00:00
|
|
|
store.dispatch('open/templates/loadIfEmpty').then(() => {
|
2022-10-02 18:38:41 +00:00
|
|
|
store.commit('open/templates/stopLoading')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2023-04-12 10:59:55 +00:00
|
|
|
|
2023-09-08 11:00:28 +00:00
|
|
|
components: { OpenFormFooter, SingleTemplate },
|
|
|
|
mixins: [SeoMeta],
|
2022-10-02 18:38:41 +00:00
|
|
|
|
2023-09-08 11:00:28 +00:00
|
|
|
beforeRouteEnter (to, from, next) {
|
2022-10-02 18:38:41 +00:00
|
|
|
loadTemplates()
|
|
|
|
next()
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
2023-09-08 11:00:28 +00:00
|
|
|
metaTitle: { type: String, default: 'Templates' },
|
|
|
|
metaDescription: { type: String, default: 'Our collection of beautiful templates to create your own forms!' }
|
2022-10-02 18:38:41 +00:00
|
|
|
},
|
|
|
|
|
2023-09-08 11:00:28 +00:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
selectedType: 'all',
|
|
|
|
selectedIndustry: 'all',
|
|
|
|
searchTemplate: new Form({
|
|
|
|
search: ''
|
2022-10-02 18:38:41 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-09-08 11:00:28 +00:00
|
|
|
mounted () {
|
|
|
|
},
|
|
|
|
|
2022-10-02 18:38:41 +00:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
templates: state => state['open/templates'].content,
|
2023-09-08 11:00:28 +00:00
|
|
|
templatesLoading: state => state['open/templates'].loading,
|
|
|
|
industries: state => state['open/templates'].industries,
|
|
|
|
types: state => state['open/templates'].types
|
2022-10-02 18:38:41 +00:00
|
|
|
}),
|
2023-09-08 11:00:28 +00:00
|
|
|
industriesOptions () {
|
|
|
|
return [{ name: 'All Industries', value: 'all' }].concat(Object.values(this.industries).map((industry) => {
|
|
|
|
return {
|
|
|
|
name: industry.name,
|
|
|
|
value: industry.slug
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
},
|
|
|
|
typesOptions () {
|
|
|
|
return [{ name: 'All Types', value: 'all' }].concat(Object.values(this.types).map((type) => {
|
|
|
|
return {
|
|
|
|
name: type.name,
|
|
|
|
value: type.slug
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
},
|
|
|
|
enrichedTemplates () {
|
|
|
|
let enrichedTemplates = this.templates
|
|
|
|
|
|
|
|
// 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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {}
|
2022-10-02 18:38:41 +00:00
|
|
|
}
|
|
|
|
</script>
|