corrected several minor flaws

This commit is contained in:
dcore94 2023-02-06 13:54:09 +01:00
parent d76d744e48
commit b4cc3f40b3
1 changed files with 21 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
}else if(this.#input.schema.format === "time"){ }else if(this.#input.schema.format === "time"){
return "time" return "time"
}else if(this.#input.schema.format === "dateTime"){ }else if(this.#input.schema.format === "dateTime"){
return "dateTime" return "datetime-local"
} }
return "text" return "text"
} }
@ -40,12 +40,24 @@ class CCPInputWidgetEditorController extends HTMLElement{
return this.#input.schema.format === fmt return this.#input.schema.format === fmt
} }
render(input, i){ renderDefaultByType(){
if(this.#input.schema.format === "code"){
return `
<textarea rows="5" name="default" class="form-control" placeholder="default">${this.#input.schema.default}</textarea>
`
} else {
return `
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/>
`
}
}
render(input, i, reopen){
this.#index = i this.#index = i
this.#input = input this.#input = input
this.#type = input.schema.enum ? "enum" : "string" this.#type = input.schema.enum ? "enum" : "string"
this.innerHTML = ` this.innerHTML = `
<details> <details ${ reopen ? 'open' : ''}>
<summary class="mb-3"> <summary class="mb-3">
<input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${this.#input.id}" title="Id of input"/> <input class="form-control" style="width:auto;display:inline" required="required" name="id" value="${this.#input.id}" title="Id of input"/>
<button data-index="${this.#index}" name="delete-input" title="Delete" class="btn btn-danger ccp-toolbar-button"> <button data-index="${this.#index}" name="delete-input" title="Delete" class="btn btn-danger ccp-toolbar-button">
@ -118,7 +130,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
</div> </div>
<div name="input-default" class="mb-3"> <div name="input-default" class="mb-3">
<div class="form-field" title="Default value"> <div class="form-field" title="Default value">
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/> ${this.renderDefaultByType()}
<span style="user-select:none;position:relative;top:-1.6rem;float:right;cursor:pointer" name="password_toggle" class="${this.isSelectedFormat('secret') ? 'inline' : 'd-none'}">&#128065;</span> <span style="user-select:none;position:relative;top:-1.6rem;float:right;cursor:pointer" name="password_toggle" class="${this.isSelectedFormat('secret') ? 'inline' : 'd-none'}">&#128065;</span>
</div> </div>
</div> </div>
@ -154,7 +166,8 @@ class CCPInputWidgetEditorController extends HTMLElement{
} }
else if(ename === "format"){ else if(ename === "format"){
this.#input.schema.format = val this.#input.schema.format = val
this.querySelector("div[name=input-default] span[name=password_toggle]").classList.add("d-none") this.render(this.#input, this.#index, true)
/*this.querySelector("div[name=input-default] span[name=password_toggle]").classList.add("d-none")
this.querySelector("div[name=input-default] input[name=default]").type = "" this.querySelector("div[name=input-default] input[name=default]").type = ""
if(this.#input.schema.format === "secret"){ if(this.#input.schema.format === "secret"){
this.querySelector("div[name=input-default] input[name=default]").type = "password" this.querySelector("div[name=input-default] input[name=default]").type = "password"
@ -167,7 +180,7 @@ class CCPInputWidgetEditorController extends HTMLElement{
this.querySelector("div[name=input-default] input[name=default]").type = "dateTime" this.querySelector("div[name=input-default] input[name=default]").type = "dateTime"
}else if(this.#input.schema.format === "file"){ }else if(this.#input.schema.format === "file"){
this.querySelector("div[name=input-default] input[name=default]").type = "file" this.querySelector("div[name=input-default] input[name=default]").type = "file"
} }*/
} }
else if(ename === "contentMediaType"){ else if(ename === "contentMediaType"){
this.#input.schema.contentMediaType = val this.#input.schema.contentMediaType = val