From c41e47e704b642dce1e9859b26b9295a95190049 Mon Sep 17 00:00:00 2001 From: John Rassa Date: Wed, 17 Jul 2024 14:19:50 -0400 Subject: [PATCH] refactor: rework asy-sort-header for improved rendering flexibility --- .../ago-date/ago-date-column.component.html | 21 ++++---- .../ago-date/ago-date-column.component.ts | 4 +- .../columns/date/date-column.component.html | 21 ++++---- .../columns/date/date-column.component.ts | 6 +-- .../asy-expandable-list-column.component.html | 19 ++++--- .../asy-expandable-list-column.component.scss | 21 +++++--- .../columns/text/text-column.component.html | 21 ++++---- .../columns/text/text-column.component.ts | 4 +- src/app/common/table/filter/_shared.scss | 2 + .../asy-header-sort.component.html | 16 ++++++ .../asy-header-sort.component.scss} | 12 ++--- .../asy-header-sort.component.ts} | 14 +++--- .../asy-sort-header.component.html | 18 ------- src/app/common/table/sort/public-api.ts | 2 +- .../list-cache-entries.component.ts | 4 +- .../list-euas/admin-list-euas.component.html | 8 ++- .../list-euas/admin-list-euas.component.ts | 4 +- .../admin-list-feedback.component.html | 12 +++-- .../admin-list-feedback.component.ts | 4 +- .../list-messages.component.html | 4 +- .../list-messages/list-messages.component.ts | 4 +- .../admin-list-users.component.html | 4 +- .../list-users/admin-list-users.component.ts | 4 +- .../list-audit-entries.component.html | 50 ++++++++++++------- .../list-audit-entries.component.ts | 4 +- .../list-team-members.component.ts | 4 +- .../list-teams/list-sub-teams.component.ts | 4 +- .../list-teams/list-teams.component.html | 8 ++- .../teams/list-teams/list-teams.component.ts | 4 +- 29 files changed, 172 insertions(+), 131 deletions(-) create mode 100644 src/app/common/table/sort/asy-header-sort/asy-header-sort.component.html rename src/app/common/table/sort/{asy-sort-header/asy-sort-header.component.scss => asy-header-sort/asy-header-sort.component.scss} (68%) rename src/app/common/table/sort/{asy-sort-header/asy-sort-header.component.ts => asy-header-sort/asy-header-sort.component.ts} (91%) delete mode 100644 src/app/common/table/sort/asy-sort-header/asy-sort-header.component.html diff --git a/src/app/common/table/columns/ago-date/ago-date-column.component.html b/src/app/common/table/columns/ago-date/ago-date-column.component.html index 92883f4b..f362eb7e 100644 --- a/src/app/common/table/columns/ago-date/ago-date-column.component.html +++ b/src/app/common/table/columns/ago-date/ago-date-column.component.html @@ -1,14 +1,17 @@ - - + + {{ header() ?? (name | titlecase) }} - - + + @if (headerTemplate(); as tpl) { + + } +
diff --git a/src/app/common/table/columns/ago-date/ago-date-column.component.ts b/src/app/common/table/columns/ago-date/ago-date-column.component.ts index 712aac45..e13fc2a0 100644 --- a/src/app/common/table/columns/ago-date/ago-date-column.component.ts +++ b/src/app/common/table/columns/ago-date/ago-date-column.component.ts @@ -5,7 +5,7 @@ import { Component, booleanAttribute, input } from '@angular/core'; import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { AgoDatePipe, UtcDatePipe } from '../../../pipes'; -import { AsySortHeaderComponent } from '../../sort/asy-sort-header/asy-sort-header.component'; +import { AsyHeaderSortComponent } from '../../sort/asy-header-sort/asy-header-sort.component'; import { DateColumnComponent } from '../date/date-column.component'; @Component({ @@ -15,7 +15,7 @@ import { DateColumnComponent } from '../date/date-column.component'; CommonModule, CdkTableModule, UtcDatePipe, - AsySortHeaderComponent, + AsyHeaderSortComponent, AgoDatePipe, NgbTooltip ], diff --git a/src/app/common/table/columns/date/date-column.component.html b/src/app/common/table/columns/date/date-column.component.html index bf918206..af78c7e1 100644 --- a/src/app/common/table/columns/date/date-column.component.html +++ b/src/app/common/table/columns/date/date-column.component.html @@ -1,14 +1,17 @@ - - + + {{ header() ?? (name | titlecase) }} - - + + @if (headerTemplate(); as tpl) { + + } + {{ obj[name] | utcDate: format() }} diff --git a/src/app/common/table/columns/date/date-column.component.ts b/src/app/common/table/columns/date/date-column.component.ts index f881a5ff..d72147c7 100644 --- a/src/app/common/table/columns/date/date-column.component.ts +++ b/src/app/common/table/columns/date/date-column.component.ts @@ -2,14 +2,14 @@ import { CdkTableModule } from '@angular/cdk/table'; import { CommonModule } from '@angular/common'; import { Component, input } from '@angular/core'; -import { UtcDatePipe } from '../../../pipes/utc-date-pipe/utc-date.pipe'; -import { AsySortHeaderComponent } from '../../sort/asy-sort-header/asy-sort-header.component'; +import { UtcDatePipe } from '../../../pipes'; +import { AsyHeaderSortComponent } from '../../sort/asy-header-sort/asy-header-sort.component'; import { AsyAbstractValueColumnComponent } from '../asy-abstract-value-column.component'; @Component({ selector: 'asy-date-column', standalone: true, - imports: [CommonModule, CdkTableModule, UtcDatePipe, AsySortHeaderComponent], + imports: [CommonModule, CdkTableModule, UtcDatePipe, AsyHeaderSortComponent], templateUrl: './date-column.component.html', styleUrls: ['./date-column.component.scss'] }) diff --git a/src/app/common/table/columns/expandable-list/asy-expandable-list-column.component.html b/src/app/common/table/columns/expandable-list/asy-expandable-list-column.component.html index 6b752ea6..be06952d 100644 --- a/src/app/common/table/columns/expandable-list/asy-expandable-list-column.component.html +++ b/src/app/common/table/columns/expandable-list/asy-expandable-list-column.component.html @@ -1,14 +1,17 @@ - +
{{ header() ?? (name | titlecase) }} - - +
+ @if (headerTemplate(); as tpl) { + + } + - - + + {{ header() ?? (name | titlecase) }} - - + + @if (headerTemplate(); as tpl) { + + } + {{ obj[name] || defaultValue() }} diff --git a/src/app/common/table/columns/text/text-column.component.ts b/src/app/common/table/columns/text/text-column.component.ts index f39fd3da..3d9bfb9c 100644 --- a/src/app/common/table/columns/text/text-column.component.ts +++ b/src/app/common/table/columns/text/text-column.component.ts @@ -2,13 +2,13 @@ import { CdkTableModule } from '@angular/cdk/table'; import { CommonModule } from '@angular/common'; import { Component, input } from '@angular/core'; -import { AsySortHeaderComponent } from '../../sort/asy-sort-header/asy-sort-header.component'; +import { AsyHeaderSortComponent } from '../../sort/asy-header-sort/asy-header-sort.component'; import { AsyAbstractValueColumnComponent } from '../asy-abstract-value-column.component'; @Component({ selector: 'asy-text-column', standalone: true, - imports: [CommonModule, AsySortHeaderComponent, CdkTableModule], + imports: [CommonModule, AsyHeaderSortComponent, CdkTableModule], templateUrl: './text-column.component.html', styleUrls: ['./text-column.component.scss'] }) diff --git a/src/app/common/table/filter/_shared.scss b/src/app/common/table/filter/_shared.scss index 7ec4f4df..0c03445e 100644 --- a/src/app/common/table/filter/_shared.scss +++ b/src/app/common/table/filter/_shared.scss @@ -5,6 +5,8 @@ $filter-dropdown-font-size: 0.75rem !default; $filter-dropdown-max-height: 250px !default; button.dropdown-toggle { + position: relative; + top: -2px; background: inherit; border: none; font: inherit; diff --git a/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.html b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.html new file mode 100644 index 00000000..056c73d3 --- /dev/null +++ b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.html @@ -0,0 +1,16 @@ + diff --git a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.scss b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.scss similarity index 68% rename from src/app/common/table/sort/asy-sort-header/asy-sort-header.component.scss rename to src/app/common/table/sort/asy-header-sort/asy-header-sort.component.scss index 0bee544c..ee73f486 100644 --- a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.scss +++ b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.scss @@ -1,11 +1,12 @@ @import '../../../../../styles/shared'; +:host { + display: inline-block; +} + button { background: inherit; - border: none; font: inherit; - padding-top: 0; - padding-bottom: 0; } .fa-solid { @@ -23,8 +24,3 @@ button { line-height: 2px; width: 22px; } - -.asy-sort-header-sortable { - cursor: pointer; - padding-right: 5px; -} diff --git a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.ts b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.ts similarity index 91% rename from src/app/common/table/sort/asy-sort-header/asy-sort-header.component.ts rename to src/app/common/table/sort/asy-header-sort/asy-header-sort.component.ts index 3891f759..88ff1bcd 100644 --- a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.ts +++ b/src/app/common/table/sort/asy-header-sort/asy-header-sort.component.ts @@ -24,21 +24,20 @@ interface AsySortHeaderColumnDef { } @Component({ - selector: '[asy-sort-header]', - templateUrl: './asy-sort-header.component.html', - styleUrls: ['./asy-sort-header.component.scss'], + selector: 'asy-header-sort', + templateUrl: './asy-header-sort.component.html', + styleUrls: ['./asy-header-sort.component.scss'], // eslint-disable-next-line @angular-eslint/no-host-metadata-property host: { - class: 'asy-sort-header', + class: 'text-nowrap', '(click)': '_handleClick()', - '[class.asy-sort-header-sorted]': 'isSorted()', '[attr.aria-sort]': '_getAriaSortAttribute()' }, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [] }) -export class AsySortHeaderComponent implements AsySortable, OnDestroy, OnInit { +export class AsyHeaderSortComponent implements AsySortable, OnDestroy, OnInit { readonly #destroyRef = inject(DestroyRef); readonly #changeDetectorRef = inject(ChangeDetectorRef); @@ -51,7 +50,8 @@ export class AsySortHeaderComponent implements AsySortable, OnDestroy, OnInit { * ID of this sort header. If used within the context of a CdkColumnDef, this will default to * the column's name. */ - @Input('asy-sort-header') + // eslint-disable-next-line @angular-eslint/no-input-rename + @Input('sortId') id: string; /** Overrides the sort start value of the containing AsySort for this AsySortable. */ diff --git a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.html b/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.html deleted file mode 100644 index 456ee5c5..00000000 --- a/src/app/common/table/sort/asy-sort-header/asy-sort-header.component.html +++ /dev/null @@ -1,18 +0,0 @@ -
- -
diff --git a/src/app/common/table/sort/public-api.ts b/src/app/common/table/sort/public-api.ts index bb85604d..eadf5b81 100644 --- a/src/app/common/table/sort/public-api.ts +++ b/src/app/common/table/sort/public-api.ts @@ -1,2 +1,2 @@ -export * from './asy-sort-header/asy-sort-header.component'; +export * from './asy-header-sort/asy-header-sort.component'; export * from './asy-sort.directive'; diff --git a/src/app/core/admin/cache-entries/list-cache-entries/list-cache-entries.component.ts b/src/app/core/admin/cache-entries/list-cache-entries/list-cache-entries.component.ts index 32547014..47f0ab78 100644 --- a/src/app/core/admin/cache-entries/list-cache-entries/list-cache-entries.component.ts +++ b/src/app/core/admin/cache-entries/list-cache-entries/list-cache-entries.component.ts @@ -23,8 +23,8 @@ import { ActionsMenuTemplateDirective, AgoDateColumnComponent, AsyFilterDirective, + AsyHeaderSortComponent, AsySortDirective, - AsySortHeaderComponent, AsyTableDataSource, AsyTableEmptyStateComponent, PaginatorComponent, @@ -47,7 +47,7 @@ import { CacheEntry } from '../cache-entry.model'; CdkTableModule, AsySortDirective, AsyFilterDirective, - AsySortHeaderComponent, + AsyHeaderSortComponent, AsyTableEmptyStateComponent, PaginatorComponent, JsonPipe, diff --git a/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.html b/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.html index cc0ad46b..04b864bb 100644 --- a/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.html +++ b/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.html @@ -45,7 +45,9 @@

EUAs

> - Title + + Title + {{ eua.title }} @@ -53,7 +55,9 @@

EUAs

- Text + + Text + {{ eua.text }} diff --git a/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.ts b/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.ts index 9bd08e59..df0cc5a0 100644 --- a/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.ts +++ b/src/app/core/admin/end-user-agreement/list-euas/admin-list-euas.component.ts @@ -21,8 +21,8 @@ import { ActionsMenuColumnComponent, ActionsMenuTemplateDirective, AsyFilterDirective, + AsyHeaderSortComponent, AsySortDirective, - AsySortHeaderComponent, AsyTableDataSource, AsyTableEmptyStateComponent, ColumnChooserComponent, @@ -46,7 +46,7 @@ import { EuaService } from '../eua.service'; CdkTableModule, AsySortDirective, AsyFilterDirective, - AsySortHeaderComponent, + AsyHeaderSortComponent, AsyTableEmptyStateComponent, SidebarComponent, ColumnChooserComponent, diff --git a/src/app/core/admin/feedback/list-feedback/admin-list-feedback.component.html b/src/app/core/admin/feedback/list-feedback/admin-list-feedback.component.html index 441a4ff9..cec93592 100644 --- a/src/app/core/admin/feedback/list-feedback/admin-list-feedback.component.html +++ b/src/app/core/admin/feedback/list-feedback/admin-list-feedback.component.html @@ -74,7 +74,9 @@

System Feedback

- Type + + Type + {{ feedback.type | titlecase }} @@ -92,8 +94,8 @@

System Feedback

- - Status + + Status @@ -148,7 +150,9 @@

System Feedback

- Assignee + + Assignee +