From 77fb39778fc4ebb3eea9e9801320efe1a4878c9a Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:08:52 -0500 Subject: =?UTF-8?q?Add=20Almacen,=20Ruta,=20Camiones=20(Flota,=20Camiones,?= =?UTF-8?q?=20Aver=C3=ADas)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #TODO - Arreglar combos - Añadir los reducer de camiones, rutas, almacen --- .../app/components/Tables/CrudTableForm.js | 8 +- .../app/components/Tables/CrudTableForm2.js | 101 +++++++++++++++++++++ .../components/Tables/tableParts/RowReadOnly.js | 10 ++ .../components/Tables/tableParts/tableStyle-jss.js | 2 +- 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 front/odiparpack/app/components/Tables/CrudTableForm2.js (limited to 'front/odiparpack/app/components/Tables') diff --git a/front/odiparpack/app/components/Tables/CrudTableForm.js b/front/odiparpack/app/components/Tables/CrudTableForm.js index 017a3fc..8b7e6d5 100644 --- a/front/odiparpack/app/components/Tables/CrudTableForm.js +++ b/front/odiparpack/app/components/Tables/CrudTableForm.js @@ -5,16 +5,16 @@ 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) { + /* 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(() => { diff --git a/front/odiparpack/app/components/Tables/CrudTableForm2.js b/front/odiparpack/app/components/Tables/CrudTableForm2.js new file mode 100644 index 0000000..dd24aec --- /dev/null +++ b/front/odiparpack/app/components/Tables/CrudTableForm2.js @@ -0,0 +1,101 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Form from './tableParts/Form'; +import MainTableForm from './tableParts/MainTableForm'; +import FloatingPanel from '../Panel/FloatingPanel'; + +class CrudTableForm extends React.Component { + /* 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() { + const { + title, + dataTable, + openForm, + closeForm, + removeRow, + addNew, + editRow, + anchor, + children, + branch, + initValues, + removeRowAPI + } = this.props; + return ( +