Added city deletion

This commit is contained in:
Kamil Klecha
2021-10-19 22:21:56 +02:00
parent 2bef009d9d
commit 5d28c17f7e
2 changed files with 18 additions and 2 deletions

View File

@@ -54,7 +54,14 @@
</v-row>
<v-divider></v-divider>
<v-card-actions>
<v-btn block class="primary" @click="details = true">Pokaż szczegóły</v-btn>
<v-row>
<v-col cols="6">
<v-btn block class="primary" @click="details = true">Szczegóły</v-btn>
</v-col>
<v-col cols="6">
<v-btn block class="error" @click="deleteCity()">Usuń</v-btn>
</v-col>
</v-row>
</v-card-actions>
</v-card>
<v-skeleton-loader type="card" v-else></v-skeleton-loader>
@@ -104,6 +111,10 @@ export default class City extends Vue {
return moment.unix(dt).format("HH:mm");
}
private deleteCity() {
this.$emit('delete');
}
private data() {
return {
data: undefined,

View File

@@ -4,7 +4,7 @@
<v-card-title>Prognoza pogody</v-card-title>
<v-row justify="space-around">
<v-col v-for="(city, i) in cities" :key="i">
<City :city="city" />
<City :city="city" @delete="deleteCity(city)" />
</v-col>
<v-col>
<v-hover v-slot="{ hover }">
@@ -70,6 +70,11 @@ export default class Forecast extends Vue {
this.saveUser();
}
deleteCity(city: object) {
this.$data.cities.splice(this.$data.cities.indexOf(city));
this.saveUser();
}
private async getFirebaseUserData() {
const q = query(this.users, where("uid", "==", this.user.uid));