From aa1b763518036c6a5cd611cf8d7300791ec22ae7 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 16 Jul 2015 17:20:03 +0100 Subject: [PATCH] Make CreateRoom remember what the values of its fields were. Remove some fairly pointless atoms --- .../base/views/atoms/create_room/RoomAlias.js | 5 ++- .../atoms/create_room/RoomNameTextbox.js | 36 ---------------- .../base/views/atoms/create_room/RoomTopic.js | 37 ----------------- skins/base/views/molecules/UserSelector.js | 2 +- skins/base/views/organisms/CreateRoom.js | 32 +++++++++++++-- .../atoms/create_room/RoomAlias.js | 14 +++---- .../atoms/create_room/RoomNameTextbox.js | 41 ------------------- .../atoms/create_room/RoomTopic.js | 41 ------------------- src/controllers/molecules/UserSelector.js | 30 ++++---------- src/controllers/organisms/CreateRoom.js | 20 ++++----- 10 files changed, 55 insertions(+), 203 deletions(-) delete mode 100644 skins/base/views/atoms/create_room/RoomNameTextbox.js delete mode 100644 skins/base/views/atoms/create_room/RoomTopic.js delete mode 100644 src/controllers/atoms/create_room/RoomNameTextbox.js delete mode 100644 src/controllers/atoms/create_room/RoomTopic.js diff --git a/skins/base/views/atoms/create_room/RoomAlias.js b/skins/base/views/atoms/create_room/RoomAlias.js index fd0789b99c..a59a8e69ad 100644 --- a/skins/base/views/atoms/create_room/RoomAlias.js +++ b/skins/base/views/atoms/create_room/RoomAlias.js @@ -25,7 +25,7 @@ module.exports = React.createClass({ mixins: [RoomAliasController], onValueChanged: function(ev) { - this.setState({room_alias: ev.target.value}) + this.props.onChange(ev.target.value); }, onFocus: function(ev) { @@ -72,7 +72,8 @@ module.exports = React.createClass({ render: function() { return ( + onChange={this.onValueChanged} onFocus={this.onFocus} onBlur={this.onBlur} + value={this.props.alias}/> ); } }); diff --git a/skins/base/views/atoms/create_room/RoomNameTextbox.js b/skins/base/views/atoms/create_room/RoomNameTextbox.js deleted file mode 100644 index 038d39a93a..0000000000 --- a/skins/base/views/atoms/create_room/RoomNameTextbox.js +++ /dev/null @@ -1,36 +0,0 @@ -/* -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 RoomNameTextboxController = require("../../../../../src/controllers/atoms/create_room/RoomNameTextbox"); - -module.exports = React.createClass({ - displayName: 'RoomNameTextbox', - mixins: [RoomNameTextboxController], - - onValueChanged: function(ev) { - this.setState({room_name: ev.target.value}) - }, - - render: function() { - return ( - - ); - } -}); diff --git a/skins/base/views/atoms/create_room/RoomTopic.js b/skins/base/views/atoms/create_room/RoomTopic.js deleted file mode 100644 index 134833f905..0000000000 --- a/skins/base/views/atoms/create_room/RoomTopic.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -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 RoomTopicController = require("../../../../../src/controllers/atoms/create_room/RoomTopic"); - -module.exports = React.createClass({ - displayName: 'RoomTopic', - mixins: [RoomTopicController], - - onValueChanged: function(ev) { - this.setState({room_topic: ev.target.value}) - }, - - render: function() { - return ( - - ); - } -}); diff --git a/skins/base/views/molecules/UserSelector.js b/skins/base/views/molecules/UserSelector.js index 7517e29d0f..81afa5f4e6 100644 --- a/skins/base/views/molecules/UserSelector.js +++ b/skins/base/views/molecules/UserSelector.js @@ -32,7 +32,7 @@ module.exports = React.createClass({ return (
diff --git a/skins/base/views/organisms/CreateRoom.js b/skins/base/views/organisms/CreateRoom.js index 7d2e35498a..fa6d55f257 100644 --- a/skins/base/views/organisms/CreateRoom.js +++ b/skins/base/views/organisms/CreateRoom.js @@ -97,6 +97,30 @@ module.exports = React.createClass({ }); }, + onTopicChange: function(ev) { + this.setState({ + topic: ev.target.value, + }); + }, + + onNameChange: function(ev) { + this.setState({ + room_name: ev.target.value, + }); + }, + + onInviteChanged: function(invited_users) { + this.setState({ + invited_users: invited_users, + }); + }, + + onAliasChanged: function(alias) { + this.setState({ + alias: alias + }) + }, + render: function() { var curr_phase = this.state.phase; if (curr_phase == this.phases.CREATING) { @@ -114,10 +138,10 @@ module.exports = React.createClass({ } return (
-
-
-
-
+
+