widgets: RRuleOptions to match RecurData in ical.js from etesync IOS

master
Tal Leibman 5 years ago committed by Tom Hacohen
parent 47ba581a24
commit 3f1194f8bd

@ -18,13 +18,17 @@ export interface RRuleOptions {
byweekno?: number; byweekno?: number;
bymonth?: Months; bymonth?: Months;
bysetpos?: number; bysetpos?: number;
} wkst?: Weekday;
bysecond?: number[];
byminute?: number[];
byday?: number[];
}
enum Frequency { enum Frequency {
Year = 0, YEARLY,
Month = 1, MONTHLY,
Week = 2, WEEKLY,
Day = 3, DAILY,
} }
enum Ends { enum Ends {
Never, Never,
@ -70,7 +74,7 @@ const menuItemsEnds = [Ends.Never, Ends.Date, Ends.After].map((key) => {
); );
}); });
const weekdays = [Weekday.Mo, Weekday.Tu, Weekday.We, Weekday.Th, Weekday.Fr, Weekday.Sa, Weekday.Su]; const weekdays = [Weekday.Mo, Weekday.Tu, Weekday.We, Weekday.Th, Weekday.Fr, Weekday.Sa, Weekday.Su];
const menuItemsFrequency = [Frequency.Year, Frequency.Month, Frequency.Week, Frequency.Day].map((value) => { const menuItemsFrequency = [Frequency.YEARLY, Frequency.MONTHLY, Frequency.WEEKLY, Frequency.DAILY].map((value) => {
return ( return (
<MenuItem key={value} value={value}>{Frequency[value]}</MenuItem> <MenuItem key={value} value={value}>{Frequency[value]}</MenuItem>
); );
@ -164,9 +168,9 @@ export default function RRuleEteSync(props: PropsType) {
const updatedOptions = { const updatedOptions = {
freq: freq, freq: freq,
bysetpos: undefined, bysetpos: undefined,
bymonthday: freq === Frequency.Month || Frequency.Year === freq ? 1 : undefined, bymonthday: freq === Frequency.MONTHLY || Frequency.YEARLY === freq ? 1 : undefined,
byweekday: undefined, byweekday: undefined,
bymonth: freq === Frequency.Year ? Months.Jan : undefined, bymonth: freq === Frequency.YEARLY ? Months.Jan : undefined,
}; };
updateRule(updatedOptions); updateRule(updatedOptions);
}} }}
@ -176,7 +180,7 @@ export default function RRuleEteSync(props: PropsType) {
</div> </div>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{(options.freq === Frequency.Month) && {(options.freq === Frequency.MONTHLY) &&
<Select <Select
value={options.bysetpos ? MonthRepeat.Bysetpos : MonthRepeat.Bymonthday} value={options.bysetpos ? MonthRepeat.Bysetpos : MonthRepeat.Bymonthday}
onChange={(event: React.FormEvent<{ value: unknown }>) => { onChange={(event: React.FormEvent<{ value: unknown }>) => {
@ -207,7 +211,7 @@ export default function RRuleEteSync(props: PropsType) {
<MenuItem value={-1}>Last</MenuItem> <MenuItem value={-1}>Last</MenuItem>
</Select> </Select>
} }
{(options.freq === Frequency.Year && options.bymonth) && {(options.freq === Frequency.YEARLY && options.bymonth) &&
<Select <Select
value={options.bymonth} value={options.bymonth}
onChange={(event: React.FormEvent<{ value: unknown }>) => { onChange={(event: React.FormEvent<{ value: unknown }>) => {
@ -238,7 +242,7 @@ export default function RRuleEteSync(props: PropsType) {
} }
</div> </div>
<div> <div>
{options.freq !== Frequency.Day && {options.freq !== Frequency.DAILY &&
<FormGroup row>{checkboxWeekDays}</FormGroup> <FormGroup row>{checkboxWeekDays}</FormGroup>
} }
<FormControl> <FormControl>

Loading…
Cancel
Save