diff options
author | nickago <ngonella@calpoly.edu> | 2015-07-17 14:44:13 -0700 |
---|---|---|
committer | nickago <ngonella@calpoly.edu> | 2015-07-23 09:03:57 -0700 |
commit | 0acab11cf46a9e279d16e803ad32b8aa67e20679 (patch) | |
tree | 573b614f06dc2bf30f74d4f184c9240e1eb57b8c | |
parent | dc79707787b521ea5fc0d9088ccd9069780c8e0c (diff) | |
download | chat-0acab11cf46a9e279d16e803ad32b8aa67e20679.tar.gz chat-0acab11cf46a9e279d16e803ad32b8aa67e20679.tar.bz2 chat-0acab11cf46a9e279d16e803ad32b8aa67e20679.zip |
When closing out of a modal, unsaved data and text inside of it is erased.
-rw-r--r-- | web/react/components/create_post.jsx | 2 | ||||
-rw-r--r-- | web/react/components/edit_channel_modal.jsx | 3 | ||||
-rw-r--r-- | web/react/components/rename_channel_modal.jsx | 3 | ||||
-rw-r--r-- | web/react/components/rename_team_modal.jsx | 2 | ||||
-rw-r--r-- | web/react/components/user_settings.jsx | 46 |
5 files changed, 51 insertions, 5 deletions
diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index 91d070958..17ed16735 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -275,7 +275,7 @@ module.exports = React.createClass({ messageText = draft['message']; uploadsInProgress = draft['uploadsInProgress']; } - this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress }); + this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, limit_error: null, server_error: null, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress }); } }, _onActiveThreadChanged: function(rootId, parentId) { diff --git a/web/react/components/edit_channel_modal.jsx b/web/react/components/edit_channel_modal.jsx index d055feacd..0398dba93 100644 --- a/web/react/components/edit_channel_modal.jsx +++ b/web/react/components/edit_channel_modal.jsx @@ -36,6 +36,9 @@ module.exports = React.createClass({ var button = e.relatedTarget; self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), server_error: "" }); }); + $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function() { + self.setState({description: ""}); + }) }, getInitialState: function() { return { description: "", title: "", channel_id: "" }; diff --git a/web/react/components/rename_channel_modal.jsx b/web/react/components/rename_channel_modal.jsx index 2ae331626..5488b34c6 100644 --- a/web/react/components/rename_channel_modal.jsx +++ b/web/react/components/rename_channel_modal.jsx @@ -95,6 +95,9 @@ module.exports = React.createClass({ var button = $(e.relatedTarget); self.setState({ display_name: button.attr('data-display'), title: button.attr('data-name'), channel_id: button.attr('data-channelid') }); }); + $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function() { + self.setState({display_name: "", channel_name: "", display_name_error: "", server_error: "", name_error: ""}); + }); }, getInitialState: function() { return { display_name: "", channel_name: "", channel_id: "" }; diff --git a/web/react/components/rename_team_modal.jsx b/web/react/components/rename_team_modal.jsx index a6da57b67..79836e4a8 100644 --- a/web/react/components/rename_team_modal.jsx +++ b/web/react/components/rename_team_modal.jsx @@ -47,7 +47,7 @@ module.exports = React.createClass({ componentDidMount: function() { var self = this; $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) { - self.setState({ name: self.props.teamDisplayName }); + self.setState({ name: self.props.teamDisplayName, name_error: "", server_error: ""}); }); }, getInitialState: function() { diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx index 1fbbf16ed..17b8a5e30 100644 --- a/web/react/components/user_settings.jsx +++ b/web/react/components/user_settings.jsx @@ -95,11 +95,18 @@ var NotificationsTab = React.createClass({ }.bind(this) ); }, + handleClose: function() { + this.setState({server_error: null}); + }, componentDidMount: function() { UserStore.addChangeListener(this._onChange); + + $('#user_settings1').on('hidden.bs.modal', this.handleClose); }, componentWillUnmount: function() { UserStore.removeChangeListener(this._onChange); + + $('#user_settings1').off('hidden.bs.modal', this.handleClose); }, _onChange: function() { var newState = getNotificationsStateFromStores(); @@ -502,6 +509,23 @@ var SecurityTab = React.createClass({ handleDevicesOpen: function() { $("#user_settings1").modal('hide'); }, + handleClose: function() { + if(this.props.activeSection === 'password') { + this.refs.curPass.getDOMNode().value = ""; + this.refs.newPass.getDOMNode().value = ""; + this.refs.reNewPass.getDOMNode().value = ""; + + this.setState({current_password: '', new_password: '', confirm_password: ''}); + } + + this.setState({server_error: null, password_error: null}); + }, + componentDidMount: function() { + $('#user_settings1').on('hidden.bs.modal', this.handleClose); + }, + componentWillUnmount: function() { + $('#user_settings1').off('hidden.bs.modal', this.handleClose); + }, getInitialState: function() { return { current_password: '', new_password: '', confirm_password: '' }; }, @@ -518,7 +542,7 @@ var SecurityTab = React.createClass({ <div className="form-group"> <label className="col-sm-5 control-label">Current Password</label> <div className="col-sm-7"> - <input className="form-control" type="password" onChange={this.updateCurrentPassword} value={this.state.current_password}/> + <input ref="curPass" className="form-control" type="password" onChange={this.updateCurrentPassword} value={this.state.current_password}/> </div> </div> ); @@ -526,7 +550,7 @@ var SecurityTab = React.createClass({ <div className="form-group"> <label className="col-sm-5 control-label">New Password</label> <div className="col-sm-7"> - <input className="form-control" type="password" onChange={this.updateNewPassword} value={this.state.new_password}/> + <input ref="newPass" className="form-control" type="password" onChange={this.updateNewPassword} value={this.state.new_password}/> </div> </div> ); @@ -534,7 +558,7 @@ var SecurityTab = React.createClass({ <div className="form-group"> <label className="col-sm-5 control-label">Retype New Password</label> <div className="col-sm-7"> - <input className="form-control" type="password" onChange={this.updateConfirmPassword} value={this.state.confirm_password}/> + <input ref="reNewPass" className="form-control" type="password" onChange={this.updateConfirmPassword} value={this.state.confirm_password}/> </div> </div> ); @@ -735,6 +759,15 @@ var GeneralTab = React.createClass({ this.submitActive = false this.props.updateSection(section); }, + handleClose: function() { + this.setState({client_error: null, server_error: null, email_error: null}); + }, + componentDidMount: function() { + $('#user_settings1').on('hidden.bs.modal', this.handleClose); + }, + componentWillUnmount: function() { + $('#user_settings1').off('hidden.bs.modal', this.handleClose); + }, getInitialState: function() { var user = this.props.user; @@ -978,10 +1011,14 @@ var AppearanceTab = React.createClass({ var hex = utils.rgb2hex(e.target.style.backgroundColor); this.setState({ theme: hex.toLowerCase() }); }, + handleClose: function() { + this.setState({server_error: null}); + }, componentDidMount: function() { if (this.props.activeSection === "theme") { $(this.refs[this.state.theme].getDOMNode()).addClass('active-border'); } + $('#user_settings1').on('hidden.bs.modal', this.handleClose); }, componentDidUpdate: function() { if (this.props.activeSection === "theme") { @@ -989,6 +1026,9 @@ var AppearanceTab = React.createClass({ $(this.refs[this.state.theme].getDOMNode()).addClass('active-border'); } }, + componentWillUnmount: function() { + $('#user_settings1').off('hidden.bs.modal', this.handleClose); + }, getInitialState: function() { var user = UserStore.getCurrentUser(); var theme = config.ThemeColors != null ? config.ThemeColors[0] : "#2389d7"; |