Skip to content

Commit fe42302

Browse files
committed
feat: add legacy storybook
1 parent 59b44e4 commit fe42302

File tree

1 file changed

+105
-7
lines changed

1 file changed

+105
-7
lines changed

apps/react-storybook/stories/scheduler/SchedulerFormCustomization.stories.tsx

Lines changed: 105 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/react";
2-
import React from "react";
2+
import React, { useRef } from "react";
33
import dxScheduler from "devextreme/ui/scheduler";
44
import type { Properties } from "devextreme/ui/scheduler";
55
import { wrapDxWithReact } from "../utils";
@@ -8,6 +8,8 @@ import "./form-customization.css";
88

99
const Scheduler = wrapDxWithReact<Properties>(dxScheduler);
1010

11+
import ReactScheduler from 'devextreme-react/scheduler';
12+
1113
const iconsShowModeArgType = {
1214
"editing.form.iconsShowMode": {
1315
control: "radio",
@@ -332,21 +334,117 @@ export const RTL: Story = {
332334
export 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

Comments
 (0)