Skip to content

Commit 50a4d24

Browse files
authored
Merge pull request #42 from ShlomoPorges/development
Props logic - prop table and some other changes
2 parents 801cf7b + 2a59c1c commit 50a4d24

File tree

9 files changed

+300
-16739
lines changed

9 files changed

+300
-16739
lines changed

package-lock.json

Lines changed: 0 additions & 16635 deletions
This file was deleted.

src/actions/components.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ export const openExpansionPanel = component => ({
213213
// type: DELETE_ALL_DATA,
214214
// });
215215

216-
export const deleteProp = ({ id, index }) => ({
217-
type: DELETE_PROP,
218-
payload: { id, index },
219-
});
216+
217+
218+
export const deleteProp = ( propId ) => (dispatch) => {
219+
; dispatch({ type: DELETE_PROP, payload: propId });
220+
};
220221

221222
export const addProp = prop => ({
222223
type: ADD_PROP,

src/components/BottomPanel.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ const mapDispatchToProps = dispatch => ({
1212
});
1313

1414
const mapStateToProps = store => ({
15-
successOpen: store.workspace.successOpen,
16-
errorOpen: store.workspace.errorOpen,
17-
appDir: store.workspace.appDir,
15+
// successOpen: store.workspace.successOpen,
16+
// errorOpen: store.workspace.errorOpen,
17+
// appDir: store.workspace.appDir,
1818
});
1919

2020
class BottomPanel extends Component {
21-
state = {
22-
successOpen: false,
23-
errorOpen: false,
24-
};
21+
// state = {
22+
// successOpen: false,
23+
// errorOpen: false,
24+
// };
2525

2626
viewAppDir = () => {
2727
IPC.send('view_app_dir', this.props.appDir);

src/components/DataTable.jsx

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React from 'react';
2+
// import PropTypes from 'prop-types';
3+
import { withStyles } from '@material-ui/core/styles';
4+
import Table from '@material-ui/core/Table';
5+
import TableBody from '@material-ui/core/TableBody';
6+
import TableCell from '@material-ui/core/TableCell';
7+
import TableHead from '@material-ui/core/TableHead';
8+
import TableRow from '@material-ui/core/TableRow';
9+
import Paper from '@material-ui/core/Paper';
10+
import Button from '@material-ui/core/Button';
11+
12+
13+
14+
const styles = theme => ({
15+
root: {
16+
width: '100%',
17+
marginTop: theme.spacing.unit * 3,
18+
overflowX: 'auto',
19+
},
20+
table: {
21+
minWidth: 700,
22+
},
23+
});
24+
25+
26+
/****************************
27+
* cannot have a row header or a key in the data called "key"
28+
* ,ust have unique id
29+
* ****************************** */
30+
31+
function dataTable(props) {
32+
const { classes , rowData, rowHeader , deletePropHandler } = props;
33+
34+
// console.log(classes)
35+
console.log(`rowHeader`)
36+
console.log(rowHeader)
37+
console.log(`rowData`)
38+
console.log(rowData)
39+
40+
const renderHeader = rowHeader.map( (col,idx) => {
41+
return <TableCell key={`head_+${idx}`}>{col}</TableCell>
42+
})
43+
44+
function renderRowCells (row) {
45+
if(!row) return;
46+
// for some reason we must put each value in a div.
47+
return (
48+
rowHeader.map( (header,idx) =>
49+
<TableCell key={'td_'+ idx}>
50+
<div>
51+
{ typeof row[header] == 'string' ? row[header] : row[header].toString() }
52+
</div>
53+
</TableCell>
54+
)
55+
)
56+
}
57+
58+
const renderRows =
59+
rowData.map((row) =>
60+
<TableRow key={`row-${row.id}`}>
61+
{renderRowCells(row)}
62+
<TableCell>
63+
<Button onClick={ ()=>deletePropHandler(row.id) } >
64+
Delete
65+
</Button>
66+
</TableCell>
67+
</TableRow>
68+
)
69+
70+
return (
71+
<Paper className={classes.root}>
72+
<Table className={classes.table}>
73+
<TableHead>
74+
<TableRow>
75+
{renderHeader}
76+
</TableRow>
77+
</TableHead>
78+
<TableBody>
79+
{renderRows}
80+
</TableBody>
81+
</Table>
82+
</Paper>
83+
);
84+
}
85+
86+
// dataTable.propTypes = {
87+
// classes: PropTypes.object.isRequired,
88+
// };
89+
90+
export default withStyles(styles)(dataTable);

src/components/LeftColExpansionPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const LeftColExpansionPanel = (props) => {
4949
style={{ color }}
5050
/>
5151
<ListItemSecondaryAction>
52-
{isFocused() || !selectableChildren.includes(id) ? (
52+
{ id == 1 || isFocused() || !selectableChildren.includes(id) ? (
5353
<div />
5454
) : (
5555
<IconButton aria-label="Add">

0 commit comments

Comments
 (0)