Merge branch 'develop' into feature/692

This commit is contained in:
mateuswetah 2023-01-25 11:42:24 -03:00
commit d235f18a13
29 changed files with 1224 additions and 669 deletions

6
package-lock.json generated
View File

@ -4293,9 +4293,9 @@
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
},
"json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true
},
"jsprim": {

View File

@ -423,6 +423,9 @@ class REST_Items_Controller extends REST_Controller {
foreach($tax_query as $tax) {
if ( !isset($tax['taxonomy']) || !isset($tax['terms']) )
continue;
$taxonomy = $tax['taxonomy'];
$taxonomy_id = $this->taxonomies_repository->get_id_by_db_identifier($taxonomy);
$terms_id = is_array($tax['terms']) ? $tax['terms']: [$tax['terms']];

View File

@ -274,6 +274,8 @@ class Elastic_Press {
if( isset($args['tax_query']) ) {
foreach( $args['tax_query'] as $taxquery ) {
if ( !isset($tax['taxonomy']) || !isset($tax['terms']) )
continue;
if( $taxquery['taxonomy'] === $taxonomy_slug ) {
$include = is_array($taxquery['terms']) ? $taxquery['terms'] : [$taxquery['terms']];
}
@ -288,6 +290,8 @@ class Elastic_Press {
if( isset($args['meta_query']) ) {
foreach( $args['meta_query'] as $metaquery ) {
if ( !isset($meta['key']) || !isset($meta['value']) )
continue;
if( isset($metaquery['key']) && $metaquery['key'] == $metadatum_id ){
$include = is_array($metaquery['value']) ? $metaquery['value'] : [$metaquery['value']];
}

View File

@ -545,7 +545,7 @@ class CSV extends Importer {
$id = $TainacanMedia->insert_attachment_from_file($server_path_files . $correct_value, $item_inserted->get_id());
if(!$id) {
$this->add_error_log('Error in Document file imported from server ' . $correct_value);
$this->add_error_log('Error in Document file imported from server ' . $server_path_files . $correct_value);
return false;
}
@ -604,7 +604,7 @@ class CSV extends Importer {
$id = $TainacanMedia->insert_attachment_from_file($server_path_files . $attachment, $item_inserted->get_id());
if(!$id) {
$this->add_log('Error in Attachment file imported from server ' . $attachment);
$this->add_log('Error in Attachment file imported from server ' . $server_path_files . $attachment);
continue;
}

File diff suppressed because it is too large Load Diff

View File

@ -1084,7 +1084,8 @@ class Theme_Helper {
* Optional. Array of arguments.
* @type string $item_id The Item ID
* @type string $items_list_layout The type of list to be rendered. Accepts 'grid', 'list', 'mosaic' and 'carousel'.
* @type string $order Sorting direction to the related items query. Either 'desc' or 'asc'.
* @type string $order Sorting direction to the related items query. Either 'desc' or 'asc'.
* @type string $orderby Sortby metadata. By now we're accepting only 'title' and 'date'.
* @type string $class_name Extra class to add to the wrapper, besides the default wp-block-tainacan-carousel-related-items
* @type string $collection_heading_class_name Extra class to add to the collection name wrapper. Defaults to ''
* @type string $collection_heading_tag Tag to be used as wrapper of the collection name. Defaults to h2
@ -1113,6 +1114,10 @@ class Theme_Helper {
// Then fetches related ones
$related_items_query_args = [];
if ( isset($args['orderby']) )
$related_items_query_args['orderby'] = $args['orderby'];
if ( isset($args['order']) )
$related_items_query_args['order'] = $args['order'];

View File

@ -302,6 +302,13 @@
{{ statusOption.name }}
</b-radio>
</div>
<transition name="filter-item">
<p
class="help"
v-if="form.submission_default_status == 'draft'">
{{ $i18n.get('info_item_submission_draft_status') }}
</p>
</transition>
</b-field>
<!-- Submission process uses reCAPTCHA ------------------------ -->

View File

@ -14,7 +14,7 @@
drag-class="sortable-drag">
<div
:id="metadatum.component"
@click.prevent="addMetadatumViaButton(metadatum)"
@click.prevent.once="addMetadatumViaButton(metadatum)"
class="available-metadatum-item"
:class="{ 'hightlighted-metadatum' : hightlightedMetadatum == metadatum.name, 'inherited-metadatum': metadatum.inherited || isRepositoryLevel }"
v-for="(metadatum, index) in availableMetadatumList"

View File

@ -138,6 +138,20 @@
</template>
</b-taginput>
</b-field>
<b-field
:addons="false"
:label="$i18n.getHelperTitle('tainacan-taxonomy', 'hide_hierarchy_path')">
&nbsp;
<b-switch
size="is-small"
v-model="hide_hierarchy_path"
@input="emitValues()"
true-value="yes"
false-value="no" />
<help-button
:title="$i18n.getHelperTitle('tainacan-taxonomy', 'hide_hierarchy_path')"
:message="$i18n.getHelperMessage('tainacan-taxonomy', 'hide_hierarchy_path')"/>
</b-field>
</section>
</template>
@ -159,6 +173,7 @@
taxonomy: '',
loading: false,
allow_new_terms: 'yes',
hide_hierarchy_path: 'no',
link_filtered_by_collections: [],
visible_options_list: false,
input_type: 'tainacan-taxonomy-radio',
@ -230,6 +245,7 @@
this.taxonomy_id = this.value.taxonomy_id;
this.allow_new_terms = ( this.value.allow_new_terms ) ? this.value.allow_new_terms : 'no';
this.hide_hierarchy_path = ( this.value.hide_hierarchy_path ) ? this.value.hide_hierarchy_path : 'no';
if (this.metadatum && this.metadatum.multiple === 'no') {
let types = Object.keys( this.single_types );
@ -296,6 +312,7 @@
allow_new_terms: this.allow_new_terms,
visible_options_list: this.visible_options_list,
link_filtered_by_collections: this.link_filtered_by_collections,
hide_hierarchy_path: this.hide_hierarchy_path,
taxonomy: this.taxonomy
})
},

View File

@ -23,6 +23,7 @@ class Taxonomy extends Metadata_Type {
'allow_new_terms' => 'no',
'link_filtered_by_collections' => [],
'input_type' => 'tainacan-taxonomy-radio',
'hide_hierarchy_path' => 'no'
]);
$this->set_form_component('tainacan-form-taxonomy');
@ -101,6 +102,10 @@ class Taxonomy extends Metadata_Type {
'link_filtered_by_collections' => [
'title' => __( 'Link filtered by collections', 'tainacan' ),
'description' => __( 'Links to term items list filtered by certain collections instead of repository level term items page.', 'tainacan' ),
],
'hide_hierarchy_path' => [
'title' => __( 'Hide hierarchy path', 'tainacan' ),
'description' => __( 'Display only the current child term when showing values that belong to a term hierarchy.', 'tainacan' ),
]
];
}
@ -191,6 +196,15 @@ class Taxonomy extends Metadata_Type {
$readable_option_value = __( 'None', 'tainacan' );
break;
case 'hide_hierarchy_path':
if ($option_value == 'yes')
$readable_option_value = __('Yes', 'tainacan');
else if ($option_value == 'no')
$readable_option_value = __('No', 'tainacan');
else
$readable_option_value = $option_value;
break;
default:
$readable_option_value = $option_value;
}
@ -334,7 +348,7 @@ class Taxonomy extends Metadata_Type {
public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( $item_metadata->is_multiple() ) {
$count = 1;
$total = sizeof($value);
@ -369,6 +383,10 @@ class Taxonomy extends Metadata_Type {
}
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) {
if ( $this->get_option('hide_hierarchy_path') == 'yes' )
return $this->term_to_html($term);
$terms = [];
$terms[] = $this->term_to_html($term);

View File

@ -14,7 +14,7 @@
</span>
</a>
<template #popper>
<h5>{{ $i18n.get('instruction_click_error_to_go_to_metadata') }}</h5>
<p><strong>{{ $i18n.get('instruction_click_error_to_go_to_metadata') }}</strong></p>
<ol>
<template v-for="(error, index) of formErrors">
<li

View File

@ -100,6 +100,7 @@ export default {
'getCollections'
]),
onChangeTab(status) {
this.$eventBusSearch.resetPageOnStore();
this.$eventBusSearch.setStatus(status);
}
}

View File

@ -1,7 +1,10 @@
<template>
<transition name="filter-item">
<div v-show="filterTags != undefined && filterTags.length > 0">
<p class="filter-tags-info">
<!-- The following v-if seems redundant, but we cannot add a v-if to the upper div as the swiper needs to exist to be updated, while the info bellow should never appear in this situation -->
<p
v-if="filterTags != undefined && filterTags.length > 0"
class="filter-tags-info">
<span
style="margin-right: 1em"
v-html="totalItems == 1 ? $i18n.getWithVariables('info_item_%s_found', [totalItems]) : $i18n.getWithVariables('info_items_%s_found', [totalItems])" />

View File

@ -67,7 +67,7 @@ export default {
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
if (orderValue)
this.$route.query.order = orderValue;
else {
@ -80,7 +80,7 @@ export default {
if (this.$route.query.orderby == undefined || to.params.collectionId != from.params.collectionId) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object

View File

@ -94,7 +94,7 @@ export const sendMetadatum = ({commit}, {collectionId, name, metadatumType, stat
.then(res => {
let metadatum = res.data;
if (sectionId != undefined && sectionId != false)
if (sectionId != undefined && sectionId != false && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: newIndex, sectionId: sectionId })
else
commit('setSingleMetadatum', { metadatum: metadatum, index: newIndex, isRepositoryLevel: isRepositoryLevel });
@ -129,8 +129,8 @@ export const updateMetadatum = ({commit}, {collectionId, metadatumId, isReposito
axios.tainacan.put(endpoint, options)
.then(res => {
let metadatum = res.data;
if (sectionId !== null && sectionId !== undefined)
if (sectionId !== null && sectionId !== undefined && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: index, sectionId: sectionId });
else
commit('setSingleMetadatum', { metadatum: metadatum, index: index, isRepositoryLevel: isRepositoryLevel });

View File

@ -13,176 +13,204 @@
},
"attributes": {
"termId": {
"type": "String",
"type": "string",
"default": null
},
"taxonomyId": {
"type": "String",
"type": "string",
"default": null
},
"collectionId": {
"type": "String",
"type": "string",
"default": null
},
"defaultViewMode": {
"type": "String",
"type": "string",
"default": "masonry"
},
"enabledViewModes": {
"type": "Array",
"type": "array",
"default": null
},
"collectionDefaultViewMode": {
"type": "String",
"type": "string",
"default": "masonry"
},
"collectionEnabledViewModes": {
"type": "Array",
"type": "array",
"default": []
},
"hideFilters": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideHideFiltersButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideSearch": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideAdvancedSearch": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideDisplayedMetadataButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideSortingArea": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideSortByButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideItemsThumbnail": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideExposersButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideItemsPerPageButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"defaultItemsPerPage": {
"type": "Number",
"type": "number",
"default": 12
},
"hideGoToPageButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hidePaginationArea": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"showFiltersButtonInsideSearchControl": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"startWithFiltersHidden": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"filtersAsModal": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"showInlineViewModeOptions": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"showFullscreenWithViewModes": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"listType": {
"type": "String",
"type": "string",
"default": ""
},
"isCollectionModalOpen": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"isTermModalOpen": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"backgroundColor": {
"type": "String",
"type": "string",
"default": "#ffffff"
},
"baseFontSize": {
"type": "Number",
"type": "number",
"default": 16
},
"filtersAreaWidth": {
"type": "Number",
"type": "number",
"default": 20
},
"inputColor": {
"type": "String",
"type": "string",
"default": "#1d1d1d"
},
"inputBackgroundColor": {
"type": "String",
"type": "string",
"default": "#ffffff"
},
"inputBorderColor": {
"type": "String",
"type": "string",
"default": "#dbdbdb"
},
"labelColor": {
"type": "String",
"type": "string",
"default": "#454647"
},
"infoColor": {
"type": "String",
"type": "string",
"default": "#555758"
},
"headingColor": {
"type": "String",
"type": "string",
"default": "#000000"
},
"skeletonColor": {
"type": "String",
"type": "string",
"default": "#eeeeee"
},
"itemBackgroundColor": {
"type": "String",
"type": "string",
"default": "#ffffff"
},
"itemHoverBackgroundColor": {
"type": "String",
"type": "string",
"default": "#f2f2f2"
},
"itemHeadingHoverBackgroundColor": {
"type": "String",
"type": "string",
"default": "#dbdbdb"
},
"primaryColor": {
"type": "String",
"type": "string",
"default": "#d9eced"
},
"secondaryColor": {
"type": "String",
"type": "string",
"default": "#298596"
},
"order": {
"type": "string",
"default": "ASC"
},
"orderBy": {
"type": "string",
"default": "date"
},
"orderByMeta": {
"type": "string",
"default": ""
},
"orderByType": {
"type": "string",
"default": ""
},
"collectionOrderBy": {
"type": "string",
"default": "date"
},
"collectionOrderByMeta": {
"type": "string",
"default": ""
},
"collectionOrderByType": {
"type": "string",
"default": ""
}
},
"supports": {

View File

@ -13,17 +13,25 @@ export default class CollectionModal extends React.Component {
// Initialize state
this.state = {
collectionDefaultOrderBy: 'date',
collectionDefaultOrder: 'ASC',
collectionDefaultOrderByMeta: '',
collectionDefaultOrderByType: '',
collectionViewModes: [],
collectionsPerPage: 24,
collectionId: undefined,
isLoadingCollections: false,
modalCollections: [],
totalModalCollections: 0,
collectionPage: 1,
collectionOrderBy: 'date-desc',
collectionsPage: 1,
collectionsOrderBy: 'date-desc',
temporaryCollectionId: '',
temporaryCollectionDefaultViewMode: '',
temporaryCollectionEnabledViewModes: [],
temporaryCollectionDefaultOrderBy: 'date',
temporaryCollectionDefaultOrderByMeta: '',
temporaryCollectionDefaultOrderByType: '',
temporaryCollectionDefaultOrder: 'ASC',
searchCollectionName: '',
collections: [],
collectionsRequestSource: undefined
@ -43,7 +51,11 @@ export default class CollectionModal extends React.Component {
temporaryCollectionId: this.props.existingCollectionId,
temporaryCollectionDefaultViewMode: this.props.existingCollectionDefaultViewMode,
temporaryCollectionEnabledViewModes: this.props.existingCollectionEnabledViewModes,
collectionPage: 1
temporaryCollectionDefaultOrder: this.props.existingCollectionDefaultOrder,
temporaryCollectionDefaultOrderBy: this.props.existingCollectionDefaultOrderBy,
temporaryCollectionDefaultOrderByMeta: this.props.existingCollectionDefaultOrderByMeta,
temporaryCollectionDefaultOrderByType: this.props.existingCollectionDefaultOrderByType,
collectionsPage: 1
});
this.fetchModalCollections();
@ -62,12 +74,12 @@ export default class CollectionModal extends React.Component {
fetchModalCollections() {
let someModalCollections = this.state.modalCollections;
if (this.state.collectionPage <= 1)
if (this.state.collectionsPage <= 1)
someModalCollections = [];
let query = {
perpage: this.state.collectionsPerPage,
paged: this.state.collectionPage
paged: this.state.collectionsPage
}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
@ -84,18 +96,18 @@ export default class CollectionModal extends React.Component {
let endpoint = '/collections/?' + qs.stringify(query);
if (this.state.collectionOrderBy == 'date')
if (this.state.collectionsOrderBy == 'date')
endpoint += '&orderby=date&order=asc';
else if (this.state.collectionOrderBy == 'date-desc')
else if (this.state.collectionsOrderBy == 'date-desc')
endpoint += '&orderby=date&order=desc';
else if (this.state.collectionOrderBy == 'title')
else if (this.state.collectionsOrderBy == 'title')
endpoint += '&orderby=title&order=asc';
else if (this.state.collectionOrderBy == 'title-desc')
else if (this.state.collectionsOrderBy == 'title-desc')
endpoint += '&orderby=title&order=desc';
this.setState({
isLoadingCollections: true,
collectionPage: this.state.collectionPage + 1,
collectionsPage: this.state.collectionsPage + 1,
modalCollections: someModalCollections
});
@ -108,7 +120,9 @@ export default class CollectionModal extends React.Component {
name: collection.name,
id: collection.id,
default_view_mode: collection.default_view_mode,
enabled_view_modes: collection.enabled_view_modes
enabled_view_modes: collection.enabled_view_modes,
default_orderby: collection.default_orderby,
default_order: collection.default_order
});
}
@ -125,10 +139,10 @@ export default class CollectionModal extends React.Component {
});
}
selectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes }) {
selectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType }) {
collectionId = collectionId;
this.setState({ collectionId: collectionId });
this.props.onSelectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes });
this.props.onSelectCollection({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType });
}
fetchCollections(name) {
@ -146,7 +160,7 @@ export default class CollectionModal extends React.Component {
let query = {
perpage: this.state.collectionsPerPage,
paged: this.state.collectionPage
paged: this.state.collectionsPage
}
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
@ -166,13 +180,13 @@ export default class CollectionModal extends React.Component {
if (name != undefined && name != '')
endpoint += '&search=' + name;
if (this.state.collectionOrderBy == 'date')
if (this.state.collectionsOrderBy == 'date')
endpoint += '&orderby=date&order=asc';
else if (this.state.collectionOrderBy == 'date-desc')
else if (this.state.collectionsOrderBy == 'date-desc')
endpoint += '&orderby=date&order=desc';
else if (this.state.collectionOrderBy == 'title')
else if (this.state.collectionsOrderBy == 'title')
endpoint += '&orderby=title&order=asc';
else if (this.state.collectionOrderBy == 'title-desc')
else if (this.state.collectionsOrderBy == 'title-desc')
endpoint += '&orderby=title&order=desc';
tainacan.get(endpoint, { cancelToken: aCollectionRequestSource.token })
@ -181,7 +195,9 @@ export default class CollectionModal extends React.Component {
name: collection.name,
id: collection.id + '',
default_view_mode: collection.default_view_mode,
enabled_view_modes: collection.enabled_view_modes
enabled_view_modes: collection.enabled_view_modes,
default_orderby: collection.default_orderby,
default_order: collection.default_order
}));
this.setState({
@ -200,7 +216,7 @@ export default class CollectionModal extends React.Component {
this.setState({
collectionId: null,
collectionPage: 1,
collectionsPage: 1,
modalCollections: []
});
this.fetchModalCollections();
@ -227,19 +243,19 @@ export default class CollectionModal extends React.Component {
}}/>
<SelectControl
label={__('Order by', 'tainacan')}
value={ this.state.collectionOrderBy }
value={ this.state.collectionsOrderBy }
options={ [
{ label: __('Latest', 'tainacan'), value: 'date-desc' },
{ label: __('Oldest', 'tainacan'), value: 'date' },
{ label: __('Name (A-Z)', 'tainacan'), value: 'title' },
{ label: __('Name (Z-A)', 'tainacan'), value: 'title-desc' }
] }
onChange={ ( aCollectionOrderBy ) => {
this.state.collectionOrderBy = aCollectionOrderBy;
this.state.collectionPage = 1;
onChange={ ( acollectionsOrderBy ) => {
this.state.collectionsOrderBy = acollectionsOrderBy;
this.state.collectionsPage = 1;
this.setState({
collectionOrderBy: this.state.collectionOrderBy,
collectionPage: this.state.collectionPage
collectionsOrderBy: this.state.collectionsOrderBy,
collectionsPage: this.state.collectionsPage
});
if (this.state.searchCollectionName && this.state.searchCollectionName != '') {
this.fetchCollections(this.state.searchCollectionName);
@ -267,9 +283,17 @@ export default class CollectionModal extends React.Component {
this.state.temporaryCollectionId = aCollectionId;
this.state.temporaryCollectionDefaultViewMode = selectedCollection.default_view_mode;
this.state.temporaryCollectionEnabledViewModes = selectedCollection.enabled_view_modes;
this.state.temporaryCollectionDefaultOrder = selectedCollection.default_order;
this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby;
this.state.temporaryCollectionDefaultOrderByMeta = selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '';
this.state.temporaryCollectionDefaultOrderByType = selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '';
this.setState({ temporaryCollectionId: aCollectionId });
this.setState({ temporaryCollectionDefaultViewMode: selectedCollection.default_view_mode });
this.setState({ temporaryCollectionEnabledViewModes: selectedCollection.enabled_view_modes });
this.setState({ temporaryCollectionDefaultOrder: selectedCollection.default_order });
this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby });
this.setState({ temporaryCollectionDefaultOrderByMeta: selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '' });
this.setState({ temporaryCollectionDefaultOrderByType: selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '' });
} } />
}
</div>
@ -299,9 +323,19 @@ export default class CollectionModal extends React.Component {
this.state.temporaryCollectionId = aCollectionId;
this.state.temporaryCollectionDefaultViewMode = selectedCollection.default_view_mode;
this.state.temporaryCollectionEnabledViewModes = selectedCollection.enabled_view_modes;
this.state.temporaryCollectionDefaultOrder = selectedCollection.default_order;
this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby;
this.state.temporaryCollectionDefaultOrderBy = selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby;
this.state.temporaryCollectionDefaultOrderByMeta = selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '';
this.state.temporaryCollectionDefaultOrderByType = selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '';
this.setState({ temporaryCollectionId: aCollectionId });
this.setState({ temporaryCollectionDefaultViewMode: selectedCollection.default_view_mode });
this.setState({ temporaryCollectionEnabledViewModes: selectedCollection.enabled_view_modes });
this.setState({ temporaryCollectionDefaultOrder: selectedCollection.default_order });
this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby });
this.setState({ temporaryCollectionDefaultOrderBy: selectedCollection.default_orderby.orderby ? selectedCollection.default_orderby.orderby : selectedCollection.default_orderby });
this.setState({ temporaryCollectionDefaultOrderByMeta: selectedCollection.default_orderby.metakey ? selectedCollection.default_orderby.metakey : '' });
this.setState({ temporaryCollectionDefaultOrderByType: selectedCollection.default_orderby.metatype ? selectedCollection.default_orderby.metatype : '' });
} } />
}
</div>
@ -336,7 +370,11 @@ export default class CollectionModal extends React.Component {
onClick={ () => this.selectCollection({
collectionId: this.state.temporaryCollectionId,
collectionDefaultViewMode: this.state.temporaryCollectionDefaultViewMode,
collectionEnabledViewModes: this.state.temporaryCollectionEnabledViewModes
collectionEnabledViewModes: this.state.temporaryCollectionEnabledViewModes,
collectionDefaultOrder: this.state.temporaryCollectionDefaultOrder,
collectionDefaultOrderBy: this.state.temporaryCollectionDefaultOrderBy,
collectionDefaultOrderByMeta: this.state.temporaryCollectionDefaultOrderByMeta,
collectionDefaultOrderByType: this.state.temporaryCollectionDefaultOrderByType
}) }>
{__('Use selected Collection', 'tainacan')}
</Button>

View File

@ -1,4 +1,289 @@
export default [
/* Deprecated in version 0.19.4 due to add of orderby, orderbymeta and orderbykey */
{
attributes: {
"termId": {
"type": "String",
"default": null
},
"taxonomyId": {
"type": "String",
"default": null
},
"collectionId": {
"type": "String",
"default": null
},
"defaultViewMode": {
"type": "String",
"default": "masonry"
},
"enabledViewModes": {
"type": "Array",
"default": null
},
"collectionDefaultViewMode": {
"type": "String",
"default": "masonry"
},
"collectionEnabledViewModes": {
"type": "Array",
"default": []
},
"hideFilters": {
"type": "Boolean",
"default": false
},
"hideHideFiltersButton": {
"type": "Boolean",
"default": false
},
"hideSearch": {
"type": "Boolean",
"default": false
},
"hideAdvancedSearch": {
"type": "Boolean",
"default": false
},
"hideDisplayedMetadataButton": {
"type": "Boolean",
"default": false
},
"hideSortingArea": {
"type": "Boolean",
"default": false
},
"hideSortByButton": {
"type": "Boolean",
"default": false
},
"hideItemsThumbnail": {
"type": "Boolean",
"default": false
},
"hideExposersButton": {
"type": "Boolean",
"default": false
},
"hideItemsPerPageButton": {
"type": "Boolean",
"default": false
},
"defaultItemsPerPage": {
"type": "Number",
"default": 12
},
"hideGoToPageButton": {
"type": "Boolean",
"default": false
},
"hidePaginationArea": {
"type": "Boolean",
"default": false
},
"showFiltersButtonInsideSearchControl": {
"type": "Boolean",
"default": false
},
"startWithFiltersHidden": {
"type": "Boolean",
"default": false
},
"filtersAsModal": {
"type": "Boolean",
"default": false
},
"showInlineViewModeOptions": {
"type": "Boolean",
"default": false
},
"showFullscreenWithViewModes": {
"type": "Boolean",
"default": false
},
"listType": {
"type": "String",
"default": ""
},
"isCollectionModalOpen": {
"type": "Boolean",
"default": false
},
"isTermModalOpen": {
"type": "Boolean",
"default": false
},
"backgroundColor": {
"type": "String",
"default": "#ffffff"
},
"baseFontSize": {
"type": "Number",
"default": 16
},
"filtersAreaWidth": {
"type": "Number",
"default": 20
},
"inputColor": {
"type": "String",
"default": "#1d1d1d"
},
"inputBackgroundColor": {
"type": "String",
"default": "#ffffff"
},
"inputBorderColor": {
"type": "String",
"default": "#dbdbdb"
},
"labelColor": {
"type": "String",
"default": "#454647"
},
"infoColor": {
"type": "String",
"default": "#555758"
},
"headingColor": {
"type": "String",
"default": "#000000"
},
"skeletonColor": {
"type": "String",
"default": "#eeeeee"
},
"itemBackgroundColor": {
"type": "String",
"default": "#ffffff"
},
"itemHoverBackgroundColor": {
"type": "String",
"default": "#f2f2f2"
},
"itemHeadingHoverBackgroundColor": {
"type": "String",
"default": "#dbdbdb"
},
"primaryColor": {
"type": "String",
"default": "#d9eced"
},
"secondaryColor": {
"type": "String",
"default": "#298596"
}
},
supports: {
align: ['full', 'wide'],
html: true,
multiple: false
},
save({ attributes, className }) {
const {
termId,
taxonomyId,
collectionId,
defaultViewMode,
enabledViewModes,
collectionDefaultViewMode,
collectionEnabledViewModes,
hideDisplayedMetadataButton,
hideSortingArea,
hideFilters,
hideHideFiltersButton,
hideSearch,
hideAdvancedSearch,
hideSortByButton,
hideItemsThumbnail,
hidePaginationArea,
hideExposersButton,
hideItemsPerPageButton,
defaultItemsPerPage,
hideGoToPageButton,
showFiltersButtonInsideSearchControl,
startWithFiltersHidden,
filtersAsModal,
showInlineViewModeOptions,
showFullscreenWithViewModes,
listType,
backgroundColor,
baseFontSize,
filtersAreaWidth,
inputColor,
inputBackgroundColor,
inputBorderColor,
labelColor,
infoColor,
headingColor,
skeletonColor,
itemBackgroundColor,
itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor,
primaryColor,
secondaryColor
} = attributes;
let updatedListType = '' + listType;
if (updatedListType === '' && collectionId)
updatedListType = 'collection';
else if (updatedListType === '' && termId && taxonomyId)
updatedListType = 'term';
return <div
style={{
'font-size': baseFontSize + 'px',
'--tainacan-base-font-size': baseFontSize + 'px',
'--tainacan-background-color': backgroundColor,
'--tainacan-filter-menu-width-theme': filtersAreaWidth + '%',
'--tainacan-input-color': inputColor,
'--tainacan-input-background-color': inputBackgroundColor,
'--tainacan-input-border-color': inputBorderColor,
'--tainacan-label-color': labelColor,
'--tainacan-info-color': infoColor,
'--tainacan-heading-color': headingColor,
'--tainacan-skeleton-color': skeletonColor,
'--tainacan-item-background-color': itemBackgroundColor,
'--tainacan-item-hover-background-color': itemHoverBackgroundColor,
'--tainacan-item-heading-hover-background-color': itemHeadingHoverBackgroundColor,
'--tainacan-primary': primaryColor,
'--tainacan-secondary': secondaryColor
}}
className={ className }>
<main
id="tainacan-items-page"
data-module="faceted-search"
term-id={ updatedListType == 'term' ? termId : null }
taxonomy={ updatedListType == 'term' ? 'tnc_tax_' + taxonomyId : null }
collection-id={ updatedListType == 'collection' ? collectionId : null }
default-view-mode={ defaultViewMode != 'none' ? defaultViewMode : (updatedListType == 'collection' ? collectionDefaultViewMode : (hideItemsThumbnail ? 'table' : 'masonry') ) }
is-forced-view-mode={ defaultViewMode == 'none' ? 'true' : 'false' }
enabled-view-modes={ enabledViewModes.toString() }
hide-filters = { hideFilters.toString() }
hide-hide-filters-button= { hideHideFiltersButton.toString() }
hide-search = { hideSearch.toString() }
hide-advanced-search = { hideAdvancedSearch.toString() }
hide-displayed-metadata-button = { hideDisplayedMetadataButton.toString() }
hide-pagination-area = { hidePaginationArea.toString() }
hide-sorting-area = { hideSortingArea.toString() }
hide-items-thumbnail = { hideItemsThumbnail ? hideItemsThumbnail.toString() : 'false' }
hide-sort-by-button = { hideSortByButton.toString() }
hide-pagination-area = { hidePaginationArea.toString() }
hide-exposers-button = { hideExposersButton.toString() }
hide-items-per-page-button = { hideItemsPerPageButton.toString() }
default-items-per-page = { defaultItemsPerPage }
hide-go-to-page-button = { hideGoToPageButton.toString() }
show-filters-button-inside-search-control = { showFiltersButtonInsideSearchControl.toString() }
start-with-filters-hidden = { startWithFiltersHidden.toString() }
filters-as-modal = { filtersAsModal.toString() }
show-inline-view-mode-options = { showInlineViewModeOptions.toString() }
show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() } >
</main>
</div>
}
},
/* Deprecated in version 0.18.4 due to WP 5.8 support */
{
attributes: {

View File

@ -2,7 +2,6 @@ const { __ } = wp.i18n;
const {
Button,
ColorPalette,
BaseControl,
CheckboxControl,
RangeControl,
@ -70,7 +69,14 @@ export default function({ attributes, setAttributes, className, isSelected, clie
itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor,
primaryColor,
secondaryColor
secondaryColor,
order,
orderBy,
orderByMeta,
orderByType,
collectionOrderBy,
collectionOrderByMeta,
collectionOrderByType
} = attributes;
let registeredViewModesEntries = [];
@ -411,6 +417,50 @@ export default function({ attributes, setAttributes, className, isSelected, clie
}
/>
<BaseControl
id="defaulOrder"
label={ __('Default order', 'tainacan')}
help={ __('The default sorting direction', 'tainacan') }>
<SelectControl
label={ __('Default order', 'tainacan') }
hideLabelFromVision
value={ order }
options={
[
{ value: 'ASC', label: __('Ascending', 'tainacan') },
{ value: 'DESC', label: __('Descending', 'tainacan') }
]
}
onChange={ (anOrder) => {
order = anOrder;
setAttributes({ order: anOrder });
} }
/>
</BaseControl>
{ listType != 'collection' ?
<BaseControl
id="defaulOrderBy"
label={ __('Default order by', 'tainacan')}
help={ __('The default metadata by which the sorting will be applied', 'tainacan') }>
<SelectControl
label={ __('Default order by', 'tainacan') }
hideLabelFromVision
value={ orderBy }
options={
[
{ value: 'date', label: __('Creation date', 'tainacan') },
{ value: 'title', label: __('Title', 'tainacan') }
]
}
onChange={ (anOrderBy) => {
orderBy = anOrderBy;
setAttributes({ orderBy: anOrderBy });
} }
/>
</BaseControl>
: null }
<BaseControl
id="defaultViewModeSelect"
label={ __('Forced default view mode', 'tainacan')}
@ -976,18 +1026,31 @@ export default function({ attributes, setAttributes, className, isSelected, clie
{ isCollectionModalOpen ?
<CollectionModal
existingCollectionId={ collectionId }
existingCollectionDefaultOrder={ order }
existingCollectionDefaultOrderBy={ collectionOrderBy }
existingCollectionDefaultOrderByMeta={ collectionOrderByMeta }
existingCollectionDefaultOrderByType={ collectionOrderByType }
existingCollectionDefaultViewMode={ collectionDefaultViewMode }
existingCollectionEnabledViewModes={ collectionEnabledViewModes }
onSelectCollection={ ({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes }) => {
onSelectCollection={ ({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType }) => {
collectionId = collectionId;
collectionDefaultViewMode = collectionDefaultViewMode ? collectionDefaultViewMode : defaultViewMode;
collectionEnabledViewModes = collectionEnabledViewModes && collectionEnabledViewModes.length ? collectionEnabledViewModes : enabledViewModes;
order = collectionDefaultOrder ? collectionDefaultOrder : 'ASC';
collectionOrderBy = collectionDefaultOrderBy ? collectionDefaultOrderBy : 'date';
collectionOrderByMeta = collectionDefaultOrderByMeta ? collectionDefaultOrderByMeta : '';
collectionOrderByType = collectionDefaultOrderByType ? collectionDefaultOrderByType : '';
console.log(collectionDefaultOrderByMeta)
setAttributes({
collectionId: collectionId,
collectionDefaultViewMode: collectionDefaultViewMode,
defaultViewMode: collectionDefaultViewMode,
collectionEnabledViewModes: collectionEnabledViewModes,
enabledViewModes: collectionEnabledViewModes,
order: order,
collectionOrderBy, collectionOrderBy,
collectionOrderByMeta: collectionOrderByMeta,
collectionOrderByType: collectionOrderByType,
isCollectionModalOpen: false
});
}}

View File

@ -40,7 +40,14 @@ export default function({ attributes, className }) {
itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor,
primaryColor,
secondaryColor
secondaryColor,
order,
orderBy,
orderByMeta,
orderByType,
collectionOrderBy,
collectionOrderByMeta,
collectionOrderByType
} = attributes;
let updatedListType = '' + listType;
@ -88,7 +95,6 @@ export default function({ attributes, className }) {
hide-sorting-area = { hideSortingArea.toString() }
hide-items-thumbnail = { hideItemsThumbnail ? hideItemsThumbnail.toString() : 'false' }
hide-sort-by-button = { hideSortByButton.toString() }
hide-pagination-area = { hidePaginationArea.toString() }
hide-exposers-button = { hideExposersButton.toString() }
hide-items-per-page-button = { hideItemsPerPageButton.toString() }
default-items-per-page = { defaultItemsPerPage }
@ -97,7 +103,11 @@ export default function({ attributes, className }) {
start-with-filters-hidden = { startWithFiltersHidden.toString() }
filters-as-modal = { filtersAsModal.toString() }
show-inline-view-mode-options = { showInlineViewModeOptions.toString() }
show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() } >
show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() }
default-order = { order ? order : 'ASC' }
default-orderby = { updatedListType == 'collection' ? (collectionOrderBy ? collectionOrderBy : 'date') : (orderBy ? orderBy : 'date') }
default-orderby-meta = { updatedListType == 'collection' ? (collectionOrderByMeta ? collectionOrderByMeta : '') : (orderByMeta ? orderByMeta : '') }
default-orderby-type = { updatedListType == 'collection' ? (collectionOrderByType ? collectionOrderByType : '') : (orderByType ? orderByType : '') } >
</main>
</div>
};

View File

@ -728,6 +728,8 @@
// Other Tweaks
defaultOrder: 'ASC',
defaultOrderBy: 'date',
defaultOrderByMeta: '',
defaultOrderByType: '',
defaultItemsPerPage: Number,
showFiltersButtonInsideSearchControl: false,
startWithFiltersHidden: false,
@ -767,7 +769,7 @@
},
computed: {
isSortingByCustomMetadata() {
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date');
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date' && this.orderBy != 'modified');
},
items() {
return this.getItems();
@ -855,10 +857,33 @@
this.$eventBusSearch.setCollectionId(this.collectionId);
if (this.termId != undefined && this.termId != null)
this.$eventBusSearch.setTerm(this.termId, this.taxonomy);
if (this.defaultOrder != undefined)
if (this.defaultOrder != undefined) {
this.$eventBusSearch.setDefaultOrder(this.defaultOrder);
if (!this.$route.query.order)
this.$eventBusSearch.setOrder(this.defaultOrder);
}
if (this.defaultOrderBy != undefined) {
this.$eventBusSearch.setDefaultOrderBy(this.defaultOrderBy);
if (this.defaultOrderByMeta || this.defaultOrderByType) {
let orderByObject = { orderby: this.defaultOrderBy }
if (this.defaultOrderByMeta)
orderByObject['metakey'] = this.defaultOrderByMeta;
if (this.defaultOrderByType)
orderByObject['metatype'] = this.defaultOrderByType;
this.$eventBusSearch.setDefaultOrderBy(orderByObject);
if (!this.$route.query.orderby)
this.$eventBusSearch.setOrderBy(orderByObject);
} else {
this.$eventBusSearch.setDefaultOrderBy(this.defaultOrderBy);
if (!this.$route.query.orderby)
this.$eventBusSearch.setOrderBy(this.defaultOrderBy);
}
}
this.$eventBusSearch.updateStoreFromURL();
@ -999,6 +1024,7 @@
},
methods: {
...mapGetters('collection', [
'getCollection',
'getItems',
'getItemsListTemplate'
]),
@ -1062,10 +1088,10 @@
if (filterTagsAfterFiltersCollection)
this.hooks['filter_tags_after'] = filterTagsAfterFiltersCollection;
const itemsListAreaBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_area_list_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_area_list_before`, '');
const itemsListAreaBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_before`) || itemsListAreaBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_before`, itemsListAreaBeforeFilters);
const itemsListAreaBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_area_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_area_before`, '');
const itemsListAreaBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_before`) || itemsListAreaBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_before`, itemsListAreaBeforeFilters);
if (itemsListAreaBeforeFiltersCollection)
this.hooks['items_area_list_before'] = itemsListAreaBeforeFiltersCollection;
this.hooks['items_list_area_before'] = itemsListAreaBeforeFiltersCollection;
const itemsListBeforeFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_before`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_before`, '');
const itemsListBeforeFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`) || itemsListBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_before`, itemsListBeforeFilters);
@ -1087,10 +1113,10 @@
if (paginationAfterFiltersCollection)
this.hooks['pagination_after'] = paginationAfterFiltersCollection;
const itemsListAreaAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_area_list_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_area_list_after`, '');
const itemsListAreaAfterFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_after`) || itemsListAreaAfterFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_after`, itemsListAreaAfterFilters);
const itemsListAreaAfterFilters = wp.hooks.hasFilter(`tainacan_faceted_search_items_list_area_after`) && wp.hooks.applyFilters(`tainacan_faceted_search_items_list_area_after`, '');
const itemsListAreaAfterFiltersCollection = (wp.hooks.hasFilter(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_after`) || itemsListAreaAfterFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_list_area_after`, itemsListAreaAfterFilters);
if (itemsListAreaAfterFiltersCollection)
this.hooks['items_area_list_after'] = itemsListAreaAfterFiltersCollection;
this.hooks['items_list_area_after'] = itemsListAreaAfterFiltersCollection;
}
},
openExposersModal() {

View File

@ -175,6 +175,8 @@ export default (element) => {
defaultViewMode: '',
defaultOrder: 'ASC',
defaultOrderBy: 'date',
defaultOrderByMeta: '',
defaultOrderByType: '',
isForcedViewMode: false,
enabledViewModes: {},
defaultItemsPerPage: '',
@ -230,7 +232,11 @@ export default (element) => {
this.defaultOrder = this.$el.attributes['default-order'].value;
if (this.$el.attributes['default-orderby'] != undefined)
this.defaultOrderBy = this.maybeConvertFromJSON(this.$el.attributes['default-orderby'].value);
if (this.$el.attributes['default-orderby-meta'] != undefined)
this.defaultOrderByMeta = this.$el.attributes['default-orderby-meta'].value;
if (this.$el.attributes['default-orderby-type'] != undefined)
this.defaultOrderByType = this.maybeConvertFromJSON(this.$el.attributes['default-orderby-type'].value);
// Options related to hidding elements
if (this.$el.attributes['hide-filters'] != undefined)
this.hideFilters = this.isParameterTrue('hide-filters');

View File

@ -9,6 +9,8 @@
:is-forced-view-mode="$root.isForcedViewMode"
:default-order="$root.defaultOrder"
:default-order-by="$root.defaultOrderBy"
:default-order-by-meta="$root.defaultOrderByMeta"
:default-order-by-type="$root.defaultOrderByType"
:default-items-per-page="$root.defaultItemsPerPage"
:hide-filters="$root.hideFilters ? $root.hideFilters : false"
:hide-hide-filters-button="$root.hideHideFiltersButton ? $root.hideHideFiltersButton : false"

View File

@ -579,7 +579,8 @@
<!-- Message displayed when the form is being submitted -->
<section
v-if="isSubmitting || isUploading"
class="section">
class="section"
id="submission-form-processing">
<div class="content has-text-grey has-text-centered">
<br>
<p>
@ -587,9 +588,17 @@
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-updating tainacan-icon-spin"/>
</span>
</p>
<h2>{{ $i18n.get('label_sending_form') }}</h2>
<p v-if="isSubmitting">{{ $i18n.get('info_submission_processing') }}</p>
<p v-if="isUploading">{{ $i18n.get('info_submission_uploading') }}</p>
<h2 id="submission-form-is-processing-label">{{ $i18n.get('label_sending_form') }}</h2>
<p
id="submission-form-is-processing-info"
v-if="isSubmitting">
{{ $i18n.get('info_submission_processing') }}
</p>
<p
id="submission-form-is-uploading-info"
v-if="isUploading">
{{ $i18n.get('info_submission_uploading') }}
</p>
<br>
</div>
</section>
@ -597,7 +606,8 @@
<!-- Message displayed once the form is submitted -->
<section
v-if="hasSentForm"
class="section">
class="section"
id="submission-form-sent">
<div class="content has-text-grey has-text-centered">
<br>
<p>
@ -605,16 +615,28 @@
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-approvedcircle"/>
</span>
</p>
<h2 v-if="sentFormHeading">{{ sentFormHeading }}</h2>
<p v-if="sentFormMessage">{{ sentFormMessage }}</p>
<p v-if="showItemLinkButton && linkToCreatedItem">
<a
style="text-decoration: none"
:href="linkToCreatedItem"
class="button is-secondary">
{{ itemLinkButtonLabel }}
</a>
</p>
<div>
<h2
id="submission-form-sent-label"
v-if="sentFormHeading">
{{ sentFormHeading }}
</h2>
<p
id="submission-form-sent-info"
v-if="sentFormMessage">
{{ sentFormMessage }}
</p>
<p
id="submission-form-sent-link"
v-if="showItemLinkButton && linkToCreatedItem">
<a
style="text-decoration: none"
:href="linkToCreatedItem"
class="button is-secondary">
{{ itemLinkButtonLabel }}
</a>
</p>
</div>
<br>
</div>
</section>

View File

@ -7,16 +7,16 @@ const TAINACAN_BLOCKS = [
'items-list' => [],
'collections-list' => [],
'search-bar' => [],
'facets-list' => [],
'dynamic-items-list' => [],
'carousel-items-list' => [],
'carousel-terms-list' => [],
'carousel-collections-list' => [],
'facets-list' => [ 'set_script_translations' => true ],
'dynamic-items-list' => [ 'set_script_translations' => true ],
'carousel-items-list' => [ 'set_script_translations' => true ],
'carousel-terms-list' => [ 'set_script_translations' => true ],
'carousel-collections-list' => [ 'set_script_translations' => true ],
'related-items-list' => [],
'terms-list' => [],
'faceted-search' => [],
'item-submission-form' => [],
'item-gallery' => ['render_callback' => 'tainacan_blocks_render_items_gallery'],
'item-gallery' => [ 'set_script_translations' => true, 'render_callback' => 'tainacan_blocks_render_items_gallery' ],
'item-metadata-sections' => ['render_callback' => 'tainacan_blocks_render_metadata_sections'],
'item-metadata-section' => ['render_callback' => 'tainacan_blocks_render_metadata_section'],
'item-metadata' => ['render_callback' => 'tainacan_blocks_render_item_metadata'],
@ -135,6 +135,7 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
$editor_script_deps,
$TAINACAN_VERSION
);
wp_set_script_translations( $block_slug, 'tainacan' );
$register_params['editor_script'] = $block_slug;
// Passes global variables to the blocks editor side
@ -152,6 +153,18 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
);
$register_params['style'] = $block_slug;
// Makes sure translations that use wp.i18n work with our lazy loading strategy
if ( isset($options['set_script_translations']) && $options['set_script_translations'] ) {
wp_register_script(
'tainacan-chunks-' . $block_slug . '-theme',
$TAINACAN_BASE_URL . '/assets/js/tainacan-chunks-' . $block_slug . '-theme.js',
array('wp-i18n'),
$TAINACAN_VERSION
);
wp_set_script_translations( 'tainacan-chunks-' . $block_slug . '-theme', 'tainacan' );
wp_add_inline_script( 'wp-i18n', wp_scripts()->print_translations('tainacan-chunks-' . $block_slug . '-theme', false) );
}
// Registers the new block
if (function_exists('register_block_type')) {
if ( version_compare( $wp_version, '5.8-RC', '>=') )
@ -226,6 +239,8 @@ function tainacan_blocks_add_common_theme_scripts() {
$TAINACAN_VERSION
);
wp_set_script_translations( 'tainacan-blocks-common-scripts', 'tainacan' );
$block_settings = tainacan_blocks_get_plugin_js_settings();
$plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();

View File

@ -67,7 +67,7 @@ performWhenDocumentIsLoaded(() => {
moduleImport: name => import(
/* webpackMode: "lazy" */
/* webpackInclude: /theme\.js$/ */
/* webpackChunkName: "tainacan-chunks-" */
/* webpackChunkName: "tainacan-chunks-[request]" */
`${name}`
)
.catch((error) => {

View File

@ -1001,6 +1001,7 @@ return apply_filters( 'tainacan-i18n', [
'info_try_enabling_search_by_word' => __( 'Try enabling the search by words.', 'tainacan' ),
'info_try_disabling_search_by_word' => __( 'Try disabling the search by words, to search for the complete phrase.', 'tainacan' ),
'info_details_about_search_by_word' => __( 'They may be located on different metadata and order, but you will still be able to use quotes to group them.', 'tainacan' ),
'info_item_submission_draft_status' => __( 'Warning: draft items may be submitted even without filling all required metadata.', 'tainacan' ),
'info_empty_geocoordinate_metadata_list' => __( 'No geocoordinate metadata was found. Try enabling it in the "displayed metadata" dropdown.', 'tainacan' ),
'info_non_located_item' => __( 'This item does not have any location based on this metadata.', 'tainacan' ),

View File

@ -28,7 +28,7 @@ performWhenDocumentIsLoaded(() => {
moduleImport: name => import(
/* webpackMode: "lazy" */
/* webpackInclude: /main\.js$/ */
/* webpackChunkName: "tainacan-chunks-" */
/* webpackChunkName: "tainacan-chunks-[request]" */
`${name}`
)
.catch((error) => {

View File

@ -34,7 +34,8 @@ module.exports = {
output: {
path: path.resolve(__dirname, './src/assets/js/'),
publicPath: './wp-content/plugins/tainacan/assets/js/',
filename: '[name].js'
filename: '[name].js',
chunkFilename: `[name].js?ver=[contenthash]`
},
module: {
rules: [