Skip to content

Commit

Permalink
add edit to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
TECH7Fox committed May 3, 2022
1 parent 3b71110 commit 19742f4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class SipJsCardEditor extends LitElement {
break;
case "custom":
rowEditor = html`
<ha-formfield
.label=${"Edit"}
><ha-switch
.checked=${ent.edit!}
.index="${this._rowEditor.index}"
@change=${this._editValueChanged}
></ha-switch>
</ha-formfield>
<paper-input
.label=${"Name"}
.index="${this._rowEditor.index}"
Expand Down Expand Up @@ -498,6 +506,27 @@ class SipJsCardEditor extends LitElement {
this.configChanged(this._config);
}

private _editValueChanged(ev: { target: any; }): void {
if (!this._config || !this.hass) {
return;
}

const target = ev.target;
const index = (ev.target as any).index;

var array = Object.assign([], this._config["custom"]);
array[index] = {
...array[index],
["edit"]: target.checked
};
this._config = {
...this._config,
["custom"]: array
};

this.configChanged(this._config);
}

private _goBack(): void {
this._rowEditor = undefined;
this.requestUpdate();
Expand Down
8 changes: 7 additions & 1 deletion src/sipjs-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ class SipJsCard extends LitElement {
flex-direction: column;
height: 100%;
}
.editField {
width: 100%;
margin-left: 16px;
margin-right: 8px;
}
`;
}

Expand Down Expand Up @@ -471,7 +477,7 @@ class SipJsCard extends LitElement {
.label=${custom.name}
type="text"
.inputmode="text"
style="width:100%;"
class="editField"
></ha-textfield>
<mwc-button @click="${() => this._custom_call(nameid, custom.camera)}">CALL</mwc-button>
</div>
Expand Down

0 comments on commit 19742f4

Please sign in to comment.