Use new modal for edit functionality

This commit is contained in:
Jonas Schwabe
2017-01-30 21:46:58 +01:00
parent b94303bfc5
commit bb21cf56d3
2 changed files with 42 additions and 10 deletions

View File

@@ -14,7 +14,7 @@ const TeamList = React.createClass({
getInitialState() {
return {
showTeamListItemNew: false,
showEditTeamForm: false,
indexToRemoveServer: -1,
team: {
url: '',
@@ -41,7 +41,7 @@ const TeamList = React.createClass({
}
this.setState({
showTeamListItemNew: false,
showEditTeamForm: false,
team: {
url: '',
name: '',
@@ -53,7 +53,7 @@ const TeamList = React.createClass({
},
handleTeamEditing(teamName, teamUrl, teamIndex) {
this.setState({
showTeamListItemNew: true,
showEditTeamForm: true,
team: {
url: teamUrl,
name: teamName,
@@ -94,19 +94,40 @@ const TeamList = React.createClass({
});
var addTeamForm;
if (this.props.showAddTeamForm || this.state.showTeamListItemNew) {
if (this.props.showAddTeamForm || this.state.showEditTeamForm) {
addTeamForm = (
<NewTeamModal
onClose={this.props.toggleAddTeamForm}
onSave={(newTeam) => {
onClose={() => {
this.setState({
showNewTeamModal: false
showNewTeamModal: false,
showEditTeamForm: false,
team: {
name: '',
url: '',
index: false
}
});
}}
onSave={(newTeam) => {
if (this.props.showAddTeamForm) {
this.props.teams.push(newTeam);
} else {
this.props.teams[newTeam.index] = newTeam;
}
this.setState({
showNewTeamModal: false,
showEditTeamForm: false,
team: {
name: '',
url: '',
index: false
}
});
this.props.teams.push(newTeam);
this.render();
this.props.onTeamsChange(this.props.teams);
}}
team={this.state.team}
/>);
} else {
addTeamForm = '';