Updates to filters getting information from metadat_type_object.

This commit is contained in:
Mateus Machado Luna 2019-10-16 11:23:56 -03:00
parent ef8ceeffce
commit 6531b3cdf7
4 changed files with 56 additions and 31 deletions

View File

@ -49,7 +49,8 @@
return {
selected:'',
options: [],
label: ''
label: '',
relatedCollectionId: ''
}
},
watch: {
@ -57,6 +58,15 @@
this.updateSelectedValues();
},
},
created() {
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' &&
this.filter.metadatum &&
this.filter.metadatum.metadata_type_object &&
this.filter.metadatum.metadata_type_object.options &&
this.filter.metadatum.metadata_type_object.options.collection_id) {
this.relatedCollectionId = this.filter.metadatum.metadata_type_object.options.collection_id;
}
},
mounted() {
this.updateSelectedValues();
},
@ -122,7 +132,12 @@
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship') {
axios.get('/items/' + metadata.value + '?fetch_only=title,thumbnail')
let endpoint = '/items/' + metadata.value + '?fetch_only=title,thumbnail';
if (this.relatedCollectionId != '')
endpoint = '/collection/' + this.relatedCollectionId + endpoint;
axios.get(endpoint)
.then( res => {
let item = res.data;
this.label = item.title;

View File

@ -54,7 +54,8 @@
return {
results:'',
selected:[],
options: []
options: [],
relatedCollectionId: ''
}
},
watch: {
@ -62,6 +63,15 @@
this.updateSelectedValues();
}
},
created() {
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' &&
this.filter.metadatum &&
this.filter.metadatum.metadata_type_object &&
this.filter.metadatum.metadata_type_object.options &&
this.filter.metadatum.metadata_type_object.options.collection_id) {
this.relatedCollectionId = this.filter.metadatum.metadata_type_object.options.collection_id;
}
},
mounted() {
this.updateSelectedValues();
},
@ -106,8 +116,12 @@
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' ) {
let query = qs.stringify({ postin: metadata.value, fetch_only: 'title,thumbnail', fetch_only_meta: '' });
axios.get('/items?' + query)
let endpoint = '/items/' + metadata.value;
if (this.relatedCollectionId != '')
endpoint = '/collection/' + this.relatedCollectionId + endpoint;
axios.get(endpoint + query)
.then( res => {
if (res.data.items) {
this.selected = [];

View File

@ -60,7 +60,7 @@
options: [],
selected: [],
taxonomy: '',
taxonomy_id: Number
taxonomyId: ''
}
},
watch: {
@ -80,6 +80,16 @@
this.loadOptions();
}
},
created() {
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' &&
this.filter.metadatum &&
this.filter.metadatum.metadata_type_object &&
this.filter.metadatum.metadata_type_object.options &&
this.filter.metadatum.metadata_type_object.options.taxonomy_id) {
this.taxonomyId = this.filter.metadatum.metadata_type_object.options.taxonomy_id;
this.taxonomy = 'tnc_tax_' + this.taxonomyId;
}
},
mounted(){
this.loadOptions();
},
@ -239,7 +249,7 @@
props: {
parent: parent,
filter: this.filter,
taxonomy_id: this.taxonomy_id,
taxonomy_id: this.taxonomyId,
selected: this.selected,
metadatumId: this.metadatumId,
taxonomy: this.taxonomy,
@ -258,11 +268,6 @@
},
prepareOptionsForTaxonomy(items) {
if (items[0] != undefined) {
this.taxonomy = items[0].taxonomy;
this.taxonomy_id = items[0].taxonomy_id;
}
this.options = [];
this.options = items.slice(); // copy array.

View File

@ -43,24 +43,19 @@
export default {
mixins: [ filterTypeMixin, dynamicFilterTypeMixin ],
created(){
let endpoint = '/collection/' + this.collectionId + '/metadata/' + this.metadatumId;
if (this.isRepositoryLevel || this.collectionId == 'default'){
endpoint = '/metadata/' + this.metadatumId;
}
axios.get(endpoint)
.then( res => {
let metadatum = res.data;
this.taxonomyId = metadatum.metadata_type_options.taxonomy_id
this.updateSelectedValues();
});
created() {
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' &&
this.filter.metadatum &&
this.filter.metadatum.metadata_type_object &&
this.filter.metadatum.metadata_type_object.options &&
this.filter.metadatum.metadata_type_object.options.taxonomy_id) {
this.taxonomyId = this.filter.metadatum.metadata_type_object.options.taxonomy_id;
this.taxonomy = 'tnc_tax_' + this.taxonomyId;
}
},
watch: {
'query.taxquery'() {
if (this.taxonomyId != '')
this.updateSelectedValues();
this.updateSelectedValues();
}
},
data(){
@ -92,8 +87,6 @@
return axios.get(endpoint).then( res => {
for (let term of res.data.values) {
this.taxonomy = term.taxonomy;
if (valuesToIgnore != undefined && valuesToIgnore.length > 0) {
let indexToIgnore = valuesToIgnore.findIndex(value => value == term.value);
@ -127,8 +120,6 @@
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
return false;
this.taxonomy = 'tnc_tax_' + this.taxonomyId;
let index = this.query.taxquery.findIndex(newMetadatum => newMetadatum.taxonomy == this.taxonomy);
if ( index >= 0){