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"){
return "time"
}else if(this.#input.schema.format === "dateTime"){
return "dateTime"
return "datetime-local"
}
return "text"
}
@ -39,13 +39,25 @@ class CCPInputWidgetEditorController extends HTMLElement{
isSelectedFormat(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.#input = input
this.#type = input.schema.enum ? "enum" : "string"
this.innerHTML = `
<details>
<details ${ reopen ? 'open' : ''}>
<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"/>
<button data-index="${this.#index}" name="delete-input" title="Delete" class="btn btn-danger ccp-toolbar-button">
@ -118,8 +130,8 @@ class CCPInputWidgetEditorController extends HTMLElement{
</div>
<div name="input-default" class="mb-3">
<div class="form-field" title="Default value">
<input type="${this.computeDefaultInputType()}" value="${this.#input.schema.default}" name="default" class="form-control" placeholder="default"/>
<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>
${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>
</div>
</div>
</div>
@ -154,7 +166,8 @@ class CCPInputWidgetEditorController extends HTMLElement{
}
else if(ename === "format"){
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 = ""
if(this.#input.schema.format === "secret"){
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"
}else if(this.#input.schema.format === "file"){
this.querySelector("div[name=input-default] input[name=default]").type = "file"
}
}*/
}
else if(ename === "contentMediaType"){
this.#input.schema.contentMediaType = val