Skip to content

Commit

Permalink
Fixed: missing label in dataReceived (#1030)
Browse files Browse the repository at this point in the history
* Fixed: missing label in dataReceived

* Add label in dataReceived for API Update as well
  • Loading branch information
sadiqkhoja authored Oct 24, 2023
1 parent 643fd63 commit 9d1bbd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/model/frames/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class Entity extends Frame.define(
});
const { uuid, label } = entityData.system;
const { data } = entityData;
const dataReceived = { ...body.data };
if (body.label != null) dataReceived.label = body.label;
return new Entity.Partial({ uuid, datasetId: dataset.id, id: oldEntity?.id }, {
def: new Entity.Def({ data, label, dataReceived: body.data || {} }),
def: new Entity.Def({ data, label, dataReceived }),
dataset: dataset.name
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/model/query/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const _updateEntity = (dataset, entityData, submissionId, submissionDef, submiss
def: new Entity.Def({
data: mergedData,
label: mergedLabel,
dataReceived: clientEntity.def.data,
dataReceived: clientEntity.def.dataReceived,
conflictingProperties
})
});
Expand Down
2 changes: 2 additions & 0 deletions test/integration/api/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ describe('Entities API', () => {
const { currentVersion } = person;
currentVersion.data.should.eql({ age: '99', first_name: 'Alice' });
currentVersion.label.should.eql('Alicia - 85');
currentVersion.dataReceived.should.eql({ label: 'Alicia - 85' });
currentVersion.version.should.equal(3);
currentVersion.conflictingProperties.should.be.eql([]);
});
Expand Down Expand Up @@ -1235,6 +1236,7 @@ describe('Entities API', () => {
.expect(200)
.then(({ body: person }) => {
person.currentVersion.should.have.property('label').which.is.eql('New Label');
person.currentVersion.dataReceived.should.have.property('label').which.is.eql('New Label');
});
}));

Expand Down

0 comments on commit 9d1bbd7

Please sign in to comment.