Fixes tag category bar to show available skills (#1636)

This commit is contained in:
Andrey Sobolev 2022-05-05 13:44:31 +07:00 committed by GitHub
parent cc57821962
commit 88ccff9ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 14 deletions

View File

@ -41,15 +41,43 @@
let categoryKeys: Ref<TagCategory>[] = [] let categoryKeys: Ref<TagCategory>[] = []
const elementsQuery = createQuery() const elementsQuery = createQuery()
$: elementsQuery.query( $: if ((tagElements?.size ?? 0) > 0) {
tags.class.TagElement, elementsQuery.query(
{ targetClass }, tags.class.TagElement,
{ targetClass },
(res) => {
elements = res
},
{
sort: {
title: SortingOrder.Ascending
}
}
)
}
type TagElementInfo = { count: number; modifiedOn: number }
let tagElements: Map<Ref<TagElement>, TagElementInfo> | undefined = undefined
const refQuery = createQuery()
$: refQuery.query(
tags.class.TagReference,
{},
(res) => { (res) => {
elements = res const result = new Map<Ref<TagElement>, TagElementInfo>()
for (const d of res) {
const v = result.get(d.tag) ?? { count: 0, modifiedOn: 0 }
v.count++
v.modifiedOn = Math.max(v.modifiedOn, d.modifiedOn)
result.set(d.tag, v)
}
tagElements = result
}, },
{ {
sort: { projection: {
title: SortingOrder.Ascending _id: 1,
tag: 1
} }
} }
) )

View File

@ -128,7 +128,7 @@
{#if elements.length > 0} {#if elements.length > 0}
<div class="sticky-wrapper"> <div class="sticky-wrapper">
<div class="menu-group" style:overflow="visible"> <div class="menu-group" style:overflow="visible">
{#each elements as element} {#each elements.filter((it) => tagElements?.has(it._id)) as element}
<button <button
class="menu-item" class="menu-item"
on:click={() => { on:click={() => {
@ -183,13 +183,6 @@
</div> </div>
<style lang="scss"> <style lang="scss">
// .counter {
// padding-right: 0.125rem;
// min-width: 1.5rem;
// text-align: right;
// font-size: 0.8125rem;
// color: var(--caption-color);
// }
.empty { .empty {
display: flex; display: flex;
justify-content: center; justify-content: center;