@@ -102,21 +102,6 @@ const createTimeZoneDataSource = (): DataSource => new DataSource({
102102
103103const MAIN_GROUP_NAME = 'mainGroup' ;
104104
105- /*
106- MainForm
107- - recurrenceExpr: 'FREQ=DAILY...'
108- - Should update repeatEditors state (buttons and value) in these cases:
109- 1. repeat editor valueChanged
110- 2. repeat editor contentReady
111- 3. form.optionChange
112- 4. recurrence form saved
113- - We don't update recurrenceExpr just when repeatEditor's value changed
114-
115- RecurrenceForm
116- - contains RecurrenceRule object
117- - Should update formData.recurrenceExpr on MainForm when save is pressed
118- */
119-
120105export class AppointmentForm {
121106 private readonly scheduler : any ;
122107
@@ -142,9 +127,6 @@ export class AppointmentForm {
142127
143128 set formData ( formData : Record < string , any > ) {
144129 this . dxForm . option ( 'formData' , formData ) ;
145-
146- const repeatEditorValue = this . dxForm . getEditor ( EDITOR_NAMES . repeat ) ?. option ( 'value' ) ;
147- this . _recurrentForm . updateRecurrenceFormValues ( repeatEditorValue , this . recurrenceRuleRaw ) ;
148130 }
149131
150132 get startDate ( ) : Date | null {
@@ -176,13 +158,11 @@ export class AppointmentForm {
176158 this . scheduler = scheduler ;
177159 }
178160
179- // TODO: remove this method
180- reset ( ) : void {
181- if ( this . _dxForm ) {
182- const repeatEditor = this . _dxForm . getEditor ( EDITOR_NAMES . repeat ) ;
183- if ( repeatEditor ) {
184- repeatEditor . option ( 'value' , 'never' ) ;
185- }
161+ dispose ( ) : void {
162+ this . _dxForm ?. dispose ( ) ;
163+ this . _dxForm = undefined ;
164+ if ( this . _recurrentForm ) {
165+ this . _recurrentForm . dxForm = undefined ;
186166 }
187167 }
188168
@@ -582,7 +562,7 @@ export class AppointmentForm {
582562 if ( e . value === repeatNeverValue ) {
583563 const { recurrenceRuleExpr } = this . scheduler . getDataAccessors ( ) . expr ;
584564 this . dxForm . updateData ( recurrenceRuleExpr , '' ) ;
585- } else {
565+ } else if ( e . event ) {
586566 this . showRecurrenceGroup ( ) ;
587567 }
588568 } ,
@@ -696,7 +676,6 @@ export class AppointmentForm {
696676 showRecurrenceGroup ( ) : void {
697677 this . _isRecurrenceFormVisible = true ;
698678
699- // TODO: it better to store these group elements in the class fields
700679 const $formElement = $ ( this . dxForm . element ( ) ) ;
701680 const mainGroup = $formElement . find ( `.${ CLASSES . mainGroupClass } ` ) ;
702681 const recurrenceGroup = $formElement . find ( `.${ CLASSES . recurrenceGroup } ` ) ;
@@ -706,7 +685,11 @@ export class AppointmentForm {
706685
707686 const repeatEditorValue = this . dxForm . getEditor ( EDITOR_NAMES . repeat ) ?. option ( 'value' ) ;
708687
709- this . _recurrentForm . updateRecurrenceFormValues ( repeatEditorValue , this . recurrenceRuleRaw ) ;
688+ this . _recurrentForm . updateRecurrenceFormValues (
689+ repeatEditorValue ,
690+ this . recurrenceRuleRaw ,
691+ this . startDate ,
692+ ) ;
710693
711694 this . _popup . updateToolbarForRecurrenceGroup ( ) ;
712695 }
@@ -724,30 +707,14 @@ export class AppointmentForm {
724707 this . _isRecurrenceFormVisible = false ;
725708
726709 if ( saveRecurrenceValue ) {
710+ const { recurrenceRule } = this . _recurrentForm ;
727711 const { recurrenceRuleExpr } = this . scheduler . getDataAccessors ( ) . expr ;
712+
728713 this . dxForm . updateData (
729714 recurrenceRuleExpr ,
730- this . _recurrentForm . recurrenceRule . getRecurrenceString ( ) ?? undefined ,
715+ recurrenceRule . toString ( ) ?? undefined ,
731716 ) ;
732-
733- // const repeatEditor = this.dxForm.getEditor(EDITOR_NAMES.repeat);
734-
735- // if (repeatEditor) {
736- // const { freq } = this._recurrenceRule.getRules();
737-
738- // if (freq) {
739- // const freqValue = freq.toLowerCase();
740- // repeatEditor.option('value', freqValue);
741-
742- // const buttons = this.getRepeatEditorButtons();
743- // repeatEditor.option('buttons', buttons);
744- // } else {
745- // repeatEditor.option('value', 'never');
746- // repeatEditor.option('buttons', this.getRepeatEditorButtons());
747- // }
748- // }
749- // } else if (!saveChanges) {
750- // this._recurrentForm.tempRecurrenceRule = undefined;
717+ this . dxForm . getEditor ( EDITOR_NAMES . startDate ) ?. option ( 'value' , recurrenceRule . startDate ) ;
751718 }
752719 }
753720
@@ -773,9 +740,9 @@ export class AppointmentForm {
773740 if ( this . recurrenceRuleRaw === null ) {
774741 repeatEditor . option ( 'value' , repeatNeverValue ) ;
775742 } else {
776- const recurrenceRule = new RecurrenceRule ( this . recurrenceRuleRaw ) ;
777- const freq = recurrenceRule . getRule ( 'freq' ) ;
778- const value = freq ? ( freq as string ) . toLowerCase ( ) : repeatNeverValue ;
743+ const recurrenceRule = new RecurrenceRule ( this . recurrenceRuleRaw , this . startDate ) ;
744+ const { frequency } = recurrenceRule ;
745+ const value = frequency ?? repeatNeverValue ;
779746
780747 repeatEditor . option ( 'value' , value ) ;
781748 }
0 commit comments