Skip to content
Snippets Groups Projects
Commit fb439f9c authored by Tom Robinson's avatar Tom Robinson
Browse files

Fix pulse schedule to match backend changes

parent 8f8a18c4
Branches
Tags
No related merge requests found
......@@ -58,8 +58,20 @@ export default class PulseEdit extends Component {
if (!channelSpec) {
return false;
}
if (!channel.schedule_type) {
// TODO: validate schedule_details?
switch (channel.schedule_type) {
// these cases intentionally fall though
case "weekly": if (channel.schedule_day == null) { return false };
case "daily": if (channel.schedule_hour == null) { return false };
case "hourly": break;
default: return false;
}
if (channel.schedule_type === "weekly") {
} else if (channel.schedule_type === "daily") {
} else if (channel.schedule_type === "hourly") {
} else {
return false;
}
if (channelSpec.recipients) {
......
......@@ -39,7 +39,8 @@ export default class PulseEditChannels extends Component {
recipients: [],
details: details,
schedule_type: channelSpec.schedules[0],
schedule_details: { day_of_week: "mon", hour_of_day: 8 }
schedule_day: "mon",
schedule_hour: 8
};
this.props.setPulse({ ...pulse, channels: pulse.channels.concat(channel) });
......
......@@ -37,18 +37,18 @@ export default class SchedulePicker extends Component {
<span className="mt1">
<span className="h4 text-bold mx1">on</span>
<Select
value={_.find(DAY_OF_WEEK_OPTIONS, (o) => o.value === c.schedule_details.day_of_week)}
value={_.find(DAY_OF_WEEK_OPTIONS, (o) => o.value === c.schedule_day)}
options={DAY_OF_WEEK_OPTIONS}
optionNameFn={o => o.name}
optionValueFn={o => o.value}
onChange={(o) => this.props.onPropertyChange("schedule_details", { ...c.schedule_details, day_of_week: o }) }
onChange={(o) => this.props.onPropertyChange("schedule_day", o) }
/>
</span>
);
}
renderHourPicker(c) {
let hourOfDay = isNaN(c.schedule_details.hour_of_day) ? 8 : c.schedule_details.hour_of_day;
let hourOfDay = isNaN(c.schedule_hour) ? 8 : c.schedule_hour;
let hour = hourOfDay % 12;
let amPm = hourOfDay >= 12 ? 1 : 0;
return (
......@@ -60,14 +60,14 @@ export default class SchedulePicker extends Component {
options={HOUR_OPTIONS}
optionNameFn={o => o.name}
optionValueFn={o => o.value}
onChange={(o) => this.props.onPropertyChange("schedule_details", { ...c.schedule_details, hour_of_day: o + amPm * 12 }) }
onChange={(o) => this.props.onPropertyChange("schedule_hour", o + amPm * 12) }
/>
<Select
value={_.find(AM_PM_OPTIONS, (o) => o.value === amPm)}
options={AM_PM_OPTIONS}
optionNameFn={o => o.name}
optionValueFn={o => o.value}
onChange={(o) => this.props.onPropertyChange("schedule_details", { ...c.schedule_details, hour_of_day: hour + o * 12 }) }
onChange={(o) => this.props.onPropertyChange("schedule_hour", hour + o * 12) }
/>
</div>
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment