Adds alert for custom emtadata values used for sorting.

This commit is contained in:
Mateus Machado Luna 2019-07-17 13:16:36 -03:00
parent e07285d638
commit dbeac4f798
3 changed files with 67 additions and 8 deletions

View File

@ -701,6 +701,28 @@
<!-- <skeleton-items-list v-if="!isOnTheme"/> -->
</div>
<!-- Alert if custom metada is being used for sorting -->
<div
v-if="hasAnOpenAlert &&
isSortingByCustomMetadata &&
!showLoading &&
((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
class="metadata-alert">
<p class="text">{{ $i18n.getWithVariables('info_sorting_by_metadata_value_%s', [orderByName]) }}</p>
<div>
<button
@click="openMetatadaSortingWarningDialog({ offerCheckbox: false })"
class="button">
{{ $i18n.get('label_view_more') }}
</button>
<button
@click="hasAnOpenAlert = false"
class="button icon">
<i class="tainacan-icon tainacan-icon-close"/>
</button>
</div>
</div>
<!-- Admin View Modes-->
<items-list
v-if="!isOnTheme &&
@ -883,7 +905,8 @@
sortingMetadata: [],
isFilterModalActive: false,
collection: undefined,
hasAnOpenModal: false
hasAnOpenModal: false,
hasAnOpenAlert: true
}
},
props: {
@ -1084,7 +1107,7 @@
},
onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum);
this.showItemsHiddingDueSorting();
this.showItemsHiddingDueSortingDialog();
},
onChangeOrder() {
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
@ -1398,14 +1421,18 @@
})
}
},
showItemsHiddingDueSorting() {
showItemsHiddingDueSortingDialog() {
if (this.isSortingByCustomMetadata &&
this.$userPrefs.get('neverShowItemsHiddenDueSortingDialog') != true) {
this.hasAnOpenModal = true;
this.$modal.open({
this.openMetatadaSortingWarningDialog({ offerCheckbox: true });
}
},
openMetatadaSortingWarningDialog({ offerCheckbox }) {
this.$modal.open({
parent: this,
component: CustomDialog,
props: {
@ -1416,11 +1443,10 @@
this.hasAnOpenModal = false;
},
hideCancel: true,
showNeverShowAgainOption: tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
showNeverShowAgainOption: offerCheckbox && tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
}
});
}
},
adjustSearchControlHeight: _.debounce( function() {
this.$nextTick(() => {
@ -1532,7 +1558,7 @@
}
}
this.showItemsHiddingDueSorting();
this.showItemsHiddingDueSortingDialog();
// Watches window resize to adjust filter's top position and compression on mobile
this.adjustSearchControlHeight();
@ -1912,6 +1938,38 @@
}
}
.metadata-alert {
display: flex;
justify-content: space-between;
align-items: center;
margin: 6px $page-side-padding;
border-radius: 3px;
padding: 4px 12px;
color: $yellow2;
background: $yellow1;
animation-name: appear;
animation-duration: 0.5s;
p {
margin: 0 auto;
}
&>div {
display: flex;
.button,
.button:hover,
.button:active,
.button:focus {
background: none;
color:$yellow2;
font-weight: bold;
border: none;
cursor: pointer;
}
}
}
.items-list-area {
margin-left: 0;
height: 100%;

View File

@ -1,7 +1,7 @@
.notices {
z-index: 99999999;
.toast {
.toast, .snackbar {
font-size: 0.75rem;
border-radius: 8px;
box-shadow: none;

View File

@ -625,6 +625,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'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' => __('When ordering by metadata value, items that have no value for the chosen metadata will not be listed. This list may have less elements than the total existing for current search criteria.', 'tainacan'),
'info_sorting_by_metadata_value_%s' => __('Showing only items that have value for metadata %s.'),
// Tainacan Metadatum Types
'tainacan-text' => __( 'Text', 'tainacan' ),