Changes logic for display warning on pagination due to sorting by custom metadata. Fixes undefined functions on term items list.

This commit is contained in:
Mateus Machado Luna 2019-03-14 15:05:02 -03:00
parent 3aa39aac92
commit d737ca4952
4 changed files with 64 additions and 53 deletions

View File

@ -13,7 +13,7 @@
getLastItemNumber() +
$i18n.get('info_of')
}}
<span :class="{ 'has-text-warning': collectionTotalItems > totalItems }">
<span :class="{ 'has-text-warning': isSortingByCustomMetadata }">
{{ totalItems + '.' }}
</span>
<span
@ -24,7 +24,7 @@
}"
style="margin-top: -3px"
class="icon has-text-warning"
v-if="collectionTotalItems > totalItems">
v-if="isSortingByCustomMetadata">
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-alertcircle" />
</span>
</div>
@ -106,28 +106,10 @@ 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 ){
@ -136,15 +118,11 @@ export default {
}
},
methods: {
...mapGetters('collection', [
'getCollectionTotalItems'
]),
...mapGetters('search', [
'getTotalItems',
'getPage',
'getItemsPerPage',
'getPostQuery',
'getStatus'
'getPostQuery'
]),
onChangeItemsPerPage(value) {
if( this.itemsPerPage == value){

View File

@ -730,6 +730,7 @@
<!-- Pagination -->
<pagination
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
v-if="totalItems > 0 &&
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
(advancedSearchResults || !openAdvancedSearch)"/>
@ -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;

View File

@ -708,6 +708,7 @@
<!-- Pagination -->
<pagination
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
v-if="totalItems > 0 &&
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
(advancedSearchResults || !openAdvancedSearch)"/>
@ -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,6 +1286,29 @@
this.isLoadingMetadata = false;
});
},
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(() => {
@ -1302,6 +1331,7 @@
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
},
},
created() {
this.isOnTheme = (this.$route.name === null);
@ -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);

View File

@ -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' ),