Work in progress for form create guess user
This commit is contained in:
parent
5df3245543
commit
b4365b5e30
|
@ -90,6 +90,7 @@ const closeOnEscape = (e) => {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (process.server) return
|
if (process.server) return
|
||||||
document.addEventListener('keydown', closeOnEscape)
|
document.addEventListener('keydown', closeOnEscape)
|
||||||
|
initMotions()
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
@ -160,13 +161,15 @@ const content = ref(null)
|
||||||
const backdropMotion = ref(null)
|
const backdropMotion = ref(null)
|
||||||
const contentMotion = ref(null)
|
const contentMotion = ref(null)
|
||||||
|
|
||||||
watch(() => props.show, (newVal, oldVal) => {
|
const initMotions = () => {
|
||||||
if (newVal) {
|
if (props.show) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
backdropMotion.value = useMotion(backdrop.value, motionFadeIn)
|
backdropMotion.value = useMotion(backdrop.value, motionFadeIn)
|
||||||
contentMotion.value = useMotion(content.value, motionSlideBottom)
|
contentMotion.value = useMotion(content.value, motionSlideBottom)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
watch(() => props.show, initMotions)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -61,6 +61,7 @@ export default {
|
||||||
setup () {
|
setup () {
|
||||||
return {
|
return {
|
||||||
authStore: useAuthStore(),
|
authStore: useAuthStore(),
|
||||||
|
formsStore: useFormsStore(),
|
||||||
workspaceStore: useWorkspacesStore()
|
workspaceStore: useWorkspacesStore()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -88,6 +89,9 @@ export default {
|
||||||
const workspaces = await fetchAllWorkspaces()
|
const workspaces = await fetchAllWorkspaces()
|
||||||
this.workspaceStore.set(workspaces.data.value)
|
this.workspaceStore.set(workspaces.data.value)
|
||||||
|
|
||||||
|
// Load forms
|
||||||
|
this.formsStore.loadAll(this.workspaceStore.currentId)
|
||||||
|
|
||||||
// Redirect home.
|
// Redirect home.
|
||||||
this.redirect()
|
this.redirect()
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<modal :show="show" :closeable="!aiForm.busy" @close="$emit('close')">
|
<Modal :show="show" :closeable="!aiForm.busy" @close="$emit('close')">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<template v-if="state=='default'">
|
<template v-if="state=='default'">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-10 h-10 text-blue">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-10 h-10 text-blue">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
~60 sec
|
~60 sec
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
class="w-full flex flex-grow"
|
class="w-full flex flex-grow"
|
||||||
:error="error"
|
:error="error"
|
||||||
:is-guest="isGuest"
|
:is-guest="isGuest"
|
||||||
@openRegister="openRegister"
|
@openRegister="registerModal=true"
|
||||||
/>
|
/>
|
||||||
<div v-else class="text-center mt-4 py-6">
|
<div v-else class="text-center mt-4 py-6">
|
||||||
<Loader class="h-6 w-6 text-nt-blue mx-auto" />
|
<Loader class="h-6 w-6 text-nt-blue mx-auto"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
@ -23,124 +23,74 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import {initForm} from "~/composables/forms/initForm.js"
|
import FormEditor from "~/components/open/forms/components/FormEditor.vue"
|
||||||
import QuickRegister from '~/components/pages/auth/components/QuickRegister.vue'
|
import QuickRegister from '~/components/pages/auth/components/QuickRegister.vue'
|
||||||
import CreateFormBaseModal from '../../../components/pages/forms/create/CreateFormBaseModal.vue'
|
import CreateFormBaseModal from '../../../components/pages/forms/create/CreateFormBaseModal.vue'
|
||||||
|
import {initForm} from "~/composables/forms/initForm.js"
|
||||||
|
import {loadAllTemplates} from "~/stores/templates.js";
|
||||||
|
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
|
||||||
|
|
||||||
const loadTemplates = function () {
|
// middleware: 'guest',
|
||||||
const templatesStore = useTemplatesStore()
|
|
||||||
templatesStore.startLoading()
|
|
||||||
templatesStore.loadIfEmpty().then(() => {
|
|
||||||
templatesStore.stopLoading()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
const templatesStore = useTemplatesStore()
|
||||||
name: 'CreateFormGuest',
|
const workingFormStore = useWorkingFormStore()
|
||||||
components: {
|
const workspacesStore = useWorkspacesStore()
|
||||||
QuickRegister, CreateFormBaseModal
|
const route = useRoute()
|
||||||
},
|
loadAllTemplates(templatesStore)
|
||||||
middleware: 'guest',
|
|
||||||
|
|
||||||
beforeRouteEnter (to, from, next) {
|
// Store values
|
||||||
loadTemplates()
|
const workspace = computed(() => workspacesStore.getCurrent)
|
||||||
next()
|
const workspacesLoading = computed(() => workspacesStore.loading)
|
||||||
},
|
const form = storeToRefs(workingFormStore).content
|
||||||
|
|
||||||
setup () {
|
// metaTitle: 'Create a new Form as Guest',
|
||||||
const templatesStore = useTemplatesStore()
|
// Data
|
||||||
const workingFormStore = useWorkingFormStore()
|
const stateReady = ref(false)
|
||||||
const workspacesStore = useWorkspacesStore()
|
const loading = ref(false)
|
||||||
return {
|
const error = ref('')
|
||||||
templatesStore,
|
const registerModal = ref(false)
|
||||||
workingFormStore,
|
const isGuest = ref(true)
|
||||||
workspacesStore,
|
const showInitialFormModal = ref(false)
|
||||||
workspaces : computed(() => workspacesStore.content),
|
|
||||||
workspacesLoading : computed(() => workspacesStore.loading)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
data () {
|
// Component ref
|
||||||
return {
|
const editor = ref(null)
|
||||||
metaTitle: 'Create a new Form as Guest',
|
|
||||||
stateReady: false,
|
|
||||||
loading: false,
|
|
||||||
error: '',
|
|
||||||
registerModal: false,
|
|
||||||
isGuest: true,
|
|
||||||
showInitialFormModal: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
onMounted(() => {
|
||||||
form: {
|
|
||||||
get () {
|
|
||||||
return this.workingFormStore.content
|
|
||||||
},
|
|
||||||
/* We add a setter */
|
|
||||||
set (value) {
|
|
||||||
this.workingFormStore.set(value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
workspace () {
|
|
||||||
return this.workspacesStore.getCurrent()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
workspace () {
|
|
||||||
if (this.workspace) {
|
|
||||||
this.form.workspace_id = this.workspace.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted () {
|
|
||||||
// Set as guest user
|
// Set as guest user
|
||||||
const guestWorkspace = {
|
workspacesStore.set([{
|
||||||
id: null,
|
id: null,
|
||||||
name: 'Guest Workspace',
|
name: 'Guest Workspace',
|
||||||
is_enterprise: false,
|
is_enterprise: false,
|
||||||
is_pro: false
|
is_pro: false
|
||||||
}
|
}])
|
||||||
this.workspacesStore.set([guestWorkspace])
|
|
||||||
this.workspacesStore.setCurrentId(guestWorkspace.id)
|
|
||||||
|
|
||||||
this.form = initForm()
|
form.value = initForm()
|
||||||
if (this.$route.query.template !== undefined && this.$route.query.template) {
|
if (route.query.template !== undefined && route.query.template) {
|
||||||
const template = this.templatesStore.getByKey(this.$route.query.template)
|
const template = this.templatesStore.getByKey(route.query.template)
|
||||||
if (template && template.structure) {
|
if (template && template.structure) {
|
||||||
this.form = useForm({ ...this.form.data(), ...template.structure })
|
form.value = useForm({...this.form.data(), ...template.structure})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No template loaded, ask how to start
|
// No template loaded, ask how to start
|
||||||
this.showInitialFormModal = true
|
showInitialFormModal.value = true
|
||||||
}
|
}
|
||||||
this.closeAlert()
|
// this.closeAlert()
|
||||||
this.stateReady = true
|
stateReady.value = true
|
||||||
},
|
})
|
||||||
|
|
||||||
created () {},
|
const afterLogin = () => {
|
||||||
unmounted () {},
|
registerModal.value = false
|
||||||
|
isGuest.value = false
|
||||||
methods: {
|
fetchAllWorkspaces()
|
||||||
openRegister () {
|
|
||||||
this.registerModal = true
|
|
||||||
},
|
|
||||||
afterLogin () {
|
|
||||||
this.registerModal = false
|
|
||||||
this.isGuest = false
|
|
||||||
this.workspacesStore.load()
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.$refs.editor) {
|
if (editor) {
|
||||||
this.$refs.editor.saveFormCreate()
|
editor.saveFormCreate()
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
}
|
||||||
formGenerated (form) {
|
|
||||||
this.form = useForm({ ...this.form.data(), ...form })
|
const formGenerated = (newForm) => {
|
||||||
}
|
form.value = useForm({...form.value.data(), ...newForm})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue