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:
parent
3aa39aac92
commit
d737ca4952
|
@ -13,7 +13,7 @@
|
||||||
getLastItemNumber() +
|
getLastItemNumber() +
|
||||||
$i18n.get('info_of')
|
$i18n.get('info_of')
|
||||||
}}
|
}}
|
||||||
<span :class="{ 'has-text-warning': collectionTotalItems > totalItems }">
|
<span :class="{ 'has-text-warning': isSortingByCustomMetadata }">
|
||||||
{{ totalItems + '.' }}
|
{{ totalItems + '.' }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
}"
|
}"
|
||||||
style="margin-top: -3px"
|
style="margin-top: -3px"
|
||||||
class="icon has-text-warning"
|
class="icon has-text-warning"
|
||||||
v-if="collectionTotalItems > totalItems">
|
v-if="isSortingByCustomMetadata">
|
||||||
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-alertcircle" />
|
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-alertcircle" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -106,28 +106,10 @@ export default {
|
||||||
},
|
},
|
||||||
totalPages(){
|
totalPages(){
|
||||||
return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage));
|
return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
collectionTotalItems() {
|
props: {
|
||||||
let collectionTotalItemsObject = this.getCollectionTotalItems().total_items;
|
isSortingByCustomMetadata: Boolean
|
||||||
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;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
page( value ){
|
page( value ){
|
||||||
|
@ -136,15 +118,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapGetters('collection', [
|
|
||||||
'getCollectionTotalItems'
|
|
||||||
]),
|
|
||||||
...mapGetters('search', [
|
...mapGetters('search', [
|
||||||
'getTotalItems',
|
'getTotalItems',
|
||||||
'getPage',
|
'getPage',
|
||||||
'getItemsPerPage',
|
'getItemsPerPage',
|
||||||
'getPostQuery',
|
'getPostQuery'
|
||||||
'getStatus'
|
|
||||||
]),
|
]),
|
||||||
onChangeItemsPerPage(value) {
|
onChangeItemsPerPage(value) {
|
||||||
if( this.itemsPerPage == value){
|
if( this.itemsPerPage == value){
|
||||||
|
|
|
@ -730,6 +730,7 @@
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
<pagination
|
<pagination
|
||||||
|
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
|
||||||
v-if="totalItems > 0 &&
|
v-if="totalItems > 0 &&
|
||||||
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
|
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
|
||||||
(advancedSearchResults || !openAdvancedSearch)"/>
|
(advancedSearchResults || !openAdvancedSearch)"/>
|
||||||
|
@ -851,6 +852,9 @@
|
||||||
enabledViewModes: Object // Used only on theme
|
enabledViewModes: Object // Used only on theme
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
isSortingByCustomMetadata() {
|
||||||
|
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date');
|
||||||
|
},
|
||||||
repositoryTotalItems(){
|
repositoryTotalItems(){
|
||||||
let collections = this.getCollections();
|
let collections = this.getCollections();
|
||||||
|
|
||||||
|
@ -1322,10 +1326,7 @@
|
||||||
},
|
},
|
||||||
showItemsHiddingDueSorting() {
|
showItemsHiddingDueSorting() {
|
||||||
|
|
||||||
if (this.orderBy != undefined &&
|
if (this.isSortingByCustomMetadata &&
|
||||||
this.orderBy != '' &&
|
|
||||||
this.orderBy != 'title' &&
|
|
||||||
this.orderBy != 'date' &&
|
|
||||||
this.$userPrefs.get('neverShowItemsHiddenDueSortingDialog') != true) {
|
this.$userPrefs.get('neverShowItemsHiddenDueSortingDialog') != true) {
|
||||||
|
|
||||||
this.hasAnOpenModal = true;
|
this.hasAnOpenModal = true;
|
||||||
|
|
|
@ -708,6 +708,7 @@
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
<pagination
|
<pagination
|
||||||
|
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
|
||||||
v-if="totalItems > 0 &&
|
v-if="totalItems > 0 &&
|
||||||
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
|
(!isOnTheme || (registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
|
||||||
(advancedSearchResults || !openAdvancedSearch)"/>
|
(advancedSearchResults || !openAdvancedSearch)"/>
|
||||||
|
@ -792,6 +793,7 @@
|
||||||
import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
||||||
import ExposersModal from '../../components/other/exposers-modal.vue';
|
import ExposersModal from '../../components/other/exposers-modal.vue';
|
||||||
import AvailableImportersModal from '../../components/other/available-importers-modal.vue';
|
import AvailableImportersModal from '../../components/other/available-importers-modal.vue';
|
||||||
|
import CustomDialog from '../../components/other/custom-dialog.vue';
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -829,6 +831,9 @@
|
||||||
enabledViewModes: Object // Used only on theme,
|
enabledViewModes: Object // Used only on theme,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
isSortingByCustomMetadata() {
|
||||||
|
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date');
|
||||||
|
},
|
||||||
items() {
|
items() {
|
||||||
return this.getItems();
|
return this.getItems();
|
||||||
},
|
},
|
||||||
|
@ -983,6 +988,7 @@
|
||||||
},
|
},
|
||||||
onChangeOrderBy(metadatum) {
|
onChangeOrderBy(metadatum) {
|
||||||
this.$eventBusSearch.setOrderBy(metadatum);
|
this.$eventBusSearch.setOrderBy(metadatum);
|
||||||
|
this.showItemsHiddingDueSorting();
|
||||||
},
|
},
|
||||||
onChangeOrder() {
|
onChangeOrder() {
|
||||||
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
||||||
|
@ -1280,6 +1286,29 @@
|
||||||
this.isLoadingMetadata = false;
|
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() {
|
adjustSearchControlHeight: _.debounce( function() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
@ -1302,6 +1331,7 @@
|
||||||
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
||||||
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
this.isOnTheme = (this.$route.name === null);
|
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
|
// Watches window resize to adjust filter's top position and compression on mobile
|
||||||
this.adjustSearchControlHeight();
|
this.adjustSearchControlHeight();
|
||||||
window.addEventListener('resize', this.adjustSearchControlHeight);
|
window.addEventListener('resize', this.adjustSearchControlHeight);
|
||||||
|
|
|
@ -549,7 +549,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'info_other_item_listing_options' => __('Other items listing options: ', 'tainacan'),
|
'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_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_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 Metadatum Types
|
||||||
'tainacan-text' => __( 'Text', 'tainacan' ),
|
'tainacan-text' => __( 'Text', 'tainacan' ),
|
||||||
|
|
Loading…
Reference in New Issue