add category input with hints

This commit is contained in:
dcore94 2023-04-06 15:31:42 +02:00
parent 6f2522ec48
commit 78eaef1c61
1 changed files with 12 additions and 2 deletions

View File

@ -379,9 +379,9 @@ class CCPMethodEditorController extends HTMLElement{
<div class="mb-3 row">
${this.renderAuthors()}
</div>
<div class="mb-3 row">
<!-- div class="mb-3 row">
${this.renderContexts()}
</div>
</div-->
<div class="mb-3 row">
<div class="col">
<label class="form-label">Title</label>
@ -493,6 +493,16 @@ class CCPMethodEditorController extends HTMLElement{
this.#rootdoc.querySelector("span[name=header]").innerText = this.#current.title
})
this.#rootdoc.querySelector("input[name=category]").addEventListener("input", ev=>{
const category = ev.currentTarget.value ? ev.currentTarget.value : "Uncategorized"
const fields = this.#current.metadata.filter(md=>md.role === "category")
if(fields.length === 0){
this.#current.metadata.push({ "role" : "category", "title" : category})
}else{
fields[0].title = category
}
})
this.#rootdoc.querySelector("input[name=version]").addEventListener("input", ev=>{
this.#current.version = ev.currentTarget.value
})