Sorted teams by alphabetical order under System Console > Teams (#3868)

Этот коммит содержится в:
Ryan Wang
2016-08-25 10:45:24 -04:00
коммит произвёл Joram Wilander
родитель b49a019cec
Коммит dfaccff44b

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

@@ -14,6 +14,7 @@ export default class SelectTeamModal extends React.Component {
this.doSubmit = this.doSubmit.bind(this); this.doSubmit = this.doSubmit.bind(this);
this.doCancel = this.doCancel.bind(this); this.doCancel = this.doCancel.bind(this);
this.compare = this.compare.bind(this);
} }
doSubmit(e) { doSubmit(e) {
@@ -23,15 +24,32 @@ export default class SelectTeamModal extends React.Component {
doCancel() { doCancel() {
this.props.onModalDismissed(); this.props.onModalDismissed();
} }
compare(a, b) {
if (a.display_name < b.display_name) {
return -1;
}
if (a.display_name > b.display_name) {
return 1;
}
return 0;
}
render() { render() {
if (this.props.teams == null) { if (this.props.teams == null) {
return <div/>; return <div/>;
} }
var options = []; const options = [];
var teams = this.props.teams; const teamsArray = [];
Reflect.ownKeys(teams).forEach((key) => {
var team = teams[key]; Reflect.ownKeys(this.props.teams).forEach((key) => {
teamsArray.push(this.props.teams[key]);
});
teamsArray.sort(this.compare);
for (let i = 0; i < teamsArray.length; i++) {
const team = teamsArray[i];
options.push( options.push(
<option <option
key={'opt_' + team.id} key={'opt_' + team.id}
@@ -40,7 +58,7 @@ export default class SelectTeamModal extends React.Component {
{team.display_name} {team.display_name}
</option> </option>
); );
}); }
return ( return (
<Modal <Modal