11import type { Meta , StoryObj } from "@storybook/react" ;
2- import React from "react" ;
2+ import React , { useRef } from "react" ;
33import dxScheduler from "devextreme/ui/scheduler" ;
44import type { Properties } from "devextreme/ui/scheduler" ;
55import { wrapDxWithReact } from "../utils" ;
@@ -8,6 +8,8 @@ import "./form-customization.css";
88
99const Scheduler = wrapDxWithReact < Properties > ( dxScheduler ) ;
1010
11+ import ReactScheduler from 'devextreme-react/scheduler' ;
12+
1113const iconsShowModeArgType = {
1214 "editing.form.iconsShowMode" : {
1315 control : "radio" ,
@@ -332,21 +334,117 @@ export const RTL: Story = {
332334export const LegacyPopup : Story = {
333335 args : {
334336 ...baseConfig ,
335- "editing.form.iconsShowMode" : "none " ,
337+ "editing.form.iconsShowMode" : "both " ,
336338 } as Properties ,
337339 argTypes : iconsShowModeArgType ,
338340 render : ( args ) => {
341+ let form : any = null ;
342+
343+ const schedulerRef = useRef ( null ) ;
344+
339345 return (
340- < Scheduler
346+ // @ts -ignore
347+ < ReactScheduler
348+ ref = { schedulerRef }
341349 { ...baseConfig }
342350 editing = { {
351+ popup : {
352+ maxWidth : 800 ,
353+ toolbarItems : [
354+ {
355+ toolbar : 'top' ,
356+ location : 'before' ,
357+ text : "Edit Appointment" ,
358+ cssClass : 'dx-toolbar-label' ,
359+ } ,
360+ {
361+ toolbar : 'top' ,
362+ location : 'after' ,
363+ options : {
364+ stylingMode : 'contained' ,
365+ type : 'default' ,
366+ onClick : ( ) => {
367+ // @ts -ignore
368+ schedulerRef . current ?. instance ( ) ?. hideAppointmentPopup ( true ) ;
369+ } ,
370+ text : 'Save' ,
371+ } ,
372+ shortcut : 'done' ,
373+ } ,
374+ {
375+ toolbar : 'top' ,
376+ location : 'after' ,
377+ shortcut : 'cancel' ,
378+ } ,
379+ ] ,
380+ } ,
343381 form : {
382+ onContentReady : function ( e ) {
383+ form = e . component ;
384+ const onValueChanged = form . getEditor ( "startDateEditor" ) . option ( "onValueChanged" ) ;
385+
386+ form . getEditor ( "startDateEditor" ) . option ( "onValueChanged" , ( e ) => {
387+ onValueChanged ( e ) ;
388+ form . getEditor ( "recurrenceStartDateEditor" ) ?. option ( "value" , e . value ) ;
389+ } ) ;
390+ } ,
391+ iconsShowMode : "both" ,
344392 items : [
345- "mainGroup" ,
346- { name : 'recurenceGroup' , visible : true }
393+ {
394+ name : "mainGroup" ,
395+ cssClass : "" ,
396+ items : [
397+ "subjectGroup" ,
398+ "dateGroup" ,
399+ {
400+ name : "repeatGroup" ,
401+ items : [
402+ "repeatIcon" ,
403+ {
404+ name : "customRepeatEditor" ,
405+ editorType : "dxSwitch" ,
406+ editorOptions : {
407+ onValueChanged : ( e ) => {
408+ if ( e . value === true ) {
409+ form . option ( "colCount" , 2 ) ;
410+ form . itemOption ( "recurrenceGroup" , "cssClass" , "" ) ;
411+
412+ const onValueChanged = form . getEditor ( "repeatEditor" ) . option ( "onValueChanged" ) ;
413+ form . getEditor ( "repeatEditor" ) . option ( "value" , "daily" ) ;
414+ onValueChanged ( { ...e , value : "daily" } ) ;
415+ } else {
416+ form . option ( "colCount" , 1 ) ;
417+ form . itemOption ( "recurrenceGroup" , "cssClass" , "dx-hidden" ) ;
418+
419+ const onValueChanged = form . getEditor ( "repeatEditor" ) . option ( "onValueChanged" ) ;
420+ form . getEditor ( "repeatEditor" ) . option ( "value" , "never" ) ;
421+ onValueChanged ( { ...e , value : "never" } ) ;
422+ }
423+
424+ form . getEditor ( "customRepeatEditor" ) . option ( "value" , e . value ) ;
425+ } ,
426+ } ,
427+ } ,
428+ { name : "repeatEditor" , colCount : 0 , cssClass : "dx-hidden" } ,
429+ ] ,
430+ } ,
431+ "resourcesGroup" ,
432+ "descriptionGroup" ,
433+ ] ,
434+ } ,
435+ {
436+ name : "recurrenceGroup" ,
437+ itemType : "group" ,
438+ items : [
439+ {
440+ name : "recurrenceStartDateEditor" ,
441+ } ,
442+ "recurrenceRuleGroup" ,
443+ "recurrenceEndGroup" ,
444+ ] ,
445+ } ,
347446 ] ,
348- iconsShowMode : args [ "editing.form.iconsShowMode" ]
349- }
447+ } ,
350448 } as Properties [ 'editing' ] }
351449 />
352450 ) ;
0 commit comments