@LessonBookingDecision = React.createClass({ #slot.creatorRole #slot.slotTime # props.initial # props.counter # props.slots # props.is_recurring # props.slot_decision # props.otherRole # props.cancelErrors # props.counterErrors mixins: [ ICheckMixin, ] propTypes: { onSlotDecision: React.PropTypes.func.isRequired onUserCancel: React.PropTypes.func.isRequired onUserDecision: React.PropTypes.func.isRequired onUpdateAllDecision: React.PropTypes.func.isRequired } getInitialState: () -> { slot_decision: null } componentWillMount: () -> @days = [] @days.push(``) @days.push(``) @days.push(``) @days.push(``) @days.push(``) @days.push(``) @days.push(``) @days.push(``) @hours = [] for hour in ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] if hour == '12' key = '00' else key = hour @hours.push(``) @minutes = [] for minute in ['00', '15', '30', '45'] @minutes.push(``) @am_pm = [``, ``] componentDidMount: () -> @checkboxes = [{selector: 'input.slot-decision', stateKey: 'slot-decision'}, {selector: 'input.update-all', propsKey: 'update_all'}] @root = $(@getDOMNode()) @iCheckify() @slotDate = @root.find('.date-picker') @slotDate.datepicker({ dateFormat: "D M d yy", onSelect: ((e) => @toggleDate(e)) }) componentDidUpdate: () -> @iCheckify() @slotDate = @root.find('.date-picker') @slotDate.datepicker({ dateFormat: "D M d yy", onSelect: ((e) => @toggleDate(e)) }) toggleDate: (e) -> componentWillReceiveProps: (nextProps) -> if @onlyOption() console.log("setting it counter") # if this isn't a counter situation, then there is no 'Accept their time', so there should only be one radio button, and we'll select that value already @setState({"slot-decision": "counter"}) checkboxChanged: (e) -> name = $(e.target).attr('name') if name == 'slot-decision' value = $(e.target).val() logger.debug("LessonBookingDecision: slot-decision made with value: " + value) @setState({"slot-decision": value}) @props.onSlotDecision({slot_decision: value}) else if name == 'update-all' checked = $(e.target).is(':checked') logger.debug("LessonBookingDecision: update-all changed: " + checked) @props.onUpdateAllDecision({update_all: checked}) else throw "checkbox changed with unknown name #{name}" onUserDecision: (e) -> e.preventDefault() if this.props.disabled return this.props.onUserDecision(this.state.slot_decision) onUserCancel: (e) -> e.preventDefault() if this.props.disabled return this.props.onUserCancel() dayOfWeek: (slot) -> switch slot.day_of_week when 0 then "Sunday" when 1 then "Monday" when 2 then "Tuesday" when 3 then "Wednesday" when 4 then "Thursday" when 5 then "Friday" when 6 then "Saturday" slotLabelText: (index, slot) -> if @props.counter "Accept #{slot.creatorRoleRelative} proposed day/time" else if index == 0 "Accept #{slot.creatorRoleRelative} preferred day/time" else "Accept #{slot.creatorRoleRelative} secondary day/time" showDeclineVerb: () -> this.props.initial && this.props.otherRole == 'student' nullOp: ()-> onlyOption: () -> # (!this.props.initial && this.props.selfLastToAct ) || !(this.props.counter && !this.props.selfLastToAct) !@multipleOptions() multipleOptions: () -> if this.props.initial if this.props.noSlots false else !(!this.props.counter && this.props.selfLastToAct) else if this.props.counter !this.props.selfLastToAct else false render: () -> #showUpdateAll = !this.props.initial if (!this.props.initial && !this.props.counter) || this.props.selfLastToAct userPromptHeader = `