moves fillExtraForm data function on the role formHook to the correct place. #664.

This commit is contained in:
mateuswetah 2022-02-04 11:24:04 -03:00
parent 5a562016af
commit 8bbb5542a7
2 changed files with 24 additions and 14 deletions

View File

@ -107,8 +107,7 @@ export const formHooks = {
if (
this.formHooks[this.entityName] &&
this.formHooks[this.entityName][position] &&
this.formHooks[this.entityName][position]['form'] &&
this.formHooks[this.entityName][position]['form'] != undefined
this.formHooks[this.entityName][position] != undefined
) {
let formElement = document.getElementById('form-' + this.entityName + '-' + position);
if (formElement) {
@ -142,15 +141,17 @@ export const formHooks = {
if (
this.formHooks[this.entityName] &&
this.formHooks[this.entityName][position] &&
this.formHooks[this.entityName][position]['form'] &&
this.formHooks[this.entityName][position]['form'] != undefined
this.formHooks[this.entityName][position] != undefined
) {
let formElement = document.getElementById('form-' + this.entityName + '-' + position);
if (formElement) {
console.log(formElement)
if (formElement) {
console.log(formElement)
for (let element of formElement.elements) {
console.log(element)
for (let key of Object.keys(entityObject)) {
if (element['name'] == key) {
console.log(entityObject[key])
if (Array.isArray(entityObject[key])) {
let obj = entityObject[key].find((value) => { return value == element['value'] });
element['checked'] = obj != undefined ? true : false;
@ -171,7 +172,6 @@ export const formHooks = {
}
},
checkFormConditionals(aForm) {
console.log(this.form, aForm)
if (aForm['form']) {
if (aForm['conditional'] && aForm['conditional']['attribute'] && aForm['conditional']['value'])
return (this.form && this.form[aForm['conditional']['attribute']] === aForm['conditional']['value'] ) ? aForm['form'] : '';

View File

@ -304,7 +304,16 @@
this.fetchRole(this.roleSlug)
.then((originalRole) => {
this.form = JSON.parse(JSON.stringify(originalRole));
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData(this.form);
console.log(this.form)
});
this.isLoadingRole = false;
}).catch(() => {
this.isLoadingRole = false;
});
@ -315,6 +324,14 @@
this.form = JSON.parse(JSON.stringify(originalRole));
this.form.name = this.form.name + ' ' + this.$i18n.get('(Copy)');
this.form.slug = undefined;
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData(this.form);
console.log(this.form)
});
this.isLoadingRole = false;
}).catch(() => {
this.isLoadingRole = false;
@ -349,13 +366,6 @@
this.isLoadingCollections = false;
});
},
mounted() {
// Fills hook forms with it's real values
this.$nextTick()
.then(() => {
this.updateExtraFormData(this.form);
});
},
methods: {
...mapActions('collection', [
'fetchAllCollectionNames'