Stuck at changing routes

This commit is contained in:
Julien Nahum
2023-10-14 18:24:44 +02:00
parent 358bf0e4d0
commit 3d3759c58c
29 changed files with 316 additions and 540 deletions

View File

@@ -55,21 +55,21 @@
Please create this form on a device with a larger screen. That will allow you to preview your form changes.
</div>
<form-information/>
<form-structure/>
<form-customization/>
<form-about-submission/>
<form-notifications/>
<form-security-privacy/>
<form-information />
<form-structure />
<form-customization />
<form-about-submission />
<form-notifications />
<form-security-privacy />
<form-custom-seo />
<form-custom-code/>
<form-integrations/>
<form-custom-code />
<form-integrations />
</div>
<form-editor-preview/>
<form-editor-preview />
<form-field-edit-sidebar/>
<add-form-block-sidebar/>
<form-field-edit-sidebar />
<add-form-block-sidebar />
<!-- Form Error Modal -->
<form-error-modal
@@ -80,12 +80,12 @@
</div>
</div>
<div v-else class="flex justify-center items-center">
<loader class="w-6 h-6"/>
<loader class="w-6 h-6" />
</div>
</template>
<script>
import {mapGetters} from 'vuex'
import { mapGetters } from 'vuex'
import AddFormBlockSidebar from './form-components/AddFormBlockSidebar.vue'
import FormFieldEditSidebar from '../fields/FormFieldEditSidebar.vue'
import FormErrorModal from './form-components/FormErrorModal.vue'
@@ -143,7 +143,7 @@ export default {
}
},
data() {
data () {
return {
showFormErrorModal: false,
validationErrorResponse: null,
@@ -157,21 +157,21 @@ export default {
user: 'auth/user'
}),
form: {
get() {
get () {
return this.$store.state['open/working_form'].content
},
/* We add a setter */
set(value) {
set (value) {
this.$store.commit('open/working_form/set', value)
}
},
createdForm() {
createdForm () {
return this.$store.getters['open/forms/getById'](this.createdFormId)
},
workspace() {
workspace () {
return this.$store.getters['open/workspaces/getCurrent']()
},
steps() {
steps () {
return [
{
target: '#v-step-0',
@@ -211,12 +211,12 @@ export default {
watch: {},
mounted() {
mounted () {
this.$emit('mounted')
this.$root.hideNavbar()
},
beforeDestroy () {
beforeUnmount () {
this.$root.hideNavbar(false)
},
@@ -225,12 +225,12 @@ export default {
window.$crisp.push(['do', 'chat:show'])
window.$crisp.push(['do', 'chat:open'])
},
showValidationErrors() {
showValidationErrors () {
this.showFormErrorModal = true
},
saveForm() {
saveForm () {
this.form.properties = this.validateFieldsLogic(this.form.properties)
if(this.isGuest) {
if (this.isGuest) {
this.saveFormGuest()
} else if (this.isEdit) {
this.saveFormEdit()
@@ -238,7 +238,7 @@ export default {
this.saveFormCreate()
}
},
saveFormEdit() {
saveFormEdit () {
if (this.updateFormLoading) return
this.updateFormLoading = true
@@ -247,8 +247,8 @@ export default {
const data = response.data
this.$store.commit('open/forms/addOrUpdate', data.form)
this.$emit('on-save')
this.$router.push({name: 'forms.show', params: {slug: this.form.slug}})
this.$logEvent('form_saved', {form_id: this.form.id, form_slug: this.form.slug})
this.$router.push({ name: 'forms.show', params: { slug: this.form.slug } })
this.$logEvent('form_saved', { form_id: this.form.id, form_slug: this.form.slug })
this.displayFormModificationAlert(data)
}).catch((error) => {
if (error.response.status === 422) {
@@ -259,7 +259,7 @@ export default {
this.updateFormLoading = false
})
},
saveFormCreate() {
saveFormCreate () {
if (this.updateFormLoading) return
this.form.workspace_id = this.workspace.id
this.validationErrorResponse = null
@@ -270,7 +270,7 @@ export default {
this.$emit('on-save')
this.createdFormId = response.data.form.id
this.$logEvent('form_created', {form_id: response.data.form.id, form_slug: response.data.form.slug})
this.$logEvent('form_created', { form_id: response.data.form.id, form_slug: response.data.form.slug })
this.$crisp.push(['set', 'session:event', [[['form_created', {
form_id: response.data.form.id,
form_slug: response.data.form.slug
@@ -292,7 +292,7 @@ export default {
this.updateFormLoading = false
})
},
saveFormGuest() {
saveFormGuest () {
this.$emit('openRegister')
}
}

View File

@@ -7,71 +7,72 @@
:class="{'absolute': data.length !== 0}"
style="will-change: transform; transform: translate3d(0px, 0px, 0px)"
>
<tr class="n-table-row overflow-x-hidden">
<resizable-th v-for="col, index in form.properties" :id="'table-head-cell-' + col.id" :key="col.id"
scope="col" :allow-resize="allowResize" :width="(col.cell_width ? col.cell_width + 'px':'auto')"
class="n-table-cell p-0 relative"
@resize-width="resizeCol(col, $event)"
>
<p
:class="{'border-r': index < form.properties.length - 1 || hasActions}"
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs"
<tr class="n-table-row overflow-x-hidden">
<resizable-th v-for="col, index in form.properties" :id="'table-head-cell-' + col.id" :key="col.id"
scope="col" :allow-resize="allowResize" :width="(col.cell_width ? col.cell_width + 'px':'auto')"
class="n-table-cell p-0 relative"
@resize-width="resizeCol(col, $event)"
>
{{ col.name }}
</p>
</resizable-th>
<th v-if="hasActions" class="n-table-cell p-0 relative" style="width: 100px">
<p
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs">
Actions
</p>
</th>
</tr>
<p
:class="{'border-r': index < form.properties.length - 1 || hasActions}"
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs"
>
{{ col.name }}
</p>
</resizable-th>
<th v-if="hasActions" class="n-table-cell p-0 relative" style="width: 100px">
<p
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs"
>
Actions
</p>
</th>
</tr>
</thead>
<tbody v-if="data.length > 0" class="n-table-body bg-white dark:bg-notion-dark-light">
<tr v-if="$slots.hasOwnProperty('actions')"
:id="'table-actions-'+tableHash"
ref="actions-row"
class="action-row absolute w-full"
style="will-change: transform; transform: translate3d(0px, 32px, 0px)"
>
<td :colspan="form.properties.length" class="p-1">
<slot name="actions"/>
</td>
</tr>
<tr v-for="row, index in data" :key="index" class="n-table-row" :class="{'first':index===0}">
<td v-for="col, colIndex in form.properties"
:key="col.id"
:style="{width: col.cell_width + 'px'}"
class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 overflow-hidden"
:class="[{'border-b': index !== data.length - 1, 'border-r': colIndex !== form.properties.length - 1 || hasActions},
<tr v-if="$slots.hasOwnProperty('actions')"
:id="'table-actions-'+tableHash"
ref="actions-row"
class="action-row absolute w-full"
style="will-change: transform; transform: translate3d(0px, 32px, 0px)"
>
<td :colspan="form.properties.length" class="p-1">
<slot name="actions" />
</td>
</tr>
<tr v-for="row, index in data" :key="index" class="n-table-row" :class="{'first':index===0}">
<td v-for="col, colIndex in form.properties"
:key="col.id"
:style="{width: col.cell_width + 'px'}"
class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 overflow-hidden"
:class="[{'border-b': index !== data.length - 1, 'border-r': colIndex !== form.properties.length - 1 || hasActions},
colClasses(col)]"
>
<component :is="fieldComponents[col.type]" class="border-gray-100 dark:border-gray-900"
:property="col" :value="row[col.id]"
/>
</td>
<td v-if="hasActions" class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 border-b"
style="width: 100px"
>
<record-operations :form="form" :structure="form.properties" :rowid="row.id" @deleted="$emit('deleted')" />
</td>
</tr>
<tr v-if="loading" class="n-table-row border-t bg-gray-50 dark:bg-gray-900">
<td :colspan="form.properties.length" class="p-8 w-full">
<loader class="w-4 h-4 mx-auto"/>
</td>
</tr>
>
<component :is="fieldComponents[col.type]" class="border-gray-100 dark:border-gray-900"
:property="col" :value="row[col.id]"
/>
</td>
<td v-if="hasActions" class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 border-b"
style="width: 100px"
>
<record-operations :form="form" :structure="form.properties" :rowid="row.id" @deleted="$emit('deleted')" />
</td>
</tr>
<tr v-if="loading" class="n-table-row border-t bg-gray-50 dark:bg-gray-900">
<td :colspan="form.properties.length" class="p-8 w-full">
<loader class="w-4 h-4 mx-auto" />
</td>
</tr>
</tbody>
<tbody v-else key="body-content" class="n-table-body">
<tr class="n-table-row loader w-full">
<td :colspan="form.properties.length" class="n-table-cell w-full p-8">
<loader v-if="loading" class="w-4 h-4 mx-auto"/>
<p v-else class="text-gray-500 text-center">
No data found.
</p>
</td>
</tr>
<tr class="n-table-row loader w-full">
<td :colspan="form.properties.length" class="n-table-cell w-full p-8">
<loader v-if="loading" class="w-4 h-4 mx-auto" />
<p v-else class="text-gray-500 text-center">
No data found.
</p>
</td>
</tr>
</tbody>
</table>
</template>
@@ -101,7 +102,7 @@ const cyrb53 = function (str, seed = 0) {
}
export default {
components: {ResizableTh, RecordOperations},
components: { ResizableTh, RecordOperations },
props: {
data: {
type: Array,
@@ -115,10 +116,10 @@ export default {
required: false,
default: true,
type: Boolean
},
}
},
data() {
data () {
return {
tableHash: null,
skip: false
@@ -127,18 +128,18 @@ export default {
computed: {
form: {
get() {
get () {
return this.$store.state['open/working_form'].content
},
set(value) {
set (value) {
this.$store.commit('open/working_form/set', value)
}
},
hasActions() {
hasActions () {
// In future if want to hide based on condition
return true
},
fieldComponents() {
fieldComponents () {
return {
text: OpenText,
number: OpenText,
@@ -150,35 +151,35 @@ export default {
url: OpenUrl,
email: OpenText,
phone_number: OpenText,
signature: OpenFile,
signature: OpenFile
}
},
}
},
watch: {
'form.properties': {
handler() {
handler () {
this.onStructureChange()
},
deep: true
},
data() {
data () {
this.$nextTick(() => {
this.handleScroll()
})
}
},
mounted() {
mounted () {
const parent = document.getElementById('table-page')
this.tableHash = cyrb53(JSON.stringify(this.form.properties))
parent.addEventListener('scroll', this.handleScroll, {passive: true})
parent.addEventListener('scroll', this.handleScroll, { passive: true })
window.addEventListener('resize', this.handleScroll)
this.onStructureChange()
this.handleScroll()
},
beforeDestroy() {
beforeUnmount () {
const parent = document.getElementById('table-page')
if (parent) {
parent.removeEventListener('scroll', this.handleScroll)
@@ -187,7 +188,7 @@ export default {
},
methods: {
colClasses(col) {
colClasses (col) {
let colAlign, colColor, colFontWeight, colWrap
// Column align
@@ -212,7 +213,7 @@ export default {
return [colAlign, colColor, colWrap, colFontWeight]
},
onStructureChange() {
onStructureChange () {
if (this.form && this.form.properties) {
this.$nextTick(() => {
this.form.properties.forEach(col => {
@@ -226,7 +227,7 @@ export default {
})
}
},
resizeCol(col, width) {
resizeCol (col, width) {
if (!this.form) return
const columns = clonedeep(this.form.properties)
const index = this.form.properties.findIndex(c => c.id === col.id)
@@ -236,7 +237,7 @@ export default {
this.$emit('resize')
})
},
handleScroll() {
handleScroll () {
const parent = document.getElementById('table-page')
const posTop = parent.getBoundingClientRect().top
const tablePosition = Math.max(0, posTop - this.$refs.table.getBoundingClientRect().top)
@@ -264,7 +265,7 @@ export default {
}
}
}
},
}
}
}
</script>