fixed sensor tree

This commit is contained in:
snoop 2017-07-25 19:52:20 +09:00
parent 8355a6c4ba
commit 8be06bf2ae
2 changed files with 15 additions and 5 deletions

View File

@ -24,7 +24,7 @@ export type SensorItemTreeProps = SensorItemTreeStateProps & SensorItemTreeDispa
export interface SensorItemTreeState { export interface SensorItemTreeState {
portState: { [key: number]: boolean }; portState: Map<number, boolean>;
} }
interface TreeItem { interface TreeItem {
@ -42,7 +42,7 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
this.itemMap = new Map; this.itemMap = new Map;
this.state = { this.state = {
portState: {}, portState: new Map(),
}; };
this.sortItemMap(); this.sortItemMap();
@ -69,13 +69,20 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
public ViewSensorItemType(): JSX.Element[] { public ViewSensorItemType(): JSX.Element[] {
let elems: JSX.Element[] = new Array(); let elems: JSX.Element[] = new Array();
this.itemMap.forEach((data: TreeItem, key: number) => { this.itemMap.forEach((data: TreeItem, key: number) => {
// this.state.portState[key] = false;
elems.push( elems.push(
<List.Item key={key} > <List.Item key={key} >
<List.Icon name='chevron up' /> <List.Icon name={this.state.portState[key] ? 'chevron up' : 'chevron down'} onClick={() => {
let newPortState: Map<number, boolean> = new Map(this.state.portState);
newPortState[key] = true;
this.setState({ portState: newPortState });
}} />
<List.Content> <List.Content>
<List.Header> <Checkbox label={data.metaSensorItemType.name} /> </List.Header> <List.Header> <Checkbox label={data.metaSensorItemType.name} /> </List.Header>
<List.Description>Category</List.Description> <List.Description>Category</List.Description>
{this.ViewSensorItem(data.metaSensorItemList)} {this.state.portState[key] ? this.ViewSensorItem(data.metaSensorItemList) : ''}
</List.Content> </List.Content>
</List.Item>, </List.Item>,
); );

View File

@ -4,6 +4,8 @@ import { Grid, Image, Label, Segment, Dropdown, Input, List, Accordion, Loader }
import MetaCrawler from '@overflow/meta/api/model/MetaCrawler'; import MetaCrawler from '@overflow/meta/api/model/MetaCrawler';
import SensorItemTree from '@overflow/meta/react/SensorItemTree';
export interface SensorConfigurationStateProps { export interface SensorConfigurationStateProps {
} }
@ -28,7 +30,7 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp
public render(): JSX.Element { public render(): JSX.Element {
let steps = [<CrawlerSelector />, <SensorItemSelector />, <ETCSelector />]; let steps = [<CrawlerSelector />, <SensorItemTree />, <ETCSelector />];
return ( return (
<ConfigStepper steps={steps} /> <ConfigStepper steps={steps} />
@ -143,6 +145,7 @@ export class ConfigStepper extends React.Component<ConfigStepperProps, ConfigSte
<Button content='Next' icon='right arrow' labelPosition='right' positive <Button content='Next' icon='right arrow' labelPosition='right' positive
onClick={this.handleNext.bind(this)} disabled={this.checkNextDisabled()} /> onClick={this.handleNext.bind(this)} disabled={this.checkNextDisabled()} />
</Button.Group> </Button.Group>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</Container> </Container>
); );
} }