When closing out of a modal, unsaved data and text inside of it is erased.

Этот коммит содержится в:
nickago
2015-07-17 14:44:13 -07:00
родитель dc79707787
Коммит 0acab11cf4
5 изменённых файлов: 51 добавлений и 5 удалений

Просмотреть файл

@@ -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) {

Просмотреть файл

@@ -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: "" };

Просмотреть файл

@@ -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: "" };

Просмотреть файл

@@ -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() {

Просмотреть файл

@@ -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";