1- import { autoinject } from 'aurelia-framework' ;
1+ import { autoinject , PLATFORM } from 'aurelia-framework' ;
22import { ValidationControllerFactory , ValidationController , validateTrigger , ValidationRules } from 'aurelia-validation' ;
33import { DialogService } from 'aurelia-dialog' ;
44
55import { LogManager , Logger } from './../../services/logger.service' ;
66import { AppConfigService } from './../../services/app-config.service' ;
77import { LanguageService } from './../../services/language.service' ;
88import { EditPersonCustomElement } from './../../resources/elements/edit-person/edit-person.element' ;
9+ import { GenericDialogService } from './../../services/generic-dialog.service' ;
10+ import { ShowPersonCustomElement } from '../../resources/elements/show-person/show-person.element' ;
911
1012@autoinject
1113export class WelcomeViewModel {
@@ -24,7 +26,8 @@ export class WelcomeViewModel {
2426 private appConfigService : AppConfigService ,
2527 private languageService : LanguageService ,
2628 private dialogService : DialogService ,
27- validationControllerFactory : ValidationControllerFactory
29+ validationControllerFactory : ValidationControllerFactory ,
30+ private genericDialogService : GenericDialogService ,
2831 ) {
2932 this . logger = LogManager . getLogger ( 'Welcome VM' ) ;
3033 this . logger . info ( 'appConfig => name:' , this . appConfigService . getName ( ) ) ;
@@ -86,6 +89,31 @@ export class WelcomeViewModel {
8689 this . languageService . setLocale ( this . languageService . getSupportedLanguages ( ) [ 0 ] ) ;
8790 }
8891 }
92+
93+ public openGenericDialog ( ) : void {
94+ const dialog = this . genericDialogService . showDialog < ShowPersonCustomElement > ( {
95+ title : 'Zeige Person' , // Can be a translation string
96+ contentViewModel : PLATFORM . moduleName ( 'resources/elements/show-person/show-person.element' ) ,
97+ contentModel : {
98+ firstName : this . firstName
99+ } ,
100+ buttons : [
101+ GenericDialogService . createCancelButton < ShowPersonCustomElement > ( ( ) => Promise . resolve ( ) ) ,
102+ GenericDialogService . createSaveButton < ShowPersonCustomElement > ( ele => {
103+ this . logger . debug ( 'Clicked on save in dialog' , ele ) ;
104+ return Promise . resolve ( ) ;
105+ } , ele => ele . isValid )
106+ ]
107+ } ) ;
108+
109+ dialog . whenClosed ( result => {
110+ if ( ! result . wasCancelled ) {
111+ this . logger . debug ( 'Dialog not canceld' , result ) ;
112+ } else {
113+ this . logger . debug ( 'Dialog canceld' , result ) ;
114+ }
115+ } ) ;
116+ }
89117}
90118
91119export class UpperValueConverter {
0 commit comments