Passes currentCollectionId properly to facets requests. #368.

This commit is contained in:
Mateus Machado Luna 2020-03-09 15:03:01 -03:00
parent 083e52cc81
commit 4739f69a63
4 changed files with 44 additions and 18 deletions

View File

@ -39,8 +39,9 @@
:is-using-elastic-search="isUsingElasticSearch"
:is-repository-level="isRepositoryLevel"
:is-loading-items.sync="isLoadingItems"
:current-collection-id="$eventBusSearch.collectionId"
@input="onInput"
@sendValuesToTags="onSendValuesToTags"/>
@sendValuesToTags="onSendValuesToTags" />
</div>
</b-collapse>
</b-field>

View File

@ -53,7 +53,11 @@
import { filterTypeMixin } from '../../../js/filter-types-mixin';
export default {
mixins: [ filterTypeMixin ],
mixins: [ filterTypeMixin ],
props: {
isRepositoryLevel: Boolean,
currentCollectionId: String
},
data(){
return {
isLoadingOptions: true,
@ -129,10 +133,14 @@
let route = '';
if (this.collectionId == 'default')
if (this.isRepositoryLevel)
route = `/facets/${this.metadatumId}?getSelected=1&order=asc&parent=0&number=${this.filter.max_options}&` + qs.stringify(query_items);
else
route = `/collection/${this.collectionId}/facets/${this.metadatumId}?getSelected=1&order=asc&parent=0&number=${this.filter.max_options}&` + qs.stringify(query_items);
else {
if (this.collectionId == 'default' && this.currentCollectionId)
route = `/collection/${this.currentCollectionId}/facets/${this.metadatumId}?getSelected=1&order=asc&parent=0&number=${this.filter.max_options}&` + qs.stringify(query_items);
else
route = `/collection/${this.collectionId}/facets/${this.metadatumId}?getSelected=1&order=asc&parent=0&number=${this.filter.max_options}&` + qs.stringify(query_items);
}
this.options = [];

View File

@ -112,7 +112,16 @@
'number': 12
};
let endpoint = this.isRepositoryLevel ? '/facets/' + this.metadatumId : '/collection/'+ this.collectionId +'/facets/' + this.metadatumId;
let endpoint = '';
if (this.isRepositoryLevel)
endpoint += '/facets/' + this.metadatumId;
else {
if (this.collectionId == 'default' && this.currentCollection)
endpoint += '/collection/' + this.currentCollectionId +'/facets/' + this.metadatumId;
else
endpoint += '/collection/' + this.collectionId +'/facets/' + this.metadatumId;
}
endpoint += '?order=asc&' + qs.stringify(query_items);

View File

@ -17,7 +17,8 @@ export const filterTypeMixin = {
query: Object,
isRepositoryLevel: Boolean,
isUsingElasticSearch: Boolean,
isLoadingItems: Boolean
isLoadingItems: Boolean,
currentCollectionId: Boolean
},
created() {
this.collectionId = this.filter.collection_id ? this.filter.collection_id : this.collectionId;
@ -67,11 +68,15 @@ export const dynamicFilterTypeMixin = {
let query_items = { 'current_query': currentQuery };
let url = '';
if (isRepositoryLevel || this.filter.collection_id == 'default')
if (isRepositoryLevel)
url = `/facets/${metadatumId}?getSelected=${getSelected}&`;
else
url = `/collection/${this.filter.collection_id}/facets/${metadatumId}?getSelected=${getSelected}&`;
else {
if (this.filter.collection_id == 'default' && this.currentCollectionId)
url = `/collection/${this.currentCollectionId}/facets/${metadatumId}?getSelected=${getSelected}&`;
else
url = `/collection/${this.filter.collection_id}/facets/${metadatumId}?getSelected=${getSelected}&`;
}
if (offset != undefined && number != undefined) {
if (!this.isUsingElasticSearch)
@ -145,12 +150,16 @@ export const dynamicFilterTypeMixin = {
let query_items = { 'current_query': currentQuery };
let url = '';
if (isRepositoryLevel || this.filter.collection_id == 'default')
url = '/facets/' + this.filter.metadatum.metadatum_id + `?getSelected=${getSelected}&`;
else
url = '/collection/' + this.filter.collection_id + '/facets/' + this.filter.metadatum.metadatum_id + `?getSelected=${getSelected}&`;
if (isRepositoryLevel)
url = `/facets/${this.filter.metadatum.metadatum_id}?getSelected=${getSelected}&`;
else {
if (this.filter.collection_id == 'default' && this.currentCollectionId)
url = `/collection/${this.currentCollectionId}/facets/${this.filter.metadatum.metadatum_id}?getSelected=${getSelected}&`;
else
url = `/collection/${this.filter.collection_id}/facets/${this.filter.metadatum.metadatum_id}?getSelected=${getSelected}&`;
}
if (offset != undefined && number != undefined)
url += `offset=${offset}&number=${number}`;
else
@ -314,7 +323,6 @@ export const dynamicFilterTypeMixin = {
}
}
}
console.log(this.shouldAddOptions)
if (this.shouldAddOptions === true && this.searchResults && this.searchResults.length)
this.searchResults = this.searchResults.concat(sResults);