Skip to content

Commit

Permalink
Merge pull request #45 from TECH7Fox/develop
Browse files Browse the repository at this point in the history
Enable typescript check
  • Loading branch information
TECH7Fox authored Mar 13, 2022
2 parents 606ce3b + 9c474f6 commit 36bb4db
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 88 deletions.
45 changes: 22 additions & 23 deletions src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// @ts-nocheck

import {
LitElement,
html,
css,
} from "lit";

import {
customElement
} from 'lit/decorators.js';
import { customElement } from 'lit/decorators.js';

@customElement('sipjs-card-editor')
export class SipJsCardEditor extends LitElement {
class SipJsCardEditor extends LitElement {
_config: any;
hass: any;
_rowEditor: any;

setConfig(config) {
setConfig(config: any): void {
this._config = config;
}

Expand All @@ -24,12 +22,12 @@ export class SipJsCardEditor extends LitElement {
};
}

configChanged(newConfig) {
configChanged(newConfig: any) {
const event = new Event("config-changed", {
bubbles: true,
composed: true
});
event.detail = {config: newConfig};
(event as any).detail = {config: newConfig};
this.dispatchEvent(event);
}

Expand All @@ -40,9 +38,10 @@ export class SipJsCardEditor extends LitElement {

if (this._rowEditor) {
var ent = this._config[this._rowEditor.key][this._rowEditor.index];
var rowEditor;
switch (this._rowEditor.key) {
case "extensions":
var rowEditor = html`
rowEditor = html`
<ha-entity-picker
.hass="${this.hass}"
.label="${"Person"}"
Expand Down Expand Up @@ -110,7 +109,7 @@ export class SipJsCardEditor extends LitElement {
`;
break;
case "custom":
var rowEditor = html`
rowEditor = html`
<paper-input
.label=${"Name"}
.index="${this._rowEditor.index}"
Expand Down Expand Up @@ -161,7 +160,7 @@ export class SipJsCardEditor extends LitElement {
`;
break;
case "dtmfs":
var rowEditor = html`
rowEditor = html`
<paper-input
.label=${"Name"}
.index="${this._rowEditor.index}"
Expand Down Expand Up @@ -192,7 +191,7 @@ export class SipJsCardEditor extends LitElement {
`;
break;
case "buttons":
var rowEditor = html`
rowEditor = html`
<paper-input
.label=${"Name"}
.index="${this._rowEditor.index}"
Expand Down Expand Up @@ -312,7 +311,7 @@ export class SipJsCardEditor extends LitElement {
></paper-input>
<div class="entities">
<h3>Extensions (required)</h3>
${this._config.extensions ? this._config.extensions.map((ent, index) => {
${this._config.extensions ? this._config.extensions.map((ent: { person: any; }, index: any) => {
return html`
<div class="entity">
<ha-entity-picker
Expand Down Expand Up @@ -357,7 +356,7 @@ export class SipJsCardEditor extends LitElement {
</div>
<div class="entities">
<h3>Custom</h3>
${this._config.custom ? this._config.custom.map((ent, index) => {
${this._config.custom ? this._config.custom.map((ent: { name: any; }, index: any) => {
return html`
<div class="entity">
<paper-input
Expand Down Expand Up @@ -398,7 +397,7 @@ export class SipJsCardEditor extends LitElement {
</div>
<div class="entities">
<h3>DTMF's</h3>
${this._config.dtmfs ? this._config.dtmfs.map((ent, index) => {
${this._config.dtmfs ? this._config.dtmfs.map((ent: { name: any; }, index: any) => {
return html`
<div class="entity">
<paper-input
Expand Down Expand Up @@ -439,7 +438,7 @@ export class SipJsCardEditor extends LitElement {
</div>
<div class="entities">
<h3>Buttons</h3>
${this._config.buttons ? this._config.buttons.map((ent, index) => {
${this._config.buttons ? this._config.buttons.map((ent: { name: any; }, index: any) => {
return html`
<div class="entity">
<paper-input
Expand Down Expand Up @@ -482,7 +481,7 @@ export class SipJsCardEditor extends LitElement {
`;
}

private _valueChanged(ev): void {
private _valueChanged(ev: { target: any; }): void {
if (!this._config || !this.hass) {
return;
}
Expand All @@ -504,7 +503,7 @@ export class SipJsCardEditor extends LitElement {
this.requestUpdate();
}

private _addRow(ev): void {
private _addRow(ev: { target: { value: string | null; configKey: any; configValue: any; }; }): void {
if (ev.target.value == "") {
return;
}
Expand All @@ -522,7 +521,7 @@ export class SipJsCardEditor extends LitElement {
this.requestUpdate();
}

private _removeRow(ev): void {
private _removeRow(ev: { currentTarget: any; }): void {
var key = (ev.currentTarget as any).configKey;
var index = (ev.currentTarget as any).index;
var array = Object.assign([], this._config[key]);
Expand All @@ -535,7 +534,7 @@ export class SipJsCardEditor extends LitElement {
this.requestUpdate();
}

private _editRow(ev): void {
private _editRow(ev: { currentTarget: any; }): void {
var key = (ev.currentTarget as any).configKey;
const index = (ev.currentTarget as any).index;
this._rowEditor = {
Expand All @@ -545,7 +544,7 @@ export class SipJsCardEditor extends LitElement {
this.requestUpdate();
}

private _editArray(ev): void {
private _editArray(ev: { target: { configKey: any; index: any; configValue: any; value: any; }; }): void {
var key = ev.target.configKey;
var index = ev.target.index;
var array = Object.assign([], this._config[key]);
Expand Down
Loading

0 comments on commit 36bb4db

Please sign in to comment.