Adds several client-side hooks to item submission, faceted search and view modes.

This commit is contained in:
mateuswetah 2022-05-16 17:21:05 -03:00
parent a77f46be61
commit ef730ddeda
10 changed files with 332 additions and 147 deletions

View File

@ -560,7 +560,7 @@
<textarea
id="tainacan-text-description"
class="textarea"
rows="3"
rows="4"
v-model="form.thumbnail_alt" />
</b-field>
<div class="thumbnail-buttons-row">

View File

@ -42,6 +42,12 @@
<a
class="tainacan-card"
:href="getItemLink(item.url, index)">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<!-- Title -->
<div class="metadata-title">
@ -74,6 +80,7 @@
<i class="tainacan-icon tainacan-icon-viewgallery tainacan-icon-1-125em"/>
</span>
</div>
<!-- Remaining metadata -->
<div class="media">
<div
@ -111,6 +118,13 @@
</div>
</div>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</a>
</div>
</div>

View File

@ -42,6 +42,12 @@
class="tainacan-list">
<a :href="getItemLink(item.url, index)">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<!-- Title -->
<div class="metadata-title">
<p
@ -111,6 +117,13 @@
</span>
</div>
</div>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</a>
</div>
</div>

View File

@ -50,6 +50,12 @@
class="tainacan-masonry-item"
:href="getItemLink(item.url, index)">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<!-- Title -->
<div class="metadata-title">
<p v-html="item.title != undefined ? item.title : ''" />
@ -82,6 +88,12 @@
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500"
/>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</a>
</div>
</masonry>

View File

@ -48,6 +48,12 @@
<a
:href="getItemLink(item.url, index)"
class="tainacan-record">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<!-- Title -->
<div class="metadata-title">
@ -121,6 +127,12 @@
</span>
</div>
</div>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</a>
</div>
</masonry>

View File

@ -143,6 +143,7 @@
class="icon is-large loading-icon">
<div class="is-large control has-icons-right is-loading is-clearfix" />
</span>
<!-- Empty result placeholder -->
<section
v-if="!isLoading && !isLoadingItem && items.length <= 0"
@ -156,6 +157,13 @@
<p>{{ $i18n.get('info_no_item_found') }}</p>
</div>
</section>
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<div
v-if="!isLoadingItem && slideItems.length > 0 && (item.document != undefined && item.document != undefined && item.document != '')"
v-html="item.document_as_html" />
@ -167,6 +175,12 @@
:src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_mimetype)">
</div>
</div>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</transition>
</div>
<button

View File

@ -100,6 +100,12 @@
:key="index"
v-for="(item, index) of items">
<!-- JS-side hook for extra content -->
<td
v-if="hasBeforeHook()"
class="faceted-search-hook faceted-search-hook-item-before"
v-html="getBeforeHook(item)" />
<!-- Item Displayed Metadata -->
<td
:key="metadatumIndex"
@ -208,6 +214,12 @@
</span>
</div>
</td>
<!-- JS-side hook for extra content -->
<td
v-if="hasAfterHook()"
class="faceted-search-hook faceted-search-hook-item-after"
v-html="getAfterHook(item)" />
</tr>
</tbody>
</table>

View File

@ -34,6 +34,22 @@ export const viewModesMixin = {
this.isSlideshowViewModeEnabled = (this.enabledViewModes && Array.isArray(this.enabledViewModes)) ? (this.enabledViewModes.findIndex((viewMode) => viewMode == 'slideshow') >= 0) : false;
},
methods: {
hasBeforeHook() {
if (wp !== undefined)
return wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_item_before`);
},
hasAfterHook() {
if (wp !== undefined)
return wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_item_after`);
},
getBeforeHook(item) {
if (wp !== undefined)
return wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_item_before`, item);
},
getAfterHook(item) {
if (wp !== undefined)
return wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_item_after`, item);
},
getItemLink(itemUrl, index) {
if (this.queries) {
// Inserts information necessary for item by item navigation on single pages

View File

@ -28,9 +28,11 @@
{{ $i18n.get('label_sort_visualization') }}
</h3>
<!-- <b-loading
:is-full-page="false"
:active.sync="isLoadingMetadata"/> -->
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['search_control_before']"
class="faceted-search-hook faceted-search-hook-search-control-before"
v-html="hooks['search_control_before']" />
<!-- Button for hiding filters -->
<button
@ -353,6 +355,12 @@
<span class="is-hidden-tablet-only is-hidden-desktop-only ">{{ $i18n.get('label_view_as') }}</span>
</button>
</div>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['search_control_after']"
class="faceted-search-hook faceted-search-hook-search-control-after"
v-html="hooks['search_control_after']" />
</div>
<!-- SIDEBAR WITH FILTERS -->
@ -369,6 +377,13 @@
:custom-class="'tainacan-modal tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '')"
:can-cancel="hideHideFiltersButton || !filtersAsModal ? ['x', 'outside'] : ['x', 'escape', 'outside']"
:close-button-aria-label="$i18n.get('close')">
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['filters_before']"
class="faceted-search-hook faceted-search-hook-filters-before"
v-html="hooks['filters_before']" />
<filters-items-list
:is-loading-items="isLoadingItems"
@updateIsLoadingItemsState="(state) => isLoadingItems = state"
@ -383,6 +398,13 @@
:filters-as-modal="filtersAsModal"
:has-filtered="hasFiltered"
:is-mobile-screen="isMobileScreen" />
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['filters_after']"
class="faceted-search-hook faceted-search-hook-filters-after"
v-html="hooks['filters_after']" />
</b-modal>
</template>
@ -399,21 +421,50 @@
role="search"
v-if="openAdvancedSearch && !hideAdvancedSearch">
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['advanced_search_before']"
class="faceted-search-hook faceted-search-hook-advanced-search-before"
v-html="hooks['advanced_search_before']" />
<advanced-search
:is-repository-level="isRepositoryLevel"
:collection-id="collectionId"
@close="openAdvancedSearch = false" />
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['advanced_search_after']"
class="faceted-search-hook faceted-search-hook-advanced-search-after"
v-html="hooks['advanced_search_after']" />
</div>
</transition>
<!-- FILTERS TAG LIST-->
<filters-tags-list
class="filter-tags-list"
v-if="!filtersAsModal &&
!hideFilters &&
hasFiltered &&
!openAdvancedSearch &&
!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen)" />
<template
v-if="!filtersAsModal &&
!hideFilters &&
hasFiltered &&
!openAdvancedSearch &&
!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen)">
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['filter_tags_before']"
class="faceted-search-hook faceted-search-hook-filter-tags-before"
v-html="hooks['filter_tags_before']" />
<filters-tags-list
class="filter-tags-list"
/>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['filter_tags_after']"
class="faceted-search-hook faceted-search-hook-filter-tags-after"
v-html="hooks['filter_tags_after']" />
</template>
<!-- ITEMS LISTING RESULTS ------------------------- -->
<div
@ -478,6 +529,12 @@
</button>
</div>
</div>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['items_list_before']"
class="faceted-search-hook faceted-search-hook-items-list-before"
v-html="hooks['items_list_before']" />
<!-- Theme View Modes -->
<div
@ -497,16 +554,37 @@
:is-loading="showLoading"
:enabled-view-modes="enabledViewModes"
:initial-item-position="initialItemPosition"
:is="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].component : ''"/>
<!-- Pagination -->
<pagination
v-show="!hidePaginationArea"
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
:is="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].component : ''"/>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['items_list_after']"
class="faceted-search-hook faceted-search-hook-items-list-after"
v-html="hooks['items_list_after']" />
<template
v-if="totalItems > 0 &&
((registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination))"
:hide-items-per-page-button="hideItemsPerPageButton"
:hide-go-to-page-button="hideGoToPageButton"/>
((registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination))">
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['pagination_before']"
class="faceted-search-hook faceted-search-hook-pagination-before"
v-html="hooks['pagination_before']" />
<!-- Pagination -->
<pagination
v-show="!hidePaginationArea"
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
:hide-items-per-page-button="hideItemsPerPageButton"
:hide-go-to-page-button="hideGoToPageButton"/>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['pagination_after']"
class="faceted-search-hook faceted-search-hook-pagination-after"
v-html="hooks['pagination_after']" />
</template>
<!-- This is used by intersection observers to set filters menu as fixed on the bottom -->
<div
@ -596,6 +674,7 @@
itemsListBottomIntersectionObserver: null,
latestPerPageAfterViewModeWithoutPagination: 12,
latestPageAfterViewModeWithoutPagination: 1,
hooks: {}
}
},
computed: {
@ -727,6 +806,9 @@
this.onChangeViewMode('slideshow');
this.initialItemPosition = index;
});
// Parse js-side hooks
this.parseHooks();
},
mounted() {
@ -837,6 +919,55 @@
'getPage',
'getItemsPerPage'
]),
parseHooks() {
const searchControlBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_search_control_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_search_control_before`, '');
if (searchControlBeforeFilters)
this.hooks['search_control_before'] = searchControlBeforeFilters;
const searchControlAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_search_control_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_search_control_after`, '');
if (searchControlAfterFilters)
this.hooks['search_control_after'] = searchControlAfterFilters;
const advancedSearchBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_advanced_search_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_advanced_search_before`, '');
if (advancedSearchBeforeFilters)
this.hooks['advanced_search_before'] = advancedSearchBeforeFilters;
const advancedSearchAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_advanced_search_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_advanced_search_after`, '');
if (advancedSearchAfterFilters)
this.hooks['advanced_search_after'] = advancedSearchAfterFilters;
const filtersBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_filters_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_filters_before`, '');
if (filtersBeforeFilters)
this.hooks['filters_before'] = filtersBeforeFilters;
const filtersAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_filters_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_filters_after`, '');
if (filtersAfterFilters)
this.hooks['filters_after'] = filtersAfterFilters;
const filterTagsBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_filter_tags_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_filter_tags_before`, '');
if (filterTagsBeforeFilters)
this.hooks['filte_tags_before'] = filterTagsBeforeFilters;
const filterTagsAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_filter_tags_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_filter_tags_after`, '');
if (filterTagsAfterFilters)
this.hooks['filter_tags_after'] = filterTagsAfterFilters;
const itemsListBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`, '');
if (itemsListBeforeFilters)
this.hooks['items_list_before'] = itemsListBeforeFilters;
const itemsListAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_after`, '');
if (itemsListAfterFilters)
this.hooks['items_list_after'] = itemsListAfterFilters;
const paginationBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_pagination_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_pagination_before`, '');
if (paginationBeforeFilters)
this.hooks['pagination_before'] = paginationBeforeFilters;
const paginationAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_pagination_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_pagination_after`, '');
if (paginationAfterFilters)
this.hooks['pagination_after'] = paginationAfterFilters;
},
openExposersModal() {
this.$buefy.modal.open({
parent: this,

View File

@ -11,7 +11,7 @@
class="tainacan-form"
label-width="120px">
<!-- Hook for extra Form options -->
<!-- Hook for extra options -->
<template v-if="hasBeginLeftForm">
<form
id="form-item-begin-left"
@ -19,11 +19,11 @@
v-html="getBeginLeftForm"/>
</template>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['document_before']"
v-if="hasBeforeHook('document')"
class="item-submission-hook item-submission-hook-document-before"
v-html="hooks['document_before']" />
v-html="getBeforeHook('document')" />
<!-- Document -------------------------------- -->
<template v-if="!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton">
@ -191,15 +191,17 @@
</template>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['document_after']"
v-if="hasAfterHook('document')"
class="item-submission-hook item-submission-hook-document-after"
v-html="hooks['document_after']" />
v-html="getAfterHook('document')" />
<!-- JS-side hook for extra content -->
<div
v-if="hooks['thumbnail_before']"
v-if="hasBeforeHook('thumbnail')"
class="item-submission-hook item-submission-hook-thumbnail-before"
v-html="hooks['thumbnail_before']" />
v-html="getBeforeHook('thumbnail')" />
<!-- Thumbnail -------------------------------- -->
<template v-if="!hideThumbnailSection">
@ -269,13 +271,13 @@
</div>
</template>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['thumbnail_after']"
v-if="hasAfterHook('thumbnail')"
class="item-submission-hook item-submission-hook-thumbnail-after"
v-html="hooks['thumbnail_after']" />
v-html="getAfterHook('thumbnail')" />
<!-- Hook for extra Form options -->
<!-- Hook for extra options -->
<template v-if="hasEndLeftForm">
<form
id="form-item-end-left"
@ -283,11 +285,12 @@
v-html="getEndLeftForm"/>
</template>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['attachments_before']"
v-if="hasBeforeHook('attachments')"
class="item-submission-hook item-submission-hook-attachments-before"
v-html="hooks['attachments_before']" />
v-html="getBeforeHook('attachments')" />
<!-- Attachments ------------------------------------------ -->
<template v-if="!hideAttachmentsSection">
@ -344,13 +347,13 @@
</div>
</template>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['attachments_after']"
v-if="hasAfterHook('attachments')"
class="item-submission-hook item-submission-hook-attachments-after"
v-html="hooks['attachments_after']" />
v-html="getAfterHook('attachments')" />
<!-- Hook for extra Form options -->
<!-- Hook for extra options -->
<template v-if="hasBeginRightForm">
<form
id="form-item-begin-right"
@ -408,12 +411,11 @@
</span>
</a>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['metadata_before']"
v-if="hasBeforeHook('metadata')"
class="item-submission-hook item-submission-hook-metadata-before"
v-html="hooks['metadata_before']" />
v-html="getBeforeHook('metadata')" />
<div
v-for="(metadataSection, sectionIndex) of metadataSections"
@ -421,16 +423,6 @@
:class="'metadata-section-slug-' + metadataSection.slug"
:id="'metadata-section-id-' + metadataSection.id">
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['metadata_section_index_' + sectionIndex + '_before']"
:class="'item-submission-hook item-submission-hook-metadata_section_index_' + sectionIndex + '-before'"
v-html="hooks['metadata_section_index_' + sectionIndex + '_before']" />
<div
v-if="hooks['metadata_section_id_' + metadataSection.id + '_before']"
:class="'item-submission-hook item-submission-hook-metadata_section_id_' + metadataSection.id + '-before'"
v-html="hooks['metadata_section_id_' + metadataSection.id + '_before']" />
<div class="metadata-section-header section-label">
<span
class="collapse-handle"
@ -459,12 +451,28 @@
<div
class="metadata-section-metadata-list"
v-show="metadataSectionCollapses[sectionIndex]">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-before"
v-html="getBeforeHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<p
class="metadatum-description-help-info"
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
{{ metadataSection.description }}
</p>
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasBeforeHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-before"
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<tainacan-form-item
:key="index"
v-if="enabledMetadata[index] == 'true'"
@ -472,29 +480,33 @@
:hide-collapses="hideCollapses"
:is-collapsed="metadataCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/>
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasAfterHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-after"
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</template>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-after"
v-html="getAfterHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</div>
</transition>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['metadata_section_index_' + sectionIndex + '_after']"
:class="'item-submission-hook item-submission-hook-metadata_section_index_' + sectionIndex + '-after'"
v-html="hooks['metadata_section_index_' + sectionIndex + '_after']" />
<div
v-if="hooks['metadata_section_id_' + metadataSection.id + '_after']"
:class="'item-submission-hook item-submission-hook-metadata_section_id_' + metadataSection.id + '-after'"
v-html="hooks['metadata_section_id_' + metadataSection.id + '_after']" />
</div>
<!-- JS-side hook for extra form content -->
<!-- JS-side hook for extra content -->
<div
v-if="hooks['metadata_after']"
v-if="hasAfterHook('metadata')"
class="item-submission-hook item-submission-hook-metadata-after"
v-html="hooks['metadata_after']" />
v-html="getAfterHook('metadata')" />
<!-- Hook for extra Form options -->
<!-- Hook for extra options -->
<template v-if="hasEndRightForm">
<form
id="form-item-end-right"
@ -523,14 +535,14 @@
</b-field>
</div>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['footer_before']"
class="item-submission-hook item-submission-hook-footer-before"
v-html="hooks['footer_before']" />
<footer class="form-submission-footer">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook('footer')"
class="item-submission-hook item-submission-hook-footer-before"
v-html="getBeforeHook('footer')" />
<button
@click="onDiscard()"
type="button"
@ -554,13 +566,13 @@
@click="onSubmit()"
type="button"
class="button is-secondary">{{ $i18n.get('label_submit') }}</button>
</footer>
<!-- JS-side hook for extra form content -->
<div
v-if="hooks['footer_after']"
class="item-submission-hook item-submission-hook-footer-after"
v-html="hooks['footer_after']" />
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook('footer')"
class="item-submission-hook item-submission-hook-footer-after"
v-html="getAfterHook('footer')" />
</footer>
</form>
@ -690,8 +702,7 @@ export default {
useCaptcha: 'no',
captchaSiteKey: tainacan_plugin['item_submission_captcha_site_key'],
linkToCreatedItem: '',
userHasAgreedToTerms: false,
hooks: {}
userHasAgreedToTerms: false
}
},
computed: {
@ -738,10 +749,6 @@ export default {
},
created() {
// Parse static JS hooks
if (wp !== undefined)
this.parseStaticHooks();
// Puts loading on form
this.isLoading = true;
@ -786,27 +793,6 @@ export default {
})
.then((metadataSections) => {
this.metadataSectionCollapses = Array(metadataSections.length).fill(true);
// Parse dynamic metadata section hooks
if (wp !== undefined) {
for (let sectionIndex = 0; sectionIndex < metadataSections.length; sectionIndex++) {
const metadataSectionByIndexBeforeFilter = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_section_index_${sectionIndex}_before`, '');
if (metadataSectionByIndexBeforeFilter)
this.hooks[`metadata_section_index_${sectionIndex}_before`] = metadataSectionByIndexBeforeFilter;
const metadataSectionByIdBeforeFilter = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_section_id_${metadataSections[sectionIndex].id}_before`, '');
if (metadataSectionByIdBeforeFilter)
this.hooks[`metadata_section_id_${metadataSections[sectionIndex].id}_before`] = metadataSectionByIdBeforeFilter;
const metadataSectionByIdAfterFilter = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_section_id_${metadataSections[sectionIndex].id}_after`, '');
if (metadataSectionByIdAfterFilter)
this.hooks[`metadata_section_id_${metadataSections[sectionIndex].id}_after`] = metadataSectionByIdAfterFilter;
const metadataSectionByIndexAfterFilter = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_section_index_${sectionIndex}_after`, '');
if (metadataSectionByIndexAfterFilter)
this.hooks[`metadata_section_index_${sectionIndex}_after`] = metadataSectionByIndexAfterFilter;
}
}
this.isLoadingMetadataSections = false;
})
.catch((error) => {
@ -850,46 +836,21 @@ export default {
...mapActions('collection',[
'fetchCollectionForItemSubmission'
]),
parseStaticHooks() {
const documentBeforeFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_document_before`, '');
if (documentBeforeFilters)
this.hooks['document_before'] = documentBeforeFilters;
const documentAfterFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_document_after`, '');
if (documentAfterFilters)
this.hooks['document_after'] = documentAfterFilters;
const thumbnailBeforeFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_thumbnail_before`, '');
if (thumbnailBeforeFilters)
this.hooks['thumbnail_before'] = thumbnailBeforeFilters;
const thumbnailAfterFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_thumbnail_after`, '');
if (thumbnailAfterFilters)
this.hooks['thumbnail_after'] = thumbnailAfterFilters;
const attachmentsBeforeFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_attachments_before`, '');
if (attachmentsBeforeFilters)
this.hooks['attachments_before'] = attachmentsBeforeFilters;
const attachmentsAfterFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_attachments_after`, '');
if (attachmentsAfterFilters)
this.hooks['attachments_after'] = attachmentsAfterFilters;
const metadataBeforeFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_metadata_before`, '');
if (metadataBeforeFilters)
this.hooks['metadata_before'] = metadataBeforeFilters;
const metadataAfterFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_metadata_after`, '');
if (metadataAfterFilters)
this.hooks['metadata_after'] = metadataAfterFilters;
const footerBeforeFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_footer_before`, '');
if (footerBeforeFilters)
this.hooks['footer_before'] = footerBeforeFilters;
const footerAfterFilters = wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_footer_after`, '');
if (footerAfterFilters)
this.hooks['footer_after'] = footerAfterFilters;
hasBeforeHook(location) {
if (wp !== undefined)
return wp.hooks.hasFilter(`tainacan_item_submission_collection_${this.collectionId}_${location}_before`);
},
hasAfterHook(location) {
if (wp !== undefined)
return wp.hooks.hasFilter(`tainacan_item_submission_collection_${this.collectionId}_${location}_after`);
},
getBeforeHook(location, entity = '') {
if (wp !== undefined)
return wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_${location}_before`, entity);
},
getAfterHook(location, entity = '') {
if (wp !== undefined)
return wp.hooks.applyFilters(`tainacan_item_submission_collection_${this.collectionId}_${location}_after`, entity);
},
onSubmit() {