Apply bug fixes from Noteforms (#341)

* rename const emits to emit

* auth bug fixes

* refactor page meta

* fix file input empty ref

* setProperties working_form store

* add form creator to form list

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-03-12 12:48:51 +01:00
committed by GitHub
parent 18afd44664
commit 478b68074d
10 changed files with 43 additions and 25 deletions

View File

@@ -33,9 +33,11 @@ const error = ref(null)
const formInitialHash = ref(null)
function isDirty() {
return formInitialHash.value &&
updatedForm.value &&
formInitialHash.value !== hash(JSON.stringify(updatedForm?.value?.data() ?? null))
try {
return formInitialHash.value && updatedForm.value && formInitialHash.value !== hash(JSON.stringify(updatedForm?.value?.data() ?? null))
} catch (e) {
return false
}
}
function initUpdatedForm() {

View File

@@ -123,7 +123,11 @@ onMounted(() => {
if (process.client) {
if (form.value.custom_code) {
const scriptEl = document.createRange().createContextualFragment(form.value.custom_code)
document.head.append(scriptEl)
try {
document.head.append(scriptEl)
} catch (e) {
console.error('Error appending custom code', e)
}
}
if (!isIframe) focusOnFirstFormElement()
}
@@ -135,22 +139,28 @@ onBeforeRouteLeave((to, from) => {
disableDarkMode()
})
const pageMeta = computed(() => {
if (form.value && form.value.is_pro && form.value.seo_meta) {
return form.value.seo_meta
}
return {}
})
useOpnSeoMeta({
title: () => {
if (form && form.value?.is_pro && form.value.seo_meta.page_title) {
return form.value.seo_meta.page_title
if (pageMeta.value.page_title) {
return pageMeta.value.page_title
}
return form.value ? form.value.title : 'Create beautiful forms'
},
description: () => {
if (form && form.value?.is_pro && form.value.seo_meta.page_description) {
return form.value.seo_meta.page_description
if (pageMeta.value.description) {
return pageMeta.value.description
}
return (form && form.value?.description) ? form.value?.description.substring(0, 160) : null
},
ogImage: () => {
if (form && form.value?.is_pro && form.value.seo_meta.page_thumbnail) {
return form.value.seo_meta.page_thumbnail
if (pageMeta.value.page_thumbnail) {
return pageMeta.value.page_thumbnail
}
return (form && form.value?.cover_picture) ? form.value?.cover_picture : null
},
@@ -160,7 +170,7 @@ useOpnSeoMeta({
})
useHead({
titleTemplate: (titleChunk) => {
if (form && form.value?.is_pro && form.value?.seo_meta.page_title) {
if (pageMeta.value.page_title) {
// Disable template if custom SEO title
return titleChunk
}

View File

@@ -69,17 +69,21 @@
<NuxtLink :to="{name:'forms-slug-show-submissions', params: {slug:form.slug}}"
class="absolute inset-0"/>
<span class="font-semibold text-gray-900 dark:text-white">{{ form.title }}</span>
<ul class="flex text-gray-500">
<li class="pr-1">
<ul class="flex text-gray-500 text-sm gap-4">
<li class="pr-1 mr-3">
{{ form.views_count }} view{{ form.views_count > 0 ? 's' : '' }}
</li>
<li class="list-disc ml-6 pr-1">
<li class="list-disc mr-3">
{{ form.submissions_count }}
submission{{ form.submissions_count > 0 ? 's' : '' }}
</li>
<li class="list-disc ml-6">
<li class="list-disc mr-3">
Edited {{ form.last_edited_human }}
</li>
<li class='list-disc hidden lg:list-item'>
By
{{ form.creator.name }}
</li>
</ul>
<div v-if="['draft','closed'].includes(form.visibility) || (form.tags && form.tags.length > 0)"
class="mt-1 flex items-center flex-wrap gap-3">

View File

@@ -41,6 +41,8 @@ const update = () => {
form.patch('/settings/password').then((response) => {
form.reset()
useAlert().success('Password updated.')
}).catch((error) => {
console.error(error)
})
}
</script>