From abe0226a6c7482673f01bbf58dbf4c0f1a409c10 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Thu, 6 Apr 2023 18:00:25 +0200 Subject: [PATCH] group based on category instead of method name --- ccp/js/methodlistcontroller.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ccp/js/methodlistcontroller.js b/ccp/js/methodlistcontroller.js index e2341cd..0947239 100644 --- a/ccp/js/methodlistcontroller.js +++ b/ccp/js/methodlistcontroller.js @@ -188,11 +188,18 @@ class CCPMethodList extends HTMLElement{ groupBy(){ this.#filtered = this.#filtered.reduce((catalog, meth)=>{ - const category = meth.title - catalog[category] = catalog[category] ?? [] - catalog[category].push(meth) + const categories = meth.metadata.filter(md=>md.role === "category").map(c=>c.title) + if(categories.length === 0){ + catalog["Uncategorized"].push(meth) + }else{ + for(let c in categories){ + const category = categories[c] + catalog[category] = catalog[category] ?? [] + catalog[category].push(meth) + } + } return catalog - }, {}) + }, { "Uncategorized" : []}) } getCategoryHints(){