Skip to content

Props logic - prop table and some other changes #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,635 changes: 0 additions & 16,635 deletions package-lock.json

This file was deleted.

9 changes: 5 additions & 4 deletions src/actions/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ export const openExpansionPanel = component => ({
// type: DELETE_ALL_DATA,
// });

export const deleteProp = ({ id, index }) => ({
type: DELETE_PROP,
payload: { id, index },
});


export const deleteProp = ( propId ) => (dispatch) => {
; dispatch({ type: DELETE_PROP, payload: propId });
};

export const addProp = prop => ({
type: ADD_PROP,
Expand Down
14 changes: 7 additions & 7 deletions src/components/BottomPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ const mapDispatchToProps = dispatch => ({
});

const mapStateToProps = store => ({
successOpen: store.workspace.successOpen,
errorOpen: store.workspace.errorOpen,
appDir: store.workspace.appDir,
// successOpen: store.workspace.successOpen,
// errorOpen: store.workspace.errorOpen,
// appDir: store.workspace.appDir,
});

class BottomPanel extends Component {
state = {
successOpen: false,
errorOpen: false,
};
// state = {
// successOpen: false,
// errorOpen: false,
// };

viewAppDir = () => {
IPC.send('view_app_dir', this.props.appDir);
Expand Down
90 changes: 90 additions & 0 deletions src/components/DataTable.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from 'react';
// import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';



const styles = theme => ({
root: {
width: '100%',
marginTop: theme.spacing.unit * 3,
overflowX: 'auto',
},
table: {
minWidth: 700,
},
});


/****************************
* cannot have a row header or a key in the data called "key"
* ,ust have unique id
* ****************************** */

function dataTable(props) {
const { classes , rowData, rowHeader , deletePropHandler } = props;

// console.log(classes)
console.log(`rowHeader`)
console.log(rowHeader)
console.log(`rowData`)
console.log(rowData)

const renderHeader = rowHeader.map( (col,idx) => {
return <TableCell key={`head_+${idx}`}>{col}</TableCell>
})

function renderRowCells (row) {
if(!row) return;
// for some reason we must put each value in a div.
return (
rowHeader.map( (header,idx) =>
<TableCell key={'td_'+ idx}>
<div>
{ typeof row[header] == 'string' ? row[header] : row[header].toString() }
</div>
</TableCell>
)
)
}

const renderRows =
rowData.map((row) =>
<TableRow key={`row-${row.id}`}>
{renderRowCells(row)}
<TableCell>
<Button onClick={ ()=>deletePropHandler(row.id) } >
Delete
</Button>
</TableCell>
</TableRow>
)

return (
<Paper className={classes.root}>
<Table className={classes.table}>
<TableHead>
<TableRow>
{renderHeader}
</TableRow>
</TableHead>
<TableBody>
{renderRows}
</TableBody>
</Table>
</Paper>
);
}

// dataTable.propTypes = {
// classes: PropTypes.object.isRequired,
// };

export default withStyles(styles)(dataTable);
2 changes: 1 addition & 1 deletion src/components/LeftColExpansionPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const LeftColExpansionPanel = (props) => {
style={{ color }}
/>
<ListItemSecondaryAction>
{isFocused() || !selectableChildren.includes(id) ? (
{ id == 1 || isFocused() || !selectableChildren.includes(id) ? (
<div />
) : (
<IconButton aria-label="Add">
Expand Down
Loading