[UBER-387] Hide tags category if category is single (#3365)

This commit is contained in:
Sergei Ogorelkov 2023-06-06 19:41:18 +04:00 committed by GitHub
parent fd353b4ec4
commit d798d872aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 22 deletions

View File

@ -137,19 +137,21 @@
</div>
</div>
<svelte:fragment slot="pool">
<div class="ml-12">
<DropdownLabels
icon={IconFolder}
label={tags.string.CategoryLabel}
kind={'secondary'}
size={'large'}
bind:selected={category}
items={categoryItems}
on:selected={() => {
categoryWasSet = true
}}
/>
</div>
{#if categories.length > 1}
<div class="ml-12">
<DropdownLabels
icon={IconFolder}
label={tags.string.CategoryLabel}
kind={'secondary'}
size={'large'}
bind:selected={category}
items={categoryItems}
on:selected={() => {
categoryWasSet = true
}}
/>
</div>
{/if}
</svelte:fragment>
</Card>

View File

@ -51,6 +51,7 @@
let show: boolean = false
let objects: TagElement[] = []
let categories: TagCategory[] = []
let isSingleCategory = true
const dispatch = createEventDispatcher()
const query = createQuery()
@ -58,6 +59,7 @@
const client = getClient()
client.findAll(tags.class.TagCategory, { targetClass }).then((res) => {
categories = res
isSingleCategory = categories.length <= 1
})
// TODO: Add $not: {$in: []} query
@ -113,14 +115,16 @@
{placeholderParam}
on:change
/>
<Button
kind={'transparent'}
size={'large'}
icon={show ? IconView : IconViewHide}
on:click={() => {
show = !show
}}
/>
{#if !isSingleCategory}
<Button
kind={'transparent'}
size={'large'}
icon={show ? IconView : IconViewHide}
on:click={() => {
show = !show
}}
/>
{/if}
{#if !hideAdd}<Button kind={'transparent'} size={'large'} icon={IconAdd} on:click={createTagElement} />{/if}
</div>
<div class="scroll">
@ -132,7 +136,8 @@
<div class="sticky-wrapper">
<button
class="menu-group__header"
class:show={categories.length === 1 || search !== '' || show}
class:show={isSingleCategory || search !== '' || show}
class:hidden={isSingleCategory}
on:click={toggleGroup}
>
<div class="flex-row-center">
@ -211,4 +216,7 @@
font-size: 0.75rem;
color: var(--theme-dark-color);
}
.hidden {
display: none;
}
</style>