add catery input with hints

This commit is contained in:
dcore94 2023-04-06 15:20:31 +02:00
parent be655d6e49
commit 1ab1bbef7e
1 changed files with 22 additions and 0 deletions

View File

@ -391,6 +391,11 @@ class CCPMethodEditorController extends HTMLElement{
<label class="form-label">Version</label> <label class="form-label">Version</label>
<input name="version" class="form-control" type="text" required="required" value="${this.#current.version}"/> <input name="version" class="form-control" type="text" required="required" value="${this.#current.version}"/>
</div> </div>
<div class="col">
<label class="form-label">Category</label>
<input list="categoryhints" name="category" class="form-control" type="text" required="required" value="${this.getCurrentCategory()}"/>
${this.renderCategoryHints()}
</div>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label class="form-label">Description</label> <label class="form-label">Description</label>
@ -739,6 +744,23 @@ class CCPMethodEditorController extends HTMLElement{
` `
} }
getCurrentCategory(){
if(this.#current){
const cats = this.#current.metadata.filter(md=>md.role === "category")
if(cats.length === 0) return "Uncategorized";
return cats[0].title
}else return "Uncategorized"
}
renderCategoryHints(){
const cats = ["Uncategorized", this.getCurrentCategory()]
return `
<datalist id="categoryhints">
${cats.map(c=>`<option value="${c}">${c}</option>`}
</datalist>
`
}
renderContexts(){ renderContexts(){
return ` return `
<ul class="context_list"> <ul class="context_list">