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==" "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
}, },
"json5": { "json5": {
"version": "2.2.1", "version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true "dev": true
}, },
"jsprim": { "jsprim": {

View File

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

View File

@ -274,6 +274,8 @@ class Elastic_Press {
if( isset($args['tax_query']) ) { if( isset($args['tax_query']) ) {
foreach( $args['tax_query'] as $taxquery ) { foreach( $args['tax_query'] as $taxquery ) {
if ( !isset($tax['taxonomy']) || !isset($tax['terms']) )
continue;
if( $taxquery['taxonomy'] === $taxonomy_slug ) { if( $taxquery['taxonomy'] === $taxonomy_slug ) {
$include = is_array($taxquery['terms']) ? $taxquery['terms'] : [$taxquery['terms']]; $include = is_array($taxquery['terms']) ? $taxquery['terms'] : [$taxquery['terms']];
} }
@ -288,6 +290,8 @@ class Elastic_Press {
if( isset($args['meta_query']) ) { if( isset($args['meta_query']) ) {
foreach( $args['meta_query'] as $metaquery ) { foreach( $args['meta_query'] as $metaquery ) {
if ( !isset($meta['key']) || !isset($meta['value']) )
continue;
if( isset($metaquery['key']) && $metaquery['key'] == $metadatum_id ){ if( isset($metaquery['key']) && $metaquery['key'] == $metadatum_id ){
$include = is_array($metaquery['value']) ? $metaquery['value'] : [$metaquery['value']]; $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()); $id = $TainacanMedia->insert_attachment_from_file($server_path_files . $correct_value, $item_inserted->get_id());
if(!$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; return false;
} }
@ -604,7 +604,7 @@ class CSV extends Importer {
$id = $TainacanMedia->insert_attachment_from_file($server_path_files . $attachment, $item_inserted->get_id()); $id = $TainacanMedia->insert_attachment_from_file($server_path_files . $attachment, $item_inserted->get_id());
if(!$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; continue;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1084,7 +1084,8 @@ class Theme_Helper {
* Optional. Array of arguments. * Optional. Array of arguments.
* @type string $item_id The Item ID * @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 $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 $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_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 * @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 // Then fetches related ones
$related_items_query_args = []; $related_items_query_args = [];
if ( isset($args['orderby']) )
$related_items_query_args['orderby'] = $args['orderby'];
if ( isset($args['order']) ) if ( isset($args['order']) )
$related_items_query_args['order'] = $args['order']; $related_items_query_args['order'] = $args['order'];

View File

@ -302,6 +302,13 @@
{{ statusOption.name }} {{ statusOption.name }}
</b-radio> </b-radio>
</div> </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> </b-field>
<!-- Submission process uses reCAPTCHA ------------------------ --> <!-- Submission process uses reCAPTCHA ------------------------ -->

View File

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

View File

@ -138,6 +138,20 @@
</template> </template>
</b-taginput> </b-taginput>
</b-field> </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> </section>
</template> </template>
@ -159,6 +173,7 @@
taxonomy: '', taxonomy: '',
loading: false, loading: false,
allow_new_terms: 'yes', allow_new_terms: 'yes',
hide_hierarchy_path: 'no',
link_filtered_by_collections: [], link_filtered_by_collections: [],
visible_options_list: false, visible_options_list: false,
input_type: 'tainacan-taxonomy-radio', input_type: 'tainacan-taxonomy-radio',
@ -230,6 +245,7 @@
this.taxonomy_id = this.value.taxonomy_id; this.taxonomy_id = this.value.taxonomy_id;
this.allow_new_terms = ( this.value.allow_new_terms ) ? this.value.allow_new_terms : 'no'; 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') { if (this.metadatum && this.metadatum.multiple === 'no') {
let types = Object.keys( this.single_types ); let types = Object.keys( this.single_types );
@ -296,6 +312,7 @@
allow_new_terms: this.allow_new_terms, allow_new_terms: this.allow_new_terms,
visible_options_list: this.visible_options_list, visible_options_list: this.visible_options_list,
link_filtered_by_collections: this.link_filtered_by_collections, link_filtered_by_collections: this.link_filtered_by_collections,
hide_hierarchy_path: this.hide_hierarchy_path,
taxonomy: this.taxonomy taxonomy: this.taxonomy
}) })
}, },

View File

@ -23,6 +23,7 @@ class Taxonomy extends Metadata_Type {
'allow_new_terms' => 'no', 'allow_new_terms' => 'no',
'link_filtered_by_collections' => [], 'link_filtered_by_collections' => [],
'input_type' => 'tainacan-taxonomy-radio', 'input_type' => 'tainacan-taxonomy-radio',
'hide_hierarchy_path' => 'no'
]); ]);
$this->set_form_component('tainacan-form-taxonomy'); $this->set_form_component('tainacan-form-taxonomy');
@ -101,6 +102,10 @@ class Taxonomy extends Metadata_Type {
'link_filtered_by_collections' => [ 'link_filtered_by_collections' => [
'title' => __( 'Link filtered by collections', 'tainacan' ), 'title' => __( 'Link filtered by collections', 'tainacan' ),
'description' => __( 'Links to term items list filtered by certain collections instead of repository level term items page.', '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' ); $readable_option_value = __( 'None', 'tainacan' );
break; 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: default:
$readable_option_value = $option_value; $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) { public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value(); $value = $item_metadata->get_value();
$return = ''; $return = '';
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$count = 1; $count = 1;
$total = sizeof($value); $total = sizeof($value);
@ -369,6 +383,10 @@ class Taxonomy extends Metadata_Type {
} }
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) { 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 = [];
$terms[] = $this->term_to_html($term); $terms[] = $this->term_to_html($term);

View File

@ -14,7 +14,7 @@
</span> </span>
</a> </a>
<template #popper> <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> <ol>
<template v-for="(error, index) of formErrors"> <template v-for="(error, index) of formErrors">
<li <li

View File

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

View File

@ -1,7 +1,10 @@
<template> <template>
<transition name="filter-item"> <transition name="filter-item">
<div v-show="filterTags != undefined && filterTags.length > 0"> <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 <span
style="margin-right: 1em" style="margin-right: 1em"
v-html="totalItems == 1 ? $i18n.getWithVariables('info_item_%s_found', [totalItems]) : $i18n.getWithVariables('info_items_%s_found', [totalItems])" /> 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) { if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order'); let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder; let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
if (orderValue) if (orderValue)
this.$route.query.order = orderValue; this.$route.query.order = orderValue;
else { else {
@ -80,7 +80,7 @@ export default {
if (this.$route.query.orderby == undefined || to.params.collectionId != from.params.collectionId) { if (this.$route.query.orderby == undefined || to.params.collectionId != from.params.collectionId) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by'); let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy; let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') { if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object // 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 => { .then(res => {
let metadatum = res.data; let metadatum = res.data;
if (sectionId != undefined && sectionId != false) if (sectionId != undefined && sectionId != false && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: newIndex, sectionId: sectionId }) commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: newIndex, sectionId: sectionId })
else else
commit('setSingleMetadatum', { metadatum: metadatum, index: newIndex, isRepositoryLevel: isRepositoryLevel }); commit('setSingleMetadatum', { metadatum: metadatum, index: newIndex, isRepositoryLevel: isRepositoryLevel });
@ -129,8 +129,8 @@ export const updateMetadatum = ({commit}, {collectionId, metadatumId, isReposito
axios.tainacan.put(endpoint, options) axios.tainacan.put(endpoint, options)
.then(res => { .then(res => {
let metadatum = res.data; let metadatum = res.data;
if (sectionId !== null && sectionId !== undefined) if (sectionId !== null && sectionId !== undefined && !isRepositoryLevel)
commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: index, sectionId: sectionId }); commit('updateMetadatumInsideSectionMetadata', { metadatum: metadatum, index: index, sectionId: sectionId });
else else
commit('setSingleMetadatum', { metadatum: metadatum, index: index, isRepositoryLevel: isRepositoryLevel }); commit('setSingleMetadatum', { metadatum: metadatum, index: index, isRepositoryLevel: isRepositoryLevel });

View File

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

View File

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

View File

@ -1,4 +1,289 @@
export default [ 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 */ /* Deprecated in version 0.18.4 due to WP 5.8 support */
{ {
attributes: { attributes: {

View File

@ -2,7 +2,6 @@ const { __ } = wp.i18n;
const { const {
Button, Button,
ColorPalette,
BaseControl, BaseControl,
CheckboxControl, CheckboxControl,
RangeControl, RangeControl,
@ -70,7 +69,14 @@ export default function({ attributes, setAttributes, className, isSelected, clie
itemHoverBackgroundColor, itemHoverBackgroundColor,
itemHeadingHoverBackgroundColor, itemHeadingHoverBackgroundColor,
primaryColor, primaryColor,
secondaryColor secondaryColor,
order,
orderBy,
orderByMeta,
orderByType,
collectionOrderBy,
collectionOrderByMeta,
collectionOrderByType
} = attributes; } = attributes;
let registeredViewModesEntries = []; 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 <BaseControl
id="defaultViewModeSelect" id="defaultViewModeSelect"
label={ __('Forced default view mode', 'tainacan')} label={ __('Forced default view mode', 'tainacan')}
@ -976,18 +1026,31 @@ export default function({ attributes, setAttributes, className, isSelected, clie
{ isCollectionModalOpen ? { isCollectionModalOpen ?
<CollectionModal <CollectionModal
existingCollectionId={ collectionId } existingCollectionId={ collectionId }
existingCollectionDefaultOrder={ order }
existingCollectionDefaultOrderBy={ collectionOrderBy }
existingCollectionDefaultOrderByMeta={ collectionOrderByMeta }
existingCollectionDefaultOrderByType={ collectionOrderByType }
existingCollectionDefaultViewMode={ collectionDefaultViewMode } existingCollectionDefaultViewMode={ collectionDefaultViewMode }
existingCollectionEnabledViewModes={ collectionEnabledViewModes } existingCollectionEnabledViewModes={ collectionEnabledViewModes }
onSelectCollection={ ({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes }) => { onSelectCollection={ ({ collectionId, collectionDefaultViewMode, collectionEnabledViewModes, collectionDefaultOrder, collectionDefaultOrderBy, collectionDefaultOrderByMeta, collectionDefaultOrderByType }) => {
collectionId = collectionId; collectionId = collectionId;
collectionDefaultViewMode = collectionDefaultViewMode ? collectionDefaultViewMode : defaultViewMode; collectionDefaultViewMode = collectionDefaultViewMode ? collectionDefaultViewMode : defaultViewMode;
collectionEnabledViewModes = collectionEnabledViewModes && collectionEnabledViewModes.length ? collectionEnabledViewModes : enabledViewModes; collectionEnabledViewModes = collectionEnabledViewModes && collectionEnabledViewModes.length ? collectionEnabledViewModes : enabledViewModes;
order = collectionDefaultOrder ? collectionDefaultOrder : 'ASC';
collectionOrderBy = collectionDefaultOrderBy ? collectionDefaultOrderBy : 'date';
collectionOrderByMeta = collectionDefaultOrderByMeta ? collectionDefaultOrderByMeta : '';
collectionOrderByType = collectionDefaultOrderByType ? collectionDefaultOrderByType : '';
console.log(collectionDefaultOrderByMeta)
setAttributes({ setAttributes({
collectionId: collectionId, collectionId: collectionId,
collectionDefaultViewMode: collectionDefaultViewMode, collectionDefaultViewMode: collectionDefaultViewMode,
defaultViewMode: collectionDefaultViewMode, defaultViewMode: collectionDefaultViewMode,
collectionEnabledViewModes: collectionEnabledViewModes, collectionEnabledViewModes: collectionEnabledViewModes,
enabledViewModes: collectionEnabledViewModes, enabledViewModes: collectionEnabledViewModes,
order: order,
collectionOrderBy, collectionOrderBy,
collectionOrderByMeta: collectionOrderByMeta,
collectionOrderByType: collectionOrderByType,
isCollectionModalOpen: false isCollectionModalOpen: false
}); });
}} }}

View File

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

View File

@ -728,6 +728,8 @@
// Other Tweaks // Other Tweaks
defaultOrder: 'ASC', defaultOrder: 'ASC',
defaultOrderBy: 'date', defaultOrderBy: 'date',
defaultOrderByMeta: '',
defaultOrderByType: '',
defaultItemsPerPage: Number, defaultItemsPerPage: Number,
showFiltersButtonInsideSearchControl: false, showFiltersButtonInsideSearchControl: false,
startWithFiltersHidden: false, startWithFiltersHidden: false,
@ -767,7 +769,7 @@
}, },
computed: { computed: {
isSortingByCustomMetadata() { 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() { items() {
return this.getItems(); return this.getItems();
@ -855,10 +857,33 @@
this.$eventBusSearch.setCollectionId(this.collectionId); this.$eventBusSearch.setCollectionId(this.collectionId);
if (this.termId != undefined && this.termId != null) if (this.termId != undefined && this.termId != null)
this.$eventBusSearch.setTerm(this.termId, this.taxonomy); this.$eventBusSearch.setTerm(this.termId, this.taxonomy);
if (this.defaultOrder != undefined) if (this.defaultOrder != undefined) {
this.$eventBusSearch.setDefaultOrder(this.defaultOrder); this.$eventBusSearch.setDefaultOrder(this.defaultOrder);
if (!this.$route.query.order)
this.$eventBusSearch.setOrder(this.defaultOrder);
}
if (this.defaultOrderBy != undefined) { 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(); this.$eventBusSearch.updateStoreFromURL();
@ -999,6 +1024,7 @@
}, },
methods: { methods: {
...mapGetters('collection', [ ...mapGetters('collection', [
'getCollection',
'getItems', 'getItems',
'getItemsListTemplate' 'getItemsListTemplate'
]), ]),
@ -1062,10 +1088,10 @@
if (filterTagsAfterFiltersCollection) if (filterTagsAfterFiltersCollection)
this.hooks['filter_tags_after'] = 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 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_area_list_before`) || itemsListAreaBeforeFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_before`, itemsListAreaBeforeFilters); 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) 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 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); 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) if (paginationAfterFiltersCollection)
this.hooks['pagination_after'] = 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 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_area_list_after`) || itemsListAreaAfterFilters) && wp.hooks.applyFilters(`tainacan_faceted_search_collection_${this.collectionId}_items_area_list_after`, itemsListAreaAfterFilters); 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) if (itemsListAreaAfterFiltersCollection)
this.hooks['items_area_list_after'] = itemsListAreaAfterFiltersCollection; this.hooks['items_list_area_after'] = itemsListAreaAfterFiltersCollection;
} }
}, },
openExposersModal() { openExposersModal() {

View File

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

View File

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

View File

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

View File

@ -7,16 +7,16 @@ const TAINACAN_BLOCKS = [
'items-list' => [], 'items-list' => [],
'collections-list' => [], 'collections-list' => [],
'search-bar' => [], 'search-bar' => [],
'facets-list' => [], 'facets-list' => [ 'set_script_translations' => true ],
'dynamic-items-list' => [], 'dynamic-items-list' => [ 'set_script_translations' => true ],
'carousel-items-list' => [], 'carousel-items-list' => [ 'set_script_translations' => true ],
'carousel-terms-list' => [], 'carousel-terms-list' => [ 'set_script_translations' => true ],
'carousel-collections-list' => [], 'carousel-collections-list' => [ 'set_script_translations' => true ],
'related-items-list' => [], 'related-items-list' => [],
'terms-list' => [], 'terms-list' => [],
'faceted-search' => [], 'faceted-search' => [],
'item-submission-form' => [], '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-sections' => ['render_callback' => 'tainacan_blocks_render_metadata_sections'],
'item-metadata-section' => ['render_callback' => 'tainacan_blocks_render_metadata_section'], 'item-metadata-section' => ['render_callback' => 'tainacan_blocks_render_metadata_section'],
'item-metadata' => ['render_callback' => 'tainacan_blocks_render_item_metadata'], 'item-metadata' => ['render_callback' => 'tainacan_blocks_render_item_metadata'],
@ -135,6 +135,7 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
$editor_script_deps, $editor_script_deps,
$TAINACAN_VERSION $TAINACAN_VERSION
); );
wp_set_script_translations( $block_slug, 'tainacan' );
$register_params['editor_script'] = $block_slug; $register_params['editor_script'] = $block_slug;
// Passes global variables to the blocks editor side // 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; $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 // Registers the new block
if (function_exists('register_block_type')) { if (function_exists('register_block_type')) {
if ( version_compare( $wp_version, '5.8-RC', '>=') ) if ( version_compare( $wp_version, '5.8-RC', '>=') )
@ -226,6 +239,8 @@ function tainacan_blocks_add_common_theme_scripts() {
$TAINACAN_VERSION $TAINACAN_VERSION
); );
wp_set_script_translations( 'tainacan-blocks-common-scripts', 'tainacan' );
$block_settings = tainacan_blocks_get_plugin_js_settings(); $block_settings = tainacan_blocks_get_plugin_js_settings();
$plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params(); $plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();

View File

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

View File

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