Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display odata v4 binding context properly #220

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app/vendor/ToolsAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
var isResourceModel = type === "sap.ui.model.resource.ResourceModel";
var fullPath;
var contextPath;
// Remember the context in case it is odata.v4.Context
var context = type === 'sap.ui.model.odata.v4.Context' && model;

// we dont care about the context if path is absolute
if(!isRelative) {
Expand All @@ -475,9 +477,15 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
// in case its a model context, retrieve the underlying model
model = model.getModel && model.getModel() || model;

// functions in the model cannot communicated via message
modelInfo.modelData = isResourceModel ? "" : model.getObject(contextPath || "/");
modelInfo.pathData = model.getProperty(fullPath);
// in case it is v4 ODataContext we get the data from the context
if (context) {
// There is no modelData in OData v4 just pathData
modelInfo.pathData = path !== context.getPath() ? context.getObject(path) : context.getObject();
} else {
// functions in the model cannot communicated via message
modelInfo.modelData = isResourceModel ? "" : model.getObject(contextPath || "/");
modelInfo.pathData = model.getProperty(fullPath);
}
modelInfo.fullPath = fullPath;
modelInfo.path = pathWithoutModel;
modelInfo.mode = model.getDefaultBindingMode();
Expand Down Expand Up @@ -609,8 +617,10 @@ sap.ui.define(["jquery.sap.global", "sap/ui/core/ElementMetadata"],
if (bindingContexts && Object.keys(bindingContexts).length) {
return {
parts: Object.keys(bindingContexts).map(function (key) {
return controlInformation._getModelInfo(bindingContexts[key].getModel(),
(key && key !== "undefined" && key !== "null" ? key + ">" : "") + bindingContexts[key].getPath());
var context = bindingContexts[key];
var modelOrContext = context.getMetadata().getName() === 'sap.ui.model.odata.v4.Context' ? context : context.getModel();
return controlInformation._getModelInfo(modelOrContext,
(key && key !== "undefined" && key !== "null" ? key + ">" : "") + context.getPath());
})
};
}
Expand Down