fix enum default selection #12

Merged
m.lettere merged 1 commits from master into prod 2024-04-11 17:38:53 +02:00
4 changed files with 13 additions and 12 deletions

View File

@ -11,11 +11,12 @@ class CCPExecutionForm extends HTMLElement{
constructor(){ constructor(){
super() super()
this.#boot = document.querySelector("d4s-boot-2") this.#boot = document.querySelector("d4s-boot-2")
this.#serviceurl = this.getAttribute("serviceurl")
this.#rootdoc = this.attachShadow({ "mode" : "open"}) this.#rootdoc = this.attachShadow({ "mode" : "open"})
}
connectedCallback(){
this.#serviceurl = this.getAttribute("serviceurl")
this.connectNewExecutionRequest() this.connectNewExecutionRequest()
this.render() this.render()
const params = new URLSearchParams(window.location.search) const params = new URLSearchParams(window.location.search)

View File

@ -325,12 +325,13 @@ class CCPEnumInputWidgetController extends CCPBaseInputWidgetController{
} }
content(){ content(){
const opts = this.options.map(o=>`<option value="${o}">${o}</option>`).join("\n")
if(this.value.length <= 1){ if(this.value.length <= 1){
const opts = this.options.map(o=>`<option value="${o}" ${ this.value.length && o === this.value[0] ? 'selected' : ''}>${o}</option>`).join("\n")
return `<select data-index="0" value="${this.value.length ? this.value[0] : ''}" class="my-2 form-control" placeholder="${this.title}" name="${this.name}" ${this.readonly ? 'disabled' : ''} ${this.required ? 'required' : ''}>${opts}</select>` return `<select data-index="0" value="${this.value.length ? this.value[0] : ''}" class="my-2 form-control" placeholder="${this.title}" name="${this.name}" ${this.readonly ? 'disabled' : ''} ${this.required ? 'required' : ''}>${opts}</select>`
} }
var out = var out =
this.value.map((c,i)=>{ this.value.map((c,i)=>{
const opts = this.options.map(o=>`<option value="${o}" ${ this.value.length >= i && c === this.value[i] ? 'selected' : ''}>${o}</option>`).join("\n")
return ` return `
<select data-index="${i}" value="${this.value.length ? this.value[0] : ''}" class="my-2 form-control" placeholder="${this.title}" name="${this.name}" ${this.readonly ? 'disabled' : ''} ${this.required ? 'required' : ''}>${opts}</select> <select data-index="${i}" value="${this.value.length ? this.value[0] : ''}" class="my-2 form-control" placeholder="${this.title}" name="${this.name}" ${this.readonly ? 'disabled' : ''} ${this.required ? 'required' : ''}>${opts}</select>
` `

View File

@ -153,16 +153,15 @@ class CCPMethodEditorController extends HTMLElement{
super(); super();
this.#boot = document.querySelector("d4s-boot-2") this.#boot = document.querySelector("d4s-boot-2")
this.#rootdoc = this.attachShadow({ "mode" : "open"}) this.#rootdoc = this.attachShadow({ "mode" : "open"})
}
connectedCallback(){
this.#serviceurl = this.getAttribute("serviceurl") this.#serviceurl = this.getAttribute("serviceurl")
this.initMethod() this.initMethod()
this.fetchInfrastructures() this.fetchInfrastructures()
this.connectNewEditRequest() this.connectNewEditRequest()
} }
connectedCallback(){
}
connectNewEditRequest(){ connectNewEditRequest(){
document.addEventListener("neweditrequest", ev=>{ document.addEventListener("neweditrequest", ev=>{
this.cloneOrEditMethod(ev.detail) this.cloneOrEditMethod(ev.detail)

View File

@ -17,11 +17,8 @@ class CCPMethodList extends HTMLElement{
constructor(){ constructor(){
super() super()
this.#boot = document.querySelector("d4s-boot-2") this.#boot = document.querySelector("d4s-boot-2")
this.#serviceurl = this.getAttribute("serviceurl")
this.#rootdoc = this.attachShadow({ "mode" : "open"}) this.#rootdoc = this.attachShadow({ "mode" : "open"})
this.#archive = this.getAttribute("archive") this.#archive = this.getAttribute("archive")
this.render()
this.fetchProcesses()
} }
render(){ render(){
@ -167,6 +164,9 @@ class CCPMethodList extends HTMLElement{
connectedCallback(){ connectedCallback(){
this.#allowedit = this.getAttribute("allow-edit") === "true" this.#allowedit = this.getAttribute("allow-edit") === "true"
this.#allowexecute = this.getAttribute("allow-execute") === "true" this.#allowexecute = this.getAttribute("allow-execute") === "true"
this.#serviceurl = this.getAttribute("serviceurl")
this.render()
this.fetchProcesses()
} }
fetchProcesses(){ fetchProcesses(){