Verified Commit 5caf4ecc authored by Agate's avatar Agate 💬

Fixed #45: search template when querying import sources

parent f8505336
Pipeline #279 passed with stage
in 29 seconds
......@@ -5,6 +5,8 @@ Changelog
0.2.5 (unreleased)
------------------
- Import: can now specify search template when querying import sources (#45)
0.2.4 (2017-12-14)
------------------
......
......@@ -12,6 +12,10 @@
<label>{{ t }}</label>
</div>
</div>
<div class="field">
<label>Query template</label>
<input v-model="customQueryTemplate" />
</div>
</div>
</form>
<template
......@@ -22,6 +26,7 @@
:backends="backends"
:defaultEnabled="false"
:default-backend-id="defaultBackendId"
:query-template="customQueryTemplate"
@import-data-changed="recordReleaseData"
@enabled="recordReleaseEnabled"
></release-import>
......
......@@ -13,10 +13,12 @@ export default {
metadata: {type: Object, required: true},
defaultEnabled: {type: Boolean, default: true},
backends: {type: Array},
defaultBackendId: {type: String}
defaultBackendId: {type: String},
queryTemplate: {type: String, default: '$artist $title'}
},
data () {
return {
customQueryTemplate: this.queryTemplate,
currentBackendId: this.defaultBackendId,
isImporting: false,
enabled: this.defaultEnabled
......@@ -56,6 +58,9 @@ export default {
return this.backends.filter(b => {
return b.id === self.currentBackendId
})[0]
},
realQueryTemplate () {
}
},
watch: {
......@@ -70,6 +75,14 @@ export default {
},
enabled (newValue) {
this.$emit('enabled', this.importData, newValue)
},
queryTemplate (newValue, oldValue) {
// we inherit from the prop template unless the component changed
// the value
if (oldValue === this.customQueryTemplate) {
// no changed from prop, we keep the sync
this.customQueryTemplate = newValue
}
}
}
}
......
......@@ -20,6 +20,7 @@
:release-metadata="metadata"
:backends="backends"
:default-backend-id="defaultBackendId"
:query-template="customQueryTemplate"
@import-data-changed="recordTrackData"
@enabled="recordTrackEnabled"
></track-import>
......
......@@ -92,13 +92,7 @@ export default Vue.extend({
releaseMetadata: {type: Object, required: true}
},
data () {
let queryParts = [
this.releaseMetadata['artist-credit'][0]['artist']['name'],
this.releaseMetadata['title'],
this.metadata['recording']['title']
]
return {
query: queryParts.join(' '),
isLoading: false,
results: [],
currentResultIndex: 0,
......@@ -151,6 +145,18 @@ export default Vue.extend({
mbid: this.metadata.recording.id,
source: this.importedUrl
}
},
query () {
let queryMapping = [
['artist', this.releaseMetadata['artist-credit'][0]['artist']['name']],
['album', this.releaseMetadata['title']],
['title', this.metadata['recording']['title']]
]
let query = this.customQueryTemplate
queryMapping.forEach(e => {
query = query.split('$' + e[0]).join(e[1])
})
return query
}
},
watch: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment