From b267828d91620e1b1e701e83930c6592ce24a095 Mon Sep 17 00:00:00 2001 From: Noor Date: Mon, 12 Oct 2020 18:22:49 -0400 Subject: [PATCH 1/7] added edit button and basic functionality --- frontend/src/components/EditPropertyModal.js | 33 ++++++-------------- frontend/src/components/SearchTable.js | 6 +++- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/EditPropertyModal.js b/frontend/src/components/EditPropertyModal.js index b8076be0..b4b10a07 100644 --- a/frontend/src/components/EditPropertyModal.js +++ b/frontend/src/components/EditPropertyModal.js @@ -1,52 +1,37 @@ import React from "react"; import { Modal, Button } from "react-bootstrap"; -import EditPropertyForm from "./EditPropertyForm"; -import { editProperty } from "../api/property"; +import PropertyForm from "./PropertyForm"; +import { postProperty } from "../api/property"; //fix with update import "../style/App.css"; const updateProperty = (formValues, setFormValues, setShowEditModal) => { - let formValues_withoutID = { ...formValues }; - delete formValues_withoutID.id; - editProperty(formValues_withoutID, formValues.id); + postProperty(formValues); setFormValues({}); setShowEditModal(false); }; const EditPropertyModal = ({ - showEditModal, + showModal, setShowEditModal, formValues, setFormValues, }) => { -const originalFormValues = { ...formValues }; {/**/} - console.log(originalFormValues); {/**/} - return ( <> - { - setShowEditModal(false) - }}> + setShowEditModal(false)}> - Edit Property + EDITING PROPERTY - + - diff --git a/frontend/src/components/SearchTable.js b/frontend/src/components/SearchTable.js index 1bcabd6a..7bf04562 100644 --- a/frontend/src/components/SearchTable.js +++ b/frontend/src/components/SearchTable.js @@ -24,7 +24,7 @@ export default function SearchTable(props) { )} {showEditModal ? ( { + setFormValues(r); + setShowEditModal(true); + }} /> From 8d07317a58ac2daf970026efe19930357cc90293 Mon Sep 17 00:00:00 2001 From: Noor Date: Wed, 4 Nov 2020 21:34:05 -0500 Subject: [PATCH 2/7] added API call --- frontend/src/components/EditPropertyModal.js | 28 ++++++++++++++------ frontend/src/components/SearchTable.js | 6 +---- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/EditPropertyModal.js b/frontend/src/components/EditPropertyModal.js index b4b10a07..628070a3 100644 --- a/frontend/src/components/EditPropertyModal.js +++ b/frontend/src/components/EditPropertyModal.js @@ -1,32 +1,44 @@ import React from "react"; import { Modal, Button } from "react-bootstrap"; -import PropertyForm from "./PropertyForm"; -import { postProperty } from "../api/property"; //fix with update +import EditPropertyForm from "./EditPropertyForm"; +import { editProperty } from "../api/property"; //fix with update import "../style/App.css"; const updateProperty = (formValues, setFormValues, setShowEditModal) => { - postProperty(formValues); + let formValues_withoutID = { ...formValues }; + delete formValues_withoutID.id; + editProperty(formValues_withoutID, formValues.id); setFormValues({}); setShowEditModal(false); }; const EditPropertyModal = ({ - showModal, + showEditModal, setShowEditModal, formValues, setFormValues, }) => { +const originalFormValues = { ...formValues }; {/**/} + console.log(originalFormValues); {/**/} + return ( <> - setShowEditModal(false)}> + { + setShowEditModal(false) + }}> - EDITING PROPERTY + Edit Property - + - From bb503d62422683106df3c3dbf4d0dfbe58ecdd42 Mon Sep 17 00:00:00 2001 From: Noor Date: Mon, 12 Oct 2020 18:22:49 -0400 Subject: [PATCH 4/7] added edit button and basic functionality --- frontend/src/components/EditPropertyModal.js | 33 ++++++-------------- frontend/src/components/SearchTable.js | 6 +++- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/EditPropertyModal.js b/frontend/src/components/EditPropertyModal.js index b8076be0..b4b10a07 100644 --- a/frontend/src/components/EditPropertyModal.js +++ b/frontend/src/components/EditPropertyModal.js @@ -1,52 +1,37 @@ import React from "react"; import { Modal, Button } from "react-bootstrap"; -import EditPropertyForm from "./EditPropertyForm"; -import { editProperty } from "../api/property"; +import PropertyForm from "./PropertyForm"; +import { postProperty } from "../api/property"; //fix with update import "../style/App.css"; const updateProperty = (formValues, setFormValues, setShowEditModal) => { - let formValues_withoutID = { ...formValues }; - delete formValues_withoutID.id; - editProperty(formValues_withoutID, formValues.id); + postProperty(formValues); setFormValues({}); setShowEditModal(false); }; const EditPropertyModal = ({ - showEditModal, + showModal, setShowEditModal, formValues, setFormValues, }) => { -const originalFormValues = { ...formValues }; {/**/} - console.log(originalFormValues); {/**/} - return ( <> - { - setShowEditModal(false) - }}> + setShowEditModal(false)}> - Edit Property + EDITING PROPERTY - + - diff --git a/frontend/src/components/SearchTable.js b/frontend/src/components/SearchTable.js index 1bcabd6a..7bf04562 100644 --- a/frontend/src/components/SearchTable.js +++ b/frontend/src/components/SearchTable.js @@ -24,7 +24,7 @@ export default function SearchTable(props) { )} {showEditModal ? ( { + setFormValues(r); + setShowEditModal(true); + }} /> From 4437bc9a758c49ccee1e7ce926a36bba44649ea8 Mon Sep 17 00:00:00 2001 From: Noor Date: Wed, 4 Nov 2020 21:34:05 -0500 Subject: [PATCH 5/7] added API call --- frontend/src/components/EditPropertyModal.js | 28 ++++++++++++++------ frontend/src/components/SearchTable.js | 6 +---- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/EditPropertyModal.js b/frontend/src/components/EditPropertyModal.js index b4b10a07..628070a3 100644 --- a/frontend/src/components/EditPropertyModal.js +++ b/frontend/src/components/EditPropertyModal.js @@ -1,32 +1,44 @@ import React from "react"; import { Modal, Button } from "react-bootstrap"; -import PropertyForm from "./PropertyForm"; -import { postProperty } from "../api/property"; //fix with update +import EditPropertyForm from "./EditPropertyForm"; +import { editProperty } from "../api/property"; //fix with update import "../style/App.css"; const updateProperty = (formValues, setFormValues, setShowEditModal) => { - postProperty(formValues); + let formValues_withoutID = { ...formValues }; + delete formValues_withoutID.id; + editProperty(formValues_withoutID, formValues.id); setFormValues({}); setShowEditModal(false); }; const EditPropertyModal = ({ - showModal, + showEditModal, setShowEditModal, formValues, setFormValues, }) => { +const originalFormValues = { ...formValues }; {/**/} + console.log(originalFormValues); {/**/} + return ( <> - setShowEditModal(false)}> + { + setShowEditModal(false) + }}> - EDITING PROPERTY + Edit Property - + - From 310b5a60ebb05438b5404253fb7bab3f20ed7a0f Mon Sep 17 00:00:00 2001 From: Noor Date: Fri, 18 Dec 2020 13:30:09 -0500 Subject: [PATCH 7/7] edit modal open on row click, ignore delete click --- frontend/src/components/SearchTable.js | 22 +++++++++++++++++----- frontend/src/components/Table.js | 4 ++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/SearchTable.js b/frontend/src/components/SearchTable.js index 1bcabd6a..8e99f340 100644 --- a/frontend/src/components/SearchTable.js +++ b/frontend/src/components/SearchTable.js @@ -10,6 +10,8 @@ export default function SearchTable(props) { const [showModal, setShowModal] = useState(false); const [showEditModal, setShowEditModal] = useState(false); const [formValues, setFormValues] = useState({}); + let isDeleteClicked = false; + return ( <> {showModal ? ( @@ -41,14 +43,24 @@ export default function SearchTable(props) { console.log("cname is ", cName); console.log("cIndex is ", cIndex); }} - onEditClick={(r) => { - setFormValues(r); - setShowEditModal(true); - }} + // onEditClick={(r) => { + // setFormValues(r); + // setShowEditModal(true); + // }} onRowSelect={(rName, rIndex) => { console.log(rName, rIndex); - // setShowModal(true); + console.log(isDeleteClicked); + if (!isDeleteClicked) { + setFormValues(rName); + setShowEditModal(true); + } + isDeleteClicked = false; }} + onDeleteClick={() => { + isDeleteClicked = true; + console.log(isDeleteClicked); + } + } /> diff --git a/frontend/src/components/Table.js b/frontend/src/components/Table.js index 7a523514..c3cb5eb4 100644 --- a/frontend/src/components/Table.js +++ b/frontend/src/components/Table.js @@ -18,8 +18,8 @@ const LocalTable = (props) => { {props.columns.map((c, columnIndex) => _renderCell(r[c.field], rowIndex, columnIndex) )} - - + {/* */} + );