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

feat(dialogs): extend MatDialogConfig to leverage all the dialog config (closes #1011) #1059

Merged
merged 5 commits into from
Jan 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/components/components/dialogs/dialogs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h3>Example(after setup):</h3>
viewContainerRef: this._viewContainerRef, //OPTIONAL
title: 'Alert', //OPTIONAL, hides if not provided
closeButton: 'Close', //OPTIONAL, defaults to 'CLOSE'
width: '400px', //OPTIONAL
});
}

Expand All @@ -59,6 +60,7 @@ <h3>Example(after setup):</h3>
title: 'Confirm', //OPTIONAL, hides if not provided
cancelButton: 'Disagree', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Agree', //OPTIONAL, defaults to 'ACCEPT'
width: '400px', //OPTIONAL
}).afterClosed().subscribe((accept: boolean) => {
if (accept) {
// DO SOMETHING
Expand All @@ -77,6 +79,7 @@ <h3>Example(after setup):</h3>
value: 'Prepopulated value', //OPTIONAL
cancelButton: 'Cancel', //OPTIONAL, defaults to 'CANCEL'
acceptButton: 'Ok', //OPTIONAL, defaults to 'ACCEPT'
width: '400px', //OPTIONAL
}).afterClosed().subscribe((newValue: string) => {
if (newValue) {
// DO SOMETHING
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/components/dialogs/dialogs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DialogsDemoComponent {
title: 'Alert',
disableClose: true,
message: 'This is how simple it is to create an alert with this wrapper service.',
width: '400px',
});
}

Expand All @@ -55,6 +56,7 @@ export class DialogsDemoComponent {
message: 'This is how simple it is to create a confirm with this wrapper service. Do you agree?',
cancelButton: 'Disagree',
acceptButton: 'Agree',
width: '400px',
});
}

Expand All @@ -65,6 +67,7 @@ export class DialogsDemoComponent {
value: 'Populated value',
cancelButton: 'Cancel',
acceptButton: 'Ok',
width: '400px',
});
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
.td-dialog-message {
word-break: break-word;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
.td-dialog-message {
word-break: break-word;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
@media (min-width: 600px) {
td-dialog {
width: 400px;
}
}
@media (max-width: 599px) {
td-dialog {
width: 250px;
}
}
.td-dialog-input-wrapper {
// layout row
flex-direction: row;
Expand All @@ -19,3 +9,7 @@
box-sizing: border-box;
}
}

.td-dialog-message {
word-break: break-word;
}
9 changes: 4 additions & 5 deletions src/platform/core/dialogs/services/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { TdAlertDialogComponent } from '../alert-dialog/alert-dialog.component';
import { TdConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component';
import { TdPromptDialogComponent } from '../prompt-dialog/prompt-dialog.component';

export interface IDialogConfig {
export interface IDialogConfig extends MatDialogConfig {
title?: string;
message: string;
viewContainerRef?: ViewContainerRef;
disableClose?: boolean;
}

export interface IAlertConfig extends IDialogConfig {
Expand Down Expand Up @@ -137,8 +135,9 @@ export class TdDialogService {

private _createConfig(config: MatDialogConfig): MatDialogConfig {
let dialogConfig: MatDialogConfig = new MatDialogConfig();
dialogConfig.viewContainerRef = config.viewContainerRef;
dialogConfig.disableClose = config.disableClose;
for (let key in config) {
dialogConfig[key] = config[key];
}
return dialogConfig;
}

Expand Down