Skip to content

Commit e66ff2d

Browse files
committed
ToolbarService: Added "addBackActionRoute" method to add a back action route with query parameters to the toolbar
1 parent fdaf5ef commit e66ff2d

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ The versioning of material-addons is based on the Angular version. The Angular v
3131

3232
_Hint: Changes marked as **visible change** directly affect your application during version upgrade. **Breaking**
3333
requires your attention during upgrade._
34-
34+
- **19.0.8**: ToolbarService: Added "addBackActionRoute" method to add a back action route with query parameters to the toolbar
35+
- **19.0.7**: fix position of filter button in data table
36+
- **19.0.6**: Improve data table filter
3537
- **19.0.5**: fix: stepper error state color, css, add mat-error to stepper demo
3638
- **19.0.4**: Major: fix cdkObserveContent deadlock in Chromium >= 135 version
3739
- **19.0.3**: Fix Endless Loop in Readonly FormField [#223](https://github.com/porscheinformatik/material-addons/pull/223)
3840
- **19.0.2**: bugfix for version: fix dist output
3941
- **19.0.0**: Upgrade to Angular 19
42+
43+
<details><summary>View older changelogs</summary>
44+
4045
- **18.0.8**: Major: fix cdkObserveContent deadlock in Chromium >= 135 version
4146
- **18.0.7**: Fix Endless Loop in Readonly FormField [#223](https://github.com/porscheinformatik/material-addons/pull/223)
4247
- **18.0.5**: FileUpload: Added additional param as 'removable' which allows user to remove file from fileList [#212](https://github.com/porscheinformatik/material-addons/pull/212)
@@ -74,9 +79,6 @@ requires your attention during upgrade._
7479
- **breaking changes** - [#131 Upgrade to Angular 15 with MDC Components](https://github.com/porscheinformatik/material-addons/pull/131)
7580
- This version requires your application to use Angular 15
7681
- The framework is now based on Angular Material components using MDC (Material Design Components)
77-
78-
<details><summary>View older changelogs</summary>
79-
8082
- **14.1.6**: Show tooltips in toolbar action burger menu
8183
- **14.1.4**: data-table fixes: action button became too small for tables with a lot of colums
8284
- **14.1.x**: Fix Button Styling for Stepper and Quicklist: change "add" button in Quicklist to "Outline" Styling and "next" and "done" button in MatStepper to "Primary" Styling

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/material-addons/src/lib/layout/toolbar/toolbar-action.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Observable } from 'rxjs';
22
import { ThemePalette } from '@angular/material/core';
3+
import { Params } from '@angular/router';
34

45
export interface Action {
56
matIcon: string;
@@ -17,6 +18,7 @@ export interface MainAction extends Action {
1718

1819
export interface BackAction extends Action {
1920
routerLink?: string;
21+
queryParams?: Params;
2022
href?: string;
2123
action?: () => any;
2224
}

projects/material-addons/src/lib/layout/toolbar/toolbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<mat-toolbar class="content-toolbar">
2-
<a data-cy="back-link-button" [routerLink]="getBackAction().routerLink" *ngIf="isRouterLink(getBackAction())">
2+
<a data-cy="back-link-button" [routerLink]="getBackAction().routerLink" [queryParams]="getBackAction().queryParams" *ngIf="isRouterLink(getBackAction())">
33
<button [id]="'go-back'" color="primary" mat-icon-button class="go-back-button">
44
<mat-icon>{{ getBackAction().matIcon }}</mat-icon>
55
</button>

projects/material-addons/src/lib/layout/toolbar/toolbar.service.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable, OnDestroy } from '@angular/core';
2-
import { NavigationEnd, Router } from '@angular/router';
2+
import { NavigationEnd, Params, Router } from '@angular/router';
33
import { Subscription } from 'rxjs';
44
import { TranslateService } from '@ngx-translate/core';
55
import { BackAction, MainAction, ToolbarAction } from './toolbar-action.interface';
@@ -125,6 +125,18 @@ export class ToolbarService implements OnDestroy {
125125
}
126126
}
127127

128+
/**
129+
* Only supports routerLink (no href), but with additional query parameters
130+
*/
131+
addBackActionRoute(goBackRoute: string, queryParams?: Params): void {
132+
this.backAction = {
133+
matIcon: 'keyboard_backspace',
134+
i18nActionKey: '',
135+
routerLink: goBackRoute,
136+
queryParams: queryParams || {},
137+
};
138+
}
139+
128140
addSimpleBackButton(overrideIfPresent = false): void {
129141
if (this.getBackAction() && !overrideIfPresent) {
130142
return;

0 commit comments

Comments
 (0)