diff --git a/CHANGELOG.md b/CHANGELOG.md index fad8aebd..a2d32782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ V1.0.3 If a user gets halfway through and stops, when they return they will be brought back to where they were. The data has always been saved. This will simply return them to that place in the process. +* Fixed bug which prevented adding new relationships to existing entities V1.0.2 diff --git a/client/scripts/stores/DisclosureStore.js b/client/scripts/stores/DisclosureStore.js index 08abfb86..beb16fd8 100644 --- a/client/scripts/stores/DisclosureStore.js +++ b/client/scripts/stores/DisclosureStore.js @@ -746,9 +746,7 @@ class _DisclosureStore extends AutoBindingStore { } }); } - entity.files = existingFiles; - formData.append('entity', JSON.stringify(entity)); if (!this.applicationState.entityStates[entity.id]) { diff --git a/server/db/DisclosureDB.js b/server/db/DisclosureDB.js index 2257959d..d58efc5e 100644 --- a/server/db/DisclosureDB.js +++ b/server/db/DisclosureDB.js @@ -176,7 +176,7 @@ export const saveExistingFinancialEntity = (dbInfo, userInfo, entityId, body, fi .then(dbRelationships => { return Promise.all( dbRelationships.filter(dbRelationship => { - const match = financialEntity.relationships.find(relationship => { + const match = financialEntity.relationships.some(relationship => { return relationship.id === dbRelationship.id; }); return !match; @@ -205,7 +205,8 @@ export const saveExistingFinancialEntity = (dbInfo, userInfo, entityId, body, fi person_cd: relationship.personCd, type_cd: !relationship.typeCd ? null : relationship.typeCd, amount_cd: !relationship.amountCd ? null : relationship.amountCd, - comments: relationship.comments + comments: relationship.comments, + status: COIConstants.RELATIONSHIP_STATUS.IN_PROGRESS }, 'id') .then(relationshipId => { relationship.id = relationshipId[0]; @@ -265,18 +266,20 @@ export const saveExistingFinancialEntity = (dbInfo, userInfo, entityId, body, fi }); if (!match) { queries.push( - knex('file').where('id', result.id).del() - .then(() => { - return new Promise((resolve, reject) => { - FileService.deleteFile(result.key, err => { - if (err) { - reject(err); - } else { - resolve(); - } + knex('file') + .where('id', result.id) + .del() + .then(() => { + return new Promise((resolve, reject) => { + FileService.deleteFile(result.key, err => { + if (err) { + reject(err); + } else { + resolve(); + } + }); }); - }); - }) + }) ); } });