Refactoring stores and templates pages to comp. api

This commit is contained in:
Julien Nahum
2023-12-19 13:46:55 +01:00
parent 3b798c12fd
commit bb519907f6
24 changed files with 432 additions and 457 deletions

View File

@@ -129,6 +129,12 @@ export default {
submitButtonClass: { type: String, default: '' }
},
setup() {
return {
isIframe: useIsIframe()
}
},
data () {
return {
loading: false,
@@ -143,11 +149,8 @@ export default {
},
computed: {
isIframe () {
return window.location !== window.parent.location || window.frameElement
},
isEmbedPopup () {
return window.location.href.includes('popup=true')
return process.client && window.location.href.includes('popup=true')
},
theme () {
return this.themes[this.themes.hasOwnProperty(this.form.theme) ? this.form.theme : 'default']
@@ -156,7 +159,7 @@ export default {
return this.$route.name === 'forms.show_public'
},
isHideTitle () {
return this.form.hide_title || window.location.href.includes('hide_title=true')
return this.form.hide_title || (process.client && window.location.href.includes('hide_title=true'))
}
},

View File

@@ -106,7 +106,8 @@ export default {
const workingFormStore = useWorkingFormStore()
return {
recordsStore,
workingFormStore
workingFormStore,
darkModeEnabled: useDark()
}
},
@@ -118,7 +119,6 @@ export default {
* Used to force refresh components by changing their keys
*/
formVersionId: 1,
darkModeEnabled: document.body.classList.contains('dark'),
isAutoSubmit: false,
/**
* If currently dragging a field
@@ -259,7 +259,7 @@ export default {
return
}
if (this.form.use_captcha) {
if (this.form.use_captcha && process.client) {
this.dataForm['h-captcha-response'] = document.getElementsByName('h-captcha-response')[0].value
this.$refs.hcaptcha.reset()
}
@@ -291,6 +291,7 @@ export default {
}
// Scroll to error
if (process.server) return
const elements = document.getElementsByClassName('has-error')
if (elements.length > 0) {
window.scroll({

View File

@@ -161,7 +161,7 @@ export default {
if (response.data.message) {
this.alertSuccess(response.data.message)
}
this.templatesStore.addOrUpdate(response.data.data)
this.templatesStore.save(response.data.data)
this.$emit('close')
})
},
@@ -171,7 +171,7 @@ export default {
if (response.data.message) {
this.alertSuccess(response.data.message)
}
this.templatesStore.addOrUpdate(response.data.data)
this.templatesStore.save(response.data.data)
this.$emit('close')
})
},