diff --git a/src/admin/class-tainacan-admin.php b/src/admin/class-tainacan-admin.php index 2b1e09a89..116083cf8 100644 --- a/src/admin/class-tainacan-admin.php +++ b/src/admin/class-tainacan-admin.php @@ -207,38 +207,41 @@ class Admin { $settings['form_hooks'] = [ 'form-collection' => [ - 'begin-left' => '', - 'end-left' => '', - 'begin-right' => '', - 'end-right' => '' + 'begin-left' => [ + '', + '' + ], + 'end-left' => [''], + 'begin-right' => [''], + 'end-right' => [''] ], 'form-item' => [ - 'begin-left' => '', - 'end-left' => '', - 'begin-right' => '', - 'end-right' => '' + 'begin-left' => [''], + 'end-left' => [''], + 'begin-right' => [''], + 'end-right' => [''] ], 'view-item' => [ - 'begin-left' => '

blue

', - 'end-left' => '

black

', - 'begin-right' => '

red

', - 'end-right' => '

green

', + 'begin-left' => ['

blue

'], + 'end-left' => ['

black

'], + 'begin-right' => ['

red

'], + 'end-right' => ['

green

'], ], 'form-taxonomy' => [ - 'begin' => '', - 'end' => '' + 'begin' => [''], + 'end' => [''] ], 'form-term' => [ - 'begin' => '', - 'end' => '' + 'begin' => [''], + 'end' => [''] ], 'form-metadatum' => [ - 'begin' => '', - 'end' => '' + 'begin' => [''], + 'end' => [''] ], 'form-filter' => [ - 'begin' => '', - 'end' => '' + 'begin' => [''], + 'end' => [''] ] ]; diff --git a/src/admin/components/edition/collection-edition-form.vue b/src/admin/components/edition/collection-edition-form.vue index 5ec545acb..78023429d 100644 --- a/src/admin/components/edition/collection-edition-form.vue +++ b/src/admin/components/edition/collection-edition-form.vue @@ -34,7 +34,7 @@ formHooks['form-collection']['begin-left'] != undefined">
+ v-html="this.formHooks['form-collection']['begin-left'].join('')"/> @@ -238,7 +238,7 @@ formHooks['form-collection']['end-left'] != undefined"> + v-html="formHooks['form-collection']['end-left'].join('')"/> @@ -252,7 +252,7 @@ formHooks['form-collection']['begin-right'] != undefined"> + v-html="formHooks['form-collection']['begin-right'].join('')"/> @@ -423,7 +423,7 @@ formHooks['form-collection']['end-right'] != undefined"> + v-html="formHooks['form-collection']['end-right'].join('')"/> @@ -593,6 +593,9 @@ export default { this.collection = updatedCollection; + // 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; this.form.slug = this.collection.slug; @@ -608,10 +611,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) { @@ -638,7 +641,7 @@ export default { // Initializes Media Frames now that collectonId exists this.initializeMediaFrames(); - + // Fill this.form data with current data. this.form.name = this.collection.name; this.form.description = this.collection.description; @@ -825,6 +828,9 @@ export default { // Initializes Media Frames now that collectonId exists this.initializeMediaFrames(); + // 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; this.form.description = this.collection.description; diff --git a/src/admin/components/edition/filter-edition-form.vue b/src/admin/components/edition/filter-edition-form.vue index 83be68971..73dfb2626 100644 --- a/src/admin/components/edition/filter-edition-form.vue +++ b/src/admin/components/edition/filter-edition-form.vue @@ -11,7 +11,7 @@ formHooks['form-filter']['begin'] != undefined"> + v-html="formHooks['form-filter']['begin'].join('')"/> + v-html="formHooks['form-filter']['end'].join('')"/>
diff --git a/src/admin/components/edition/item-edition-form.vue b/src/admin/components/edition/item-edition-form.vue index 0686cbe74..739f55cd9 100644 --- a/src/admin/components/edition/item-edition-form.vue +++ b/src/admin/components/edition/item-edition-form.vue @@ -23,7 +23,7 @@ formHooks['form-item']['begin-left'] != undefined"> + v-html="formHooks['form-item']['begin-left'].join('')"/> @@ -309,7 +309,7 @@ formHooks['form-item']['end-left'] != undefined"> + v-html="formHooks['form-item']['end-left'].join('')"/>
@@ -324,7 +324,7 @@ formHooks['form-item']['begin-right'] != undefined"> + v-html="formHooks['form-item']['begin-right'].join('')"/> @@ -394,7 +394,7 @@ formHooks['form-item']['end-right'] != undefined"> + v-html="formHooks['form-item']['end-right'].join('')"/> diff --git a/src/admin/components/edition/metadatum-edition-form.vue b/src/admin/components/edition/metadatum-edition-form.vue index e16a18edb..4b58eeada 100644 --- a/src/admin/components/edition/metadatum-edition-form.vue +++ b/src/admin/components/edition/metadatum-edition-form.vue @@ -12,7 +12,7 @@ formHooks['form-metadatum']['begin'] != undefined"> + v-html="formHooks['form-metadatum']['begin'].join('')"/> + v-html="formHooks['form-metadatum']['end'].join('')"/>
diff --git a/src/admin/components/edition/taxonomy-edition-form.vue b/src/admin/components/edition/taxonomy-edition-form.vue index 611b5d8c6..a8706d993 100644 --- a/src/admin/components/edition/taxonomy-edition-form.vue +++ b/src/admin/components/edition/taxonomy-edition-form.vue @@ -16,7 +16,7 @@ formHooks['form-taxonomy']['begin'] != undefined"> + v-html="formHooks['form-taxonomy']['begin'].join('')"/> @@ -116,7 +116,7 @@ formHooks['form-taxonomy']['end'] != undefined"> + v-html="formHooks['form-taxonomy']['end'].join('')"/> diff --git a/src/admin/components/edition/term-edition-form.vue b/src/admin/components/edition/term-edition-form.vue index db00c511a..adc19d1e4 100644 --- a/src/admin/components/edition/term-edition-form.vue +++ b/src/admin/components/edition/term-edition-form.vue @@ -15,7 +15,7 @@ formHooks['form-term']['begin'] != undefined"> + v-html="formHooks['form-term']['begin'].join('')"/> @@ -139,7 +139,7 @@ formHooks['form-term']['end'] != undefined"> + v-html="formHooks['form-term']['end'].join('')"/> diff --git a/src/admin/js/mixins.js b/src/admin/js/mixins.js index 2e3de00e0..b75e977ef 100644 --- a/src/admin/js/mixins.js +++ b/src/admin/js/mixins.js @@ -52,7 +52,7 @@ export const dateInter = { export const formHooks = { data() { return { - formHooks: tainacan_plugin['form_hooks'] + formHooks: JSON.parse(JSON.stringify(tainacan_plugin['form_hooks'])) } }, methods: { @@ -77,6 +77,29 @@ export const formHooks = { } } } + }, + updateExtraFormData(entity, entityObject) { + let positions = [ + 'begin-left', + 'begin-right', + 'begin', + 'end-left', + 'end-right', + 'end' + ]; + // Gets data from existing extra form hooks + for (let position of positions) { + if (this.formHooks['form-' + entity][position] && this.formHooks['form-' + entity][position] != undefined) { + let formElement = document.getElementById('form-' + entity + '-' + position); + if (formElement) { + let formData = new FormData(formElement); + for (let [key, value] of formData.entries()) { + if (entityObject[key] != undefined && entityObject[key] != null) + value = entityObject[key]; + } + } + } + } } } }; \ No newline at end of file diff --git a/src/admin/pages/singles/item-page.vue b/src/admin/pages/singles/item-page.vue index 7e4696d09..b025811d2 100644 --- a/src/admin/pages/singles/item-page.vue +++ b/src/admin/pages/singles/item-page.vue @@ -20,7 +20,7 @@ formHooks['view-item']['begin-left'] != undefined">
+ v-html="formHooks['view-item']['begin-left'].join('')"/> @@ -174,7 +174,7 @@ formHooks['view-item']['end-left'] != undefined">
+ v-html="formHooks['view-item']['end-left'].join('')"/>
@@ -189,7 +189,7 @@ formHooks['view-item']['begin-right'] != undefined">
+ v-html="formHooks['view-item']['begin-right'].join('')"/> @@ -274,7 +274,7 @@ formHooks['view-item']['end-right'] != undefined">
+ v-html="formHooks['view-item']['end-right'].join('')"/>