From 0b0915a457db67877288a627ea0ef05d54316060 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Thu, 6 Apr 2023 16:06:08 +0200 Subject: [PATCH] add category hints from methodlist --- ccp/js/methodeditorcontroller.js | 5 +++-- ccp/js/methodlistcontroller.js | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index b315eda..d14f970 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -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 ` ${cats.map(c=>``)} diff --git a/ccp/js/methodlistcontroller.js b/ccp/js/methodlistcontroller.js index 5af3b51..7ed4ec3 100644 --- a/ccp/js/methodlistcontroller.js +++ b/ccp/js/methodlistcontroller.js @@ -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))