Skip to content

Commit

Permalink
Implement hide_all and unhide_all options
Browse files Browse the repository at this point in the history
  • Loading branch information
elchininet committed Jan 10, 2024
1 parent b6c15f1 commit 48342b4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
27 changes: 25 additions & 2 deletions src/custom-more-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ class CustomMoreInfo {
this._anyGlobMatch(entityId, parameter?.by_glob) ||
parameter?.by_device_class?.includes(deviceClass) ||
parameter?.by_domain?.includes(domain) ||
parameter?.by_entity_id?.includes(entityId) ||
parameter?.[ALL_FILTER]
parameter?.by_entity_id?.includes(entityId)
);
}

Expand Down Expand Up @@ -516,6 +515,30 @@ class CustomMoreInfo {
hide.header_history_icon = false;
}

if (
this._anyVisbilityMatch(
this._config?.hide_all,
entityId,
deviceClass,
domain
)
) {
hide.history = true;
hide.logbook = true;
}

if (
this._anyVisbilityMatch(
this._config?.unhide_all,
entityId,
deviceClass,
domain
)
) {
hide.history = false;
hide.logbook = false;
}

this._visibility[entityId] = {
hide_history: hide.history,
hide_logbook: hide.logbook,
Expand Down
6 changes: 3 additions & 3 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ export type AttributeFilters = Record<
export type ElementsVisibility = Record<
ByTypes,
string[]
> & {
all?: boolean;
};
>;

export interface CustomMoreInfoConfig {
debug?: boolean;
filter_all?: boolean;
unfilter_all?: boolean;
filter_attributes?: AttributeFilters;
unfilter_attributes?: AttributeFilters;
hide_all?: ElementsVisibility;
unhide_all?: ElementsVisibility;
hide_history?: ElementsVisibility;
hide_logbook?: ElementsVisibility;
unhide_history?: ElementsVisibility;
Expand Down

0 comments on commit 48342b4

Please sign in to comment.