diff --git a/src/widgets/RRule.tsx b/src/widgets/RRule.tsx index e532400..a916d7b 100644 --- a/src/widgets/RRule.tsx +++ b/src/widgets/RRule.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; -import { TextField, Select, MenuItem, FormControlLabel, InputLabel, FormControl } from '@material-ui/core'; +import { TextField, Select, MenuItem, InputLabel, FormControl } from '@material-ui/core'; import DateTimePicker from '../widgets/DateTimePicker'; import * as ICAL from 'ical.js'; export type RRuleOptions = ICAL.RecurData; enum Ends { - Never, - Date, + Forever, + Until, After, } @@ -46,9 +46,22 @@ const disableComplex = true; const weekdays: WeekDay[] = Array.from(Array(7)).map((_, i) => i + 1); const months: Months[] = Array.from(Array(12)).map((_, i) => i + 1); -const menuItemsEnds = [Ends.Never, Ends.Date, Ends.After].map((key) => { +const menuItemsEnds = [Ends.Forever, Ends.Until, Ends.After].map((key) => { + let displayhName; + switch (key) { + case Ends.Forever: + displayhName = 'Forever'; + break; + case Ends.Until: + displayhName = 'Until'; + break; + case Ends.After: + displayhName = 'For'; + break; + } + return ( - {Ends[key]} + {displayhName} ); }); const menuItemsFrequency = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY'].map((value) => { @@ -93,37 +106,17 @@ export default function RRule(props: PropsType) { } function getEnds(): Ends { if (options.until && !options.count) { - return Ends.Date; + return Ends.Until; } else if (!options.until && options.count) { return Ends.After; } else { - return Ends.Never; + return Ends.Forever; } } return ( - <> -
- ) => { - event.preventDefault(); - const inputNode = event.currentTarget as HTMLInputElement; - if (inputNode.value === '') { - updateRule({ interval: 1 }); - } else if (inputNode.valueAsNumber) { - updateRule({ interval: inputNode.valueAsNumber }); - } - }} - />} - /> +
+
+ Repeat + every + ) => { + event.preventDefault(); + const inputNode = event.currentTarget as HTMLInputElement; + if (inputNode.value === '') { + updateRule({ interval: 1 }); + } else if (inputNode.valueAsNumber) { + updateRule({ interval: inputNode.valueAsNumber }); + } + }} + />
+ {(options.freq && options.freq !== 'DAILY') && +
+ + Weekdays + + +
+ } {!disableComplex && (
{(options.freq === 'MONTHLY') && @@ -165,73 +191,8 @@ export default function RRule(props: PropsType) { }
)} - - 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 && options.freq !== 'DAILY') && -
- - Weekdays - - -
- } {options.freq === 'MONTHLY' && }
- +
+ + {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 }); + } + }} + /> + events + + } +
+ +
); }