From c7c8b09e414608982bc61882efe017d45c15e5a7 Mon Sep 17 00:00:00 2001 From: Tal Leibman Date: Sun, 12 Jan 2020 19:09:31 +0200 Subject: [PATCH] widgets: RRule layout and styles --- src/widgets/RRule.tsx | 163 ++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 79 deletions(-) diff --git a/src/widgets/RRule.tsx b/src/widgets/RRule.tsx index 46b5997..e89de14 100644 --- a/src/widgets/RRule.tsx +++ b/src/widgets/RRule.tsx @@ -100,6 +100,10 @@ const menuItemsWeekDays = weekdays.map((day) => { {WeekDay[day]} ); }); +const styles = { + multiSelect: { minWidth: 120, maxWidth: '100%' }, + width: { width: 120 }, +}; export default function RRuleEteSync(props: PropsType) { const options = props.rrule; function updateRule(newOptions: Partial): void { @@ -148,25 +152,6 @@ export default function RRuleEteSync(props: PropsType) { {menuItemsFrequency} - {options.bymonthday && - ) => { - event.preventDefault(); - const value = (event.currentTarget as HTMLInputElement).value; - const numberValue = Number(value); - if (value === '') { - updateRule({ bymonthday: undefined }); - } else if (numberValue < 32 && numberValue > 0) { - updateRule({ bymonthday: [numberValue] }); - } - }} - /> - } { !disableComplex &&
{(options.freq === 'MONTHLY') && @@ -193,26 +178,56 @@ export default function RRuleEteSync(props: PropsType) { Last }
} + + Ends + + + {options.until && + { + const value = date ? date : null; + updateRule({ until: ICAL.Time.fromJSDate(value, true) }); + }} + /> + } + {options.count && + ) => { + event.preventDefault(); + const inputNode = event.currentTarget as HTMLInputElement; + if (inputNode.value === '') { + updateRule({ count: 1 }); + } else if (inputNode.valueAsNumber) { + updateRule({ count: inputNode.valueAsNumber }); + } + }} + /> + }
- {options.freq === 'YEARLY' && -
- - Months - - -
- } {(options.freq && options.freq !== 'DAILY') &&
@@ -220,7 +235,7 @@ export default function RRuleEteSync(props: PropsType) { ) => { - const value = Number((event.target as HTMLSelectElement).value); - let updateOptions; - if (value === Ends.Date) { - updateOptions = { count: undefined, until: ICAL.Time.now() }; - } else if (value === Ends.After) { - updateOptions = { until: undefined, count: 1 }; - } else { - updateOptions = { count: undefined, until: undefined }; - } - updateRule(updateOptions); - }}> - {menuItemsEnds} - - - {options.until && - { - const value = date ? date : null; - updateRule({ until: ICAL.Time.fromJSDate(value, true) }); - }} - /> - } - {options.count && + {options.freq === 'MONTHLY' && ) => { event.preventDefault(); - const inputNode = event.currentTarget as HTMLInputElement; - if (inputNode.value === '') { - updateRule({ count: 1 }); - } else if (inputNode.valueAsNumber) { - updateRule({ count: inputNode.valueAsNumber }); + const value = (event.currentTarget as HTMLInputElement).value; + const numberValue = Number(value); + if (value === '') { + updateRule({ bymonthday: undefined }); + } else if (numberValue < 32 && numberValue > 0) { + updateRule({ bymonthday: [numberValue] }); } }} /> } + {options.freq === 'YEARLY' && +
+ + Months + + +
+ }
);