From addde48f8d58891f898ab132e259f8245847edd1 Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Sat, 8 Feb 2025 19:42:18 +0700 Subject: [PATCH] feat(ui): introduce readonly attribute --- .../tags-selector.component.html | 75 +++++++++++-------- .../tags-selector.component.stories.ts | 19 +++++ .../tags-selector/tags-selector.component.ts | 1 + 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/libs/ui/src/lib/tags-selector/tags-selector.component.html b/libs/ui/src/lib/tags-selector/tags-selector.component.html index 55f8a39f2..cb86be915 100644 --- a/libs/ui/src/lib/tags-selector/tags-selector.component.html +++ b/libs/ui/src/lib/tags-selector/tags-selector.component.html @@ -1,32 +1,45 @@ - - Tags - - @for (tag of tagsSelected(); track tag.id) { - - {{ tag.name }} - - +
+
+ @if (readonly) { +
Tags
+ + @for (tag of tags; track tag) { + {{ tag.name }} + } + + } @else { + + Tags + + @for (tag of tagsSelected(); track tag.id) { + + {{ tag.name }} + + + } + + + + @for (tag of filteredOptions | async; track tag.id) { + + {{ tag.name }} + + } + + } - - - - @for (tag of filteredOptions | async; track tag.id) { - - {{ tag.name }} - - } - - +
+
diff --git a/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts b/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts index c1adf1286..4fd0f7e77 100644 --- a/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts +++ b/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts @@ -47,6 +47,25 @@ export const Default: Story = { } }; +export const Readonly: Story = { + args: { + readonly: true, + tags: [ + { + id: 'EMERGENCY_FUND', + name: 'Emergency Fund', + userId: null + }, + { + id: 'RETIREMENT_FUND', + name: 'Retirement Fund', + userId: null + } + ], + tagsAvailable: OPTIONS + } +}; + export const WithoutValue: Story = { args: { tags: [], diff --git a/libs/ui/src/lib/tags-selector/tags-selector.component.ts b/libs/ui/src/lib/tags-selector/tags-selector.component.ts index 77c776ece..6b59d53f4 100644 --- a/libs/ui/src/lib/tags-selector/tags-selector.component.ts +++ b/libs/ui/src/lib/tags-selector/tags-selector.component.ts @@ -42,6 +42,7 @@ import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; templateUrl: 'tags-selector.component.html' }) export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy { + @Input() readonly = false; @Input() tags: Tag[]; @Input() tagsAvailable: Tag[];