Skip to content

Commit 777fe3b

Browse files
Julien Veyssiernpmbuildbot-nextcloud[bot]
authored andcommitted
delete a weather favorite when its icon is clicked
Signed-off-by: Julien Veyssier <eneiluj@posteo.net> Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
1 parent ce95906 commit 777fe3b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

apps/weather_status/js/weather-status.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/weather_status/js/weather-status.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/weather_status/src/App.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<ActionButton v-for="f in displayedFavorites"
6464
:key="f"
6565
icon="icon-starred"
66-
@click="onFavoriteClick(f)">
66+
@click="onFavoriteClick($event, f)">
6767
{{ f }}
6868
</ActionButton>
6969
</Actions>
@@ -439,8 +439,16 @@ export default {
439439
}
440440
network.saveFavorites(this.favorites)
441441
},
442-
onFavoriteClick(favAddress) {
443-
if (favAddress !== this.address) {
442+
onFavoriteClick(e, favAddress) {
443+
// clicked on the icon
444+
if (e.target.classList.contains('action-button__icon')) {
445+
const i = this.favorites.indexOf(favAddress)
446+
if (i !== -1) {
447+
this.favorites.splice(i, 1)
448+
}
449+
network.saveFavorites(this.favorites)
450+
} else if (favAddress !== this.address) {
451+
// clicked on the text
444452
this.setAddress(favAddress)
445453
}
446454
},

0 commit comments

Comments
 (0)