mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
parent
8d0508f320
commit
dbe829bc7d
@ -78,6 +78,11 @@ export class HuiCardOptions extends LitElement {
|
|||||||
"ui.panel.lovelace.editor.edit_card.move"
|
"ui.panel.lovelace.editor.edit_card.move"
|
||||||
)}</paper-item
|
)}</paper-item
|
||||||
>
|
>
|
||||||
|
<paper-item @tap=${this._duplicateCard}
|
||||||
|
>${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.editor.edit_card.duplicate"
|
||||||
|
)}</paper-item
|
||||||
|
>
|
||||||
<paper-item .class="delete-item" @tap="${this._deleteCard}">
|
<paper-item .class="delete-item" @tap="${this._deleteCard}">
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
"ui.panel.lovelace.editor.edit_card.delete"
|
"ui.panel.lovelace.editor.edit_card.delete"
|
||||||
@ -152,6 +157,17 @@ export class HuiCardOptions extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _duplicateCard(): void {
|
||||||
|
const path = this.path!;
|
||||||
|
const cardConfig = this.lovelace!.config.views[path[0]].cards![path[1]];
|
||||||
|
showEditCardDialog(this, {
|
||||||
|
lovelaceConfig: this.lovelace!.config,
|
||||||
|
cardConfig,
|
||||||
|
saveConfig: this.lovelace!.saveConfig,
|
||||||
|
path: [path[0]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private _editCard(): void {
|
private _editCard(): void {
|
||||||
showEditCardDialog(this, {
|
showEditCardDialog(this, {
|
||||||
lovelaceConfig: this.lovelace!.config,
|
lovelaceConfig: this.lovelace!.config,
|
||||||
|
@ -56,7 +56,7 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
const [view, card] = params.path;
|
const [view, card] = params.path;
|
||||||
this._viewConfig = params.lovelaceConfig.views[view];
|
this._viewConfig = params.lovelaceConfig.views[view];
|
||||||
this._cardConfig =
|
this._cardConfig =
|
||||||
card !== undefined ? this._viewConfig.cards![card] : undefined;
|
card !== undefined ? this._viewConfig.cards![card] : params.cardConfig;
|
||||||
if (this._cardConfig && !Object.isFrozen(this._cardConfig)) {
|
if (this._cardConfig && !Object.isFrozen(this._cardConfig)) {
|
||||||
this._cardConfig = deepFreeze(this._cardConfig);
|
this._cardConfig = deepFreeze(this._cardConfig);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { LovelaceConfig } from "../../../../data/lovelace";
|
import { LovelaceConfig, LovelaceCardConfig } from "../../../../data/lovelace";
|
||||||
|
|
||||||
export interface EditCardDialogParams {
|
export interface EditCardDialogParams {
|
||||||
lovelaceConfig: LovelaceConfig;
|
lovelaceConfig: LovelaceConfig;
|
||||||
saveConfig: (config: LovelaceConfig) => void;
|
saveConfig: (config: LovelaceConfig) => void;
|
||||||
path: [number] | [number, number];
|
path: [number] | [number, number];
|
||||||
entities?: string[]; // We can pass entity id's that will be added to the config when a card is picked
|
entities?: string[]; // We can pass entity id's that will be added to the config when a card is picked
|
||||||
|
cardConfig?: LovelaceCardConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
const importEditCardDialog = () =>
|
const importEditCardDialog = () =>
|
||||||
|
@ -1951,6 +1951,7 @@
|
|||||||
"add": "Add Card",
|
"add": "Add Card",
|
||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"delete": "Delete Card",
|
"delete": "Delete Card",
|
||||||
|
"duplicate": "Duplicate Card",
|
||||||
"move": "Move to View",
|
"move": "Move to View",
|
||||||
"options": "More options"
|
"options": "More options"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user