Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/components/data-table/ha-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export class HaDataTable extends LitElement {

@property({ type: Boolean }) public hasFab = false;

/**
* Add an extra rows at the bottom of the datatabel
* @type {TemplateResult}
*/
@property({ attribute: false }) public appendRow?;

@property({ type: Boolean, attribute: "auto-height" })
public autoHeight = false;

Expand Down Expand Up @@ -126,6 +132,8 @@ export class HaDataTable extends LitElement {

@query("slot[name='header']") private _header!: HTMLSlotElement;

private _items: DataTableRowData[] = [];

private _checkableRowsCount?: number;

private _checkedRows: string[] = [];
Expand Down Expand Up @@ -318,10 +326,13 @@ export class HaDataTable extends LitElement {
@scroll=${this._saveScrollPos}
>
${scroll({
items: !this.hasFab
? this._filteredData
: [...this._filteredData, ...[{ empty: true }]],
items: this._items,
renderItem: (row: DataTableRowData, index) => {
if (row.append) {
return html`
<div class="mdc-data-table__row">${row.content}</div>
`;
}
if (row.empty) {
return html` <div class="mdc-data-table__row"></div> `;
}
Expand Down Expand Up @@ -447,6 +458,20 @@ export class HaDataTable extends LitElement {
if (this.curRequest !== curRequest) {
return;
}

if (this.appendRow || this.hasFab) {
this._items = [...data];

if (this.appendRow) {
this._items.push({ append: true, content: this.appendRow });
}

if (this.hasFab) {
this._items.push({ empty: true });
}
} else {
this._items = data;
}
this._filteredData = data;
}

Expand Down
14 changes: 7 additions & 7 deletions src/dialogs/generic/dialog-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import "../../components/ha-switch";
import { PolymerChangedEvent } from "../../polymer-types";
import { haStyleDialog } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import { DialogParams } from "./show-dialog-box";
import { DialogBoxParams } from "./show-dialog-box";

@customElement("dialog-box")
class DialogBox extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@internalProperty() private _params?: DialogParams;
@internalProperty() private _params?: DialogBoxParams;

@internalProperty() private _value?: string;

public async showDialog(params: DialogParams): Promise<void> {
public async showDialog(params: DialogBoxParams): Promise<void> {
this._params = params;
if (params.prompt) {
this._value = params.defaultValue;
Expand Down Expand Up @@ -55,8 +55,8 @@ class DialogBox extends LitElement {
return html`
<ha-dialog
open
?scrimClickAction=${this._params.prompt}
?escapeKeyAction=${this._params.prompt}
?scrimClickAction=${confirmPrompt}
?escapeKeyAction=${confirmPrompt}
@closed=${this._dialogClosed}
defaultAction="ignore"
.heading=${this._params.title
Expand Down Expand Up @@ -140,10 +140,10 @@ class DialogBox extends LitElement {
}

private _dialogClosed(ev) {
if (ev.detail.action === "ignore") {
if (this._params?.prompt && ev.detail.action === "ignore") {
return;
}
this.closeDialog();
this._dismiss();
}

private _close(): void {
Expand Down
16 changes: 8 additions & 8 deletions src/dialogs/generic/show-dialog-box.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { TemplateResult } from "lit-html";
import { fireEvent } from "../../common/dom/fire_event";

interface BaseDialogParams {
interface BaseDialogBoxParams {
confirmText?: string;
text?: string | TemplateResult;
title?: string;
warning?: boolean;
}

export interface AlertDialogParams extends BaseDialogParams {
export interface AlertDialogParams extends BaseDialogBoxParams {
confirm?: () => void;
}

export interface ConfirmationDialogParams extends BaseDialogParams {
export interface ConfirmationDialogParams extends BaseDialogBoxParams {
dismissText?: string;
confirm?: () => void;
cancel?: () => void;
}

export interface PromptDialogParams extends BaseDialogParams {
export interface PromptDialogParams extends BaseDialogBoxParams {
inputLabel?: string;
inputType?: string;
defaultValue?: string;
confirm?: (out?: string) => void;
}

export interface DialogParams
export interface DialogBoxParams
extends ConfirmationDialogParams,
PromptDialogParams {
confirm?: (out?: string) => void;
Expand All @@ -37,10 +37,10 @@ export const loadGenericDialog = () => import("./dialog-box");

const showDialogHelper = (
element: HTMLElement,
dialogParams: DialogParams,
dialogParams: DialogBoxParams,
extra?: {
confirmation?: DialogParams["confirmation"];
prompt?: DialogParams["prompt"];
confirmation?: DialogBoxParams["confirmation"];
prompt?: DialogBoxParams["prompt"];
}
) =>
new Promise((resolve) => {
Expand Down
7 changes: 7 additions & 0 deletions src/layouts/hass-tabs-subpage-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export class HaTabsSubpageDataTable extends LitElement {
*/
@property({ type: Boolean }) public hasFab = false;

/**
* Add an extra rows at the bottom of the datatabel
* @type {TemplateResult}
*/
@property({ attribute: false }) public appendRow?;

/**
* Field with a unique id per entry in data.
* @type {String}
Expand Down Expand Up @@ -171,6 +177,7 @@ export class HaTabsSubpageDataTable extends LitElement {
.noDataText=${this.noDataText}
.dir=${computeRTLDirection(this.hass)}
.clickable=${this.clickable}
.appendRow=${this.appendRow}
>
${!this.narrow
? html`
Expand Down
11 changes: 10 additions & 1 deletion src/panels/config/blueprint/dialog-import-blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ class DialogImportBlueprint extends LitElement {
<pre>${this._result.raw_data}</pre>
</ha-expansion-panel>`
: html`${this.hass.localize(
"ui.panel.config.blueprint.add.import_introduction"
"ui.panel.config.blueprint.add.import_introduction_link",
"community_link",
html`<a
href="https://www.home-assistant.io/get-blueprints"
target="_blank"
rel="noreferrer noopener"
>${this.hass.localize(
"ui.panel.config.blueprint.add.community_forums"
)}</a
>`
)}<paper-input
id="input"
.label=${this.hass.localize(
Expand Down
17 changes: 17 additions & 0 deletions src/panels/config/blueprint/ha-blueprint-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ class HaBlueprintOverview extends LitElement {
"ui.panel.config.blueprint.overview.no_blueprints"
)}
hasFab
.appendRow=${html` <div
class="mdc-data-table__cell"
style="width: 100%; text-align: center;"
role="cell"
>
<a
href="https://www.home-assistant.io/get-blueprints"
target="_blank"
rel="noreferrer noopener"
>
<mwc-button
>${this.hass.localize(
"ui.panel.config.blueprint.overview.discover_more"
)}</mwc-button
>
</a>
</div>`}
>
<mwc-icon-button slot="toolbar-icon" @click=${this._showHelp}>
<ha-svg-icon .path=${mdiHelpCircle}></ha-svg-icon>
Expand Down
6 changes: 4 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1472,12 +1472,14 @@
"confirm_delete_text": "Are you sure you want to delete this blueprint?",
"add_blueprint": "Import blueprint",
"use_blueprint": "Create automation",
"delete_blueprint": "Delete blueprint"
"delete_blueprint": "Delete blueprint",
"discover_more": "Discover more Blueprints"
},
"add": {
"header": "Import a blueprint",
"import_header": "Blueprint \"{name}\"",
"import_introduction": "You can import blueprints of other users from Github and the community forums. Enter the URL of the blueprint below.",
"import_introduction_link": "You can import blueprints of other users from Github and the {community_link}. Enter the URL of the blueprint below.",
"community_forums": "community forums",
"url": "URL of the blueprint",
"raw_blueprint": "Blueprint content",
"importing": "Loading blueprint...",
Expand Down