Fixes not removing of displayed metadata

This commit is contained in:
weryques 2018-12-13 12:19:24 -02:00
parent 968ffcbdb8
commit 48905e13db
6 changed files with 21 additions and 42 deletions

View File

@ -138,7 +138,9 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
},
set(key, value) {
this.tainacanPrefs[key] = value;
let data = {'meta': {'tainacan_prefs': JSON.stringify(this.tainacanPrefs)} };
return new Promise(( resolve, reject ) => {
wpApi.post('/users/me/', qs.stringify(data))
.then( res => {

View File

@ -967,10 +967,7 @@
creationDateMetadatum != undefined && creationDateMetadatum.display ? 'creation_date' : null +','+
authorNameMetadatum != undefined && authorNameMetadatum.display ? 'author_name': null +','+
(this.isRepositoryLevel ? 'title' : null) +','+
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null)
);
this.$eventBusSearch.addFetchOnlyMeta(fetchOnlyMetadatumIds.toString());
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null), false, fetchOnlyMetadatumIds.toString());
// Closes dropdown
this.$refs.displayedMetadataDropdown.toggle();
@ -1121,10 +1118,8 @@
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
(this.isRepositoryLevel ? 'title' : null) +','+
(this.isRepositoryLevel ? 'description' : null)
);
, false, fetchOnlyMetadatumIds.toString());
this.$eventBusSearch.addFetchOnlyMeta(fetchOnlyMetadatumIds.toString());
// Sorting metadata
if (this.isRepositoryLevel) {
this.sortingMetadata.push({
@ -1158,9 +1153,8 @@
// Loads only basic attributes necessary to view modes that do not allow custom meta
} else {
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true);
this.$eventBusSearch.addFetchOnlyMeta('');
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',

View File

@ -919,9 +919,7 @@
authorNameMetadatum != undefined && authorNameMetadatum.display ? 'author_name': null +','+
(this.isRepositoryLevel ? 'title' : null) +','+
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null)
);
this.$eventBusSearch.addFetchOnlyMeta(fetchOnlyMetadatumIds.toString());
, false, fetchOnlyMetadatumIds.toString());
// Closes dropdown
this.$refs.displayedMetadataDropdown.toggle();
@ -1080,9 +1078,7 @@
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
(this.isRepositoryLevel ? 'title' : null) +','+
(this.isRepositoryLevel ? 'description' : null)
);
this.$eventBusSearch.addFetchOnlyMeta(fetchOnlyMetadatumIds.toString());
, false, fetchOnlyMetadatumIds.toString());
// Sorting metadata
if (this.isRepositoryLevel) {
@ -1117,9 +1113,8 @@
// Loads only basic attributes necessay to view modes that do not allow custom meta
} else {
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true);
this.$eventBusSearch.addFetchOnlyMeta('');
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
this.sortingMetadata.push({
name: this.$i18n.get('label_title'),
metadatum: 'row_title',

View File

@ -157,7 +157,9 @@ export default {
} else {
this.$store.dispatch('search/set_postquery', this.$route.query);
}
console.log(to);
if (to.fullPath != from.fullPath) {
this.loadItems(to);
}
@ -188,17 +190,15 @@ export default {
this.$store.dispatch('search/add_taxquery', data );
}
},
addFetchOnlyMeta( metadatum ){
this.$store.dispatch('search/add_fetchonly_meta', metadatum );
this.updateURLQueries();
},
addFetchOnly( metadatum, ignorePrefs ){
addFetchOnly( metadatum, ignorePrefs, metadatumIDs ){
this.$store.dispatch('search/add_fetchonly', metadatum );
this.$store.dispatch('search/add_fetchonly_meta', metadatumIDs);
this.updateURLQueries();
if (!ignorePrefs) {
let prefsFetchOnly = this.collectionId != undefined ? 'fetch_only_' + this.collectionId : 'fetch_only';
if (JSON.stringify(this.$userPrefs.get(prefsFetchOnly)) != JSON.stringify(metadatum)) {
if (this.$userPrefs.get(prefsFetchOnly) != metadatum) {
this.$userPrefs.set(prefsFetchOnly, metadatum)
.catch(() => { this.$console.log("Error setting user prefs for fetch_only"); });
}

View File

@ -52,6 +52,8 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
dispatch('search/add_fetchonly_meta', null, { root: true });
}
console.info('Post', postQueries.fetch_only_meta);
// Differentiates between repository level and collection level queries
let endpoint = '/collection/'+ collectionId +'/items?';

View File

@ -61,24 +61,10 @@ export const addTaxQuery = ( state, filter ) => {
};
export const addFetchOnly = ( state, metadatum ) => {
state.postquery.fetch_only = ! state.postquery.fetch_only ? 'thumbnail,creation_date,author_name' : state.postquery.fetch_only;
state.postquery.fetch_only += `,${metadatum.replace(/,null/g, '')}` ;
state.postquery.fetch_only = Array.from(new Set(state.postquery.fetch_only.split(','))).toString()
state.postquery.fetch_only = metadatum.replace(/,null/g, '');
};
export const addFetchOnlyMeta = ( state, metadatum ) => {
state.postquery.fetch_only_meta = ( ! state.postquery.fetch_only_meta ) ? '' : state.postquery.fetch_only_meta;
if (metadatum) {
if (!state.postquery.fetch_only_meta) {
state.postquery.fetch_only_meta = `${metadatum}`;
} else {
state.postquery.fetch_only_meta += `,${metadatum}`;
}
state.postquery.fetch_only_meta = Array.from(new Set(state.postquery.fetch_only_meta.split(','))).toString()
}
state.postquery.fetch_only_meta = metadatum;
};
export const removeFetchOnly = ( state, metadatum ) => {