Skip to content

Commit

Permalink
Add reset button to timeline view
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccollum-woolpert committed Jun 18, 2024
1 parent bab7a25 commit bb27808
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ export const mouseEnterVisitRequest = createAction(
);

export const mouseExitVisitRequest = createAction('[RoutesChart] Mouse Exit Visit Request');

export const resetView = createAction('[RoutesChart] Reset View');

export const setView = createAction(
'[RoutesChart] Set View',
props<{ selectedRouteIds: number[]; rangeOffset: number }>()
);
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class AppComponent {
'pdf',
'play',
'pickup',
'reset_settings',
'route',
'satellite',
'save_alt',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<app-table-control-bar
[showModelSettings]="false"
[displayColumns]="displayColumns$ | async"
(displayColumnChange)="onDisplayColumnChange($event)">
(displayColumnChange)="onDisplayColumnChange($event)"
[page]="page$ | async">
<mat-divider preUndoRedo vertical></mat-divider>
<mat-button-toggle-group
preUndoRedo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<app-table-control-bar [showModelSettings]="false">
<app-table-control-bar
[showModelSettings]="false"
[page]="page$ | async"
(resetView)="onResetView()">
<app-filter-menu
[filters]="filters$ | async"
[filterOptions]="filterOptions$ | async"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,8 @@ export class RoutesChartControlBarComponent implements OnInit, OnDestroy {
onRangeOffsetChange(rangeOffset: number): void {
this.store.dispatch(PostSolveControlBarActions.changeRangeOffset({ rangeOffset }));
}

onResetView(): void {
this.store.dispatch(RoutesChartActions.resetView());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe('RoutesChartEffects', () => {
{ selector: RoutesChartSelectors.selectRangeOffset, value: 0 },
{ selector: ShipmentModelSelectors.selectGlobalDuration, value: null },
{ selector: RoutesChartSelectors.selectFilteredRoutes, value: [] },
{ selector: RoutesChartSelectors.selectDefaultRangeOffset, value: 0 },
{ selector: RoutesChartSelectors.selectRoutes, value: [] }
],
}),
],
Expand Down
19 changes: 19 additions & 0 deletions application/frontend/src/app/core/effects/routes-chart.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,24 @@ export class RoutesChartEffects {
)
);

resetViewEffect$ = createEffect(() =>
this.actions$.pipe(
ofType(RoutesChartActions.resetView),
mergeMap(() =>
this.store.pipe(
select(RoutesChartSelectors.selectRoutes),
take(1),
withLatestFrom(this.store.pipe(select(RoutesChartSelectors.selectDefaultRangeOffset))),
map(([routes, defaultRangeOffset]) => {
return RoutesChartActions.setView({
selectedRouteIds: routes.map((r) => r.id),
rangeOffset: defaultRangeOffset,
});
})
)
)
)
);

constructor(private actions$: Actions, private store: Store<fromRoot.State>) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,17 @@ export const reducer = createReducer(
[]
),
};
})
}),
on(RoutesChartActions.setView, (state, props) => ({
...state,
selectedRoutes: props.selectedRouteIds,
filters: [],
pageIndex: 0,
pageSize: 50,
addedRange: 0,
rangeIndex: chartConfig.day.defaultRangeIndex,
rangeOffset: props.rangeOffset,
}))
);

export const selectSelectedRoutes = (state: State): number[] => state.selectedRoutes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<ng-content></ng-content>
<ng-content select="[preUndoRedo]"></ng-content>
<app-undo-redo></app-undo-redo>
<button
*ngIf="page === Page.RoutesChart"
mat-button
class="mat-elevation-z0"
color=""
aria-label="Reset view"
(click)="resetView.emit()"
title="Reset view">
<mat-icon svgIcon="reset_settings"></mat-icon>
<span class="reset-text">Reset view</span>
</button>
<button *ngIf="showModelSettings" mat-button (click)="openShipmentModelSettings.emit()">
<mat-icon svgIcon="settings" class="mr-2"></mat-icon>Shipment model settings
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ app-table-control-bar {
pointer-events: none;
}
}

@media only screen and (max-width: 1600px) {
.reset-text {
display: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class TableControlBarComponent {

@Input() page: Page;

@Output() resetView = new EventEmitter();

Page = Page;

onDisplayColumnChange(column: Column, active: boolean): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@media only screen and (max-width: 1500px) {
@media only screen and (max-width: 1600px) {
.undo-redo-text {
display: none;
}
Expand Down
1 change: 1 addition & 0 deletions application/frontend/src/assets/images/reset_settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bb27808

Please sign in to comment.