add category hints from methodlist

This commit is contained in:
dcore94 2023-04-06 16:06:08 +02:00
parent 78eaef1c61
commit 0b0915a457
2 changed files with 12 additions and 2 deletions

View File

@ -763,8 +763,9 @@ class CCPMethodEditorController extends HTMLElement{
}
renderCategoryHints(){
const cats1 = ["Uncategorized", this.getCurrentCategory()]
const cats = [...new Set(cats1)]
const s = new Set(["Uncategorized", this.getCurrentCategory()])
const ml = document.querySelector("d4s-ccp-methodlist")
const cats = ml ? [...s].concat(ml.getCategoryHints()) : [...s]
return `
<datalist id="categoryhints">
${cats.map(c=>`<option value="${c}">${c}</option>`)}

View File

@ -195,6 +195,15 @@ class CCPMethodList extends HTMLElement{
}, {})
}
getCategoryHints(){
const s = new Set()
for(let i=0; i < this.#data.length; i++){
const cat = m.metadata.filter(md=>md.role === "category").map(md=>md.title)
s.add(cat)
}
return [...s]
}
exportCategory(category){
Promise.all(
this.#filtered[category].map(m=>this.exportMethod(m.id))