From 737784c6ec99663811fa4c6bcc32800e47b1c689 Mon Sep 17 00:00:00 2001 From: Milos Despotovic Date: Mon, 16 Dec 2024 12:04:17 -0800 Subject: [PATCH] Save only updated attributes --- .../customComponents/Records/MCFPersonal.js | 18 +++++++++--------- .../FOI/customComponents/Records/index.js | 5 ++--- .../request_api/services/recordservice.py | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/forms-flow-web/src/components/FOI/customComponents/Records/MCFPersonal.js b/forms-flow-web/src/components/FOI/customComponents/Records/MCFPersonal.js index b0cf9a440..cadd08d70 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/MCFPersonal.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/MCFPersonal.js @@ -92,15 +92,15 @@ const MCFPersonal = ({ && personalAttributes?.volume === "" ); } else { - setDisableSave( - personalAttributes?.person === undefined - || personalAttributes?.person === "" - || personalAttributes?.filetype === undefined - || personalAttributes?.filetype === "" - || personalAttributes?.trackingid === undefined - || personalAttributes?.trackingid === "" - || (!isMinistryCoordinator && comparePersonalAttributes(personalAttributes, curPersonalAttributes)) - || (isMinistryCoordinator && comparePersonalAttributes(personalAttributes, curPersonalAttributes) && compareDivision(currentEditRecord.attributes.divisions[0].divisionid, divisionModalTagValue)) + setDisableSave( + personalAttributes?.person === undefined + || personalAttributes?.person === "" + || personalAttributes?.filetype === undefined + || personalAttributes?.filetype === "" + || personalAttributes?.trackingid === undefined + || personalAttributes?.trackingid === "" + || (!isMinistryCoordinator && comparePersonalAttributes(personalAttributes, curPersonalAttributes)) + || (isMinistryCoordinator && comparePersonalAttributes(personalAttributes, curPersonalAttributes) && compareDivision(currentEditRecord.attributes.divisions[0].divisionid, divisionModalTagValue)) ); } },[personalAttributes, divisionModalTagValue]) diff --git a/forms-flow-web/src/components/FOI/customComponents/Records/index.js b/forms-flow-web/src/components/FOI/customComponents/Records/index.js index 15e0580f5..882bcd914 100644 --- a/forms-flow-web/src/components/FOI/customComponents/Records/index.js +++ b/forms-flow-web/src/components/FOI/customComponents/Records/index.js @@ -1892,8 +1892,7 @@ export const RecordsLog = ({ useEffect(() => { let selectedRecords = records.filter((record) => record.isselected); - let isBulkEdit = selectedRecords.length > 1; - setIsBulkEdit(isBulkEdit); + setIsBulkEdit(selectedRecords.length > 1); }, [records]) const isBulkEditDisabled = () => { @@ -1944,7 +1943,7 @@ export const RecordsLog = ({ } } } - } else if (selectedRecords.length > 1) { + } else if (selectedRecords.length > 1 && !currentEditRecord) { for (let selectedRecord of selectedRecords) { updateRecords.push( { diff --git a/request-management-api/request_api/services/recordservice.py b/request-management-api/request_api/services/recordservice.py index 658faeafe..e84b02d3a 100644 --- a/request-management-api/request_api/services/recordservice.py +++ b/request-management-api/request_api/services/recordservice.py @@ -82,7 +82,8 @@ def updatepersonalattributes(self, requestid, ministryrequestid, requestdata, us for record in records: record['attributes'] = json.loads(record['attributes']) for attribute in requestdata['newpersonalattributes']: - record['attributes']['personalattributes'][attribute] = requestdata['newpersonalattributes'][attribute] + if (requestdata['newpersonalattributes'][attribute] is not None and len(requestdata['newpersonalattributes'][attribute]) > 0): + record['attributes']['personalattributes'][attribute] = requestdata['newpersonalattributes'][attribute] # divisions = divisions + [div for div in record['attributes']['divisions'] if div not in divisions] record.update({'updated_at': datetime.now(), 'updatedby': userid}) record['version'] += 1