fix enum default selection

This commit is contained in:
dcore94 2024-04-11 17:25:41 +02:00
parent 05ef785cf0
commit 297b2f6ffe
4 changed files with 13 additions and 12 deletions

View File

@ -11,11 +11,12 @@ class CCPExecutionForm extends HTMLElement{
constructor(){
super()
this.#boot = document.querySelector("d4s-boot-2")
this.#serviceurl = this.getAttribute("serviceurl")
this.#rootdoc = this.attachShadow({ "mode" : "open"})
}
connectedCallback(){
this.#serviceurl = this.getAttribute("serviceurl")
this.connectNewExecutionRequest()
this.render()
const params = new URLSearchParams(window.location.search)
@ -29,7 +30,7 @@ class CCPExecutionForm extends HTMLElement{
this.showMethod()
}
}
static get observedAttributes() {
return ["method"];
}

View File

@ -325,12 +325,13 @@ class CCPEnumInputWidgetController extends CCPBaseInputWidgetController{
}
content(){
const opts = this.options.map(o=>`<option value="${o}">${o}</option>`).join("\n")
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>`
}
var out =
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 `
<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,15 +153,14 @@ class CCPMethodEditorController extends HTMLElement{
super();
this.#boot = document.querySelector("d4s-boot-2")
this.#rootdoc = this.attachShadow({ "mode" : "open"})
}
connectedCallback(){
this.#serviceurl = this.getAttribute("serviceurl")
this.initMethod()
this.fetchInfrastructures()
this.connectNewEditRequest()
}
connectedCallback(){
}
connectNewEditRequest(){
document.addEventListener("neweditrequest", ev=>{

View File

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