Fix that edited team is adeed to bottom of the list

This commit is contained in:
Yuya Ochiai 2016-06-18 00:53:03 +09:00
parent 96e52b6e85
commit 3650967f4c

View file

@ -34,9 +34,7 @@ var SettingsPage = React.createClass({
config = settings.loadDefault(); config = settings.loadDefault();
} }
this.setState({ config.showAddTeamForm = false;
showAddTeamForm: false
});
return config; return config;
}, },
@ -54,10 +52,8 @@ var SettingsPage = React.createClass({
this.setState({ this.setState({
teams: teams teams: teams
}); });
this.handleSave(false);
}, },
handleSave: function(toIndex) { handleSave: function() {
var config = { var config = {
teams: this.state.teams, teams: this.state.teams,
hideMenuBar: this.state.hideMenuBar, hideMenuBar: this.state.hideMenuBar,
@ -88,9 +84,7 @@ var SettingsPage = React.createClass({
ipcRenderer.send('update-menu', config); ipcRenderer.send('update-menu', config);
ipcRenderer.send('update-config'); ipcRenderer.send('update-config');
if (typeof toIndex == 'undefined' || toIndex) {
backToIndex(); backToIndex();
}
}, },
handleCancel: function() { handleCancel: function() {
backToIndex(); backToIndex();
@ -120,16 +114,10 @@ var SettingsPage = React.createClass({
autostart: this.refs.autostart.getChecked() autostart: this.refs.autostart.getChecked()
}); });
}, },
handleShowTeamForm: function() { toggleShowTeamForm: function() {
if (!this.state.showAddTeamForm) {
this.setState({ this.setState({
showAddTeamForm: true showAddTeamForm: !this.state.showAddTeamForm
}); });
} else {
this.setState({
showAddTeamForm: false
});
}
}, },
handleFlashWindowSetting: function(item) { handleFlashWindowSetting: function(item) {
this.setState({ this.setState({
@ -169,7 +157,7 @@ var SettingsPage = React.createClass({
} }
options.push(<Input key="inputDisableWebSecurity" ref="disablewebsecurity" type="checkbox" label="Allow mixed content (Enabling allows both secure and insecure content, images and scripts to render and execute. Disabling allows only secure content.)" options.push(<Input key="inputDisableWebSecurity" ref="disablewebsecurity" type="checkbox" label="Allow mixed content (Enabling allows both secure and insecure content, images and scripts to render and execute. Disabling allows only secure content.)"
checked={ this.state.disablewebsecurity } onChange={ this.handleChangeDisableWebSecurity } />); checked={ this.state.disablewebsecurity } onChange={ this.handleChangeDisableWebSecurity } />);
//OSX has an option in the tray, to set the app to autostart, so we choose to not support this option for OSX //OSX has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX
if (process.platform === 'win32' || process.platform === 'linux') { if (process.platform === 'win32' || process.platform === 'linux') {
options.push(<Input key="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart } />); options.push(<Input key="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart } />);
} }
@ -223,7 +211,7 @@ var SettingsPage = React.createClass({
<h2>Teams</h2> <h2>Teams</h2>
</Col> </Col>
<Col xs={ 4 } sm={ 2 } md={ 1 } lg={ 1 } mdPull={ 1 }> <Col xs={ 4 } sm={ 2 } md={ 1 } lg={ 1 } mdPull={ 1 }>
<Button className="pull-right" style={ buttonStyle } bsSize="small" onClick={ this.handleShowTeamForm }> <Button className="pull-right" style={ buttonStyle } bsSize="small" onClick={ this.toggleShowTeamForm }>
<Glyphicon glyph="plus" /> <Glyphicon glyph="plus" />
</Button> </Button>
</Col> </Col>
@ -267,7 +255,7 @@ var TeamList = React.createClass({
var teams = this.props.teams; var teams = this.props.teams;
// check if team already exists and then change existing team or add new one // check if team already exists and then change existing team or add new one
if (!team.index && teams[team.index]) { if ((team.index!==undefined) && teams[team.index]) {
teams[team.index].name = team.name; teams[team.index].name = team.name;
teams[team.index].url = team.url; teams[team.index].url = team.url;
} else { } else {