mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Only allow spacing card in sections
This commit is contained in:
parent
b9efdfa10e
commit
311143d6a1
@ -43,6 +43,8 @@ export class HuiCardPicker extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public suggestedCards?: string[];
|
@property({ attribute: false }) public suggestedCards?: string[];
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: false }) public isSectionsView = false;
|
||||||
|
|
||||||
@storage({
|
@storage({
|
||||||
key: "dashboardCardClipboard",
|
key: "dashboardCardClipboard",
|
||||||
state: true,
|
state: true,
|
||||||
@ -263,7 +265,11 @@ export class HuiCardPicker extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _loadCards() {
|
private _loadCards() {
|
||||||
let cards: Card[] = coreCards.map((card: Card) => ({
|
let cards: Card[] = coreCards
|
||||||
|
.filter((card: Card) =>
|
||||||
|
this.isSectionsView ? true : !card.sectionsViewOnly
|
||||||
|
)
|
||||||
|
.map((card: Card) => ({
|
||||||
name: this.hass!.localize(
|
name: this.hass!.localize(
|
||||||
`ui.panel.lovelace.editor.card.${card.type}.name`
|
`ui.panel.lovelace.editor.card.${card.type}.name`
|
||||||
),
|
),
|
||||||
|
@ -146,6 +146,10 @@ export class HuiCreateDialogCard
|
|||||||
.lovelace=${this._params.lovelaceConfig}
|
.lovelace=${this._params.lovelaceConfig}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@config-changed=${this._handleCardPicked}
|
@config-changed=${this._handleCardPicked}
|
||||||
|
.isSectionsView=${this._isSectionsView(
|
||||||
|
this._params.lovelaceConfig,
|
||||||
|
this._params.path
|
||||||
|
)}
|
||||||
></hui-card-picker>
|
></hui-card-picker>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
@ -232,6 +236,15 @@ export class HuiCreateDialogCard
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _isSectionsView = memoize((lovelaceConfig, containerPath) => {
|
||||||
|
const { viewIndex } = parseLovelaceContainerPath(containerPath);
|
||||||
|
// sections is default when undefined
|
||||||
|
return (
|
||||||
|
!lovelaceConfig.views[viewIndex].type ||
|
||||||
|
lovelaceConfig.views[viewIndex].type === "sections"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
private _handleCardPicked(ev) {
|
private _handleCardPicked(ev) {
|
||||||
const config = ev.detail.config;
|
const config = ev.detail.config;
|
||||||
if (this._params!.entities && this._params!.entities.length) {
|
if (this._params!.entities && this._params!.entities.length) {
|
||||||
|
@ -131,6 +131,6 @@ export const coreCards: Card[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "spacing",
|
type: "spacing",
|
||||||
showElement: false,
|
sectionsViewOnly: true
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -66,6 +66,7 @@ export interface Card {
|
|||||||
showElement?: boolean;
|
showElement?: boolean;
|
||||||
isCustom?: boolean;
|
isCustom?: boolean;
|
||||||
isSuggested?: boolean;
|
isSuggested?: boolean;
|
||||||
|
sectionsViewOnly?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Badge {
|
export interface Badge {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user