Skip to content

Commit

Permalink
Fixed bug which prevented adding relationships to existing entities
Browse files Browse the repository at this point in the history
  • Loading branch information
iambrandonn committed Dec 15, 2015
1 parent c416264 commit cdf2788
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions client/scripts/stores/DisclosureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,7 @@ class _DisclosureStore extends AutoBindingStore {
}
});
}

entity.files = existingFiles;

formData.append('entity', JSON.stringify(entity));

if (!this.applicationState.entityStates[entity.id]) {
Expand Down
29 changes: 16 additions & 13 deletions server/db/DisclosureDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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();
}
});
});
});
})
})
);
}
});
Expand Down

0 comments on commit cdf2788

Please sign in to comment.