context = window @TestDrivePackageDialog = React.createClass({ mixins: [Reflux.listenTo(@AppStore, "onAppInit")] teacher: null beforeShow: (args) -> # d1 should be a teacher ID (vs a user ID that happens to be a teacher) logger.debug("TestDrivePackageDialog.beforeShow", args.d1) @setState({target: args.d1, page_data: window.page_data}) afterHide: () -> onAppInit: (@app) -> dialogBindings = { 'beforeShow': @beforeShow, 'afterHide': @afterHide }; @app.bindDialog('test-drive-package-dialog', dialogBindings); getInitialState: () -> { target: null, page_data: null } componentDidMount: () -> @root = $(@getDOMNode()) @dialog = @root.closest('.dialog') renderTeacher: (teacher) -> photo_url = '/assets/shared/avatar_generic.png' if teacher.photo_url? photo_url = teacher.photo_url `
Check the boxes under the 2 instructors you want to select for your TestDrive package. Then click the Select button below.
` else help = `Check the box under the instructor you want to select for your TestDrive package. Then click the Select button below.
` teachers = [] if @state.page_data?.package?.teachers? for teacher in @state.page_data.package.teachers teachers.push(@renderTeacher(teacher)) teacherHolderClasses = {"teacher-holder" : true, "two": teachers.length == 2, "four": teachers.length == 4} dialogInnerClasses = {"dialog-inner": true, "two": teachers.length == 2, "four": teachers.length == 4} `` })