mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-04 20:14:28 +02:00
Fix hiding default domain
this solution works, but it uses another variable. If you have a better idea, please feel free to share
This commit is contained in:
2
dist/mushroom-strategy.js
vendored
2
dist/mushroom-strategy.js
vendored
File diff suppressed because one or more lines are too long
@@ -86,10 +86,12 @@ class MushroomStrategy {
|
|||||||
const exposedDomainIds = Helper.getExposedDomainIds();
|
const exposedDomainIds = Helper.getExposedDomainIds();
|
||||||
const area = info.view.strategy.options.area;
|
const area = info.view.strategy.options.area;
|
||||||
const viewCards = [...(area.extra_cards ?? [])];
|
const viewCards = [...(area.extra_cards ?? [])];
|
||||||
|
let defaultExists = false;
|
||||||
|
|
||||||
// Create cards for each domain.
|
// Create cards for each domain.
|
||||||
for (const domain of exposedDomainIds) {
|
for (const domain of exposedDomainIds) {
|
||||||
if (domain === "default") {
|
if (domain === "default") {
|
||||||
|
defaultExists = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,52 +190,54 @@ class MushroomStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if default is hidden
|
if (defaultExists) {
|
||||||
// Create cards for any other domain.
|
// TODO: Check if default is hidden
|
||||||
// Collect device entities of the current area.
|
// Create cards for any other domain.
|
||||||
const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id)
|
// Collect device entities of the current area.
|
||||||
.map(device => device.id);
|
const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id)
|
||||||
|
.map(device => device.id);
|
||||||
// Collect the remaining entities of which all conditions below are met:
|
|
||||||
// 1. The entity is linked to a device which is linked to the current area,
|
// Collect the remaining entities of which all conditions below are met:
|
||||||
// or the entity itself is linked to the current area.
|
// 1. The entity is linked to a device which is linked to the current area,
|
||||||
// 2. The entity is not hidden and is not disabled.
|
// or the entity itself is linked to the current area.
|
||||||
const miscellaneousEntities = Helper.entities.filter(entity => {
|
// 2. The entity is not hidden and is not disabled.
|
||||||
return (areaDevices.includes(entity.device_id) || entity.area_id === area.area_id)
|
const miscellaneousEntities = Helper.entities.filter(entity => {
|
||||||
&& entity.hidden_by == null
|
return (areaDevices.includes(entity.device_id) || entity.area_id === area.area_id)
|
||||||
&& entity.disabled_by == null
|
&& entity.hidden_by == null
|
||||||
&& !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0]);
|
&& entity.disabled_by == null
|
||||||
});
|
&& !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0]);
|
||||||
|
|
||||||
// Create a column of miscellaneous entity cards.
|
|
||||||
if (miscellaneousEntities.length) {
|
|
||||||
let miscellaneousCards = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
miscellaneousCards = await import("./cards/MiscellaneousCard").then(cardModule => {
|
|
||||||
/** @type Object[] */
|
|
||||||
const miscellaneousCards = [
|
|
||||||
new TitleCard([area], Helper.strategyOptions.domains.default).createCard(),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const entity of miscellaneousEntities) {
|
|
||||||
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
|
|
||||||
|
|
||||||
if (!cardOptions.hidden) {
|
|
||||||
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return miscellaneousCards;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(Helper.debug ? e : "An error occurred while creating the domain cards!");
|
|
||||||
}
|
|
||||||
|
|
||||||
viewCards.push({
|
|
||||||
type: "vertical-stack",
|
|
||||||
cards: miscellaneousCards,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create a column of miscellaneous entity cards.
|
||||||
|
if (miscellaneousEntities.length) {
|
||||||
|
let miscellaneousCards = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
miscellaneousCards = await import("./cards/MiscellaneousCard").then(cardModule => {
|
||||||
|
/** @type Object[] */
|
||||||
|
const miscellaneousCards = [
|
||||||
|
new TitleCard([area], Helper.strategyOptions.domains.default).createCard(),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const entity of miscellaneousEntities) {
|
||||||
|
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
|
||||||
|
|
||||||
|
if (!cardOptions.hidden) {
|
||||||
|
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return miscellaneousCards;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(Helper.debug ? e : "An error occurred while creating the domain cards!");
|
||||||
|
}
|
||||||
|
|
||||||
|
viewCards.push({
|
||||||
|
type: "vertical-stack",
|
||||||
|
cards: miscellaneousCards,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return cards.
|
// Return cards.
|
||||||
|
Reference in New Issue
Block a user