<commit_before>React             = require 'react'
CourseLink        = require '../common/course_link'
Editable          = require '../high_order/editable'
Calendar          = require '../common/calendar'
Modal             = require '../common/modal'
TextInput         = require '../common/text_input'
CourseStore       = require '../../stores/course_store'
CourseActions     = require '../../actions/course_actions'
ServerActions     = require '../../actions/server_actions'

getState = (course_id) ->
  course = CourseStore.getCourse()
  course: course
  anyDatesSelected: course.weekdays?.indexOf(1) >= 0
  blackoutDatesSelected: course.day_exceptions?.length > 0

Meetings = React.createClass(
  displayName: 'Meetings'
  mixins: [CourseStore.mixin]
  getInitialState: ->
    getState(@props.course_id)
  disableSave: (bool) ->
    @setState saveDisabled: bool
  storeDidChange: ->
    @setState getState(@props.course_id)
  updateCourse: (value_key, value) ->
    to_pass = @state.course
    to_pass[value_key] = value
    CourseActions.updateCourse to_pass, true
  updateCheckbox: (e) ->
    @updateCourse 'no_day_exceptions', e.target.checked
    @updateCourse 'day_exceptions', ''
  saveDisabled: ->
    enable = @state.anyDatesSelected && (@state.blackoutDatesSelected || @state.course.no_day_exceptions)

    if enable then false else true
  render: ->
    timeline_start_props =
      minDate: moment(@state.course.start)
      maxDate: moment(@state.course.timeline_end).subtract(Math.max(1, @props.weeks), 'week')
    timeline_end_props =
      minDate: moment(@state.course.timeline_start).add(Math.max(1, @props.weeks), 'week')
      maxDate: moment(@state.course.end)

    <Modal >
      <div className='wizard__panel active'>
        <h3>Course Dates</h3>
        <div className='course-dates__step'>
          <h2><span>1.</span><small> Confirm the course’s start and end dates.</small></h2>
          <div className='vertical-form full-width'>
            <TextInput
              onChange={@updateCourse}
              value={@state.course.start}
              value_key='start'
              editable=true
              type='date'
              autoExpand=true
              label='Course Start'
            />
            <TextInput
              onChange={@updateCourse}
              value={@state.course.end}
              value_key='end'
              editable=true
              type='date'
              label='Course End'
              date_props={minDate: moment(@state.course.start).add(1, 'week')}
              enabled={@state.course.start?}
            />
          </div>
        </div>
        <hr />
        <div className='wizard__form course-dates course-dates__step'>
          <Calendar course={@state.course}
            save=true
            editable=true
          />
          <label> I have no class holidays
            <input
              type='checkbox'
              onChange={@updateCheckbox}
              ref='noDates'
              checked={@state.course.day_exceptions is '' && @state.course.no_day_exceptions}
            />
          </label>
        </div>
        <div className='wizard__panel__controls'>
          <div className='left'></div><commit_msg>Restore editing of timeline dates to 'Edit Course Dates' modal<commit_after>React             = require 'react'
CourseLink        = require '../common/course_link'
Editable          = require '../high_order/editable'
Calendar          = require '../common/calendar'
Modal             = require '../common/modal'
TextInput         = require '../common/text_input'
CourseStore       = require '../../stores/course_store'
CourseActions     = require '../../actions/course_actions'
ServerActions     = require '../../actions/server_actions'

getState = (course_id) ->
  course = CourseStore.getCourse()
  course: course
  anyDatesSelected: course.weekdays?.indexOf(1) >= 0
  blackoutDatesSelected: course.day_exceptions?.length > 0

Meetings = React.createClass(
  displayName: 'Meetings'
  mixins: [CourseStore.mixin]
  getInitialState: ->
    getState(@props.course_id)
  disableSave: (bool) ->
    @setState saveDisabled: bool
  storeDidChange: ->
    @setState getState(@props.course_id)
  updateCourse: (value_key, value) ->
    to_pass = @state.course
    to_pass[value_key] = value
    CourseActions.updateCourse to_pass, true
  updateCheckbox: (e) ->
    @updateCourse 'no_day_exceptions', e.target.checked
    @updateCourse 'day_exceptions', ''
  saveDisabled: ->
    enable = @state.anyDatesSelected && (@state.blackoutDatesSelected || @state.course.no_day_exceptions)

    if enable then false else true
  render: ->
    timeline_start_props =
      minDate: moment(@state.course.start)
      maxDate: moment(@state.course.timeline_end).subtract(Math.max(1, @props.weeks), 'week')
    timeline_end_props =
      minDate: moment(@state.course.timeline_start).add(Math.max(1, @props.weeks), 'week')
      maxDate: moment(@state.course.end)

    <Modal >
      <div className='wizard__panel active'>
        <h3>Course Dates</h3>
        <div className='course-dates__step'>
          <p>Select the start and end dates of the entire course (not just the Wikipedia assignment).</p>
          <div className='vertical-form full-width'>
            <TextInput
              onChange={@updateCourse}
              value={@state.course.start}
              value_key='start'
              editable=true
              type='date'
              autoExpand=true
              label='Course Start'
            />
            <TextInput
              onChange={@updateCourse}
              value={@state.course.end}
              value_key='end'
              editable=true
              type='date'
              label='Course End'
              date_props={minDate: moment(@state.course.start).add(1, 'week')}
              enabled={@state.course.start?}
            />
          </div>
        </div>
        <hr />
        <div className='course-dates__step'>
          <p>Select the start and end dates for the Wikipedia assignment timeline. Changing the start date will shift the dates of the entire timeline.</p>
          <div className='vertical-form full-width'>
            <TextInput
              onChange={@updateCourse}
              value={@state.course.timeline_start}
              value_key='timeline_start'
              editable=true
              type='date'
              autoExpand=true
              label='Assignment Start'
              date_props={timeline_start_props}
            />
            <TextInput
              onChange={@updateCourse}
              value={@state.course.timeline_end}
              value_key='timeline_end'
              editable=true
              type='date'
              label='Assignment End'
              date_props={timeline_end_props}
              enabled={@state.course.start?}
            />
          </div>
        </div>
        <hr />
        <div className='wizard__form course-dates course-dates__step'>
          <Calendar course={@state.course}
            save=true
            editable=true
          />
          <label> I have no class holidays
            <input
              type='checkbox'
              onChange={@updateCheckbox}
              ref='noDates'
              checked={@state.course.day_exceptions is '' && @state.course.no_day_exceptions}
            />
          </label>
        </div>
        <div className='wizard__panel__controls'>
          <div className='left'></div>
{'fraction_non_alphanumeric': 0.12090848363393454, 'fraction_numerical': 0.0025384101536406146, 'mean_word_length': 2.1023622047244093, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 80, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6812678', 'n_tokens_mistral': 2111, 'n_tokens_neox': 2081, 'n_words': 402}