Fixes collection settings update for default orderby

This commit is contained in:
mateuswetah 2021-12-06 17:19:04 -03:00
parent 3a5a6bb322
commit 296d31877e
1 changed files with 9 additions and 7 deletions

View File

@ -1240,17 +1240,19 @@ export default {
});
// Updates localDefaultOrder variable that needs only the ID of the metadata
this.localDefaultOrderBy(this.form.default_orderby);
if (this.form.default_orderby.metakey)
this.localDefaultOrderBy = this.form.default_orderby.metakey;
else {
if (this.form.default_orderby == 'title')
this.localDefaultOrderBy = this.sortingMetadata.find((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title').id;
else if (this.form.default_orderby == 'description')
this.localDefaultOrderBy = this.sortingMetadata.find((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Description').id;
else
if (this.form.default_orderby == 'title') {
const localDefaultOrderByIndex = this.sortingMetadata.findIndex((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title');
this.localDefaultOrderBy = localDefaultOrderByIndex >= 0 ? this.sortingMetadata[localDefaultOrderByIndex].id : 'title';
} else if (this.form.default_orderby == 'description') {
const localDefaultOrderByIndex = this.sortingMetadata.findIndex((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Description');
this.localDefaultOrderBy = localDefaultOrderByIndex >= 0 ? this.sortingMetadata[localDefaultOrderByIndex].id : 'description';
} else {
this.localDefaultOrderBy = this.form.default_orderby;
}
}
this.isLoadingMetadata = false;
})