From efddd83087b09a2b6bfce8cd078dd8c326f48413 Mon Sep 17 00:00:00 2001 From: Jason McCollum Date: Mon, 24 Jun 2024 09:48:47 -0700 Subject: [PATCH] Move button and disable if on default view --- .../metadata-control-bar.component.html | 3 +- .../routes-chart-control-bar.component.html | 17 +++++++--- .../routes-chart-control-bar.component.scss | 10 ++++++ .../routes-chart-control-bar.component.ts | 4 ++- .../shipments-control-bar.component.html | 1 - .../shipments-control-bar.component.ts | 5 +-- .../core/effects/routes-chart.effects.spec.ts | 2 +- .../core/selectors/routes-chart.selectors.ts | 31 +++++++++++++++++++ .../table-control-bar.component.html | 11 ------- .../table-control-bar.component.scss | 6 ---- .../table-control-bar.component.ts | 8 +---- 11 files changed, 61 insertions(+), 37 deletions(-) diff --git a/application/frontend/src/app/core/containers/metadata-control-bar/metadata-control-bar.component.html b/application/frontend/src/app/core/containers/metadata-control-bar/metadata-control-bar.component.html index 65819392..72a99e0f 100644 --- a/application/frontend/src/app/core/containers/metadata-control-bar/metadata-control-bar.component.html +++ b/application/frontend/src/app/core/containers/metadata-control-bar/metadata-control-bar.component.html @@ -1,8 +1,7 @@ + (displayColumnChange)="onDisplayColumnChange($event)"> + + + ; private addSubscription: Subscription; private editSubscription: Subscription; + viewHasChanged$: Observable; get Page(): typeof Page { return Page; @@ -85,6 +86,7 @@ export class RoutesChartControlBarComponent implements OnInit, OnDestroy { select(fromUI.selectPage), map((page) => (page === Page.ShipmentsMetadata ? Page.RoutesMetadata : page)) ); + this.viewHasChanged$ = this.store.pipe(select(RoutesChartSelectors.selectViewHasChanged)); } ngOnDestroy(): void { diff --git a/application/frontend/src/app/core/containers/shipments-control-bar/shipments-control-bar.component.html b/application/frontend/src/app/core/containers/shipments-control-bar/shipments-control-bar.component.html index 26f5ca93..2b8b105d 100644 --- a/application/frontend/src/app/core/containers/shipments-control-bar/shipments-control-bar.component.html +++ b/application/frontend/src/app/core/containers/shipments-control-bar/shipments-control-bar.component.html @@ -1,7 +1,6 @@ ; readonly filters$: Observable; readonly displayColumns$: Observable; - readonly page$: Observable; private addSubscription: Subscription; private editSubscription: Subscription; @@ -66,7 +64,6 @@ export class ShipmentsControlBarComponent implements OnDestroy { this.displayColumns$ = store.pipe( select(PreSolveShipmentSelectors.selectAvailableDisplayColumnsOptions) ); - this.page$ = store.pipe(select(selectPage)); } ngOnDestroy(): void { diff --git a/application/frontend/src/app/core/effects/routes-chart.effects.spec.ts b/application/frontend/src/app/core/effects/routes-chart.effects.spec.ts index 56c229b0..a97c2a86 100644 --- a/application/frontend/src/app/core/effects/routes-chart.effects.spec.ts +++ b/application/frontend/src/app/core/effects/routes-chart.effects.spec.ts @@ -39,7 +39,7 @@ describe('RoutesChartEffects', () => { { selector: ShipmentModelSelectors.selectGlobalDuration, value: null }, { selector: RoutesChartSelectors.selectFilteredRoutes, value: [] }, { selector: RoutesChartSelectors.selectDefaultRangeOffset, value: 0 }, - { selector: RoutesChartSelectors.selectRoutes, value: [] } + { selector: RoutesChartSelectors.selectRoutes, value: [] }, ], }), ], diff --git a/application/frontend/src/app/core/selectors/routes-chart.selectors.ts b/application/frontend/src/app/core/selectors/routes-chart.selectors.ts index da4b3cd2..fe428f81 100644 --- a/application/frontend/src/app/core/selectors/routes-chart.selectors.ts +++ b/application/frontend/src/app/core/selectors/routes-chart.selectors.ts @@ -335,6 +335,36 @@ const selectDuration = createSelector(selectRange, selectRangeOffset, (range, of return [start, start.add(range)] as [Long, Long]; }); +const selectViewHasChanged = createSelector( + selectFilters, + selectPageIndex, + selectPageSize, + selectAddedRange, + selectRangeIndex, + selectRangeOffset, + selectDefaultRangeOffset, + selectRoutes, + selectSelectedRoutes, + ( + filters, + pageIndex, + pageSize, + addedRange, + rangeIndex, + rangeOffset, + defaultRangeOffset, + routes, + selectedRoutes + ) => + filters.length > 0 || + pageIndex !== 0 || + pageSize !== 50 || + addedRange !== 0 || + rangeIndex !== chartConfig.day.defaultRangeIndex || + rangeOffset !== defaultRangeOffset || + routes.length !== selectedRoutes.length +); + export const RoutesChartSelectors = { selectView, selectRangeIndex, @@ -378,6 +408,7 @@ export const RoutesChartSelectors = { selectNextColumnOffset, selectNextRangeOffset, selectDuration, + selectViewHasChanged, }; export default RoutesChartSelectors; diff --git a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.html b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.html index 666b11c4..365b6f12 100644 --- a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.html +++ b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.html @@ -1,17 +1,6 @@ - diff --git a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.scss b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.scss index 90122a7d..b4544fb8 100644 --- a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.scss +++ b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.scss @@ -29,9 +29,3 @@ app-table-control-bar { pointer-events: none; } } - -@media only screen and (max-width: 1600px) { - .reset-text { - display: none; - } -} diff --git a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.ts b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.ts index f02c6fe3..4a80bd0a 100644 --- a/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.ts +++ b/application/frontend/src/app/shared/components/table-control-bar/table-control-bar.component.ts @@ -22,7 +22,7 @@ import { Output, ViewEncapsulation, } from '@angular/core'; -import { Column, Page } from 'src/app/core/models'; +import { Column } from 'src/app/core/models'; @Component({ selector: 'app-table-control-bar', @@ -38,12 +38,6 @@ export class TableControlBarComponent { @Input() displayColumns: Column[]; @Output() displayColumnChange = new EventEmitter<{ columnId: string; active: boolean }>(); - @Input() page: Page; - - @Output() resetView = new EventEmitter(); - - Page = Page; - onDisplayColumnChange(column: Column, active: boolean): void { this.displayColumnChange.emit({ columnId: column.id, active }); }