Sets collection default default_orderby value to date instead of creation_date.

This commit is contained in:
mateuswetah 2023-03-06 18:50:22 -03:00
parent fb226bad3c
commit dfd259888e
5 changed files with 11 additions and 8 deletions

View File

@ -94,7 +94,7 @@ class Collections extends Repository {
'title' => __( 'Default order metadata', 'tainacan' ),
'type' => ['string', 'array', 'object'],
'description' => __( 'Default property that items in this collections will be ordered by', 'tainacan' ),
'default' => 'creation_date',
'default' => 'date',
//'validation' => v::stringType(),
],
'default_order' => [

View File

@ -509,7 +509,7 @@ class Theme_Helper {
$default_order = $args['default_order'];
unset($args['default_order']);
}
$default_orderby = 'date';
if ( isset($args['default_orderby']) ) {
$default_orderby = $args['default_orderby'];
@ -528,7 +528,7 @@ class Theme_Helper {
// Gets hideItemsThumbnail info from collection setting
$args['hide-items-thumbnail'] = $collection->get_hide_items_thumbnail_on_lists() == 'yes' ? true : false;
}
var_dump($default_order);
// If in a tainacan taxonomy
$term = tainacan_get_term($args);
if ($term) {

View File

@ -1099,7 +1099,7 @@
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
if (prefsFetchOnlyMetaObject.length && metadatum.display != 'yes') {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;

View File

@ -769,7 +769,7 @@
},
computed: {
isSortingByCustomMetadata() {
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date' && this.orderBy != 'modified');
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'creation_date' && this.orderBy != 'date' && this.orderBy != 'modified');
},
items() {
return this.getItems();
@ -863,6 +863,7 @@
this.$eventBusSearch.setOrder(this.defaultOrder);
}
if (this.defaultOrderBy != undefined) {
if (this.defaultOrderByMeta || this.defaultOrderByType) {
let orderByObject = { orderby: this.defaultOrderBy }
@ -1278,7 +1279,7 @@
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
if (prefsFetchOnlyMetaObject.length && metadatum.display != 'yes') {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;

View File

@ -226,12 +226,14 @@ export default (element) => {
if (this.$el.attributes['enabled-view-modes'] != undefined)
this.enabledViewModes = this.$el.attributes['enabled-view-modes'].value.split(',');
// Sorting options
if (this.$el.attributes['default-order'] != undefined)
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 === 'creation_date' ? 'date' : this.defaultOrderBy;
}
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)