diff --git a/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee b/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee new file mode 100644 index 000000000..d2be3ce9a --- /dev/null +++ b/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee @@ -0,0 +1,41 @@ +context = window +rest = window.JK.Rest() +logger = context.JK.logger + +@CheckBoxList = React.createClass({ + objects: [] + componentDidUnmount: () -> + @root.off("change", ".checkItem input[type=checkbox]") + + componentDidMount: () -> + @root = jQuery(this.getDOMNode()) + @root.off("change", ".checkItem input[type=checkbox]").on("change", ".checkItem input[type=checkbox]", @onItemChanged) + + onItemChanged: (e) -> + e.preventDefault() + this.props.onItemChanged("objects", @selectedObjects()) + + selectedObjects: -> + selected=[] + @root = jQuery(this.getDOMNode()) + $(".checkItem input[type=checkbox]:checked", @root).each -> + selected.push $(this).data("object-id") + selected + + render: () -> + object_options = [] + + for object in this.props.sourceObjects + nm = "check_#{object.id}" + checkedStr = if @isChecked(object.id) then "checked" else "" + object_options.push `
` + + `
+
+ {object_options} +
+
` + + isChecked: (id) -> + this.props.selectedObjects? && id in this.props.selectedObjects +}) \ No newline at end of file diff --git a/web/app/assets/javascripts/react-components/InstrumentSelectorList.js.jsx.coffee b/web/app/assets/javascripts/react-components/InstrumentSelectorList.js.jsx.coffee index 6b9223f15..ca26de359 100644 --- a/web/app/assets/javascripts/react-components/InstrumentSelectorList.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/InstrumentSelectorList.js.jsx.coffee @@ -6,43 +6,13 @@ logger = context.JK.logger instruments: [] componentDidUnmount: () -> @instruments = [] - @root.off("change", ".checkItem.checkItemInstrument input[type=checkbox]") componentDidMount: () -> - @root = jQuery(this.getDOMNode()) - @root.off("change", ".checkItem.checkItemInstrument input[type=checkbox]").on("change", ".checkItem.checkItemInstrument input[type=checkbox]", @onItemChanged) - rest.getInstruments().done (instruments) => @instruments = instruments - onItemChanged: (e) -> - e.preventDefault() - this.props.onInstrumentsChanged("instruments", @selectedItems()) - - - selectedItems: -> - selected=[] - @root = jQuery(this.getDOMNode()) - $(".checkItem.checkItemInstrument input[type=checkbox]:checked", @root).each -> - selected.push $(this).data("instrument-id") - selected - render: () -> - instrument_options = [] - - for instrument in @instruments - nm = "check_#{instrument.id}" - checkedStr = if @isChecked(instrument.id) then "checked" else "" - instrument_options.push `
` - `
-
- {instrument_options} -
+
` - - isChecked: (id) -> - this.props.selectedItems? && id in this.props.selectedItems - #!!(_.find this.props.selectedItems, (item) -> item.id is id) - }) \ No newline at end of file diff --git a/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee index 4c5c52edb..a9cd6f298 100644 --- a/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee @@ -31,9 +31,9 @@ rest = window.JK.Rest() }); - handleListChange: (listName, selectedItems)-> + handleListChange: (listName, selectedObjects)-> this.setState({ - "#{listName}": selectedItems + "#{listName}": selectedObjects }); @@ -69,7 +69,7 @@ rest = window.JK.Rest()
Instruments Taught - +