diff --git a/src/admin/components/search/pagination.vue b/src/admin/components/search/pagination.vue index d6992010c..1e352c1c2 100644 --- a/src/admin/components/search/pagination.vue +++ b/src/admin/components/search/pagination.vue @@ -13,7 +13,7 @@ getLastItemNumber() + $i18n.get('info_of') }} - + {{ totalItems + '.' }} + v-if="isSortingByCustomMetadata"> @@ -106,29 +106,11 @@ export default { }, totalPages(){ return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage)); - }, - collectionTotalItems() { - let collectionTotalItemsObject = this.getCollectionTotalItems().total_items; - if (collectionTotalItemsObject) { - let newCollectionTotalItems; - - switch(this.getStatus()) { - case 'draft': - newCollectionTotalItems = collectionTotalItemsObject.draft; - break; - case 'trash': - newCollectionTotalItems = collectionTotalItemsObject.trash; - break; - default: - newCollectionTotalItems = Number(collectionTotalItemsObject.publish) + Number(collectionTotalItemsObject.private); - } - - return newCollectionTotalItems; - - } else - return this.totalItems; } }, + props: { + isSortingByCustomMetadata: Boolean + }, watch: { page( value ){ if (value < 1) @@ -136,15 +118,11 @@ export default { } }, methods: { - ...mapGetters('collection', [ - 'getCollectionTotalItems' - ]), ...mapGetters('search', [ 'getTotalItems', 'getPage', 'getItemsPerPage', - 'getPostQuery', - 'getStatus' + 'getPostQuery' ]), onChangeItemsPerPage(value) { if( this.itemsPerPage == value){ diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index caab9bae9..37ab6671c 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -730,6 +730,7 @@ @@ -851,6 +852,9 @@ enabledViewModes: Object // Used only on theme }, computed: { + isSortingByCustomMetadata() { + return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date'); + }, repositoryTotalItems(){ let collections = this.getCollections(); @@ -1322,10 +1326,7 @@ }, showItemsHiddingDueSorting() { - if (this.orderBy != undefined && - this.orderBy != '' && - this.orderBy != 'title' && - this.orderBy != 'date' && + if (this.isSortingByCustomMetadata && this.$userPrefs.get('neverShowItemsHiddenDueSortingDialog') != true) { this.hasAnOpenModal = true; diff --git a/src/admin/pages/lists/term-items-page.vue b/src/admin/pages/lists/term-items-page.vue index 1d7b622d5..15f6100ae 100644 --- a/src/admin/pages/lists/term-items-page.vue +++ b/src/admin/pages/lists/term-items-page.vue @@ -708,6 +708,7 @@ @@ -792,6 +793,7 @@ import AdvancedSearch from '../../components/advanced-search/advanced-search.vue'; import ExposersModal from '../../components/other/exposers-modal.vue'; import AvailableImportersModal from '../../components/other/available-importers-modal.vue'; + import CustomDialog from '../../components/other/custom-dialog.vue'; import { mapActions, mapGetters } from 'vuex'; export default { @@ -829,6 +831,9 @@ enabledViewModes: Object // Used only on theme, }, computed: { + isSortingByCustomMetadata() { + return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date'); + }, items() { return this.getItems(); }, @@ -983,6 +988,7 @@ }, onChangeOrderBy(metadatum) { this.$eventBusSearch.setOrderBy(metadatum); + this.showItemsHiddingDueSorting(); }, onChangeOrder() { this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC'); @@ -1280,27 +1286,51 @@ this.isLoadingMetadata = false; }); }, - }, - adjustSearchControlHeight: _.debounce( function() { - this.$nextTick(() => { - if (this.$refs['search-control'] != undefined) - this.searchControlHeight = this.$refs['search-control'] ? this.$refs['search-control'].clientHeight + this.$refs['search-control'].offsetTop : 0; - this.isFiltersMenuCompressed = jQuery(window).width() <= 768; - }); - }, 500), - removeEventListeners() { - // Component - this.$off(); - // Window - window.removeEventListener('resize', this.adjustSearchControlHeight); - // $root - this.$root.$off('openAdvancedSearch'); - // $eventBusSearch - this.$eventBusSearch.$off('isLoadingItems'); - this.$eventBusSearch.$off('hasFiltered'); - this.$eventBusSearch.$off('advancedSearchResults'); - this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters'); + showItemsHiddingDueSorting() { + if (this.isSortingByCustomMetadata && + this.$userPrefs.get('neverShowItemsHiddenDueSortingDialog') != true) { + + this.hasAnOpenModal = true; + + this.$modal.open({ + parent: this, + component: CustomDialog, + props: { + icon: 'alert', + title: this.$i18n.get('label_warning'), + message: this.$i18n.get('info_items_hidden_due_sorting'), + onConfirm: () => { + this.hasAnOpenModal = false; + }, + hideCancel: true, + showNeverShowAgainOption: true, + messageKeyForUserPrefs: 'ItemsHiddenDueSorting' + } + }); + } + }, + adjustSearchControlHeight: _.debounce( function() { + this.$nextTick(() => { + if (this.$refs['search-control'] != undefined) + this.searchControlHeight = this.$refs['search-control'] ? this.$refs['search-control'].clientHeight + this.$refs['search-control'].offsetTop : 0; + this.isFiltersMenuCompressed = jQuery(window).width() <= 768; + }); + }, 500), + removeEventListeners() { + // Component + this.$off(); + // Window + window.removeEventListener('resize', this.adjustSearchControlHeight); + // $root + this.$root.$off('openAdvancedSearch'); + // $eventBusSearch + this.$eventBusSearch.$off('isLoadingItems'); + this.$eventBusSearch.$off('hasFiltered'); + this.$eventBusSearch.$off('advancedSearchResults'); + this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters'); + + }, }, created() { @@ -1393,6 +1423,8 @@ } } + this.showItemsHiddingDueSorting(); + // Watches window resize to adjust filter's top position and compression on mobile this.adjustSearchControlHeight(); window.addEventListener('resize', this.adjustSearchControlHeight); diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index 22d8b28c0..64406c2ae 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -549,7 +549,7 @@ return apply_filters( 'tainacan-admin-i18n', [ 'info_other_item_listing_options' => __('Other items listing options: ', 'tainacan'), 'info_send_email' => __('The exporter may take a while. Check this option to receive an e-mail when the process is done. You can also check the process status visiting the', 'tainacan'), 'info_tainacan_api' => __('Tainacan API on JSON format.', 'tainacan'), - 'info_items_hidden_due_sorting' => __('Items with empty values on the metadata selected for sorting won\'t appear, thus this list has less elements than the total existing.', 'tainacan'), + 'info_items_hidden_due_sorting' => __('Items with empty values on the metadata selected for sorting won\'t appear, thus this may list has less elements than the total existing.', 'tainacan'), // Tainacan Metadatum Types 'tainacan-text' => __( 'Text', 'tainacan' ),