Skip to content

Commit

Permalink
Merge pull request #36 from htmltiger/htmltiger-patch-1
Browse files Browse the repository at this point in the history
Update config-editor-card.js
  • Loading branch information
htmltiger authored Mar 3, 2022
2 parents cb30d2a + 1844ea3 commit 40d3c42
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions config-editor-card.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.info("Config Editor 3.7");
console.info("Config Editor 3.9");
const LitElement = window.LitElement || Object.getPrototypeOf(customElements.get("hui-masonry-view") );
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;
Expand Down Expand Up @@ -48,7 +48,8 @@ static get styles() {
.bar i{background:#ff7a81;cursor:pointer}
`;
}
render() {

render(){
const hver=this._hass.states['config_editor.version'];
if(!hver){return html`<ha-card>Missing 'config_editor:' in configuration.yaml
for github.com/htmltiger/config-editor</ha-card>`;}
Expand All @@ -64,7 +65,6 @@ render() {
}
}else{this.List();}
}

return html`
<ha-card>
<div class="top">
Expand All @@ -80,7 +80,7 @@ render() {
name="basic" value="1" @change=${this.basicChange}></label>
</div>
</div>
${this.edit.basic ?
${(this.edit.basic || this.edit.coder ) ?
html`<textarea rows="10" ?readonly=${!0==this.edit.readonly}
@change=${this.updateText} id="code" @keydown=${this.saveKey}>${this.code}</textarea>`:
html`<ha-code-editor id="code" mode="yaml" ?readOnly=${!0==this.edit.readonly}
Expand Down Expand Up @@ -117,7 +117,7 @@ extChange(e){
basicChange(){
this.edit.basic = this.edit.basic?'':'1';
this.localSet('Basic', this.edit.basic);
this.List();
this.reLoad();
}

updateText(e) {
Expand Down Expand Up @@ -189,11 +189,13 @@ async Coder(){
const d=document.createElement("ha-panel-config");
await d.routerOptions.routes.automation.load();
}
if(!document.createElement(c)){
const a=document.createElement(c);
this.edit.coder=0;
if(!a){
this.localSet('Basic', 1);
console.log('failed '+c);
}

this.render();
}

async List(){
Expand All @@ -211,7 +213,7 @@ async Load(x) {
if(x.target.value == this.openedFile && this.code && !x.hasOwnProperty('reload')){return;}
if(this.edit.orgCode.trim() != this.code.trim()){
if(!confirm("Switch without Saving?")){x.target.value = this.openedFile; return;}
}
}
this.code = ''; this.renderRoot.querySelector('#code').value='';this.infoLine = '';
this.openedFile = x.target.value;
if(this.openedFile){
Expand Down Expand Up @@ -269,7 +271,7 @@ getCardSize() {
}

setConfig(config) {
this.edit = {file: '', hidefooter: false, readonly: false, basic: false, ext: '', orgCode: '', ...config};
this.edit = {file: '', hidefooter: false, readonly: false, basic: false, ext: '', orgCode: '', coder:1, ...config};
if(this.edit.file){
const f=this.edit.file.split('.')[1];
if(f){
Expand Down

0 comments on commit 40d3c42

Please sign in to comment.