add category hints from methodlist

This commit is contained in:
dcore94 2023-04-06 16:30:44 +02:00
parent d2a847faa8
commit 90a62f83d2
1 changed files with 13 additions and 15 deletions

View File

@ -391,11 +391,6 @@ class CCPMethodEditorController extends HTMLElement{
<label class="form-label">Version</label>
<input name="version" class="form-control" type="text" required="required" value="${this.#current.version}"/>
</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 class="mb-3">
<label class="form-label">Description</label>
@ -410,8 +405,9 @@ class CCPMethodEditorController extends HTMLElement{
</div>
</div>
<div class="col mb-3">
<label class="form-label">Keywords</label>
<input name="category" class="form-control" type="text"/>
<label class="form-label">Categories</label>
<input list="categoryhints" name="category" class="form-control" type="text"/>
${this.renderCategoryHints()}
<div name="category-list" class="form-text">
${this.renderCategories()}
</div>
@ -763,14 +759,6 @@ 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 ml = document.querySelector("d4s-ccp-methodlist")
const cats = ml.getCategoryHints()
@ -781,6 +769,16 @@ class CCPMethodEditorController extends HTMLElement{
</datalist>
`
}
renderCategories(){
return `
<ul class="category_list">
${ this.#current.metadata.
filter(md=>md.role === "category").
map(c=>`<li class="category_list_item" title="${c.title}">${c.title}</li>`).join("") }
</ul>
`
}
renderContexts(){
return `