2014-11-09 18:12:03 +00:00
|
|
|
/*jshint browser:true */
|
2014-11-08 17:52:36 +00:00
|
|
|
/*globals React, App */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modal for managing channels
|
|
|
|
*
|
2014-11-09 21:59:46 +00:00
|
|
|
* @prop {channels: Array} List of channels
|
|
|
|
* @prop {switch: func} Called to switch a param on given channel
|
|
|
|
* @prop {open: func} Called to open the window
|
|
|
|
* @prop {close: func} Called to close the window
|
2014-11-08 17:52:36 +00:00
|
|
|
*/
|
|
|
|
App.components.modal('Channel', {
|
2014-11-09 12:10:27 +00:00
|
|
|
displayName: 'Board',
|
2014-11-08 17:52:36 +00:00
|
|
|
mixins: [React.addons.PureRenderMixin],
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
channels: React.PropTypes.array,
|
|
|
|
|
2014-11-09 21:59:46 +00:00
|
|
|
switch: React.PropTypes.func,
|
2014-11-08 17:52:36 +00:00
|
|
|
open: React.PropTypes.func,
|
|
|
|
close: React.PropTypes.func
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function () {
|
|
|
|
return {
|
|
|
|
channels: [],
|
|
|
|
|
2014-11-09 21:59:46 +00:00
|
|
|
switch: function () {},
|
2014-11-08 17:52:36 +00:00
|
|
|
open: function () {},
|
|
|
|
close: function () {}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2014-11-09 21:59:46 +00:00
|
|
|
/**
|
|
|
|
* Creates a function to switch a param on given channel
|
|
|
|
*
|
|
|
|
* @param {channel: object} Channel object
|
|
|
|
*/
|
|
|
|
switch: function (channel) {
|
|
|
|
return function (param) {
|
|
|
|
this.props.switch(param, channel.id);
|
|
|
|
}.bind(this);
|
|
|
|
},
|
|
|
|
|
2014-11-08 17:52:36 +00:00
|
|
|
/**
|
|
|
|
* Render modal
|
|
|
|
*/
|
|
|
|
render: function () {
|
2014-11-09 12:10:27 +00:00
|
|
|
var title = 'Instruments', channels;
|
2014-11-08 17:52:36 +00:00
|
|
|
|
2014-11-09 21:59:46 +00:00
|
|
|
console.log('rendering!');
|
|
|
|
|
2014-11-08 17:52:36 +00:00
|
|
|
channels = this.props.channels.map(function (channel) {
|
|
|
|
channel.key = 'channel-' + channel.id;
|
2014-11-09 21:59:46 +00:00
|
|
|
channel.switch = this.switch(channel);
|
|
|
|
|
2014-11-08 17:52:36 +00:00
|
|
|
return App.components.Channel.Channel(channel);
|
2014-11-09 21:59:46 +00:00
|
|
|
}, this);
|
2014-11-08 17:52:36 +00:00
|
|
|
|
|
|
|
return React.DOM.form({
|
|
|
|
className: 'vex-dialog-form channels'
|
|
|
|
}, [
|
|
|
|
React.DOM.h4({
|
|
|
|
key: 'title',
|
|
|
|
className: 'main-title'
|
|
|
|
}, title),
|
|
|
|
React.DOM.ul({
|
|
|
|
key: 'channels'
|
|
|
|
}, channels)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}());
|