Permalink
Browse files

Show current unit detail values in the Unit TOE tree

  • Loading branch information...
markerikson committed Jan 1, 2018
1 parent eca8838 commit cf8e19c699fa80f3f9c7fca57e812f6bb165f240
Showing with 26 additions and 4 deletions.
  1. +26 −4 src/features/unitInfo/UnitOrganizationTree/UnitOrganizationTree.jsx
@@ -13,26 +13,48 @@ const mapState = (state) => {
const session = getEntitiesSession(state);
const {Unit} = session;
let lances;
let unit, faction, lances;
const unitModel = Unit.all().first();
if(unitModel) {
unit = unitModel.ref;
faction = unitModel.affiliation.ref;
lances = unitModel.lances.toRefArray().map(lance => lance.id);
}
return {lances};
return {unit, faction, lances};
}
const UnitOrganizationTree = ({lances = []}) => {
const UNKNOWN_UNIT = {name : "Unknown"};
const UnitOrganizationTree = ({unit = UNKNOWN_UNIT, faction = {}, lances = []}) => {
const {name, color} = unit;
const {name : factionName} = faction;
const colorBlock = <div
style={{
marginLeft : 10,
backgroundColor : color,
border : "1px solid black",
height : 20,
width : 40,
}}
/>;
const displayText = factionName ? `${name} / ${factionName}` : name;
const lanceEntries = lances.map(lanceID => <Lance key={lanceID} lanceID={lanceID} />);
return (
<List size="large">
<List.Item>
<List.Icon name="cubes" />
<List.Content>
<List.Header>Black Widow Company</List.Header>
<List.Header style={{display : "flex"}}>{displayText} {colorBlock}</List.Header>
<List.List>
{lanceEntries}
</List.List>

0 comments on commit cf8e19c

Please sign in to comment.