@@ -46,17 +46,43 @@ export class AppComponent {
4646
4747 theatreData : TheatreData [ ] ;
4848
49+ views : string [ ] = [ 'day' , 'week' , 'timelineDay' ] ;
50+
51+ groups : string [ ] = [ 'theatreId' ] ;
52+
4953 formInstance : dxForm | null = null ;
5054
5155 currentSelectedMovie : MovieData | null = null ;
5256
57+ movieEditorOptions : DxSelectBoxTypes . Options ;
58+
59+ priceEditorOptions : DxSelectBoxTypes . Options ;
60+
5361 constructor ( service : Service ) {
5462 this . data = service . getData ( ) ;
5563 this . moviesData = service . getMoviesData ( ) ;
5664 this . theatreData = service . getTheatreData ( ) ;
65+
66+ this . movieEditorOptions = {
67+ items : this . moviesData ,
68+ displayExpr : 'text' ,
69+ valueExpr : 'id' ,
70+ stylingMode : this . getEditorStylingMode ( ) ,
71+ onValueChanged : this . onMovieValueChanged ,
72+ onContentReady : this . onCustomEditorContentReady ,
73+ } ;
74+
75+ this . priceEditorOptions = {
76+ items : [ 5 , 10 , 15 , 20 ] ,
77+ displayExpr : this . priceDisplayExpr ,
78+ stylingMode : this . getEditorStylingMode ( ) ,
79+ onContentReady : this . onCustomEditorContentReady ,
80+ } ;
5781 }
5882
59- getMovieById = ( id : number ) : MovieData | undefined => query ( this . moviesData ) . filter ( [ 'id' , '=' , id ] ) . toArray ( ) [ 0 ] ;
83+ getMovieById = ( id : number | undefined ) : MovieData | undefined => id
84+ ? query ( this . moviesData ) . filter ( [ 'id' , '=' , id ] ) . toArray ( ) [ 0 ]
85+ : null ;
6086
6187 getEditorStylingMode = ( ) : 'filled' | 'outlined' => {
6288 const isMaterialOrFluent = document . querySelector ( '.dx-theme-fluent, .dx-theme-material' ) ;
@@ -65,23 +91,7 @@ export class AppComponent {
6591
6692 priceDisplayExpr = ( value : number ) : string => `$${ value } ` ;
6793
68- onMovieValueChanged = ( e : DxSelectBoxTypes . ValueChangedEvent ) : void => {
69- const movie = this . getMovieById ( e . value ) ;
70- this . currentSelectedMovie = movie ;
71-
72- if ( this . formInstance && movie ) {
73- this . formInstance . updateData ( 'director' , movie . director ) ;
74- this . updateEndDate ( this . formInstance , movie ) ;
75- }
76- } ;
77-
78- onMovieEditorContentReady = ( e : DxSelectBoxTypes . ContentReadyEvent ) : void => {
79- e . component . option ( 'stylingMode' , this . getEditorStylingMode ( ) ) ;
80- } ;
81-
82- onPriceEditorContentReady = ( e : DxSelectBoxTypes . ContentReadyEvent ) : void => {
83- e . component . option ( 'stylingMode' , this . getEditorStylingMode ( ) ) ;
84- } ;
94+ colCountByScreen = { xs : 2 } ;
8595
8696 onPopupOptionChanged = ( e : DxPopupTypes . OptionChangedEvent ) : void => {
8797 if ( e . fullName === 'toolbarItems' && e . value ) {
@@ -93,39 +103,55 @@ export class AppComponent {
93103 }
94104 } ;
95105
96- updateEndDate = ( form : dxForm , movie : MovieData ) : void => {
106+ popupOptions : DxPopupTypes . Options = {
107+ maxWidth : 440 ,
108+ onOptionChanged : this . onPopupOptionChanged ,
109+ } ;
110+
111+ updateEndDate = ( movie : MovieData ) : void => {
112+ const form = this . formInstance ! ;
97113 const formData = form . option ( 'formData' ) ;
98114 const { startDate } = formData ;
99- if ( startDate && movie ?. duration ) {
115+
116+ if ( startDate ) {
100117 const newEndDate = new Date ( startDate . getTime ( ) + 60 * 1000 * movie . duration ) ;
101118 form . updateData ( 'endDate' , newEndDate ) ;
102119 }
103120 } ;
104121
105122 onFormInitialized = ( e : DxFormTypes . InitializedEvent ) : void => {
123+ console . log ( 'form initialized' ) ;
106124 const form = e . component ;
107- this . formInstance = form ;
108-
109125 const formData = form . option ( 'formData' ) ;
110- if ( formData ?. movieId ) {
111- const movie = this . getMovieById ( formData . movieId ) ;
112- this . currentSelectedMovie = movie ;
113- } else {
114- this . currentSelectedMovie = null ;
115- }
126+
127+ this . formInstance = form ;
128+ this . currentSelectedMovie = this . getMovieById ( formData ?. movieId ) ;
116129
117130 form . on ( 'fieldDataChanged' , ( fieldEvent : DxFormTypes . FieldDataChangedEvent ) => {
118131 if ( fieldEvent . dataField === 'startDate' ) {
119132 const currentFormData = form . option ( 'formData' ) ;
120- if ( currentFormData . movieId ) {
121- const movie = this . getMovieById ( currentFormData . movieId ) ;
122- if ( movie ) {
123- this . updateEndDate ( form , movie ) ;
124- }
133+ const movie = this . getMovieById ( currentFormData ?. movieId ) ;
134+
135+ if ( movie ) {
136+ this . updateEndDate ( movie ) ;
125137 }
126138 }
127139 } ) ;
128140 } ;
141+
142+ onMovieValueChanged = ( e : DxSelectBoxTypes . ValueChangedEvent ) : void => {
143+ const movie = this . getMovieById ( e . value ) ;
144+ this . currentSelectedMovie = movie ;
145+
146+ if ( movie ) {
147+ this . formInstance . updateData ( 'director' , movie . director ) ;
148+ this . updateEndDate ( movie ) ;
149+ }
150+ } ;
151+
152+ onCustomEditorContentReady = ( e : DxSelectBoxTypes . ContentReadyEvent ) : void => {
153+ e . component . option ( 'stylingMode' , this . getEditorStylingMode ( ) ) ;
154+ } ;
129155}
130156
131157@NgModule ( {
0 commit comments