More-info service
This commit is contained in:
@@ -36,7 +36,7 @@ import "./popup-card";
|
||||
- Commands
|
||||
x popup
|
||||
x close_popup
|
||||
- more-info
|
||||
x more-info
|
||||
x navigate
|
||||
- lovelace-reload?
|
||||
x window-reload
|
||||
|
||||
@@ -52,7 +52,10 @@ class PopupCard extends LitElement {
|
||||
}
|
||||
|
||||
popup(ev: CustomEvent) {
|
||||
if (ev.detail?.entityId === this._config.entity) {
|
||||
if (
|
||||
ev.detail?.entityId === this._config.entity &&
|
||||
!ev.detail?.ignore_popup_card
|
||||
) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
const config = { ...this._config };
|
||||
@@ -69,7 +72,7 @@ class PopupCard extends LitElement {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
cancelable: false,
|
||||
detail: { entityID: "." },
|
||||
detail: { entityId: "." },
|
||||
})
|
||||
),
|
||||
50
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LitElement, html, css } from "lit";
|
||||
import { property } from "lit/decorators.js";
|
||||
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
||||
import { provideHass, loadLoadCardHelpers } from "../helpers";
|
||||
import { provideHass, loadLoadCardHelpers, hass_base_el } from "../helpers";
|
||||
|
||||
class BrowserModPopup extends LitElement {
|
||||
@property() open;
|
||||
@@ -309,6 +309,26 @@ export const PopupMixin = (SuperClass) => {
|
||||
|
||||
closePopup(...args) {
|
||||
this._popupEl.closeDialog();
|
||||
this.showMoreInfo("");
|
||||
}
|
||||
|
||||
async showMoreInfo(entityId, large = false, ignore_popup_card = undefined) {
|
||||
const base = await hass_base_el();
|
||||
base.dispatchEvent(
|
||||
new CustomEvent("hass-more-info", {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
cancelable: false,
|
||||
detail: { entityId, ignore_popup_card },
|
||||
})
|
||||
);
|
||||
if (large) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
const dialog: any = base.shadowRoot.querySelector(
|
||||
"ha-more-info-dialog"
|
||||
);
|
||||
if (dialog) dialog.large = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -32,6 +32,13 @@ export const ServicesMixin = (SuperClass) => {
|
||||
[timeout: <number>]
|
||||
[timeout_action: <service call>]
|
||||
|
||||
More-info:
|
||||
service: browser_mod.more_info
|
||||
data:
|
||||
entity: <string>
|
||||
[large: <true/FALSE>]
|
||||
[ignore_popup_card: <true/FALSE>]
|
||||
|
||||
Close popup:
|
||||
service: browser_mod.close_popup
|
||||
|
||||
@@ -60,6 +67,7 @@ export const ServicesMixin = (SuperClass) => {
|
||||
"sequence",
|
||||
"delay",
|
||||
"popup",
|
||||
"more_info",
|
||||
"close_popup",
|
||||
"navigate",
|
||||
"refresh",
|
||||
@@ -101,6 +109,11 @@ export const ServicesMixin = (SuperClass) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, data.time));
|
||||
break;
|
||||
|
||||
case "more_info":
|
||||
const { entity, large, ignore_popup_card } = data;
|
||||
this.showMoreInfo(entity, large, ignore_popup_card);
|
||||
break;
|
||||
|
||||
case "popup":
|
||||
const { title, content, ...d } = data;
|
||||
for (const [k, v] of Object.entries(d)) {
|
||||
|
||||
Reference in New Issue
Block a user