Skip to content

Commit

Permalink
feature: allow to skip apply button in grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Mar 8, 2024
1 parent cc90acc commit 605ce1a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 9 additions & 2 deletions src/sections/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<div class="wrapper">
<div class="predefined-groups">
Expand Down Expand Up @@ -57,7 +61,10 @@ export class Grouping extends LitElement {
`;
})}
</div>
<ha-control-button-group class="buttons" hide=${this.modifiedItems.length === 0 || nothing}>
<ha-control-button-group
class="buttons"
hide=${this.modifiedItems.length === 0 || this.store.config.skipApplyButtonWhenGrouping || nothing}
>
<ha-control-button class="apply" @click=${this.applyGrouping}> Apply </ha-control-button>
<ha-control-button @click=${this.cancelGrouping}> Cancel </ha-control-button>
</ha-control-button-group>
Expand Down Expand Up @@ -253,7 +260,7 @@ export class Grouping extends LitElement {
}

private selectPredefinedGroup(predefinedGroup: PredefinedGroup<PredefinedGroupPlayer>) {
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);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface CardConfig extends LovelaceCardConfig {
volumeStepSize?: number;
mediaBrowserTitle?: string;
adjustVolumeRelativeToMainPlayer?: boolean;
skipApplyButtonWhenGrouping?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit 605ce1a

Please sign in to comment.