Skip to content

Commit 000b65d

Browse files
madassdevJhumanJ
andauthored
Form draft warning (#287)
* feat: add warning to draft form preview button * warning modal component * feat: use notification for draft form warning * fix: remove unused variable * fix: remove unused variable --------- Co-authored-by: Julien Nahum <julien@nahum.net>
1 parent 0c88c98 commit 000b65d

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

client/components/pages/forms/show/ExtraMenu.vue

+23-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,25 @@
2424
</svg>
2525
</v-button>
2626
</template>
27-
<a v-if="isMainPage && user" v-track.view_form_click="{form_id:form.id, form_slug:form.slug}" :href="form.share_url"
27+
<span v-if="form.visibility === 'draft'"
28+
class="block px-4 py-2 text-md text-gray-700 cursor-pointer dark:text-white hover:bg-gray-100 hover:text-gray-900 dark:text-gray-100 dark:hover:text-white dark:hover:bg-gray-600 flex items-center"
29+
@click="showDraftFormWarningNotification"
30+
>
31+
<svg class="w-4 h-4 mr-2" viewBox="0 0 24 24" fill="none"
32+
xmlns="http://www.w3.org/2000/svg"
33+
>
34+
<path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"
35+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
36+
/>
37+
<path
38+
d="M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z"
39+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
40+
/>
41+
</svg>
42+
View form
43+
</span>
44+
45+
<a v-else-if="isMainPage && user" v-track.view_form_click="{form_id:form.id, form_slug:form.slug}" :href="form.share_url"
2846
target="_blank"
2947
class="block px-4 py-2 text-md text-gray-700 dark:text-white hover:bg-gray-100 hover:text-gray-900 dark:text-gray-100 dark:hover:text-white dark:hover:bg-gray-600 flex items-center"
3048
>
@@ -133,7 +151,6 @@
133151
</div>
134152
</div>
135153
</modal>
136-
137154
<form-template-modal v-if="!isMainPage && user" :form="form" :show="showFormTemplateModal" @close="showFormTemplateModal=false" />
138155
</div>
139156
</template>
@@ -185,4 +202,8 @@ const deleteForm = () => {
185202
loadingDelete.value = false
186203
})
187204
}
205+
206+
const showDraftFormWarningNotification = () => {
207+
useAlert().warning('This form is currently in Draft mode and is not publicly accessible, You can change the form status on the edit form page.')
208+
}
188209
</script>

client/pages/forms/[slug]/show.vue

+20-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@
2222
<div class="flex">
2323
<extra-menu class="mr-2" :form="form"/>
2424

25-
<v-button v-track.view_form_click="{form_id:form.id, form_slug:form.slug}" target="_blank"
25+
<v-button v-if="form.visibility === 'draft'" color="white"
26+
class="mr-2 text-blue-600 hidden sm:block" @click="showDraftFormWarningNotification"
27+
>
28+
<svg class="w-6 h-6 inline -mt-1" viewBox="0 0 24 24" fill="none"
29+
xmlns="http://www.w3.org/2000/svg"
30+
>
31+
<path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"
32+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
33+
/>
34+
<path
35+
d="M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z"
36+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
37+
/>
38+
</svg>
39+
</v-button>
40+
<v-button v-else v-track.view_form_click="{form_id:form.id, form_slug:form.slug}" target="_blank"
2641
:href="form.share_url" color="white"
2742
class="mr-2 text-blue-600 hidden sm:block"
2843
>
@@ -196,4 +211,8 @@ watch(() => form?.value?.id, (id) => {
196211
const goBack = () => {
197212
useRouter().push({name: 'home'})
198213
}
214+
215+
const showDraftFormWarningNotification = () => {
216+
useAlert().warning('This form is currently in Draft mode and is not publicly accessible, You can change the form status on the edit form page.')
217+
}
199218
</script>

0 commit comments

Comments
 (0)