
CDS cube view with multiple data points
Now, I will add them in my annotation, either as data point or data field. It is up to you to either add them as data point or data field, but I wanted keep the distinction on what goes on header and what on items and so I added one as Data point and rest as Data field. I also wanted to navigate to a list report on pressing either the header of the card or by pressing on any of the item. If any item is pressed, the list report would only show the relevant filtered record. For this, the OData service has three different flags to filter the records out.
File structure on OVP project
Local annotations in the SAP OVP app
File Structure on OVP project
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<FlexBox class="sapOvpHeaderCountMainDiv">
<NumericContent value="{BlockCounts>/blockedOrderCount}" valueColor="Neutral"/>
</FlexBox>
</core:FragmentDefinition>
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:l="sap.ui.layout">
<Table id="idFOBlockedCardTable" inset="false" items="{path: 'BlockCounts>/KPICounts'}" itemPress="_onNavigationbyItem">
<columns>
<Column width="9em"/>
<Column/>
</columns>
<items>
<ColumnListItem visible="{BlockCounts>visible}">
<cells>
<ObjectIdentifier title="{BlockCounts>Text}" text="{BlockCounts>Count}"/>
<ProgressIndicator class="sapUiSmallMarginBottom" percentValue="{BlockCounts>Pecentage}" state="{BlockCounts>Color}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</core:FragmentDefinition>
var sLineItemAnnotationPath = oCardModelData.annotationPath,
sIdentificationAnnotationPath = oCardModelData.identificationAnnotationPath,
sSelectioinVariant = oCardModelData.selectionAnnotationPath,
sSelectFieldsString = "";
this.entitySetname = oCardModelData.entitySet;
// first get the Semantic object and action
this.sSemanticObject = oCardModelData.entityType[sIdentificationAnnotationPath][0].SemanticObject.String;
this.sAction = oCardModelData.entityType[sIdentificationAnnotationPath][0].Action.String;
var aLineItems = oCardModelData.entityType[sLineItemAnnotationPath];
for (var i = 0; i < aLineItems.length; i++) {
if (aLineItems[i].RecordType === "com.sap.vocabularies.UI.v1.DataField") {
sSelectFieldsString = aLineItems[i].Value.Path + "," + sSelectFieldsString;
} else if (aLineItems[i].RecordType === "com.sap.vocabularies.UI.v1.DataFieldForAnnotation") {
sSelectFieldsString = oCardModelData.entityType[aLineItems[i].Target.AnnotationPath.substring(1)].Value.Path + "," +
sSelectFieldsString;
}
}
this.selectFields = sSelectFieldsString.slice(0, -1);
this.getView().byId("ovpCardHeader").attachBrowserEvent("click", this._onNavigationbyCardHeader);
this.GloabalEventBus = sap.ui.getCore().getEventBus();
this.GloabalEventBus.subscribe("OVPGlobalfilter", "OVPGlobalFilterSeacrhfired", this.onGlobalfilterApply.bind(this));
this.getView().byId("idFOBlockedCardTable").getBindingInfo("items").template.setType("Active");
onAfterRendering: function () {
var oModel = this.getView().getModel();
var sEntitySet = "/" + this.entitySetname;
var oParamater = {
urlParameters: {
"$select": this.selectFields
},
filters: this.aFilter,
success: this._onSuccess.bind(this)
};
oModel.read(sEntitySet, oParamater);
}
_onSuccess: function (data) {
var nBlockedPlanningCount = 0,
nBlockedExecutionCount = 0,
nBlockedInvoiceCount = 0,
nBlockedOrderCount = 0,
nPlanning = 0,
nExecution = 0,
nInvoice = 0;
if (data.results.length > 0) {
nBlockedPlanningCount = data.results[0].BlockedPlanningCount;
nBlockedExecutionCount = data.results[0].BlockedExecutionCount;
nBlockedInvoiceCount = data.results[0].BlockedInvoiceCount;
nBlockedOrderCount = data.results[0].BlockedOrderCount;
nPlanning = nBlockedPlanningCount / nBlockedOrderCount * 100;
nExecution = nBlockedExecutionCount / nBlockedOrderCount * 100;
nInvoice = nBlockedInvoiceCount / nBlockedOrderCount * 100;
}
var aValues = [{
"Text": "Planning Block",
"Count": nBlockedPlanningCount,
"Pecentage": nPlanning,
"Field": "PlanningBlock",
"Value": true,
"Color": "None",
"visible": nBlockedPlanningCount == 0 ? false : true
}, {
"Text": "Execution Block",
"Count": nBlockedExecutionCount,
"Pecentage": nExecution,
"Field": "ExecBlock",
"Value": true,
"Color": "Success",
"visible": nBlockedExecutionCount == 0 ? false : true
}, {
"Text": "Invoice Block",
"Count": nBlockedInvoiceCount,
"Pecentage": nInvoice,
"Field": "FSDBlock",
"Value": true,
"Color": "Information",
"visible": nBlockedInvoiceCount == 0 ? false : true
}];
var oObject = {
"blockedOrderCount": nBlockedOrderCount,
"KPICounts": aValues
};
var oModel = new sap.ui.model.json.JSONModel(oObject);
this.getView().setModel(oModel, "BlockCounts");
onGlobalfilterApply: function (sChannelID, sEventName, aFilters) {
var oModel = this.getView().getModel();
var sEntitySet = "/" + this.entitySetname;
var oParamater = {
urlParameters: {
"$select": this.selectFields
},
filters: aFilters,
success: this._onSuccess.bind(this)
};
oModel.read(sEntitySet, oParamater);
},
_onNavigationbyCardHeader: function (oEvent) {
var oComponent = this.getParent().getParent().getParent().getParent().getComponentData().appComponent;
// get the cross app navigation service
var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
// get the initial app state
var oAppState = oCrossAppNavigator.createEmptyAppState(oComponent);
// get the filter freom the controller instance
var aFilter = this.getParent().getParent().getParent().getController().aFilter;
oAppState.setData({
"customFilter": aFilter
}); // object of values needed to be restored
oAppState.save();
// change the hash
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sOldHash = oHashChanger.getHash();
var sNewHash = sOldHash + "?" + "sap-iapp-state=" + oAppState.getKey();
oHashChanger.replaceHash(sNewHash);
// semantic object and action details
var sSemanticObject = this.getParent().getParent().getParent().getController().sSemanticObject;
var sAction = this.getParent().getParent().getParent().getController().sAction;
var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
target: {
semanticObject: sSemanticObject,
action: sAction
},
appStateKey: oAppState.getKey()
}));
oCrossAppNavigator.toExternal({
target: {
shellHash: hash
}
});
},
_onNavigationbyItem: function (oEvent) {
// get the cross app navigation service
var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
// get the initial app state
var oAppState = oCrossAppNavigator.createEmptyAppState(this.getOwnerComponent());
// Build the Filter data
var oObjectData = oEvent.getParameter("listItem").getBindingContext("BlockCounts").getObject();
if (oObjectData) {
var aFilter = this.aFilter;
aFilter.push(new sap.ui.model.Filter(oObjectData.Field,
sap.ui.model.FilterOperator.EQ,
"X"));
}
// set the app state
oAppState.setData({
"customFilter": aFilter
}); // object of values needed to be restored
oAppState.save();
// change the hash
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sOldHash = oHashChanger.getHash();
var sNewHash = sOldHash + "?" + "sap-iapp-state=" + oAppState.getKey();
oHashChanger.replaceHash(sNewHash);
var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
target: {
semanticObject: this.sSemanticObject,
action: this.sAction
},
appStateKey: oAppState.getKey()
}));
oCrossAppNavigator.toExternal({
target: {
shellHash: hash
}
});
},
var oNavigationHandler = new NavigationHandler(this);
var oParseNavigationPromise = oNavigationHandler.parseNavigation();
oParseNavigationPromise.done(function (oAppData, oStartupParameters, sNavType) {
var oRows = this.oTable.getBinding("rows");
if (oRows) {
oRows.filter(oAppData.customFilter);
}
}.bind(this));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |