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-row>
<v-divider></v-divider> <v-divider></v-divider>
<v-card-actions> <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-actions>
</v-card> </v-card>
<v-skeleton-loader type="card" v-else></v-skeleton-loader> <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"); return moment.unix(dt).format("HH:mm");
} }
private deleteCity() {
this.$emit('delete');
}
private data() { private data() {
return { return {
data: undefined, data: undefined,

View File

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