Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore()/update patterns to stackblitz #1064

Merged
merged 16 commits into from
Jan 25, 2018
449 changes: 131 additions & 318 deletions src/app/components/design-patterns/alerts/alerts.component.html

Large diffs are not rendered by default.

70 changes: 4 additions & 66 deletions src/app/components/design-patterns/alerts/alerts.component.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,23 @@
import { Component, HostBinding } from '@angular/core';

import { DomSanitizer } from '@angular/platform-browser';
import { slideInDownAnimation } from '../../../app.animations';

import { TdDialogService } from '../../../../platform/core';
import { TdCollapseAnimation } from '@covalent/core/common';

import { MatSnackBar } from '@angular/material/snack-bar';

@Component({
selector: 'design-patterns-alerts',
styleUrls: ['./alerts.component.scss'],
templateUrl: './alerts.component.html',
animations: [
slideInDownAnimation,
TdCollapseAnimation(),
],
})
export class AlertsComponent {

@HostBinding('@routeAnimation') routeAnimation: boolean = true;
@HostBinding('class.td-route-animation') classAnimation: boolean = true;

firstName: string;
lastName: string;
address: string;
city: string;
state: string;
zip: string;
example1: boolean = true;
example2: boolean = true;
example3: boolean = true;
source: any = '';

constructor(private _dialogService: TdDialogService,
private _snackBarService: MatSnackBar) {}

showSnackBar(): void {
this._snackBarService
.open('Connection timed out. Showing limited messages.', 'Retry', { duration: 3000 });
}
openAlert(): void {
this._dialogService.openAlert({
message: 'You don\'t have the required permissions to view this item! Contact an administrator!',
disableClose: true,
title: '401 Permissions Error!',
closeButton: 'Ok',
});
}
openConfirm(): void {
this._dialogService.openConfirm({
message: 'Are you sure you want to delete this item? It\'s used on other items.',
title: 'Confirm',
cancelButton: 'Cancel',
acceptButton: 'Delete',
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
this.confirmDelete();
} else {
// DO SOMETHING ELSE
}
});
}
confirmDelete(): void {
this._snackBarService.open('Item deleted', '', { duration: 3000 });
}
openPrompt(): void {
this._dialogService.openPrompt({
message: 'This is how simple it is to create a prompt with this wrapper service. Prompt something.',
title: 'Prompt',
value: 'Prepopulated value',
cancelButton: 'Cancel',
acceptButton: 'Ok',
}).afterClosed().subscribe((newValue: string) => {
if (newValue) {
// DO SOMETHING
} else {
// DO SOMETHING ELSE
}
});
}

toggle(div: string ): void {
this[div] = !this[div];
constructor(private sanitizer: DomSanitizer) {
this.source = sanitizer.bypassSecurityTrustResourceUrl('https://alert-patterns.stackblitz.io/');
}
}
Loading