rrule: fix spacing and locations of code.

master
Tom Hacohen 5 years ago
parent 16255e4cad
commit 8440cac7e8

@ -3,12 +3,6 @@ import { TextField, Select, MenuItem, FormControlLabel, InputLabel, FormControl
import DateTimePicker from '../widgets/DateTimePicker'; import DateTimePicker from '../widgets/DateTimePicker';
import * as ICAL from 'ical.js'; import * as ICAL from 'ical.js';
interface PropsType {
onChange: (rrule: RRuleOptions) => void;
rrule: RRuleOptions;
}
const disableComplex = true;
export type RRuleOptions = ICAL.RecurData; export type RRuleOptions = ICAL.RecurData;
enum Ends { enum Ends {
@ -16,6 +10,7 @@ enum Ends {
Date, Date,
After, After,
} }
enum Months { enum Months {
Jan = 1, Jan = 1,
Feb, Feb,
@ -30,10 +25,12 @@ enum Months {
Nov, Nov,
Dec, Dec,
} }
enum MonthRepeat { enum MonthRepeat {
Bysetpos, Bysetpos,
Bymonthday, Bymonthday,
} }
enum WeekDay { enum WeekDay {
Su = 1, Su = 1,
Mo, Mo,
@ -44,14 +41,16 @@ enum WeekDay {
Sa, Sa,
} }
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.Never, Ends.Date, Ends.After].map((key) => {
return ( return (
<MenuItem key={key} value={key}>{Ends[key]}</MenuItem> <MenuItem key={key} value={key}>{Ends[key]}</MenuItem>
); );
}); });
const weekdays: WeekDay[] = Array.from(Array(7)).map((_, i) => i + 1);
const months: Months[] = Array.from(Array(12)).map((_, i) => i + 1);
const menuItemsFrequency = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY'].map((value) => { const menuItemsFrequency = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY'].map((value) => {
return ( return (
<MenuItem key={value} value={value}>{value.toLowerCase()}</MenuItem> <MenuItem key={value} value={value}>{value.toLowerCase()}</MenuItem>
@ -67,10 +66,17 @@ const menuItemsWeekDays = weekdays.map((day) => {
<MenuItem key={day} value={WeekDay[day].toUpperCase()}>{WeekDay[day]}</MenuItem> <MenuItem key={day} value={WeekDay[day].toUpperCase()}>{WeekDay[day]}</MenuItem>
); );
}); });
const styles = { const styles = {
multiSelect: { minWidth: 120, maxWidth: '100%' }, multiSelect: { minWidth: 120, maxWidth: '100%' },
width: { width: 120 }, width: { width: 120 },
}; };
interface PropsType {
onChange: (rrule: RRuleOptions) => void;
rrule: RRuleOptions;
}
export default function RRule(props: PropsType) { export default function RRule(props: PropsType) {
const options = props.rrule; const options = props.rrule;
function updateRule(newOptions: Partial<RRuleOptions>): void { function updateRule(newOptions: Partial<RRuleOptions>): void {

Loading…
Cancel
Save