diff --git a/api.js b/api.js index 8f456acd961c9620aaff950cc1fd81ca87fa2f91..88c2277ec71c06724475462f617dc15492f1dd6c 100755 --- a/api.js +++ b/api.js @@ -43,7 +43,7 @@ function inCacheFormat (docname, docobj) { link: '/letters/' + docname.slice(0, -4), collection: docobj.TEI.teiHeader.fileDesc.titleStmt.collection._text, url: '/api/letters/' + docname.slice(0, -4), - name: docname.replace(/_/g, ' '), + name: docname.replace(/_/g, ' ').slice(0, -4), hash: hash, object: docobj } diff --git a/src/components/Features.vue b/src/components/Features.vue index 3f7698ea7968c12606c34fc1b38220a3ae646047..4417cb07c67dfe2defc02edeaf0b9bb1a1c08f95 100644 --- a/src/components/Features.vue +++ b/src/components/Features.vue @@ -5,16 +5,17 @@ <h3>{{header}}</h3> </v-flex> - <!-- <v-flex xs12> --> - <!-- <v-select --> - <!-- v-bind:items="letters" --> - <!-- v-model="e1" --> - <!-- label="Select" --> - <!-- single-line --> - <!-- bottom --> - <!-- prepend-icon="local_post_office" --> - <!-- ></v-select> --> - <!-- </v-flex> --> + <!-- Select Letter --> + <v-flex xs12> + <v-select + v-bind:items="letters" + v-model="selected" + label="Select" + single-line + bottom + prepend-icon="local_post_office" + ></v-select> + </v-flex> <!-- Input Fields for Search --> <v-flex xs12 md3> @@ -113,7 +114,8 @@ export default { showlabels: true, letters: [ { text: 'All' } - ] + ], + selected: { text: 'All' } } }, methods: { @@ -125,7 +127,15 @@ export default { }, find () { // Call feature search API with parameters - var params = { + this.searching = true + + let url = 'http://localhost:3000/api/features/' + // TODO: this is a bit silly + if (this.selected.text !== 'All') { + url = url + this.selected.text.replace(/ /g, '_') + '/' + } + + let params = { category: this.feature_category, type: this.feature_type, subtype: this.feature_subtype @@ -133,15 +143,14 @@ export default { // Remove undefined values Object.keys(params).forEach((key) => (params[key] == null) && delete params[key]) - this.searching = true - this.$http.get('http://localhost:3000/api/features/', {params: params}).then(function (data) { + this.$http.get(url, {params: params}).then(function (data) { this.results = data.body this.searching = false }) }, validate () { // Validate input fields and call find() - var invalid = this.feature_category.length === 0 && this.feature_type.length === 0 && this.feature_subtype.length === 0 + const invalid = this.feature_category.length === 0 && this.feature_type.length === 0 && this.feature_subtype.length === 0 if (invalid) { this.invalid = true } else { @@ -153,8 +162,8 @@ export default { computed: { countedHits: function () { // Sums up all hits in all letters - var hits = 0 - for (var value of this.results) { + let hits = 0 + for (let value of this.results) { hits = hits + value.count } return hits @@ -163,7 +172,7 @@ export default { created () { // Create list of all letters this.$http.get('http://localhost:3000/api/letters').then(function (data) { - for (var value of data.body) { + for (let value of data.body) { this.letters.push({text: value.name}) } })