Work in progress

This commit is contained in:
Julien Nahum
2023-12-09 15:47:03 +01:00
parent f970557b76
commit 1f853e8178
315 changed files with 34058 additions and 25 deletions

17
client/mixins/forms/fieldsLogic.js vendored Normal file
View File

@@ -0,0 +1,17 @@
import FormPropertyLogicRule from '../../forms/FormPropertyLogicRule.js'
export default {
methods: {
validateFieldsLogic (properties) {
properties.forEach((field) => {
const isValid = (new FormPropertyLogicRule(field)).isValid()
if(!isValid){
field.logic = {
conditions: null,
actions: []
}
}
})
return properties
}
}
}

View File

@@ -0,0 +1,22 @@
const cyrb53 = (str, seed = 0) => {
let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
};
export default {
computed: {
formPendingSubmissionKey() {
return (this.form) ? this.form.form_pending_submission_key + '-' + cyrb53(window.location.href) : ''
}
}
}

64
client/mixins/forms/input.js vendored Normal file
View File

@@ -0,0 +1,64 @@
import { themes } from '~/config/form-themes.js'
export default {
props: {
id: { type: String, default: null },
name: { type: String, required: true },
label: { type: String, required: false },
form: { type: Object, required: false },
value: { required: false },
required: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
placeholder: { type: String, default: null },
uppercaseLabels: { type: Boolean, default: false },
help: { type: String, default: null },
helpPosition: { type: String, default: 'below_input' },
theme: { type: Object, default: () => themes.default },
color: { type: String, default: '#3B82F6' },
wrapperClass: { type: String, default: 'relative mb-3' }
},
data () {
return {
content: this.value
}
},
computed: {
inputStyle () {
return {
'--tw-ring-color': this.color
}
},
hasValidation () {
return this.form !== null && this.form !== undefined && this.form.hasOwnProperty('errors')
},
compVal: {
set (val) {
if (this.form) {
this.form[this.name] = val
} else {
this.content = val
}
if (this.hasValidation) {
this.form.errors.clear(this.name)
}
this.$emit('input', this.compVal)
},
get () {
if (this.form) {
return this.form[this.name]
}
return this.content
}
}
},
watch: {
value (val) {
if (val !== this.compVal) {
this.compVal = val
}
}
}
}

11
client/mixins/forms/saveUpdateAlert.js vendored Normal file
View File

@@ -0,0 +1,11 @@
export default {
methods: {
displayFormModificationAlert (responseData) {
if (responseData.form && responseData.form.cleanings && Object.keys(responseData.form.cleanings).length > 0) {
this.alertWarning(responseData.message)
} else {
this.alertSuccess(responseData.message)
}
}
}
}