From 08377509f90b88af869989d0dec4d0f12dd711e8 Mon Sep 17 00:00:00 2001 From: barlas <yannisbarlas@gmail.com> Date: Mon, 5 Dec 2016 13:42:48 +0200 Subject: [PATCH] guarantee team order in team manager modal --- .../BookBuilder/TeamManager/GroupList.jsx | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/app/components/BookBuilder/TeamManager/GroupList.jsx b/app/components/BookBuilder/TeamManager/GroupList.jsx index 5c29388..e5d6d62 100644 --- a/app/components/BookBuilder/TeamManager/GroupList.jsx +++ b/app/components/BookBuilder/TeamManager/GroupList.jsx @@ -1,3 +1,4 @@ +import { find, keys } from 'lodash' import React from 'react' import Group from './Group' @@ -27,11 +28,20 @@ export class GroupList extends React.Component { render () { const { teams, users, update } = this.props - const self = this + const options = this.options - const groups = teams.map(function (team, i) { - const name = team.name.trim() - if (!self.options[name]) return + // TODO -- refactor + // do it like this to guarantee order of groups + const groups = keys(options).map((key, i) => { + let name + + // get team of this name + const team = find(teams, (team) => { + name = team.name.trim() + return name === key + }) + + if (!team) return return ( <div key={i}> @@ -39,7 +49,7 @@ export class GroupList extends React.Component { team={team} users={users} update={update} - options={self.options[name]} + options={options[name]} /> <div className={styles.groupSeperator} /> </div> @@ -61,18 +71,3 @@ GroupList.propTypes = { } export default GroupList - -/* - -<TeamGroup - type="copyEditor" -/> - -<div className={styles.groupSeperator} /> - -<TeamGroup - type="author" -/> - -<div className={styles.groupSeperator} /> -*/ -- GitLab