Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hbcarlos committed Jan 13, 2023
1 parent 682c469 commit 0f5f9f2
Showing 1 changed file with 88 additions and 86 deletions.
174 changes: 88 additions & 86 deletions src/toolbar/gridtoolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IProps {

interface IState {
Grid: IDict;
Axe: IDict;
Axe: IDict;
}

export class HelpersToolbarReact extends React.Component<IProps, IState> {
Expand All @@ -21,7 +21,7 @@ export class HelpersToolbarReact extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props);
this._model = this.props.toolbarModel.jcadModel!;
this.state = this._createSchema();
this.state = this._createSchema();
}

componentDidMount(): void {
Expand All @@ -32,104 +32,106 @@ export class HelpersToolbarReact extends React.Component<IProps, IState> {
this._model.viewChanged.disconnect(this._updateSchema, this);
}

private _createSchema(): IState {
private _createSchema(): IState {
const grid: GridHelper = {
size: 40,
divisions: 40,
visible: false
};
const axe: AxeHelper = {
size: 5,
visible: false
};
this._model.setView('grid', grid);
this._model.setView('axe', axe);
size: 40,
divisions: 40,
visible: false
};
const axe: AxeHelper = {
size: 5,
visible: false
};
this._model.setView('grid', grid);
this._model.setView('axe', axe);

return {
Grid: {
title: 'Grid Helper',
shape: 'Grid::Helper',
schema: this.props.toolbarModel.formSchema['Grid::Helper'],
default: {
Name: 'Grid Helper',
Size: grid?.size ?? 40,
Divisions: grid?.divisions ?? 40,
Visible: grid?.visible ?? true
},
syncData: (props: IDict) => {
const { Size, Divisions, Visible } = props;
const grid: GridHelper = {
size: Size,
divisions: Divisions,
visible: Visible
};
this._model.setView('grid', grid);
}
},
Axe: {
title: 'Axe Helper',
shape: 'Axe::Helper',
schema: this.props.toolbarModel.formSchema['Axe::Helper'],
default: {
Name: 'Axe Helper',
Size: axe?.size ?? 5,
Visible: axe?.visible ?? true
},
syncData: (props: IDict) => {
const { Size, Visible } = props;
const axe: AxeHelper = {
size: Size,
visible: Visible
};
this._model.setView('axe', axe);
}
}
Grid: {
title: 'Grid Helper',
shape: 'Grid::Helper',
schema: this.props.toolbarModel.formSchema['Grid::Helper'],
default: {
Name: 'Grid Helper',
Size: grid?.size ?? 40,
Divisions: grid?.divisions ?? 40,
Visible: grid?.visible ?? true
},
syncData: (props: IDict) => {
const { Size, Divisions, Visible } = props;
const grid: GridHelper = {
size: Size,
divisions: Divisions,
visible: Visible
};
this._model.setView('grid', grid);
}
},
Axe: {
title: 'Axe Helper',
shape: 'Axe::Helper',
schema: this.props.toolbarModel.formSchema['Axe::Helper'],
default: {
Name: 'Axe Helper',
Size: axe?.size ?? 5,
Visible: axe?.visible ?? true
},
syncData: (props: IDict) => {
const { Size, Visible } = props;
const axe: AxeHelper = {
size: Size,
visible: Visible
};
this._model.setView('axe', axe);
}
}
};
}

private _updateSchema(): void {
const grid = this._model.getView('grid') as GridHelper | undefined;
const axe = this._model.getView('axe') as AxeHelper | undefined;

const { Grid, Axe } = this.state;
Grid["default"] = {
Name: 'Grid Helper',
Size: grid?.size ?? 40,
Divisions: grid?.divisions ?? 40,
Visible: grid?.visible ?? true
};
const axe = this._model.getView('axe') as AxeHelper | undefined;

Axe["default"] = {
Name: 'Axe Helper',
Size: axe?.size ?? 5,
Visible: axe?.visible ?? true
};
const { Grid, Axe } = this.state;
Grid['default'] = {
Name: 'Grid Helper',
Size: grid?.size ?? 40,
Divisions: grid?.divisions ?? 40,
Visible: grid?.visible ?? true
};

Axe['default'] = {
Name: 'Axe Helper',
Size: axe?.size ?? 5,
Visible: axe?.visible ?? true
};

this.setState({ Grid, Axe });
this.setState({ Grid, Axe });
}

render(): React.ReactNode {
return (
<div style={{ paddingLeft: '10px', display: 'flex' }}>
{ Object.entries(this.state).map(([key, value]) => {
return <Button
className={'jp-ToolbarButtonComponent'}
style={{ color: 'var(--jp-ui-font-color1)' }}
onClick={async () => {
const dialog = new FormDialog({
toolbarModel: this.props.toolbarModel,
title: value.title,
sourceData: value.default,
schema: value.schema,
syncData: value.syncData,
cancelButton: true
});
await dialog.launch();
}}
>
{key}
</Button>
})}
{Object.entries(this.state).map(([key, value]) => {
return (
<Button
className={'jp-ToolbarButtonComponent'}
style={{ color: 'var(--jp-ui-font-color1)' }}
onClick={async () => {
const dialog = new FormDialog({
toolbarModel: this.props.toolbarModel,
title: value.title,
sourceData: value.default,
schema: value.schema,
syncData: value.syncData,
cancelButton: true
});
await dialog.launch();
}}
>
{key}
</Button>
);
})}
</div>
);
}
Expand Down

0 comments on commit 0f5f9f2

Please sign in to comment.