Fix Add tag popup (#1885)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-05-29 12:51:52 +07:00 committed by GitHub
parent 4270887dec
commit badfde2dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,8 @@
export let keyLabel: string = '' export let keyLabel: string = ''
export let hideAdd: boolean = false export let hideAdd: boolean = false
const tagShowLimit = 50
let search: string = '' let search: string = ''
let searchElement: HTMLInputElement let searchElement: HTMLInputElement
let show: boolean = false let show: boolean = false
@ -54,14 +56,9 @@
} }
// TODO: Add $not: {$in: []} query // TODO: Add $not: {$in: []} query
$: query.query( $: query.query(tags.class.TagElement, { title: { $like: '%' + search + '%' }, targetClass }, (result) => {
tags.class.TagElement, objects = newElements.concat(result)
{ title: { $like: '%' + search + '%' }, targetClass }, })
(result) => {
objects = newElements.concat(result)
},
{ limit: 200 }
)
async function createTagElement (): Promise<void> { async function createTagElement (): Promise<void> {
showPopup(CreateTagElement, { targetClass }, 'top') showPopup(CreateTagElement, { targetClass }, 'top')
@ -136,7 +133,10 @@
<div class="scroll"> <div class="scroll">
<div class="box"> <div class="box">
{#each categories as cat} {#each categories as cat}
{#if objects.filter((el) => el.category === cat._id).length > 0} {@const catObjects = objects
.filter((el) => el.category === cat._id)
.sort((a, b) => (b.refCount ?? 0) - (a.refCount ?? 0))}
{#if catObjects.length > 0}
<div class="sticky-wrapper"> <div class="sticky-wrapper">
<button <button
class="menu-group__header" class="menu-group__header"
@ -152,12 +152,18 @@
</div> </div>
</div> </div>
<div class="flex-row-center text-xs"> <div class="flex-row-center text-xs">
<span class="content-color mr-1">({objects.filter((el) => el.category === cat._id).length})</span> <span class="content-color mr-1">
{#if catObjects.length > tagShowLimit}
({tagShowLimit}, {catObjects.length})
{:else}
({catObjects.length})
{/if}
</span>
<span class="counter">{getCount(cat)}</span> <span class="counter">{getCount(cat)}</span>
</div> </div>
</button> </button>
<div class="menu-group"> <div class="menu-group">
{#each objects.filter((el) => el.category === cat._id) as element} {#each catObjects.slice(0, 50) as element}
<button <button
class="menu-item" class="menu-item"
on:click={() => { on:click={() => {