From 605ce1a8b5b5fda623d57a69b4b7774d16db04f9 Mon Sep 17 00:00:00 2001 From: Johan Frick Date: Fri, 8 Mar 2024 22:30:19 +0100 Subject: [PATCH] feature: allow to skip apply button in grouping --- README.md | 3 +++ src/editor/advanced-editor.ts | 4 ++++ src/sections/grouping.ts | 11 +++++++++-- src/types.ts | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 221e2cbd..8a18ec06 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,9 @@ numberOfFavoritesToShow: 10 # Use this to limit the amount of favorites to show hideBrowseMediaButton: true # default is false. Hides the button to open the media browser. replaceHttpWithHttpsForThumbnails: true # default is false. Use this if you want to replace http with https for thumbnails. mediaBrowserTitle: My favorites # default is 'All favorites'. Use this to change the title for the media browser/favorites section. + +# volumes specific +skipApplyButtonWhenGrouping: true # default is false. Will skip the apply button when grouping. ``` ## Using individual section cards diff --git a/src/editor/advanced-editor.ts b/src/editor/advanced-editor.ts index c9177c70..164d4c24 100644 --- a/src/editor/advanced-editor.ts +++ b/src/editor/advanced-editor.ts @@ -52,6 +52,10 @@ export const ADVANCED_SCHEMA = [ name: 'adjustVolumeRelativeToMainPlayer', selector: { boolean: {} }, }, + { + name: 'skipApplyButtonWhenGrouping', + selector: { boolean: {} }, + }, { type: 'string', help: 'Override default fallback artwork image if artwork is missing for the currently selected media', diff --git a/src/sections/grouping.ts b/src/sections/grouping.ts index f5082b44..00fe8369 100755 --- a/src/sections/grouping.ts +++ b/src/sections/grouping.ts @@ -27,6 +27,10 @@ export class Grouping extends LitElement { this.notJoinedPlayers = this.getNotJoinedPlayers(); this.joinedPlayers = this.getJoinedPlayers(); + if (this.store.config.skipApplyButtonWhenGrouping && this.modifiedItems.length > 0) { + this.applyGrouping(); + } + return html`
@@ -57,7 +61,10 @@ export class Grouping extends LitElement { `; })}
- + Apply Cancel @@ -253,7 +260,7 @@ export class Grouping extends LitElement { } private selectPredefinedGroup(predefinedGroup: PredefinedGroup) { - this.groupingItems.forEach((item) => { + this.groupingItems.forEach(async (item) => { const inPG = predefinedGroup.entities.some((pgp) => pgp.player.id === item.player.id); if ((inPG && !item.isSelected) || (!inPG && item.isSelected)) { this.toggleItemWithoutDisabledCheck(item); diff --git a/src/types.ts b/src/types.ts index d5207764..b13f3ed7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,6 +54,7 @@ export interface CardConfig extends LovelaceCardConfig { volumeStepSize?: number; mediaBrowserTitle?: string; adjustVolumeRelativeToMainPlayer?: boolean; + skipApplyButtonWhenGrouping?: boolean; } export interface MediaArtworkOverride {