Skip to content

Commit 86f6a0a

Browse files
jdicheverlethor
andauthored
fix: proper handling of ODataListBinding (#226)
Co-authored-by: d023269 <[email protected]>
1 parent 3b46570 commit 86f6a0a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/vendor/ToolsAPI.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
429429
*
430430
* @param {Object} model - model can be either a "real" model or a model-context
431431
* @param {string} path
432+
* @param {Object} [binding]
432433
* @returns {Object}
433434
* @private
434435
*/
435-
_getModelInfo: function (model, path) {
436+
_getModelInfo: function (model, path, binding) {
436437
if (!model) {
437438
return null;
438439
}
@@ -455,6 +456,7 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
455456
var pathWithoutModel = pathContainsModelName ? pathParts[1] : pathParts[0];
456457
var isRelative = pathWithoutModel.indexOf("/") !== 0;
457458
var type = model.getMetadata().getName();
459+
var bindingType = binding && binding.getMetadata().getName() || "";
458460
var isResourceModel = type === "sap.ui.model.resource.ResourceModel";
459461
var fullPath;
460462
var contextPath;
@@ -483,8 +485,13 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
483485
modelInfo.pathData = path !== context.getPath() ? context.getObject(path) : context.getObject();
484486
} else {
485487
// functions in the model cannot communicated via message
486-
modelInfo.modelData = isResourceModel ? "" : model.getObject(contextPath || "/");
487-
modelInfo.pathData = model.getProperty(fullPath);
488+
modelInfo.modelData = isResourceModel || type.startsWith("sap.ui.model.odata.v4") ? "" : model.getObject(contextPath || "/");
489+
if (bindingType.endsWith("ODataListBinding")) {
490+
// the binding has the data
491+
modelInfo.pathData = binding.getAllCurrentContexts().map(c => c.getObject());
492+
} else {
493+
modelInfo.pathData = model.getProperty(fullPath);
494+
}
488495
}
489496
modelInfo.fullPath = fullPath;
490497
modelInfo.path = pathWithoutModel;
@@ -512,7 +519,7 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
512519
* @private
513520
*/
514521
_getModelInfoFromBinding: function (binding, bindingInfo) {
515-
return this._getModelInfo(binding.getContext() || binding.getModel(), (bindingInfo.model ? bindingInfo.model + ">" : "") + bindingInfo.path);
522+
return this._getModelInfo(binding.getContext() || binding.getModel(), (bindingInfo.model ? bindingInfo.model + ">" : "") + bindingInfo.path, binding);
516523
},
517524

518525
/**

0 commit comments

Comments
 (0)