diff --git a/ccp/js/inputwidgetcontroller.js b/ccp/js/inputwidgetcontroller.js index ca1ae68..5bc1255 100644 --- a/ccp/js/inputwidgetcontroller.js +++ b/ccp/js/inputwidgetcontroller.js @@ -35,6 +35,12 @@ class CCPInputWidgetController extends HTMLElement { }else if(this.isSecret()){ this.innerHTML += `` + }else if(this.isBoolean()){ + this.innerHTML += `` + + }else if(this.isNumber()){ + this.innerHTML += `` + }else{ this.innerHTML += `` } @@ -58,6 +64,20 @@ class CCPInputWidgetController extends HTMLElement { return this.isEnum() && (this.#data.schema.format === "checklist") } + isNumber(){ + return (this.#data.schema.type === "string") && + ("format" in this.#data.schema) && + (this.#data.schema.format != null) && + (this.#data.schema.format.toLowerCase() === "number") + } + + isBoolean(){ + return (this.#data.schema.type === "string") && + ("format" in this.#data.schema) && + (this.#data.schema.format != null) && + (this.#data.schema.format.toLowerCase() === "boolean") + } + isEnum(){ return (this.#data.schema.type === "string") && ("enum" in this.#data.schema) } @@ -367,6 +387,43 @@ class CCPChecklistInputWidgetController extends CCPBaseInputWidgetController{ } window.customElements.define('d4s-ccp-input-checklist', CCPChecklistInputWidgetController); +class CCPBooleanInputWidgetController extends CCPBaseInputWidgetController{ + + constructor(){ + super() + } + + connectedCallback(){ + this.value.forEach((v,i)=>{ this.value[i] = v === "" ? false : v}) + this.rootdoc.addEventListener("input", ev=>{ + if(ev.target.getAttribute("name") === this.name){ + const index = Number(ev.target.getAttribute("data-index")) + this.value[index] = ev.target.checked + } + }) + } + + content(){ + if(this.value.length <= 1){ + return ` +
+ +
+ ` + } + var out = + this.value.map((c,i)=>{ + return ` +
+ +
+ ` + }).join("\n") + return out + } +} +window.customElements.define('d4s-ccp-input-boolean', CCPBooleanInputWidgetController); + class CCPTextAreaWidgetController extends CCPBaseInputWidgetController{ constructor(){ diff --git a/ccp/js/inputwidgeteditorcontroller.js b/ccp/js/inputwidgeteditorcontroller.js index 5241e46..26a79e8 100644 --- a/ccp/js/inputwidgeteditorcontroller.js +++ b/ccp/js/inputwidgeteditorcontroller.js @@ -119,9 +119,11 @@ class CCPInputWidgetEditorController extends HTMLElement{ + + - +