Add select all / deselect all button to favorites (#1501)

This commit is contained in:
Willem König
2025-11-26 16:37:55 +01:00
committed by GitHub
parent 20162264ed
commit a14ec9407a
4 changed files with 83 additions and 0 deletions
+27
View File
@@ -194,6 +194,13 @@
</div>
<div class="favorites-content__edit-actions">
<div v-if="friendEditMode && !isSearchActive" class="favorites-content__actions">
<el-button size="small" @click="toggleSelectAllFriends">
{{
isAllFriendsSelected
? t('view.favorite.deselect_all')
: t('view.favorite.select_all')
}}
</el-button>
<el-button size="small" :disabled="!hasFriendSelection" @click="clearSelectedFriends">
{{ t('view.favorite.clear') }}
</el-button>
@@ -426,6 +433,15 @@
return groupedByGroupKeyFavoriteFriends.value[activeRemoteGroup.value.key] || [];
});
const isAllFriendsSelected = computed(() => {
if (!activeRemoteGroup.value || !currentFriendFavorites.value.length) {
return false;
}
return currentFriendFavorites.value
.map((fav) => fav.id)
.every((id) => selectedFavoriteFriends.value.includes(id));
});
watch(
() => favoriteFriendGroups.value.map((group) => `${group.key}:${group.count}`),
() => {
@@ -548,6 +564,17 @@
selectedFavoriteFriends.value = [];
}
function toggleSelectAllFriends() {
if (!activeRemoteGroup.value) {
return;
}
if (isAllFriendsSelected.value) {
selectedFavoriteFriends.value = [];
} else {
selectedFavoriteFriends.value = currentFriendFavorites.value.map((fav) => fav.id);
}
}
function copySelectedFriends() {
if (!selectedFavoriteFriends.value.length) {
return;