SEVERAL metadata request cancels on component destroy. #296
This commit is contained in:
parent
77a48d126a
commit
fa0fb4857b
|
@ -232,22 +232,36 @@
|
|||
}
|
||||
},
|
||||
mounted(){
|
||||
this.$root.$on('metadatumUpdated', (isRepositoryLevel) => {
|
||||
if(isRepositoryLevel) {
|
||||
this.metadataIsLoading = true;
|
||||
this.$root.$on('metadatumUpdated', (isRepositoryLevel) => {
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.isRepositoryLevel ? false : this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false,
|
||||
includeDisabled: false,
|
||||
isAdvancedSearch: true
|
||||
}).then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
if (isRepositoryLevel) {
|
||||
this.metadataIsLoading = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.isRepositoryLevel ? false : this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false,
|
||||
includeDisabled: false,
|
||||
isAdvancedSearch: true
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
}).catch(() => {
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.metadataIsLoading = false);
|
||||
}
|
||||
});
|
||||
},
|
||||
created(){
|
||||
|
||||
|
@ -259,10 +273,19 @@
|
|||
isContextEdit: false,
|
||||
includeDisabled: false,
|
||||
isAdvancedSearch: true
|
||||
}).then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
}).catch(() => {
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.metadataIsLoading = false);
|
||||
|
||||
if ((this.$route.query.metaquery && Object.keys(this.$route.query.metaquery).length > 0) ||
|
||||
(this.$route.query.taxquery && Object.keys(this.$route.query.taxquery).length > 0) ){
|
||||
|
@ -343,6 +366,7 @@
|
|||
},
|
||||
metadataIsLoading: false,
|
||||
metadata: [],
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -557,6 +581,11 @@
|
|||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('metadatumUpdated');
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -320,20 +320,30 @@
|
|||
collectionID: Number,
|
||||
},
|
||||
created(){
|
||||
if(!this.collectionID){
|
||||
// is repository level
|
||||
|
||||
} else {
|
||||
if (this.collectionID){
|
||||
this.metadataIsLoading = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionID,
|
||||
isRepositoryLevel: false,
|
||||
isContextEdit: true,
|
||||
includeDisabled: false,
|
||||
}).then(() => {
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
includeDisabled: false
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.metadataIsLoading = false;
|
||||
}).catch(() => {
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.metadataIsLoading = false);
|
||||
}
|
||||
|
||||
this.createEditGroup({
|
||||
|
@ -378,6 +388,7 @@
|
|||
groupID: null,
|
||||
dones: [false],
|
||||
metadataIsLoading: false,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -552,6 +563,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -598,9 +598,6 @@ export default {
|
|||
'fetchUsers',
|
||||
'fetchCollectionsForParent'
|
||||
]),
|
||||
...mapActions('metadata', [
|
||||
'fetchMetadata'
|
||||
]),
|
||||
updateSlug: _.debounce(function() {
|
||||
if(!this.form.name || this.form.name.length <= 0){
|
||||
return;
|
||||
|
@ -957,7 +954,7 @@ export default {
|
|||
|
||||
@import "../../scss/_variables.scss";
|
||||
|
||||
@media screen and (max-width: 1024px) {
|
||||
@media screen and (min-width: 1024px) {
|
||||
.column:last-of-type {
|
||||
padding-left: $page-side-padding !important;
|
||||
}
|
||||
|
|
|
@ -207,7 +207,8 @@ export default {
|
|||
isEditingMetadatum: false,
|
||||
metadatum: {},
|
||||
editedMetadatum: {},
|
||||
backgroundProcess: undefined
|
||||
backgroundProcess: undefined,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
@ -275,22 +276,37 @@ export default {
|
|||
loadMetadata() {
|
||||
// Generates options for metadata listing
|
||||
this.isFetchingCollectionMetadata = true;
|
||||
this.fetchMetadata({collectionId: this.collectionId, isRepositoryLevel: false, isContextEdit: false })
|
||||
.then((metadata) => {
|
||||
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
|
||||
this.fetchMappingImporter({ collection: this.collectionId, sessionId: this.sessionId })
|
||||
.then(res => {
|
||||
if( res ) {
|
||||
this.mappedCollection['mapping'] = res;
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
});
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: false,
|
||||
isContextEdit: false
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then((metadata) => {
|
||||
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
|
||||
this.fetchMappingImporter({ collection: this.collectionId, sessionId: this.sessionId })
|
||||
.then(res => {
|
||||
if( res ) {
|
||||
this.mappedCollection['mapping'] = res;
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isFetchingCollectionMetadata = false);
|
||||
},
|
||||
cancelBack(){
|
||||
this.$router.go(-2);
|
||||
|
@ -433,6 +449,11 @@ export default {
|
|||
|
||||
this.loadImporter();
|
||||
this.loadMetadata();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -334,7 +334,9 @@ export default {
|
|||
availableMetadata: [],
|
||||
filterTypes: [],
|
||||
currentFilterTypePreview: undefined,
|
||||
columnsTopY: 0
|
||||
columnsTopY: 0,
|
||||
filtersSearchCancel: undefined,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -609,7 +611,7 @@ export default {
|
|||
return 190;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
mounted() {
|
||||
|
||||
if (!this.isRepositoryLevel)
|
||||
this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('filter') }]);
|
||||
|
@ -624,7 +626,6 @@ export default {
|
|||
else
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
|
||||
this.isLoadingMetadatumTypes = true;
|
||||
this.isLoadingFilters = true;
|
||||
this.isLoadingFilterTypes = true;
|
||||
|
||||
|
@ -637,24 +638,57 @@ export default {
|
|||
this.isLoadingFilterTypes = false;
|
||||
});
|
||||
|
||||
this.fetchFilters({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: true, includeDisabled: true })
|
||||
.then(() => {
|
||||
this.isLoadingFilters = false;
|
||||
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
||||
this.fetchMetadata({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: true })
|
||||
.then(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
this.updateListOfMetadata();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingFilters = false;
|
||||
});
|
||||
// Cancels previous Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
this.fetchFilters({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: !this.isOnTheme,
|
||||
includeDisabled: true,
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
|
||||
this.isLoadingMetadatumTypes = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: true
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
this.updateListOfMetadata();
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
});
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingMetadatumTypes = false);
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.filtersSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// On repository level we also fetch collection filters
|
||||
if (this.isRepositoryLevel) {
|
||||
this.fetchRepositoryCollectionFilters()
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
}
|
||||
|
||||
|
||||
// Obtains collection name
|
||||
if (!this.isRepositoryLevel) {
|
||||
this.fetchCollectionName(this.collectionId).then((collectionName) => {
|
||||
|
@ -666,6 +700,15 @@ export default {
|
|||
this.onCancelFilterTypeSelection();
|
||||
}
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
// Cancels previous filters Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Cancels previous metadata Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -461,7 +461,8 @@ export default {
|
|||
new_metadata_label: '',
|
||||
new_metadata_uri: '',
|
||||
new_metadata_slug: '',
|
||||
columnsTopY: 0
|
||||
columnsTopY: 0,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
@ -618,8 +619,11 @@ export default {
|
|||
.then(() => {
|
||||
if (!this.isRepositoryLevel)
|
||||
this.updateMetadataOrder();
|
||||
else
|
||||
this.$root.$emit('metadatumUpdated', this.isRepositoryLevel);
|
||||
})
|
||||
.catch(() => {
|
||||
this.$console.log("Error deleting metadatum.")
|
||||
});
|
||||
},
|
||||
}
|
||||
|
@ -846,26 +850,43 @@ export default {
|
|||
return true;
|
||||
},
|
||||
refreshMetadata() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.isRepositoryLevel = this.$route.name == 'MetadataPage' ? true : false;
|
||||
|
||||
if (this.isRepositoryLevel)
|
||||
this.collectionId = 'default';
|
||||
else
|
||||
this.collectionId = this.$route.params.collectionId;
|
||||
|
||||
this.fetchMetadata({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: true, includeDisabled: true})
|
||||
.then(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
|
||||
// Checks URL as router watcher would not wait for list to load
|
||||
if (this.$route.query.edit != undefined) {
|
||||
let existingMetadataIndex = this.activeMetadatumList.findIndex((metadatum) => metadatum.id == this.$route.query.edit);
|
||||
if (existingMetadataIndex >= 0)
|
||||
this.editMetadatum(this.activeMetadatumList[existingMetadataIndex]);
|
||||
}
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: true,
|
||||
includeDisabled: true
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
|
||||
// Checks URL as router watcher would not wait for list to load
|
||||
if (this.$route.query.edit != undefined) {
|
||||
let existingMetadataIndex = this.activeMetadatumList.findIndex((metadatum) => metadatum.id == this.$route.query.edit);
|
||||
if (existingMetadataIndex >= 0)
|
||||
this.editMetadatum(this.activeMetadatumList[existingMetadataIndex]);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
});
|
||||
.catch(() => this.isLoadingMetadata = false);
|
||||
},
|
||||
getPreviewTemplateContent(metadatum) {
|
||||
return `<div class="metadata-type-preview tainacan-form">
|
||||
|
@ -919,6 +940,13 @@ export default {
|
|||
this.collectionName = collectionName;
|
||||
});
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -915,7 +915,9 @@
|
|||
isFilterModalActive: false,
|
||||
collection: undefined,
|
||||
hasAnOpenModal: false,
|
||||
hasAnOpenAlert: true
|
||||
hasAnOpenAlert: true,
|
||||
filtersSearchCancel: undefined,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -1189,6 +1191,10 @@
|
|||
},
|
||||
prepareFilters() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
this.isLoadingFilters = true;
|
||||
|
||||
this.fetchFilters({
|
||||
|
@ -1197,7 +1203,14 @@
|
|||
isContextEdit: !this.isOnTheme,
|
||||
includeDisabled: 'no',
|
||||
})
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.then((resp) => {
|
||||
resp.request
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.filtersSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// On repository level we also fetch collection filters
|
||||
|
@ -1209,6 +1222,10 @@
|
|||
},
|
||||
prepareMetadata() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.$eventBusSearch.cleanFetchOnly();
|
||||
this.isLoadingMetadata = true;
|
||||
|
||||
|
@ -1219,212 +1236,219 @@
|
|||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false
|
||||
})
|
||||
.then(() => {
|
||||
this.sortingMetadata = [];
|
||||
.then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.sortingMetadata = [];
|
||||
|
||||
// Decides if custom meta will be loaded with item.
|
||||
let shouldLoadMeta = true;
|
||||
|
||||
if (this.isOnTheme)
|
||||
shouldLoadMeta = this.registeredViewModes[this.viewMode].dynamic_metadata;
|
||||
else
|
||||
shouldLoadMeta = this.adminViewMode == 'table' || this.adminViewMode == 'records' || this.adminViewMode == undefined;
|
||||
|
||||
if (shouldLoadMeta) {
|
||||
|
||||
// Loads user prefs object as we'll need to check if there's something configured by user
|
||||
let prefsFetchOnly = !this.isRepositoryLevel ? `fetch_only_${this.collectionId}` : 'fetch_only';
|
||||
let prefsFetchOnlyMeta = !this.isRepositoryLevel ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
|
||||
// Decides if custom meta will be loaded with item.
|
||||
let shouldLoadMeta = true;
|
||||
|
||||
if (this.isOnTheme)
|
||||
shouldLoadMeta = this.registeredViewModes[this.viewMode].dynamic_metadata;
|
||||
else
|
||||
shouldLoadMeta = this.adminViewMode == 'table' || this.adminViewMode == 'records' || this.adminViewMode == undefined;
|
||||
|
||||
if (shouldLoadMeta) {
|
||||
|
||||
// Loads user prefs object as we'll need to check if there's something configured by user
|
||||
let prefsFetchOnly = !this.isRepositoryLevel ? `fetch_only_${this.collectionId}` : 'fetch_only';
|
||||
let prefsFetchOnlyMeta = !this.isRepositoryLevel ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
|
||||
|
||||
let prefsFetchOnlyObject = this.$userPrefs.get(prefsFetchOnly) ? typeof this.$userPrefs.get(prefsFetchOnly) != 'string' ? this.$userPrefs.get(prefsFetchOnly) : this.$userPrefs.get(prefsFetchOnly).replace(/,null/g, '').split(',') : [];
|
||||
let prefsFetchOnlyMetaObject = this.$userPrefs.get(prefsFetchOnlyMeta) ? this.$userPrefs.get(prefsFetchOnlyMeta).split(',') : [];
|
||||
|
||||
let thumbnailMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[0] != null) : true;
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_thumbnail'),
|
||||
metadatum: 'row_thumbnail',
|
||||
metadata_type: undefined,
|
||||
slug: 'thumbnail',
|
||||
id: undefined,
|
||||
display: thumbnailMetadatumDisplay
|
||||
});
|
||||
|
||||
// Repository Level always shows core metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_description'),
|
||||
metadatum: 'row_description',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'description'},
|
||||
metadata_type: undefined,
|
||||
slug: 'description',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never') {
|
||||
|
||||
let display;
|
||||
|
||||
// Deciding display based on collection settings
|
||||
if (metadatum.display == 'no')
|
||||
display = false;
|
||||
else if (metadatum.display == 'yes')
|
||||
display = true;
|
||||
|
||||
// Deciding display based on user prefs
|
||||
if (prefsFetchOnlyMetaObject.length) {
|
||||
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
|
||||
|
||||
display = index >= 0;
|
||||
}
|
||||
let prefsFetchOnlyObject = this.$userPrefs.get(prefsFetchOnly) ? typeof this.$userPrefs.get(prefsFetchOnly) != 'string' ? this.$userPrefs.get(prefsFetchOnly) : this.$userPrefs.get(prefsFetchOnly).replace(/,null/g, '').split(',') : [];
|
||||
let prefsFetchOnlyMetaObject = this.$userPrefs.get(prefsFetchOnlyMeta) ? this.$userPrefs.get(prefsFetchOnlyMeta).split(',') : [];
|
||||
|
||||
let thumbnailMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[0] != null) : true;
|
||||
|
||||
metadata.push({
|
||||
name: metadatum.name,
|
||||
metadatum: metadatum.description,
|
||||
slug: metadatum.slug,
|
||||
metadata_type: metadatum.metadata_type,
|
||||
metadata_type_object: metadatum.metadata_type_object,
|
||||
metadata_type_options: metadatum.metadata_type_options,
|
||||
id: metadatum.id,
|
||||
display: display,
|
||||
collection_id: metadatum.collection_id,
|
||||
multiple: metadatum.multiple,
|
||||
name: this.$i18n.get('label_thumbnail'),
|
||||
metadatum: 'row_thumbnail',
|
||||
metadata_type: undefined,
|
||||
slug: 'thumbnail',
|
||||
id: undefined,
|
||||
display: thumbnailMetadatumDisplay
|
||||
});
|
||||
if (display) {
|
||||
fetchOnlyMetadatumIds.push(metadatum.id);
|
||||
|
||||
// Repository Level always shows core metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_description'),
|
||||
metadatum: 'row_description',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'description'},
|
||||
metadata_type: undefined,
|
||||
slug: 'description',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never') {
|
||||
|
||||
let display;
|
||||
|
||||
// Deciding display based on collection settings
|
||||
if (metadatum.display == 'no')
|
||||
display = false;
|
||||
else if (metadatum.display == 'yes')
|
||||
display = true;
|
||||
|
||||
// Deciding display based on user prefs
|
||||
if (prefsFetchOnlyMetaObject.length) {
|
||||
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
|
||||
|
||||
display = index >= 0;
|
||||
}
|
||||
|
||||
metadata.push({
|
||||
name: metadatum.name,
|
||||
metadatum: metadatum.description,
|
||||
slug: metadatum.slug,
|
||||
metadata_type: metadatum.metadata_type,
|
||||
metadata_type_object: metadatum.metadata_type_object,
|
||||
metadata_type_options: metadatum.metadata_type_options,
|
||||
id: metadatum.id,
|
||||
display: display,
|
||||
collection_id: metadatum.collection_id,
|
||||
multiple: metadatum.multiple,
|
||||
});
|
||||
if (display) {
|
||||
fetchOnlyMetadatumIds.push(metadatum.id);
|
||||
}
|
||||
|
||||
if (
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship'
|
||||
) {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != null) : true;
|
||||
let authorNameMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[2] != null) : true;
|
||||
|
||||
// Creation date and author name should appear only on admin.
|
||||
if (!this.isOnTheme) {
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship'
|
||||
) {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
this.$eventBusSearch.addFetchOnly(
|
||||
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
|
||||
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
|
||||
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
|
||||
(this.isRepositoryLevel ? 'title' : null) +','+
|
||||
(this.isRepositoryLevel ? 'description' : null)
|
||||
, false, fetchOnlyMetadatumIds.toString());
|
||||
|
||||
// Sorting metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
if (authorNameMetadatumDisplay) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != null) : true;
|
||||
let authorNameMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[2] != null) : true;
|
||||
|
||||
// Creation date and author name should appear only on admin.
|
||||
if (!this.isOnTheme) {
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
// Loads only basic attributes necessary to view modes that do not allow custom meta
|
||||
} else {
|
||||
|
||||
this.$eventBusSearch.addFetchOnly(
|
||||
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
|
||||
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
|
||||
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
|
||||
(this.isRepositoryLevel ? 'title' : null) +','+
|
||||
(this.isRepositoryLevel ? 'description' : null)
|
||||
, false, fetchOnlyMetadatumIds.toString());
|
||||
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
|
||||
|
||||
// Sorting metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
if (authorNameMetadatumDisplay) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
// 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, '');
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: true
|
||||
})
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
}
|
||||
}
|
||||
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: true
|
||||
this.isLoadingMetadata = false;
|
||||
this.displayedMetadata = metadata;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
this.isLoadingMetadata = false;
|
||||
this.displayedMetadata = metadata;
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
});
|
||||
.catch(() => this.isLoadingMetadata = false);
|
||||
},
|
||||
updateCollectionInfo () {
|
||||
if (this.collectionId) {
|
||||
|
@ -1579,8 +1603,16 @@
|
|||
},
|
||||
beforeDestroy() {
|
||||
this.removeEventListeners();
|
||||
|
||||
// Cancels previous Request
|
||||
|
||||
// Cancels previous Metadata Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Cancels previous Filters Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
// Cancels previous Items Request
|
||||
if (this.$eventBusSearch.searchCancel != undefined)
|
||||
this.$eventBusSearch.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
|
|
|
@ -890,7 +890,9 @@
|
|||
isFilterModalActive: false,
|
||||
customFilters: [],
|
||||
hasAnOpenModal: false,
|
||||
hasAnOpenAlert: true
|
||||
hasAnOpenAlert: true,
|
||||
filtersSearchCancel: undefined,
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -1133,6 +1135,10 @@
|
|||
},
|
||||
prepareFilters() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
this.isLoadingFilters = true;
|
||||
|
||||
// Normal filter loading, only collection ones
|
||||
|
@ -1143,7 +1149,14 @@
|
|||
isContextEdit: !this.isOnTheme,
|
||||
includeDisabled: 'no',
|
||||
})
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.then((resp) => {
|
||||
resp.request
|
||||
.then(() => this.isLoadingFilters = false)
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.filtersSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.isLoadingFilters = false);
|
||||
|
||||
// Custom filter loading, get's from collections that have items with that taxonomy
|
||||
|
@ -1155,6 +1168,10 @@
|
|||
}
|
||||
},
|
||||
prepareMetadata() {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.$eventBusSearch.cleanFetchOnly();
|
||||
this.isLoadingMetadata = true;
|
||||
|
@ -1165,213 +1182,218 @@
|
|||
collectionId: this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false
|
||||
})
|
||||
.then(() => {
|
||||
this.sortingMetadata = [];
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then(() => {
|
||||
this.sortingMetadata = [];
|
||||
|
||||
// Decides if custom meta will be loaded with item.
|
||||
let shouldLoadMeta = true;
|
||||
|
||||
if (this.isOnTheme)
|
||||
shouldLoadMeta = this.registeredViewModes[this.viewMode].dynamic_metadata;
|
||||
else
|
||||
shouldLoadMeta = this.adminViewMode == 'table' || this.adminViewMode == 'records' || this.adminViewMode == undefined;
|
||||
|
||||
if (shouldLoadMeta) {
|
||||
// Loads user prefs object as we'll need to check if there's something configured by user
|
||||
let prefsFetchOnly = !this.isRepositoryLevel ? `fetch_only_${this.collectionId}` : 'fetch_only';
|
||||
let prefsFetchOnlyMeta = !this.isRepositoryLevel ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
|
||||
// Decides if custom meta will be loaded with item.
|
||||
let shouldLoadMeta = true;
|
||||
|
||||
if (this.isOnTheme)
|
||||
shouldLoadMeta = this.registeredViewModes[this.viewMode].dynamic_metadata;
|
||||
else
|
||||
shouldLoadMeta = this.adminViewMode == 'table' || this.adminViewMode == 'records' || this.adminViewMode == undefined;
|
||||
|
||||
if (shouldLoadMeta) {
|
||||
// Loads user prefs object as we'll need to check if there's something configured by user
|
||||
let prefsFetchOnly = !this.isRepositoryLevel ? `fetch_only_${this.collectionId}` : 'fetch_only';
|
||||
let prefsFetchOnlyMeta = !this.isRepositoryLevel ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
|
||||
|
||||
let prefsFetchOnlyObject = this.$userPrefs.get(prefsFetchOnly) ? typeof this.$userPrefs.get(prefsFetchOnly) != 'string' ? this.$userPrefs.get(prefsFetchOnly) : this.$userPrefs.get(prefsFetchOnly).replace(/,null/g, '').split(',') : [];
|
||||
let prefsFetchOnlyMetaObject = this.$userPrefs.get(prefsFetchOnlyMeta) ? this.$userPrefs.get(prefsFetchOnlyMeta).split(',') : [];
|
||||
let prefsFetchOnlyObject = this.$userPrefs.get(prefsFetchOnly) ? typeof this.$userPrefs.get(prefsFetchOnly) != 'string' ? this.$userPrefs.get(prefsFetchOnly) : this.$userPrefs.get(prefsFetchOnly).replace(/,null/g, '').split(',') : [];
|
||||
let prefsFetchOnlyMetaObject = this.$userPrefs.get(prefsFetchOnlyMeta) ? this.$userPrefs.get(prefsFetchOnlyMeta).split(',') : [];
|
||||
|
||||
let thumbnailMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[0] != null) : true;
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_thumbnail'),
|
||||
metadatum: 'row_thumbnail',
|
||||
metadata_type: undefined,
|
||||
slug: 'thumbnail',
|
||||
id: undefined,
|
||||
display: thumbnailMetadatumDisplay
|
||||
});
|
||||
|
||||
// Repository Level always shows core metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_description'),
|
||||
metadatum: 'row_description',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'description'},
|
||||
metadata_type: undefined,
|
||||
slug: 'description',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never') {
|
||||
|
||||
let display;
|
||||
|
||||
// Deciding display based on collection settings
|
||||
if (metadatum.display == 'no')
|
||||
display = false;
|
||||
else if (metadatum.display == 'yes')
|
||||
display = true;
|
||||
|
||||
// Deciding display based on user prefs
|
||||
if (prefsFetchOnlyMetaObject.length) {
|
||||
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
|
||||
|
||||
display = index >= 0;
|
||||
}
|
||||
let thumbnailMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[0] != null) : true;
|
||||
|
||||
metadata.push({
|
||||
name: metadatum.name,
|
||||
metadatum: metadatum.description,
|
||||
slug: metadatum.slug,
|
||||
metadata_type: metadatum.metadata_type,
|
||||
metadata_type_object: metadatum.metadata_type_object,
|
||||
metadata_type_options: metadatum.metadata_type_options,
|
||||
id: metadatum.id,
|
||||
display: display,
|
||||
collection_id: metadatum.collection_id,
|
||||
multiple: metadatum.multiple,
|
||||
name: this.$i18n.get('label_thumbnail'),
|
||||
metadatum: 'row_thumbnail',
|
||||
metadata_type: undefined,
|
||||
slug: 'thumbnail',
|
||||
id: undefined,
|
||||
display: thumbnailMetadatumDisplay
|
||||
});
|
||||
|
||||
if (display) {
|
||||
fetchOnlyMetadatumIds.push(metadatum.id);
|
||||
// Repository Level always shows core metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_description'),
|
||||
metadatum: 'row_description',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'description'},
|
||||
metadata_type: undefined,
|
||||
slug: 'description',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship'
|
||||
) {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never') {
|
||||
|
||||
let display;
|
||||
|
||||
// Deciding display based on collection settings
|
||||
if (metadatum.display == 'no')
|
||||
display = false;
|
||||
else if (metadatum.display == 'yes')
|
||||
display = true;
|
||||
|
||||
// Deciding display based on user prefs
|
||||
if (prefsFetchOnlyMetaObject.length) {
|
||||
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
|
||||
|
||||
display = index >= 0;
|
||||
}
|
||||
|
||||
metadata.push({
|
||||
name: metadatum.name,
|
||||
metadatum: metadatum.description,
|
||||
slug: metadatum.slug,
|
||||
metadata_type: metadatum.metadata_type,
|
||||
metadata_type_object: metadatum.metadata_type_object,
|
||||
metadata_type_options: metadatum.metadata_type_options,
|
||||
id: metadatum.id,
|
||||
display: display,
|
||||
collection_id: metadatum.collection_id,
|
||||
multiple: metadatum.multiple,
|
||||
});
|
||||
|
||||
if (display) {
|
||||
fetchOnlyMetadatumIds.push(metadatum.id);
|
||||
}
|
||||
|
||||
if (
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship'
|
||||
) {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != null) : true;
|
||||
let authorNameMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[2] != null) : true;
|
||||
|
||||
// Creation date and author name should appear only on admin.
|
||||
if (!this.isOnTheme) {
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
this.$eventBusSearch.addFetchOnly(
|
||||
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
|
||||
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
|
||||
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
|
||||
(this.isRepositoryLevel ? 'title' : null) +','+
|
||||
(this.isRepositoryLevel ? 'description' : null)
|
||||
, false, fetchOnlyMetadatumIds.toString());
|
||||
|
||||
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != null) : true;
|
||||
let authorNameMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[2] != null) : true;
|
||||
|
||||
// Creation date and author name should appear only on admin.
|
||||
if (!this.isOnTheme) {
|
||||
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
|
||||
this.$eventBusSearch.addFetchOnly(
|
||||
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
|
||||
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
|
||||
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
|
||||
(this.isRepositoryLevel ? 'title' : null) +','+
|
||||
(this.isRepositoryLevel ? 'description' : null)
|
||||
, false, fetchOnlyMetadatumIds.toString());
|
||||
|
||||
// Sorting metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
if (authorNameMetadatumDisplay) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
// 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, '');
|
||||
// Sorting metadata
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: creationDateMetadatumDisplay
|
||||
});
|
||||
if (authorNameMetadatumDisplay) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_created_by'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type: undefined,
|
||||
slug: 'author_name',
|
||||
id: undefined,
|
||||
display: authorNameMetadatumDisplay
|
||||
});
|
||||
}
|
||||
// Loads only basic attributes necessary to view modes that do not allow custom meta
|
||||
} else {
|
||||
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
this.$eventBusSearch.addFetchOnly('thumbnail,creation_date,author_name,title,description', true, '');
|
||||
|
||||
if (this.isRepositoryLevel) {
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_title'),
|
||||
metadatum: 'row_title',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'title'},
|
||||
metadata_type: undefined,
|
||||
slug: 'title',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
for (let metadatum of this.metadata) {
|
||||
if (metadatum.display !== 'never' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
|
||||
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship') {
|
||||
this.sortingMetadata.push(metadatum);
|
||||
}
|
||||
}
|
||||
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: true
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.sortingMetadata.push({
|
||||
name: this.$i18n.get('label_creation_date'),
|
||||
metadatum: 'row_creation',
|
||||
metadata_type: undefined,
|
||||
slug: 'creation_date',
|
||||
id: undefined,
|
||||
display: true
|
||||
this.isLoadingMetadata = false;
|
||||
this.displayedMetadata = metadata;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
this.isLoadingMetadata = false;
|
||||
this.displayedMetadata = metadata;
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
})
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
});
|
||||
.catch(() => this.isLoadingMetadata = false);
|
||||
},
|
||||
showItemsHiddingDueSortingDialog() {
|
||||
|
||||
|
@ -1521,8 +1543,16 @@
|
|||
},
|
||||
beforeDestroy() {
|
||||
this.removeEventListeners();
|
||||
|
||||
// Cancels previous Request
|
||||
|
||||
// Cancels previous Metadata Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
// Cancels previous Filters Request
|
||||
if (this.filtersSearchCancel != undefined)
|
||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
// Cancels previous Items Request
|
||||
if (this.$eventBusSearch.searchCancel != undefined)
|
||||
this.$eventBusSearch.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
|
||||
promise.request.catch( error => {
|
||||
if (isCancel(error))
|
||||
this.$console.log('Request canceled: ', error.message);
|
||||
this.$console.log('Request canceled: ' + error.message);
|
||||
else
|
||||
this.$console.error( error );
|
||||
});
|
||||
|
|
|
@ -137,10 +137,10 @@
|
|||
.then(() => {
|
||||
this.selectedValues();
|
||||
})
|
||||
.catch( error => {
|
||||
if (isCancel(error))
|
||||
this.$console.log('Request canceled: ', error.message);
|
||||
else
|
||||
.catch( (error) => {
|
||||
if (isCancel(error)) {
|
||||
this.$console.log('Request canceled: ' + error.message);
|
||||
}else
|
||||
this.$console.error( error );
|
||||
});
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
})
|
||||
.catch( error => {
|
||||
if (isCancel(error))
|
||||
this.$console.log('Request canceled: ', error.message);
|
||||
this.$console.log('Request canceled: ' + error.message);
|
||||
else
|
||||
this.$console.error( error );
|
||||
});
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
promise.request
|
||||
.catch( error => {
|
||||
if (isCancel(error))
|
||||
this.$console.log('Request canceled: ', error.message);
|
||||
this.$console.log('Request canceled: ' + error.message);
|
||||
else
|
||||
this.$console.error( error );
|
||||
});
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
})
|
||||
.catch( error => {
|
||||
if (isCancel(error)) {
|
||||
this.$console.log('Request canceled: ', error.message);
|
||||
this.$console.log('Request canceled: ' + error.message);
|
||||
} else {
|
||||
this.$console.log('Error on facets request: ', error);
|
||||
this.isLoading = false;
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
fetchMetadataFromCollection( value ){
|
||||
fetchMetadataFromCollection(value) {
|
||||
this.loadingMetadata = true;
|
||||
this.hasMetadata = false;
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
.catch((thrown) => {
|
||||
if (axios.isCancel(thrown)) {
|
||||
console.log('Request canceled: ', thrown.message);
|
||||
} else {
|
||||
} else {
|
||||
reject(thrown);
|
||||
}
|
||||
}
|
||||
});
|
||||
}),
|
||||
source: source
|
||||
|
|
|
@ -3,39 +3,48 @@ import qs from 'qs';
|
|||
|
||||
// FILTERS --------------------------------------------------------
|
||||
export const fetchFilters = ({ commit }, { collectionId, isRepositoryLevel, isContextEdit, includeDisabled, customFilters }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const source = axios.CancelToken.source();
|
||||
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/filters/';
|
||||
else
|
||||
endpoint = '/filters/';
|
||||
return new Object({
|
||||
request: new Promise((resolve, reject) => {
|
||||
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/filters/';
|
||||
else
|
||||
endpoint = '/filters/';
|
||||
|
||||
endpoint += '?nopaging=1';
|
||||
endpoint += '?nopaging=1';
|
||||
|
||||
if (isContextEdit) {
|
||||
endpoint += '&context=edit';
|
||||
}
|
||||
if (isContextEdit) {
|
||||
endpoint += '&context=edit';
|
||||
}
|
||||
|
||||
if (includeDisabled){
|
||||
endpoint += '&include_disabled=' + includeDisabled;
|
||||
}
|
||||
if (includeDisabled){
|
||||
endpoint += '&include_disabled=' + includeDisabled;
|
||||
}
|
||||
|
||||
if (customFilters != undefined && customFilters.length > 0) {
|
||||
let postin = { 'postin': customFilters };
|
||||
endpoint += '&' + qs.stringify(postin);
|
||||
}
|
||||
if (customFilters != undefined && customFilters.length > 0) {
|
||||
let postin = { 'postin': customFilters };
|
||||
endpoint += '&' + qs.stringify(postin);
|
||||
}
|
||||
|
||||
axios.tainacan.get(endpoint)
|
||||
.then((res) => {
|
||||
let filters= res.data;
|
||||
commit('setFilters', filters);
|
||||
resolve (filters);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
});
|
||||
axios.tainacan.get(endpoint, { cancelToken: source.token })
|
||||
.then((res) => {
|
||||
let filters= res.data;
|
||||
commit('setFilters', filters);
|
||||
resolve (filters);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (axios.isCancel(error)) {
|
||||
console.log('Request canceled: ', error.message);
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}),
|
||||
source: source
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -2,31 +2,40 @@ import axios from '../../../axios/axios';
|
|||
|
||||
export const fetchMetadata = ({commit}, {collectionId, isRepositoryLevel, isContextEdit, includeDisabled, isAdvancedSearch}) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/metadata/';
|
||||
else
|
||||
endpoint = '/metadata/';
|
||||
const source = axios.CancelToken.source();
|
||||
|
||||
endpoint += '?nopaging=1';
|
||||
|
||||
if (isContextEdit)
|
||||
endpoint += '&context=edit';
|
||||
return new Object({
|
||||
request: new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
if (!isRepositoryLevel)
|
||||
endpoint = '/collection/' + collectionId + '/metadata/';
|
||||
else
|
||||
endpoint = '/metadata/';
|
||||
|
||||
if (includeDisabled)
|
||||
endpoint += '&include_disabled=' + includeDisabled;
|
||||
endpoint += '?nopaging=1';
|
||||
|
||||
if (isContextEdit)
|
||||
endpoint += '&context=edit';
|
||||
|
||||
axios.tainacan.get(endpoint)
|
||||
.then((res) => {
|
||||
let metadata = res.data;
|
||||
if (!isAdvancedSearch)
|
||||
commit('setMetadata', metadata);
|
||||
resolve(metadata);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
if (includeDisabled)
|
||||
endpoint += '&include_disabled=' + includeDisabled;
|
||||
|
||||
axios.tainacan.get(endpoint, { cancelToken: source.token })
|
||||
.then((res) => {
|
||||
let metadata = res.data;
|
||||
if (!isAdvancedSearch)
|
||||
commit('setMetadata', metadata);
|
||||
resolve(metadata);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (axios.isCancel(error)) {
|
||||
console.log('Request canceled: ', error.message);
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}),
|
||||
source: source
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue