From 0993fc07a3d813b8e200bb1df1fdfe295e389773 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 29 Oct 2022 15:03:27 -0700 Subject: [PATCH] Add "clearable" badge --- src-ui/src/app/app.module.ts | 2 ++ .../clearable-badge.component.html | 9 +++++ .../clearable-badge.component.scss | 25 ++++++++++++++ .../clearable-badge.component.ts | 33 +++++++++++++++++++ .../date-dropdown.component.html | 6 +--- .../date-dropdown/date-dropdown.component.ts | 7 ++++ .../filterable-dropdown.component.html | 9 +---- .../filterable-dropdown.component.ts | 5 +++ 8 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html create mode 100644 src-ui/src/app/components/common/clearable-badge/clearable-badge.component.scss create mode 100644 src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index 02fd8ea66..c5afc6942 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -24,6 +24,7 @@ import { CorrespondentEditDialogComponent } from './components/common/edit-dialo import { TagEditDialogComponent } from './components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component' import { DocumentTypeEditDialogComponent } from './components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component' import { TagComponent } from './components/common/tag/tag.component' +import { ClearableBadge } from './components/common/clearable-badge/clearable-badge.component' import { PageHeaderComponent } from './components/common/page-header/page-header.component' import { AppFrameComponent } from './components/app-frame/app-frame.component' import { ToastsComponent } from './components/common/toasts/toasts.component' @@ -141,6 +142,7 @@ function initializeApp(settings: SettingsService) { DocumentTypeEditDialogComponent, StoragePathEditDialogComponent, TagComponent, + ClearableBadge, PageHeaderComponent, AppFrameComponent, ToastsComponent, diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html new file mode 100644 index 000000000..64727e0d8 --- /dev/null +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html @@ -0,0 +1,9 @@ + diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.scss b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.scss new file mode 100644 index 000000000..14ca3fd2b --- /dev/null +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.scss @@ -0,0 +1,25 @@ +.badge { + width: 20px; + height: 20px; +} + +.x { + display: none; +} + +.number { + width: 1em; + height: 1em; + display: inline-block; +} + +button:hover { + .check, + .number { + display: none; + } + + .x { + display: inline-block; + } +} diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts new file mode 100644 index 000000000..93f63d4d8 --- /dev/null +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts @@ -0,0 +1,33 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core' + +@Component({ + selector: 'app-clearable-badge', + templateUrl: './clearable-badge.component.html', + styleUrls: ['./clearable-badge.component.scss'], +}) +export class ClearableBadge { + constructor() {} + + @Input() + number: number + + @Input() + selected: boolean + + @Output() + cleared: EventEmitter = new EventEmitter() + + get active(): boolean { + return this.selected || this.number > -1 + } + + get isNumbered(): boolean { + return this.number > -1 + } + + onClick(event: PointerEvent) { + this.cleared.emit(true) + event.stopImmediatePropagation() + event.preventDefault() + } +} diff --git a/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html b/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html index dc8ae8688..58634b4d0 100644 --- a/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html +++ b/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html @@ -1,11 +1,7 @@