Skip to content

Commit

Permalink
delete a weather favorite when its icon is clicked
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Nov 26, 2020
1 parent bb7e1bd commit c72d753
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/weather_status/js/weather-status.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/weather_status/js/weather-status.js.map

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions apps/weather_status/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ActionButton v-for="f in displayedFavorites"
:key="f"
icon="icon-starred"
@click="onFavoriteClick(f)">
@click="onFavoriteClick($event, f)">
{{ f }}
</ActionButton>
</Actions>
Expand Down Expand Up @@ -439,8 +439,16 @@ export default {
}
network.saveFavorites(this.favorites)
},
onFavoriteClick(favAddress) {
if (favAddress !== this.address) {
onFavoriteClick(e, favAddress) {
// clicked on the icon
if (e.target.classList.contains('action-button__icon')) {
const i = this.favorites.indexOf(favAddress)
if (i !== -1) {
this.favorites.splice(i, 1)
}
network.saveFavorites(this.favorites)
} else if (favAddress !== this.address) {
// clicked on the text
this.setAddress(favAddress)
}
},
Expand Down

0 comments on commit c72d753

Please sign in to comment.