Skip to content

Commit

Permalink
fix(sap.fhir.model.r4.FHIRListBinding): Invalidate list bindings (#342)
Browse files Browse the repository at this point in the history
* fix(sap.fhir.model.r4.FHIRListBinding): Invalidate list bindings

As per suggestion Server-side bindings (e.g. ODataListBinding) are expected to start with a "refresh" eventListBindings "initialize" + fire refresh-event (although not defined in the metadata)

* tests: fix test cases

* refactor: review comments

* tests: added tests
  • Loading branch information
AmirthavalliG authored Jun 29, 2022
1 parent ad36531 commit d191c15
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sap/fhir/model/r4/FHIRListBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ sap.ui.define([
}
this.sId = FHIRUtils.uuidv4();
this._resetData();
},

initialize: function () {
// List doesn't get invalidated when context length is 0
// as per suggestion Server-side bindings (e.g. ODataListBinding) are expected to start with a "refresh" event
// overwrite the ListBindings "initialize" + fire refresh-event (although not defined in the metadata)
this.fireEvent("refresh", { reason: ChangeReason.Refresh });
return this;
}

});

/**
Expand Down
12 changes: 12 additions & 0 deletions test/qunit/model/FHIRListBinding.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ sap.ui.define(["../utils/TestUtilsIntegration", "../utils/TestUtils"], function
QUnit.test("check if valueset is loaded if mentioned in the structure definition field description of type 'codeableconcept'", function (assert) {
testValueSetLoadedCorrectly(assert, "/Coverage/a7854", "type", 1, 21);
});

QUnit.test("check if refresh event is triggered during list binding initialization", function (assert) {
createContextBinding("/Patient/a2519");
oListBinding = oModel.bindList("gender", oContextBinding.getBoundContext(), undefined, undefined, undefined);
var done = assert.async();
var fnChangeHandler = function (oEvent) {
assert.strictEqual(oEvent.mParameters.reason, "refresh");
done();
};
oListBinding.attachRefresh(fnChangeHandler);
oListBinding.initialize();
});
});

0 comments on commit d191c15

Please sign in to comment.