diff --git a/app/src/components/WeatherFindLocation.vue b/app/src/components/WeatherFindLocation.vue index ab40c82..b360b10 100644 --- a/app/src/components/WeatherFindLocation.vue +++ b/app/src/components/WeatherFindLocation.vue @@ -4,7 +4,7 @@ :disabled="!api" :items="entries" :loading="isLoading" - :search-input.sync="search" + :search-input.sync="searchInput" no-filter _hide-no-data item-text="name" @@ -12,6 +12,8 @@ label="Location" placeholder="Start typing to Search" prepend-icon="$place" + return-object + clearable > - {{ item.name }}, {{ item.sys.country }} + {{ item.label }} - {{ item.weather[0].description }} + {{ item.weather.description }} - {{ item.main.temp }}°С + {{ item.temp }}°С - {{ item.name }}, {{ item.sys.country }} + {{ item.label }} @@ -60,6 +62,10 @@ type: String, required: true, }, + search: { + type: String, + required: false, + }, lang: { type: String, required: true, @@ -74,13 +80,16 @@ entries: [], isLoading: false, model: null, - search: null, + searchInput: null, }), watch: { - model (val) { - this.$emit('update:location', val) + model (item) { + if (item) { + this.$emit('update:location', item.id) + this.$emit('update:search', item.label) + } }, - search (val) { + searchInput (val) { if (!val || val.length < 3) { return } @@ -103,19 +112,31 @@ axios.get(url) .then(res => { - this.entries = res.data.list + const entries = [] + + res.data.list.forEach((item) => { + entries.push({ + id: item.id, + label: item.name + ', ' + item.sys.country, + temp: item.main.temp, + country: item.sys.country, + weather: { + icon: item.weather[0].icon, + description: item.weather[0].description, + }, + }) + }) + + this.entries = entries this.isLoading = false }) }, }, created () { - // TODO + // create entry for the current item this.entries = [{ - name: 'Freilassing', - sys: { - country: 'DE', - }, id: this.location, + label: this.search, }] this.model = this.location }, diff --git a/app/src/views/Weather.vue b/app/src/views/Weather.vue index 2aa3a54..ba54b9a 100644 --- a/app/src/views/Weather.vue +++ b/app/src/views/Weather.vue @@ -1,75 +1,73 @@ - - - - Weather settings - + + + Weather settings + - - - - - $launch - - - + + + + + $launch + + + - + - - - + + + - - - - Restore - - - - - $done - - Save - - - - + + + + Restore + + + + + $done + + Save + + +