From 29d2ed7191bd5d2ebf873f39658e09d97fac5dc9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 21 Sep 2015 16:17:29 +0100 Subject: [PATCH] Merge userselector changes --- src/controllers/molecules/UserSelector.js | 30 +++++++---------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/controllers/molecules/UserSelector.js b/src/controllers/molecules/UserSelector.js index e7e0509690..67a56163fa 100644 --- a/src/controllers/molecules/UserSelector.js +++ b/src/controllers/molecules/UserSelector.js @@ -20,38 +20,26 @@ var React = require('react'); module.exports = { propTypes: { - initially_selected: React.PropTypes.arrayOf(React.PropTypes.string), + onChange: React.PropTypes.func, + selected_users: React.PropTypes.arrayOf(React.PropTypes.string), }, getDefaultProps: function() { return { - initially_selected: [], + onChange: function() {}, + selected: [], }; }, - getInitialState: function() { - return { - selected_users: this.props.initially_selected, - } - }, - addUser: function(user_id) { - if (this.state.selected_users.indexOf(user_id == -1)) { - this.setState({ - selected_users: this.state.selected_users.concat([user_id]), - }); + if (this.props.selected_users.indexOf(user_id == -1)) { + this.props.onChange(this.props.selected_users.concat([user_id])); } }, removeUser: function(user_id) { - this.setState({ - selected_users: this.state.selected_users.filter(function(e) { - return e != user_id; - }), - }); + this.props.onChange(this.props.selected_users.filter(function(e) { + return e != user_id; + })); }, - - getUserIds: function() { - return this.state.selected_users; - } };