mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-04 23:04:47 +00:00
TSK-1403 Improve tags filter (#3126)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
149d8cda46
commit
1a98b10eee
@ -31,7 +31,7 @@
|
||||
|
||||
$: name = element?.title ?? tag?.title ?? 'New item'
|
||||
|
||||
$: tagIcon = schema === '3' ? undefined : tagLevel[(((tag?.weight ?? 0) % 3) + 1) as 1 | 2 | 3]
|
||||
$: tagIcon = schema !== '9' ? undefined : tagLevel[(((tag?.weight ?? 0) % 3) + 1) as 1 | 2 | 3]
|
||||
</script>
|
||||
|
||||
{#if inline}
|
||||
|
@ -37,7 +37,7 @@
|
||||
export let key: KeyedAttribute
|
||||
export let showTitle = true
|
||||
export let elements: Map<Ref<TagElement>, TagElement>
|
||||
export let schema: '3' | '9' = key.attr.schema ?? '9'
|
||||
export let schema: '0' | '3' | '9' = key.attr.schema ?? '0'
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
@ -138,6 +138,7 @@
|
||||
removeTag(tag._id)
|
||||
}}
|
||||
on:click={(evt) => {
|
||||
if (schema !== '0') {
|
||||
showPopup(
|
||||
WeightPopup,
|
||||
{ value: tag.weight ?? 1, format: 'number', schema },
|
||||
@ -150,6 +151,7 @@
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
|
@ -88,7 +88,7 @@
|
||||
const el: HTMLElement = ev.currentTarget as HTMLElement
|
||||
el.classList.toggle('show')
|
||||
}
|
||||
const show: boolean = false
|
||||
$: show = categories.length <= 1
|
||||
|
||||
const getCount = (cat: TagCategory): string => {
|
||||
const count = objects.filter((el) => el.category === cat._id).filter((it) => selected.includes(it._id)).length
|
||||
@ -111,7 +111,7 @@
|
||||
categories = categories
|
||||
}
|
||||
|
||||
$: schema = filter.key.attribute.schema ?? '9'
|
||||
$: schema = filter.key.attribute.schema ?? '0'
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
getValues(search)
|
||||
@ -131,6 +131,7 @@
|
||||
}}
|
||||
placeholder={phTraslate}
|
||||
/>
|
||||
{#if schema !== '0'}
|
||||
<div class="flex-row-center flex-between flex-grow p-1">
|
||||
<Label label={tags.string.Weight} />
|
||||
<Button
|
||||
@ -147,6 +148,7 @@
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="scroll">
|
||||
<div class="box">
|
||||
@ -154,9 +156,16 @@
|
||||
<Loading />
|
||||
{:else}
|
||||
{#each categories as cat}
|
||||
{#if objects.filter((el) => el.category === cat._id).length > 0}
|
||||
{@const values = objects.filter((el) => el.category === cat._id)}
|
||||
{#if values.length > 0}
|
||||
<div class="sticky-wrapper">
|
||||
<button class="menu-group__header" class:show={search !== '' || show} on:click={toggleGroup}>
|
||||
<button
|
||||
class="menu-group__header"
|
||||
class:show={search !== '' || show}
|
||||
class:hidden={show}
|
||||
on:click={toggleGroup}
|
||||
>
|
||||
{#if categories.length > 1}
|
||||
<div class="flex-row-center">
|
||||
<span class="mr-1-5">{cat.label}</span>
|
||||
<div class="icon">
|
||||
@ -166,12 +175,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<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">({values.length})</span>
|
||||
<span class="counter">{getCount(cat)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
<div class="menu-group">
|
||||
{#each objects.filter((el) => el.category === cat._id) as element}
|
||||
{#each values as element}
|
||||
<button
|
||||
class="menu-item"
|
||||
on:click={() => {
|
||||
@ -217,4 +227,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user