diff --git a/skins/base/views/molecules/UserSelector.js b/skins/base/views/molecules/UserSelector.js
new file mode 100644
index 0000000000..3053bfeb77
--- /dev/null
+++ b/skins/base/views/molecules/UserSelector.js
@@ -0,0 +1,45 @@
+/*
+Copyright 2015 OpenMarket Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+'use strict';
+
+var React = require('react');
+
+var UserSelectorController = require("../../../../src/controllers/molecules/UserSelector");
+
+module.exports = React.createClass({
+ displayName: 'UserSelector',
+ mixins: [UserSelectorController],
+
+ onAddUserId: function() {
+ this.addUser(this.refs.user_id_input.getDOMNode().value);
+ },
+
+ render: function() {
+ console.log("Render");
+ return (
+
+
+ {this.state.selected_users.map(function(user_id, i) {
+ return {user_id}
+ })}
+
+
+
Add User
+
+ );
+ }
+});
diff --git a/skins/base/views/organisms/CreateRoom.js b/skins/base/views/organisms/CreateRoom.js
index 7d91326fbd..e6115f2579 100644
--- a/skins/base/views/organisms/CreateRoom.js
+++ b/skins/base/views/organisms/CreateRoom.js
@@ -25,17 +25,31 @@ var ComponentBroker = require('../../../../src/ComponentBroker');
var CreateRoomButton = ComponentBroker.get("atoms/create_room/CreateRoomButton");
var RoomNameTextbox = ComponentBroker.get("atoms/create_room/RoomNameTextbox");
var Presets = ComponentBroker.get("atoms/create_room/Presets");
+var UserSelector = ComponentBroker.get("molecules/UserSelector");
module.exports = React.createClass({
displayName: 'CreateRoom',
mixins: [CreateRoomController],
+ getPreset: function() {
+ return this.refs.presets.getPreset();
+ },
+
+ getName: function() {
+ return this.refs.name_textbox.getName();
+ },
+
+ getInvitedUsers: function() {
+ return this.refs.user_selector.getUserIds();
+ },
+
render: function() {
return (
);
diff --git a/src/ComponentBroker.js b/src/ComponentBroker.js
index 935d304d61..8f818a657a 100644
--- a/src/ComponentBroker.js
+++ b/src/ComponentBroker.js
@@ -86,4 +86,5 @@ require('../skins/base/views/organisms/RoomView');
require('../skins/base/views/templates/Login');
require('../skins/base/views/organisms/Notifier');
require('../skins/base/views/organisms/CreateRoom');
+require('../skins/base/views/molecules/UserSelector');
}
diff --git a/src/controllers/molecules/UserSelector.js b/src/controllers/molecules/UserSelector.js
new file mode 100644
index 0000000000..e7e0509690
--- /dev/null
+++ b/src/controllers/molecules/UserSelector.js
@@ -0,0 +1,57 @@
+/*
+Copyright 2015 OpenMarket Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+'use strict';
+
+var React = require('react');
+
+module.exports = {
+ propTypes: {
+ initially_selected: React.PropTypes.arrayOf(React.PropTypes.string),
+ },
+
+ getDefaultProps: function() {
+ return {
+ initially_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]),
+ });
+ }
+ },
+
+ removeUser: function(user_id) {
+ this.setState({
+ selected_users: this.state.selected_users.filter(function(e) {
+ return e != user_id;
+ }),
+ });
+ },
+
+ getUserIds: function() {
+ return this.state.selected_users;
+ }
+};
diff --git a/src/controllers/organisms/CreateRoom.js b/src/controllers/organisms/CreateRoom.js
index e24a75cff7..d97f24939b 100644
--- a/src/controllers/organisms/CreateRoom.js
+++ b/src/controllers/organisms/CreateRoom.js
@@ -21,17 +21,23 @@ var MatrixClientPeg = require("../../MatrixClientPeg");
module.exports = {
onCreateRoom: function() {
- var room_name = this.refs.name_textbox.getName();
- console.log("Create room clicked. Name: " + room_name);
-
- var options = {
- preset: this.refs.presets.getPreset(),
- };
+ var options = {};
+ var room_name = this.getName();
if (room_name) {
options.name = room_name;
}
+ var preset = this.getPreset();
+ if (preset) {
+ options.preset = preset;
+ }
+
+ var invited_users = this.getInvitedUsers();
+ if (invited_users) {
+ options.invite = invited_users;
+ }
+
var cli = MatrixClientPeg.get();
if (!cli) {
// TODO: Error.