summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/components/Tables
diff options
context:
space:
mode:
authorDayana31 <[email protected]>2022-06-01 16:43:23 -0500
committerDayana31 <[email protected]>2022-06-01 16:43:23 -0500
commitec0c33156713e51c64f2a9de4f932cd5507c654b (patch)
treecc46421686a49bbc0a0c343e460c13a21af1015d /front/odiparpack/app/components/Tables
parent6971201caffc2fccee5bfb12e88e5510c85eeb49 (diff)
parente9cb09907f8dbc9a4a64549a3ea4d1d8313e7c25 (diff)
downloadDP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.tar.gz
DP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.tar.bz2
DP1_project-ec0c33156713e51c64f2a9de4f932cd5507c654b.zip
Merge branch 'develop' into dayana
Diffstat (limited to 'front/odiparpack/app/components/Tables')
-rw-r--r--front/odiparpack/app/components/Tables/CrudTableForm.js37
-rw-r--r--front/odiparpack/app/components/Tables/tableParts/Form.js4
-rw-r--r--front/odiparpack/app/components/Tables/tableParts/MainTableForm.js6
-rw-r--r--front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js43
4 files changed, 75 insertions, 15 deletions
diff --git a/front/odiparpack/app/components/Tables/CrudTableForm.js b/front/odiparpack/app/components/Tables/CrudTableForm.js
index d2d2ea8..017a3fc 100644
--- a/front/odiparpack/app/components/Tables/CrudTableForm.js
+++ b/front/odiparpack/app/components/Tables/CrudTableForm.js
@@ -5,14 +5,42 @@ import MainTableForm from './tableParts/MainTableForm';
import FloatingPanel from './../Panel/FloatingPanel';
class CrudTableForm extends React.Component {
- componentDidMount() {
+ /* componentDidMount(){
this.props.fetchData(this.props.dataInit, this.props.branch);
+ } */
+
+ componentDidUpdate(previousProps) {
+ if (previousProps.dataInit !== this.props.dataInit) {
+ //console.log("en el FORM",this.props.dataInit)}
+ this.props.fetchData(this.props.dataInit, this.props.branch);
+ }
}
sendValues = (values) => {
setTimeout(() => {
this.props.submit(values, this.props.branch);
}, 500);
+ if (this.props.editingId === this.props.initValues.get('id')) {
+ this.props.dispatch(this.props.editRowAPI()).then((res) => {
+ if (res) {
+ console.log("EDIT RO ", res)
+ }
+ })
+ } else {
+ this.props.dispatch(this.props.addNewAPI()).then((res) => {
+ if (res) {
+ console.log("ADD NEW FORM ", res)
+ }
+ })
+ }
+
+ }
+
+ getTitle( ){
+ if (this.props.editingId === this.props.initValues.get(this.props.anchor[0].name)) {
+ return "Editar"
+ }
+ return "Añadir nuevo"
}
render() {
@@ -27,11 +55,13 @@ class CrudTableForm extends React.Component {
anchor,
children,
branch,
- initValues
+ initValues,
+ removeRowAPI
} = this.props;
return (
<div>
- <FloatingPanel openForm={openForm} branch={branch} closeForm={closeForm}>
+
+ <FloatingPanel openForm={openForm} branch={branch} closeForm={closeForm} title = {this.getTitle()}>
<Form onSubmit={this.sendValues} initValues={initValues} branch={branch}>
{children}
</Form>
@@ -44,6 +74,7 @@ class CrudTableForm extends React.Component {
editRow={editRow}
anchor={anchor}
branch={branch}
+ removeRowAPI={removeRowAPI}
/>
</div>
);
diff --git a/front/odiparpack/app/components/Tables/tableParts/Form.js b/front/odiparpack/app/components/Tables/tableParts/Form.js
index da66966..66188c7 100644
--- a/front/odiparpack/app/components/Tables/tableParts/Form.js
+++ b/front/odiparpack/app/components/Tables/tableParts/Form.js
@@ -31,14 +31,14 @@ class Form extends Component {
</section>
<div className={css.buttonArea}>
<Button variant="contained" color="secondary" type="submit" disabled={submitting}>
- Submit
+ Guardar
</Button>
<Button
type="button"
disabled={pristine || submitting}
onClick={reset}
>
- Reset
+ Limpiar
</Button>
</div>
</form>
diff --git a/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js b/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js
index ccf0e4a..1437fa8 100644
--- a/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js
+++ b/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js
@@ -29,7 +29,8 @@ class MainTableForm extends React.Component {
editRow,
addNew,
anchor,
- branch
+ branch,
+ removeRowAPI
} = this.props;
const getItems = dataArray => dataArray.map(item => (
<RowReadOnly
@@ -39,6 +40,7 @@ class MainTableForm extends React.Component {
editRow={() => editRow(item, branch)}
anchor={anchor}
branch={branch}
+ removeRowAPI = {removeRowAPI}
/>
));
@@ -61,7 +63,7 @@ class MainTableForm extends React.Component {
<Tooltip title="Add Item">
<Button variant="contained" onClick={() => addNew(anchor, branch)} color="secondary" className={classes.button}>
<AddIcon className={classNames(classes.leftIcon, classes.iconSmall)} />
- Add New
+ Añadir
</Button>
</Tooltip>
</div>
diff --git a/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js b/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js
index 7da655f..d060d02 100644
--- a/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js
+++ b/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js
@@ -5,8 +5,10 @@ import classNames from 'classnames';
import css from 'ba-styles/Table.scss';
import DeleteIcon from '@material-ui/icons/Delete';
import EditIcon from '@material-ui/icons/BorderColor';
+import { etiqueta } from 'ba-components/Odipar/common';
-import { TableCell, IconButton } from '@material-ui/core';
+import { TableCell, IconButton, LinearProgress } from '@material-ui/core';
+import { connect } from 'react-redux';
const styles = theme => ({
button: {
@@ -22,21 +24,40 @@ class RowReadOnly extends React.Component {
item,
removeRow,
editRow,
- branch
+ branch,
+ removeRowAPI
} = this.props;
const eventDel = () => {
removeRow(item, branch);
+ this.props.dispatch(removeRowAPI()).then((res) => {
+ if (res) {
+ console.log("REMOVE READ ONLY ", res)
+ }
+ })
};
const eventEdit = () => {
editRow(item, branch);
};
const renderCell = dataArray => dataArray.map((itemCell, index) => {
if (itemCell.name !== 'action' && !itemCell.hidden) {
- return (
- <TableCell padding="none" key={index.toString()}>
- {item.get(itemCell.name) !== undefined ? item.get(itemCell.name).toString() : ''}
- </TableCell>
- );
+ const inputType = anchor[index].type;
+ switch (inputType) {
+ case 'etiq_pedido':
+ case 'etiq_camion':
+ case 'etiq_bloqueo':
+ case 'etiq_alma':
+ return (
+ <TableCell padding="none" key={index.toString()}>
+ {etiqueta(inputType, item.get(itemCell.name))}
+ </TableCell>
+ );
+ case 'texto':
+ return (
+ <TableCell padding="none" key={index.toString()}>
+ {item.get(itemCell.name) !== undefined ? item.get(itemCell.name).toString() : ''}
+ </TableCell>
+ );
+ }
}
return false;
});
@@ -72,5 +93,11 @@ RowReadOnly.propTypes = {
editRow: PropTypes.func.isRequired,
branch: PropTypes.string.isRequired,
};
+const mapDispatchToProps = dispatch => ({
+ dispatch
+});
-export default withStyles(styles)(RowReadOnly);
+const RowReadOnlyMapped = connect(
+ mapDispatchToProps
+)(RowReadOnly);
+export default withStyles(styles)(RowReadOnlyMapped);