[ADF-3286] Snackbar now supports custom configuration (#3549)

* [ADF-3286] Snackbar now supports custom configuration

* [ADF-3286] Trailing whitespace removed

* [ADF-3286] Tests added

* [ADF-3286] Improved tests

* [ADF-3286] Documentation added

* [ADF-3286]  Logic improved

* [ADF-3286] Styling error fixed

* [ADF-3286] Broken tests fixed

* [ADF-3286] Broken tests fixed
This commit is contained in:
davidcanonieto
2018-07-06 16:19:20 +02:00
committed by Eugenio Romano
parent 495f9937fe
commit a6a77b8561
5 changed files with 243 additions and 22 deletions

View File

@@ -14,16 +14,17 @@ Shows a notification message with optional feedback.
### Methods
- **openSnackMessage**(message: `string` = `null`, millisecondsDuration?: `number` = `null`): [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>`<br/>
- **openSnackMessage**(message: `string` = `null`, config?: `number` | [`MatSnackBarConfig`](https://v5.material.angular.io/components/snack-bar/api#MatSnackBarConfig) = `null`): [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>`<br/>
Opens a SnackBar notification to show a message.
- _message:_ `string` - The message (or resource key) to show.
- _millisecondsDuration:_ `number` - (Optional) Time before notification disappears after being shown
- **Returns** [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>` - Information/control object for the SnackBar
- **openSnackMessageAction**(message: `string` = `null`, action: `string` = `null`, millisecondsDuration?: `number` = `null`): [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>`<br/>
- _config:_ `number` - (Optional) Time before notification disappears after being shown or [`MatSnackBarConfig`](https://v5.material.angular.io/components/snack-bar/api#MatSnackBarConfig) object to fully customize SnackBar
- **Returns** [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>` - Information/control object for the SnackBar
<br/>
- **openSnackMessageAction**(message: `string` = `null`, action: `string` = `null`, config?: `number` | [`MatSnackBarConfig`](https://v5.material.angular.io/components/snack-bar/api#MatSnackBarConfig) = `null`): [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>`<br/>
Opens a SnackBar notification with a message and a response button.
- _message:_ `string` - The message (or resource key) to show.
- _action:_ `string` - Caption for the response button
- _millisecondsDuration:_ `number` - (Optional) Time before the notification disappears (unless the button is clicked)
- _config:_ `number` - (Optional) Time before notification disappears after being shown or [`MatSnackBarConfig`](https://v5.material.angular.io/components/snack-bar/api#MatSnackBarConfig) object to fully customize SnackBar
- **Returns** [`MatSnackBarRef`](https://material.angular.io/components/snack-bar/overview)`<any>` - Information/control object for the SnackBar
## Details
@@ -68,3 +69,25 @@ export class MyComponent implements OnInit {
}
}
```
```ts
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material';
export class MyComponent implements OnInit {
snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();
constructor(private notificationService: NotificationService) {
}
ngOnInit() {
this.notificationService
.openSnackMessageAction('Do you want to report this issue?', 'send', snackBarConfig)
.afterDismissed()
.subscribe(() => {
console.log('The snack-bar was dismissed');
});
}
}
```