Continues implementation of plugins.

This commit is contained in:
Mateus Machado Luna 2018-08-30 08:54:41 -03:00
parent 1406ee8f35
commit 4131ff9359
7 changed files with 79 additions and 67 deletions

View File

@ -30,11 +30,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-collection'] != undefined &&
formHooks['form-collection']['begin-left'] != undefined">
formHooks['collection'] != undefined &&
formHooks['collection']['begin-left'] != undefined">
<form
id="form-collection-begin-left"
v-html="this.formHooks['form-collection']['begin-left'].join('')"/>
v-html="this.formHooks['collection']['begin-left'].join('')"/>
</template>
<!-- Thumbnail -------------------------------- -->
@ -234,11 +234,12 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-collection'] != undefined &&
formHooks['form-collection']['end-left'] != undefined">
<form
formHooks['collection'] != undefined &&
formHooks['collection']['end-left'] != undefined">
<form
ref="form-collection-end-left"
id="form-collection-end-left"
v-html="formHooks['form-collection']['end-left'].join('')"/>
v-html="formHooks['collection']['end-left'].join('')"/>
</template>
</div>
@ -248,11 +249,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-collection'] != undefined &&
formHooks['form-collection']['begin-right'] != undefined">
formHooks['collection'] != undefined &&
formHooks['collection']['begin-right'] != undefined">
<form
id="form-collection-begin-right"
v-html="formHooks['form-collection']['begin-right'].join('')"/>
v-html="formHooks['collection']['begin-right'].join('')"/>
</template>
<!-- Status -------------------------------- -->
@ -419,11 +420,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-collection'] != undefined &&
formHooks['form-collection']['end-right'] != undefined">
formHooks['collection'] != undefined &&
formHooks['collection']['end-right'] != undefined">
<form
id="form-collection-end-right"
v-html="formHooks['form-collection']['end-right'].join('')"/>
v-html="formHooks['collection']['end-right'].join('')"/>
</template>
</div>
@ -611,10 +612,10 @@ export default {
this.formErrorMessage = '';
this.editFormErrors = {};
// if (this.fromImporter)
// this.$router.go(-1);
// else
// this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
if (this.fromImporter)
this.$router.go(-1);
else
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
})
.catch((errors) => {
for (let error of errors.errors) {
@ -827,9 +828,12 @@ export default {
// Initializes Media Frames now that collectonId exists
this.initializeMediaFrames();
// Fills hook forms with it's real values
this.updateExtraFormData('collection', this.collection);
this.$nextTick()
.then(() => {
// Fills hook forms with it's real values
this.updateExtraFormData('collection', this.collection);
});
// Fill this.form data with current data.
this.form.name = this.collection.name;

View File

@ -7,11 +7,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-filter'] != undefined &&
formHooks['form-filter']['begin'] != undefined">
formHooks['filter'] != undefined &&
formHooks['filter']['begin-left'] != undefined">
<form
id="form-filter-begin"
v-html="formHooks['form-filter']['begin'].join('')"/>
v-html="formHooks['filter']['begin-left'].join('')"/>
</template>
<b-field
@ -150,11 +150,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-filter'] != undefined &&
formHooks['form-filter']['end'] != undefined">
formHooks['filter'] != undefined &&
formHooks['filter']['end-left'] != undefined">
<form
id="form-filter-end"
v-html="formHooks['form-filter']['end'].join('')"/>
v-html="formHooks['filter']['end-left'].join('')"/>
</template>
<div class="field is-grouped form-submit">

View File

@ -19,11 +19,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-item'] != undefined &&
formHooks['form-item']['begin-left'] != undefined">
formHooks['item'] != undefined &&
formHooks['item']['begin-left'] != undefined">
<form
id="form-item-begin-left"
v-html="formHooks['form-item']['begin-left'].join('')"/>
v-html="formHooks['item']['begin-left'].join('')"/>
</template>
<!-- Document -------------------------------- -->
@ -305,11 +305,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-item'] != undefined &&
formHooks['form-item']['end-left'] != undefined">
formHooks['item'] != undefined &&
formHooks['item']['end-left'] != undefined">
<form
id="form-item-end-left"
v-html="formHooks['form-item']['end-left'].join('')"/>
v-html="formHooks['item']['end-left'].join('')"/>
</template>
</div>
@ -320,11 +320,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-item'] != undefined &&
formHooks['form-item']['begin-right'] != undefined">
formHooks['item'] != undefined &&
formHooks['item']['begin-right'] != undefined">
<form
id="form-item-begin-right"
v-html="formHooks['form-item']['begin-right'].join('')"/>
v-html="formHooks['item']['begin-right'].join('')"/>
</template>
@ -390,11 +390,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-item'] != undefined &&
formHooks['form-item']['end-right'] != undefined">
formHooks['item'] != undefined &&
formHooks['item']['end-right'] != undefined">
<form
id="form-item-end-right"
v-html="formHooks['form-item']['end-right'].join('')"/>
v-html="formHooks['item']['end-right'].join('')"/>
</template>
</div>
</div>

View File

@ -8,11 +8,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-metadatum'] != undefined &&
formHooks['form-metadatum']['begin'] != undefined">
formHooks['metadatum'] != undefined &&
formHooks['metadatum']['begin-left'] != undefined">
<form
id="form-metadatum-begin"
v-html="formHooks['form-metadatum']['begin'].join('')"/>
v-html="formHooks['metadatum']['begin-left'].join('')"/>
</template>
<b-field
@ -219,11 +219,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-metadatum'] != undefined &&
formHooks['form-metadatum']['end'] != undefined">
formHooks['metadatum'] != undefined &&
formHooks['metadatum']['end-left'] != undefined">
<form
id="form-metadatum-end"
v-html="formHooks['form-metadatum']['end'].join('')"/>
v-html="formHooks['metadatum']['end-left'].join('')"/>
</template>
<div class="field is-grouped form-submit">

View File

@ -12,11 +12,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-taxonomy'] != undefined &&
formHooks['form-taxonomy']['begin'] != undefined">
formHooks['taxonomy'] != undefined &&
formHooks['taxonomy']['begin-left'] != undefined">
<form
id="form-taxonomy-begin"
v-html="formHooks['form-taxonomy']['begin'].join('')"/>
v-html="formHooks['taxonomy']['begin-left'].join('')"/>
</template>
<!-- Name -------------------------------- -->
@ -112,11 +112,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-taxonomy'] != undefined &&
formHooks['form-taxonomy']['end'] != undefined">
formHooks['taxonomy'] != undefined &&
formHooks['taxonomy']['end-left'] != undefined">
<form
id="form-taxonomy-end"
v-html="formHooks['form-taxonomy']['end'].join('')"/>
v-html="formHooks['taxonomy']['end-left'].join('')"/>
</template>
<!-- Submit -->

View File

@ -11,11 +11,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-term'] != undefined &&
formHooks['form-term']['begin'] != undefined">
formHooks['term'] != undefined &&
formHooks['term']['begin-left'] != undefined">
<form
id="form-term-begin"
v-html="formHooks['form-term']['begin'].join('')"/>
v-html="formHooks['term']['begin-left'].join('')"/>
</template>
<!-- Header Image -------------------------------- -->
@ -135,11 +135,11 @@
<!-- Hook for extra Form options -->
<template
v-if="formHooks != undefined &&
formHooks['form-term'] != undefined &&
formHooks['form-term']['end'] != undefined">
formHooks['term'] != undefined &&
formHooks['term']['end-left'] != undefined">
<form
id="form-term-end"
v-html="formHooks['form-term']['end'].join('')"/>
v-html="formHooks['term']['end-left'].join('')"/>
</template>
<!-- Submit buttons -------------- -->

View File

@ -60,14 +60,12 @@ export const formHooks = {
let positions = [
'begin-left',
'begin-right',
'begin',
'end-left',
'end-right',
'end'
'end-right'
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks['form-' + entity][position] && this.formHooks['form-' + entity][position] != undefined) {
if (this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
if (formElement) {
let formData = new FormData(formElement);
@ -82,20 +80,30 @@ export const formHooks = {
let positions = [
'begin-left',
'begin-right',
'begin',
'end-left',
'end-right',
'end'
'end-right'
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks['form-' + entity][position] && this.formHooks['form-' + entity][position] != undefined) {
if (this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
console.log(formElement.elements);
if (formElement) {
let formData = new FormData(formElement);
for (let element of formElement.elements) {
console.log(entityObject);
for (let key of Object.keys(entityObject)) {
console.log(key, entityObject[key]);
if (element['name'] == key)
element['value'] = entityObject[key];
}
}
let formData = new FormData(formElement);
for (let [key, value] of formData.entries()) {
if (entityObject[key] != undefined && entityObject[key] != null)
value = entityObject[key];
console.log(key, value);
// if (entityObject[key] != undefined && entityObject[key] != null)
// formData.set(key, entityObject[key]);
}
}
}