@sapui5/sap.suite.ui.generic.template 1.139.0 → 1.139.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sap/suite/ui/generic/template/.library +1 -1
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +1 -0
- package/src/sap/suite/ui/generic/template/ObjectPage/controller/SectionTitleHandler.js +17 -13
- package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartForm.fragment.xml +2 -1
- package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/js/AnnotationHelper.js +81 -0
- package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterBarHandler.js +44 -198
- package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterDataFetcherHelper.js +334 -0
- package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/presentationControl/SmartTableHandler.js +1 -1
- package/src/sap/suite/ui/generic/template/library.js +1 -1
package/package.json
CHANGED
|
@@ -1938,6 +1938,7 @@ sap.ui.define([
|
|
|
1938
1938
|
oState.oSectionTitleHandler.adjustSubSectionTitle(oSubSection);
|
|
1939
1939
|
// Add accessible name to the SmartForm in the first subsection if all titles are hidden, because accessible name will not propogate to the form control
|
|
1940
1940
|
oState.oSectionTitleHandler.addAccessibleName(oSubSection);
|
|
1941
|
+
oState.oSectionTitleHandler.setHeaderSmartFormAriaLabelBy(oSubSection);
|
|
1941
1942
|
}
|
|
1942
1943
|
}
|
|
1943
1944
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
sap.ui.define(["sap/ui/base/Object", "sap/base/util/extend", "sap/suite/ui/generic/template/genericUtilities/controlHelper", "sap/ui/core/library",
|
|
2
|
-
"sap/suite/ui/generic/template/genericUtilities/FeLogger"
|
|
3
|
-
], function(BaseObject, extend, controlHelper, SapCoreLibrary, FeLogger) {
|
|
2
|
+
"sap/suite/ui/generic/template/genericUtilities/FeLogger", "sap/ui/core/Element", "sap/ui/core/InvisibleText"
|
|
3
|
+
], function(BaseObject, extend, controlHelper, SapCoreLibrary, FeLogger, Element, InvisibleText) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
var STYLE_CLASS_FOR_ADJUSTMENT = "sapUiTableOnObjectPageAdjustmentsForSection";
|
|
@@ -174,9 +174,8 @@ sap.ui.define(["sap/ui/base/Object", "sap/base/util/extend", "sap/suite/ui/gener
|
|
|
174
174
|
oSmartForm.addAriaLabelledBy(sAnchorBarSectionHeaderId);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function
|
|
178
|
-
var oSubSectionInfoObject = oTemplateUtils.oInfoObjectHandler.getControlInformation(oFirstSubSection.getId())
|
|
179
|
-
oSection = oFirstSubSection.getParent();
|
|
177
|
+
function fnSetHeaderSmartFormAriaLabelBy(oFirstSubSection) {
|
|
178
|
+
var oSubSectionInfoObject = oTemplateUtils.oInfoObjectHandler.getControlInformation(oFirstSubSection.getId());
|
|
180
179
|
oFirstSubSection.getBlocks().concat(oFirstSubSection.getMoreBlocks())
|
|
181
180
|
.reduce(function(accBlock, currentBlock) {
|
|
182
181
|
if (!currentBlock.getContent || !currentBlock.getContent() || !currentBlock.getContent().length) {
|
|
@@ -191,14 +190,19 @@ sap.ui.define(["sap/ui/base/Object", "sap/base/util/extend", "sap/suite/ui/gener
|
|
|
191
190
|
return accBlock;
|
|
192
191
|
}, [])
|
|
193
192
|
.forEach(function(entry) {
|
|
194
|
-
if (!oSubSectionInfoObject) {
|
|
193
|
+
if (!oSubSectionInfoObject || (entry.getGroups().length === 1 && entry.getGroups()[0].getTitle && !entry.getGroups()[0].getTitle())) {
|
|
195
194
|
// Case: header is editable. manifest.json, editableHeaderContent=true
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
var sInvisibleTextID = `${entry.getId()}-ariaLabelBy-InvisibleText`,
|
|
196
|
+
oInvisibleText = Element.getElementById(sInvisibleTextID);
|
|
197
|
+
if (!oInvisibleText) {
|
|
198
|
+
var customData = !entry.getCustomData() ? [] : entry.getCustomData().filter(function(entry) {return entry.getKey() === "smartFormAriaLabel";});
|
|
199
|
+
if (customData.length && customData[0].getValue()) {
|
|
200
|
+
oInvisibleText = new InvisibleText({id : sInvisibleTextID, text: customData[0].getValue()}).toStatic();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (oInvisibleText) {
|
|
204
|
+
entry._suggestTitleId(oInvisibleText.getId()); // set Section title id that will be used for aria
|
|
205
|
+
}
|
|
202
206
|
return;
|
|
203
207
|
}
|
|
204
208
|
});
|
|
@@ -209,7 +213,7 @@ sap.ui.define(["sap/ui/base/Object", "sap/base/util/extend", "sap/suite/ui/gener
|
|
|
209
213
|
setAsTitleOwner: fnSetAsTitleOwner,
|
|
210
214
|
adjustSubSectionTitle: fnAdjustSubSectionTitle,
|
|
211
215
|
addAccessibleName: fnAddAccessibleName,
|
|
212
|
-
|
|
216
|
+
setHeaderSmartFormAriaLabelBy: fnSetHeaderSmartFormAriaLabelBy
|
|
213
217
|
};
|
|
214
218
|
}
|
|
215
219
|
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
<core:CustomData key="defaultDropDownDisplayBehaviour" value="descriptionOnly" />
|
|
22
22
|
<core:CustomData key="defaultTextInEditModeSource" value="ValueListNoValidation" />
|
|
23
23
|
<core:CustomData key="dateFormatSettings" value='\{"UTC":true,"style":"medium"\}' />
|
|
24
|
+
<core:CustomData key="smartFormAriaLabel" value="{parts: [{path: 'facet>'}, {path: 'entitySet>name'}, {path: 'block>'}, {path: 'subSectionData>'}], formatter: 'AH.getSmartFormTitle'}" />
|
|
24
25
|
</sfo:customData>
|
|
25
26
|
<sfo:layout>
|
|
26
27
|
<template:if test="{= ${appSettings>/useColumnLayoutForSmartForm} !== false}">
|
|
27
28
|
<template:then>
|
|
28
29
|
<sfo:ColumnLayout columnsM="3" columnsL="4" columnsXL="{= ${appSettings>/objectPageColumns/screenSizeXL} === 4 ? '4' : '6'}" labelCellsLarge="12" />
|
|
29
|
-
|
|
30
|
+
</template:then>
|
|
30
31
|
<template:else>
|
|
31
32
|
<sfo:Layout columnsM="3" columnsL="4" columnsXL="{= ${appSettings>/objectPageColumns/screenSizeXL} === 4 ? '4' : '6'}" labelSpanS="12" labelSpanM="12" labelSpanL="12" labelSpanXL="12" singleGroupFullSize="false" />
|
|
32
33
|
</template:else>
|
|
@@ -4523,6 +4523,86 @@ sap.ui.define(["sap/ui/model/odata/AnnotationHelper",
|
|
|
4523
4523
|
break;
|
|
4524
4524
|
}
|
|
4525
4525
|
return sPriority;
|
|
4526
|
+
},
|
|
4527
|
+
|
|
4528
|
+
getModelData: function(oInterface, sBaseAnnotationPath, sEntitySetName) {
|
|
4529
|
+
var oModel = oInterface.getModel() ? oInterface.getModel() : oInterface.getInterface(0).getModel(),
|
|
4530
|
+
oBaseEntityType = oModel.getODataEntityType(oModel.getODataEntitySet(sEntitySetName).entityType);
|
|
4531
|
+
|
|
4532
|
+
if (sBaseAnnotationPath.indexOf("/") > -1) {
|
|
4533
|
+
var oRelevantData = oAnnotationHelper.getRelevantDataForAnnotationRecord(oModel, sBaseAnnotationPath, oBaseEntityType);
|
|
4534
|
+
return {
|
|
4535
|
+
sAnnotationPath: oRelevantData.dataFieldValuePath[0] === '@' ? oRelevantData.dataFieldValuePath.substring(1) : oRelevantData.dataFieldValuePath,
|
|
4536
|
+
oEntityType: oRelevantData.entityType
|
|
4537
|
+
};
|
|
4538
|
+
}
|
|
4539
|
+
return {
|
|
4540
|
+
sAnnotationPath: sBaseAnnotationPath[0] === '@' ? sBaseAnnotationPath.substring(1) : sBaseAnnotationPath,
|
|
4541
|
+
oEntityType: oBaseEntityType
|
|
4542
|
+
};
|
|
4543
|
+
},
|
|
4544
|
+
|
|
4545
|
+
getSmartFormTitle: function(oInterface, oFacet, sEntitySetName, oBlock, oSubSectionData) {
|
|
4546
|
+
if (!oFacet) {
|
|
4547
|
+
return oAnnotationHelper.getTitleForSectionsForms(oBlock, oSubSectionData);
|
|
4548
|
+
}
|
|
4549
|
+
return oAnnotationHelper.getTitleForHeaderForm(oInterface, oFacet, sEntitySetName);
|
|
4550
|
+
},
|
|
4551
|
+
|
|
4552
|
+
getTitleForSectionsForms: function(oBlock, oSubSectionData) {
|
|
4553
|
+
if (oSubSectionData?.annotations?.Facet?.annotation?.Facets?.length > 1
|
|
4554
|
+
|| oSubSectionData?.annotations?.Facet?.annotation?.Label?.String !== oBlock?.aggregations?.groups[0]?.annotations?.Facet?.annotation?.Label?.String
|
|
4555
|
+
) {
|
|
4556
|
+
// In case Section -> SubSection have more than one form, SmartForm will have it's titles visible
|
|
4557
|
+
// or
|
|
4558
|
+
// SubSectin title !== SmartForm title, SmartForm title will also be visible
|
|
4559
|
+
return;
|
|
4560
|
+
}
|
|
4561
|
+
if (oBlock?.aggregations?.groups[0]?.annotations?.Facet?.annotation?.Label?.String !== oBlock?.aggregations?.groups[0]?.targetAnnotation?.Label?.String) {
|
|
4562
|
+
// Compare SmartForm title !== FiledGroup title
|
|
4563
|
+
// if they differs -> use FiledGoup title
|
|
4564
|
+
return oBlock?.aggregations?.groups[0]?.targetAnnotation?.Label?.String;
|
|
4565
|
+
}
|
|
4566
|
+
return;
|
|
4567
|
+
},
|
|
4568
|
+
|
|
4569
|
+
getTitleForHeaderForm: function(oInterface, oFacet, sEntitySetName) {
|
|
4570
|
+
if (oFacet.Target && oFacet.Target.AnnotationPath && oFacet.Target.AnnotationPath.indexOf("com.sap.vocabularies.UI.v1.DataPoint") > -1) {
|
|
4571
|
+
// Process DataPoint case
|
|
4572
|
+
var { sAnnotationPath, oEntityType } = oAnnotationHelper.getModelData(oInterface, oFacet.Target.AnnotationPath, sEntitySetName);
|
|
4573
|
+
if (oEntityType[sAnnotationPath] && oEntityType[sAnnotationPath].Title && oEntityType[sAnnotationPath].Title.String) {
|
|
4574
|
+
return oEntityType[sAnnotationPath].Title.String;
|
|
4575
|
+
}
|
|
4576
|
+
// As DataPoint don't have title -> try to get property name as SmartForm title
|
|
4577
|
+
if (!oEntityType[sAnnotationPath] || !oEntityType[sAnnotationPath].Value || !oEntityType[sAnnotationPath].Value.Path || !oEntityType.property) {
|
|
4578
|
+
return;
|
|
4579
|
+
}
|
|
4580
|
+
var aProperty = oEntityType.property.filter(function(entry) {
|
|
4581
|
+
return entry.name === oEntityType[sAnnotationPath].Value.Path;
|
|
4582
|
+
});
|
|
4583
|
+
if (aProperty.length && aProperty[0]['sap:label']) {
|
|
4584
|
+
// Property name found
|
|
4585
|
+
return aProperty[0]['sap:label'];
|
|
4586
|
+
}
|
|
4587
|
+
return;
|
|
4588
|
+
}
|
|
4589
|
+
// It's Identification or FieldGroup case
|
|
4590
|
+
if (oFacet.Label && oFacet.Label.String) {
|
|
4591
|
+
return oFacet.Label.String;
|
|
4592
|
+
}
|
|
4593
|
+
if (!oFacet.Target || !oFacet.Target.AnnotationPath) {
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
if (oFacet.Target.AnnotationPath.indexOf("com.sap.vocabularies.UI.v1.Identification") > -1) {
|
|
4597
|
+
// Identification entry don't have any data which we can use as SmartForm title.
|
|
4598
|
+
return;
|
|
4599
|
+
}
|
|
4600
|
+
var { sAnnotationPath, oEntityType } = oAnnotationHelper.getModelData(oInterface, oFacet.Target.AnnotationPath, sEntitySetName);
|
|
4601
|
+
if (oEntityType[sAnnotationPath] && oEntityType[sAnnotationPath].Label && oEntityType[sAnnotationPath].Label.String) {
|
|
4602
|
+
// Use FieldGroup.Label.String as SmartForm title
|
|
4603
|
+
return oEntityType[sAnnotationPath].Label.String;
|
|
4604
|
+
}
|
|
4605
|
+
return;
|
|
4526
4606
|
}
|
|
4527
4607
|
};
|
|
4528
4608
|
oAnnotationHelper.getBlockForEditableHeaderFacet.requiresIContext = true;
|
|
@@ -4593,6 +4673,7 @@ sap.ui.define(["sap/ui/model/odata/AnnotationHelper",
|
|
|
4593
4673
|
oAnnotationHelper.getTextArrangementPath.requiresIContext = true;
|
|
4594
4674
|
oAnnotationHelper.isValueHelpTableAvailable.requiresIContext = true;
|
|
4595
4675
|
oAnnotationHelper.getTextArrangementFinalString.requiresIContext = true;
|
|
4676
|
+
oAnnotationHelper.getSmartFormTitle.requiresIContext = true;
|
|
4596
4677
|
|
|
4597
4678
|
return oAnnotationHelper;
|
|
4598
4679
|
}, /* bExport= */ true);
|
|
@@ -944,7 +944,7 @@ sap.ui.define([
|
|
|
944
944
|
* @public
|
|
945
945
|
* @extends sap.ui.core.UIComponent
|
|
946
946
|
* @author SAP SE
|
|
947
|
-
* @version 1.139.
|
|
947
|
+
* @version 1.139.1
|
|
948
948
|
* @name sap.suite.ui.generic.template.lib.AppComponent
|
|
949
949
|
*/
|
|
950
950
|
var oAppComponent = UIComponent.extend("sap.suite.ui.generic.template.lib.AppComponent", {
|
|
@@ -5,8 +5,9 @@ sap.ui.define([
|
|
|
5
5
|
"sap/suite/ui/generic/template/genericUtilities/FeLogger",
|
|
6
6
|
"sap/ui/model/FilterOperator",
|
|
7
7
|
'sap/ui/model/Filter',
|
|
8
|
-
'sap/suite/ui/generic/template/js/AnnotationHelper'
|
|
9
|
-
|
|
8
|
+
'sap/suite/ui/generic/template/js/AnnotationHelper',
|
|
9
|
+
"./EasyFilterDataFetcherHelper"
|
|
10
|
+
], function(BaseObject, extend, filterHelper, FeLogger, FilterOperator,Filter,AnnotationHelper,EasyFilterDataFetcherHelper) {
|
|
10
11
|
'use strict';
|
|
11
12
|
|
|
12
13
|
/*
|
|
@@ -315,24 +316,28 @@ sap.ui.define([
|
|
|
315
316
|
// keySpecificSelectedValues will have one selectedValues object for each operator
|
|
316
317
|
// ex : [{operator: "EQ", selectedValues: ["HT-1010","HT-10001","1097"]}, {operator: "Contains", selectedValues: ["HT-100"]}]
|
|
317
318
|
oFilterItem.keySpecificSelectedValues.forEach(function (oSelectedValues) {
|
|
318
|
-
var oRange = {
|
|
319
|
-
Sign: "I", // currently not considering "E"
|
|
320
|
-
High: ""
|
|
321
|
-
};
|
|
322
|
-
|
|
323
319
|
if ((oSelectedValues.operator === "BT" || oSelectedValues.operator === "NB")) {
|
|
320
|
+
var oRange = {
|
|
321
|
+
Sign: oSelectedValues.operator === "NB" ? "E" : "I",
|
|
322
|
+
High: ""
|
|
323
|
+
};
|
|
324
324
|
oRange.Low = oSelectedValues.selectedValues[0];
|
|
325
325
|
oRange.High = oSelectedValues.selectedValues[1];
|
|
326
|
-
oRange.Option =
|
|
326
|
+
oRange.Option = "BT";
|
|
327
327
|
oFilter.Ranges.push(oRange);
|
|
328
328
|
} else {
|
|
329
|
-
oSelectedValues.selectedValues.forEach(function (
|
|
330
|
-
|
|
329
|
+
oSelectedValues.selectedValues.forEach(function (sValue) {
|
|
330
|
+
var oRange = {
|
|
331
|
+
Sign: EasyFilterDataFetcherHelper.isNegationOperator(oSelectedValues.operator) ? "E" : "I",
|
|
332
|
+
High: ""
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
if (isCPOperator(oSelectedValues.operator)) {
|
|
331
336
|
oRange.Option = "CP";
|
|
332
|
-
oRange.Low =
|
|
337
|
+
oRange.Low = getValueForCPOperator(sValue,oSelectedValues.operator);
|
|
333
338
|
} else {
|
|
334
|
-
oRange.Option = oSelectedValues.operator;
|
|
335
|
-
oRange.Low =
|
|
339
|
+
oRange.Option = EasyFilterDataFetcherHelper.isNegationOperator(oSelectedValues.operator) ? EasyFilterDataFetcherHelper.getReverseOperator(oSelectedValues.operator) : oSelectedValues.operator;
|
|
340
|
+
oRange.Low = sValue;
|
|
336
341
|
}
|
|
337
342
|
oFilter.Ranges.push(oRange);
|
|
338
343
|
});
|
|
@@ -348,6 +353,29 @@ sap.ui.define([
|
|
|
348
353
|
};
|
|
349
354
|
}
|
|
350
355
|
|
|
356
|
+
function getValueForCPOperator(sValue,sOperator) {
|
|
357
|
+
sOperator = EasyFilterDataFetcherHelper.isNegationOperator(sOperator) ? EasyFilterDataFetcherHelper.getReverseOperator(sOperator) : sOperator;
|
|
358
|
+
switch (sOperator) {
|
|
359
|
+
case FilterOperator.Contains:
|
|
360
|
+
sValue = `*${sValue}*`;
|
|
361
|
+
break;
|
|
362
|
+
case FilterOperator.EndsWith:
|
|
363
|
+
sValue = `*${sValue}`;
|
|
364
|
+
break;
|
|
365
|
+
case FilterOperator.StartsWith:
|
|
366
|
+
sValue = `${sValue}*`;
|
|
367
|
+
break;
|
|
368
|
+
default:
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
return sValue;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function isCPOperator(sOperator) {
|
|
375
|
+
return sOperator === FilterOperator.Contains || sOperator === FilterOperator.EndsWith || sOperator === FilterOperator.NotContains || sOperator === FilterOperator.NotEndsWith
|
|
376
|
+
|| sOperator === FilterOperator.NotStartsWith || sOperator === FilterOperator.StartsWith;
|
|
377
|
+
}
|
|
378
|
+
|
|
351
379
|
/**
|
|
352
380
|
* This method is used to get the EasyFilter control from the floorplan
|
|
353
381
|
* @returns EasyFilter control
|
|
@@ -506,191 +534,10 @@ sap.ui.define([
|
|
|
506
534
|
}
|
|
507
535
|
}
|
|
508
536
|
|
|
509
|
-
function getFiltersForDataFetching(key,keySpecificSelectedResult) {
|
|
510
|
-
const aFilters = [];
|
|
511
|
-
|
|
512
|
-
for (var i = 0; i < keySpecificSelectedResult.length;++i) {
|
|
513
|
-
const result = keySpecificSelectedResult[i];
|
|
514
|
-
if (result.operator === FilterOperator.BT || result.operator === FilterOperator.NB) {
|
|
515
|
-
aFilters.push(new Filter({
|
|
516
|
-
path: key,
|
|
517
|
-
operator: result.operator,
|
|
518
|
-
value1: result.selectedValues[0],
|
|
519
|
-
value2: result.selectedValues[1]
|
|
520
|
-
}));
|
|
521
|
-
} else {
|
|
522
|
-
for (var j = 0; j < result.selectedValues.length; ++j) {
|
|
523
|
-
aFilters.push(new Filter({
|
|
524
|
-
path: key,
|
|
525
|
-
operator: result.operator,
|
|
526
|
-
value1: result.selectedValues[j]
|
|
527
|
-
}));
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
return aFilters;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
537
|
function onDataFetcher(key,keySpecificSelectedResult,totalAIResponse) {
|
|
535
|
-
return
|
|
536
|
-
|
|
537
|
-
var aFinalResponse = [];
|
|
538
|
-
var oOwnerFilterControl = oState.oSmartFilterbar;
|
|
539
|
-
var sKey = key;
|
|
540
|
-
var sEntitySet = oController.getOwnerComponent().getEntitySet();
|
|
541
|
-
var oEntityType = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sEntitySet);
|
|
542
|
-
var oSFBModel = oOwnerFilterControl.getModel();
|
|
543
|
-
var oSFBMetaModel = oSFBModel.getMetaModel();
|
|
544
|
-
var aFilters = getFiltersForDataFetching(key,keySpecificSelectedResult);
|
|
545
|
-
var oProperty = oSFBMetaModel.getODataProperty(oEntityType, key);
|
|
546
|
-
var sPropertyPath = oSFBMetaModel.getODataProperty(oEntityType, key,true);
|
|
547
|
-
var isValueHelpTableAvailable = AnnotationHelper.isValueHelpTableAvailable(oProperty);
|
|
548
|
-
|
|
549
|
-
if (isValueHelpTableAvailable) {
|
|
550
|
-
var oPropertyContext = oSFBMetaModel.createBindingContext(sPropertyPath);
|
|
551
|
-
var oVHPromise = oSFBMetaModel.getODataValueLists(oPropertyContext);
|
|
552
|
-
var filtersLength = aFilters.length;
|
|
553
|
-
// //Every Search on a value, create a seperate call to backend,but they are grouped into one batch
|
|
554
|
-
// //We need to ensure that once all calls are completed inside the batch to resolve the promise, else the system would be waiting indefenitely
|
|
555
|
-
var ctr = 0;
|
|
556
|
-
let fnForDescription = (oResponse,aMatchedFilterResults,sTextArrangementPath,sTextArrangement) => {
|
|
557
|
-
++ctr;
|
|
558
|
-
var aResults = oResponse.results;
|
|
559
|
-
|
|
560
|
-
//Check the description is present and follow the textArrangement annotation as well
|
|
561
|
-
//If the value is not present ,make the ID and Description same
|
|
562
|
-
aMatchedFilterResults.forEach((oFilter)=>{
|
|
563
|
-
var result = aResults.find((res)=>res[key] === oFilter.getValue1());
|
|
564
|
-
if (result) {
|
|
565
|
-
aFinalResponse.push({
|
|
566
|
-
operator: FilterOperator.EQ,
|
|
567
|
-
selectedValues: [{
|
|
568
|
-
value: result[key],
|
|
569
|
-
description: AnnotationHelper.getTextArrangementFinalString(result,key,sTextArrangementPath.split("/")[1],sTextArrangement)
|
|
570
|
-
}]
|
|
571
|
-
});
|
|
572
|
-
} else {
|
|
573
|
-
//Ideally description should be present, if in case its not present we will fallback to our default case where value and description would be same
|
|
574
|
-
aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter));
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
if (ctr === filtersLength) {
|
|
579
|
-
resolve(aFinalResponse);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
let fnSuccessForValueList = (oResponse,oFilter,sValueListEntity) => {
|
|
586
|
-
var oValueHelpEntity = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sValueListEntity);
|
|
587
|
-
var oValueHelpProperty = oSFBMetaModel.getODataProperty(oValueHelpEntity, key);
|
|
588
|
-
var aResults = oResponse.results;
|
|
589
|
-
var sTextArrangementPath = AnnotationHelper.getTextArrangementPath(oValueHelpProperty);
|
|
590
|
-
var sTextArrangement = AnnotationHelper.getTextArrangementForEasyFilter(oValueHelpEntity,oValueHelpProperty);
|
|
591
|
-
var navigationProperty = null;
|
|
592
|
-
var sEntityForTextDescription = null;
|
|
593
|
-
|
|
594
|
-
if (sTextArrangementPath && sTextArrangementPath.split("/").length > 1) {
|
|
595
|
-
navigationProperty = sTextArrangementPath.split("/")[0];
|
|
596
|
-
sEntityForTextDescription = oSFBMetaModel.getODataAssociationSetEnd(oValueHelpEntity,navigationProperty).entitySet;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
//We are triggering the below call, only for fetching of the TextDescription.If its a different entity than ValueList only then trigger it
|
|
600
|
-
if (aResults.length === 0) {
|
|
601
|
-
++ctr;
|
|
602
|
-
aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter));
|
|
603
|
-
} else if (aResults.length !== 0 && sEntityForTextDescription && sValueListEntity !== sEntityForTextDescription) {
|
|
604
|
-
var aAllMatchedResults = aResults.map((result)=>{
|
|
605
|
-
return result[key];
|
|
606
|
-
});
|
|
607
|
-
var aMatchedFilterResults = aAllMatchedResults.map((matchedResult)=>{
|
|
608
|
-
return new Filter({
|
|
609
|
-
path: key,
|
|
610
|
-
operator: FilterOperator.EQ,
|
|
611
|
-
value1:matchedResult
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
// The below code only be executed when the textDescription and ValueList entities are different
|
|
615
|
-
oSFBModel.read("/" + sEntityForTextDescription, {
|
|
616
|
-
filters: aMatchedFilterResults,
|
|
617
|
-
success : function(response) {
|
|
618
|
-
fnForDescription(response,aMatchedFilterResults);
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
} else {
|
|
622
|
-
//The below condition is when valueList entity and navigation property entity are same
|
|
623
|
-
++ctr;
|
|
624
|
-
aResults.forEach((result)=>{
|
|
625
|
-
aFinalResponse.push({
|
|
626
|
-
operator: FilterOperator.EQ,
|
|
627
|
-
selectedValues: [{
|
|
628
|
-
value: result[key],
|
|
629
|
-
description: AnnotationHelper.getTextArrangementFinalString(result,key,
|
|
630
|
-
sTextArrangementPath,sTextArrangement)
|
|
631
|
-
}]
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
if (ctr === filtersLength) {
|
|
637
|
-
resolve(aFinalResponse);
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
oVHPromise.then((oValueList)=>{
|
|
642
|
-
var oValueListDefaultBinding = oValueList[""];
|
|
643
|
-
var sValueListEntity = oValueListDefaultBinding.CollectionPath.String;
|
|
644
|
-
if (Array.isArray(oValueListDefaultBinding.Parameters)) {
|
|
645
|
-
var oParameter = oValueListDefaultBinding.Parameters.find(oParam => (oParam.RecordType === "com.sap.vocabularies.Common.v1.ValueListParameterInOut" && oParam.LocalDataProperty.PropertyPath === sKey));
|
|
646
|
-
if (oParameter) {
|
|
647
|
-
key = oParameter.ValueListProperty.String;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
//Get All Records using $search
|
|
651
|
-
aFilters.forEach((oFilter)=>{
|
|
652
|
-
oSFBModel.read("/" + sValueListEntity, {
|
|
653
|
-
urlParameters : {
|
|
654
|
-
search: oFilter.getValue1()
|
|
655
|
-
},
|
|
656
|
-
success : function(response) {
|
|
657
|
-
fnSuccessForValueList(response,oFilter,sValueListEntity);
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
});
|
|
662
|
-
|
|
663
|
-
} else {
|
|
664
|
-
//When there is no valueList associate, just return the original value in CodeList type
|
|
665
|
-
aFilters.forEach((oFilter)=>aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter)));
|
|
666
|
-
resolve(aFinalResponse);
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
function getkeySpecifiedResultFromFilters(oFilter) {
|
|
672
|
-
var values = [];
|
|
673
|
-
if (oFilter.getOperator() === FilterOperator.BT || oFilter.getOperator() === FilterOperator.NB) {
|
|
674
|
-
var values = [{
|
|
675
|
-
value: oFilter.getValue1(),
|
|
676
|
-
description: oFilter.getValue1()
|
|
677
|
-
},{
|
|
678
|
-
value: oFilter.getValue2(),
|
|
679
|
-
description: oFilter.getValue2()
|
|
680
|
-
}];
|
|
681
|
-
} else {
|
|
682
|
-
values.push({
|
|
683
|
-
value: oFilter.getValue1(),
|
|
684
|
-
description: oFilter.getValue1()
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
return {
|
|
688
|
-
operator: oFilter.getOperator(),
|
|
689
|
-
selectedValues: values
|
|
690
|
-
};
|
|
538
|
+
return EasyFilterDataFetcherHelper.fetchDataForKey(key, keySpecificSelectedResult, oState, oController, oTemplateUtils);
|
|
691
539
|
}
|
|
692
540
|
|
|
693
|
-
|
|
694
541
|
return {
|
|
695
542
|
getEasyFilterBar : fnGetEasyFilterBar,
|
|
696
543
|
initialiseEasyFilterBar : fnInitialiseEasyFilterBar,
|
|
@@ -704,8 +551,7 @@ sap.ui.define([
|
|
|
704
551
|
onShowValueHelp: fnShowValueHelp,
|
|
705
552
|
onFilterChange : fnOnFilterChange,
|
|
706
553
|
handleVariantLoad : fnHandleVariantLoad,
|
|
707
|
-
onDataFetcher
|
|
708
|
-
getkeySpecifiedResultFromFilters
|
|
554
|
+
onDataFetcher
|
|
709
555
|
};
|
|
710
556
|
}
|
|
711
557
|
|
|
@@ -714,5 +560,5 @@ sap.ui.define([
|
|
|
714
560
|
extend(this, getMethods(oState, oController, oTemplateUtils));
|
|
715
561
|
}
|
|
716
562
|
});
|
|
717
|
-
|
|
563
|
+
|
|
718
564
|
});
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
sap.ui.define([
|
|
2
|
+
'sap/ui/model/FilterOperator',
|
|
3
|
+
'sap/ui/model/Filter',
|
|
4
|
+
'sap/suite/ui/generic/template/js/AnnotationHelper'
|
|
5
|
+
], function(FilterOperator, Filter, AnnotationHelper) {
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const mReverseOperator = {};
|
|
9
|
+
fillReverseOperator();
|
|
10
|
+
|
|
11
|
+
function fillReverseOperator() {
|
|
12
|
+
mReverseOperator[FilterOperator.EQ] = FilterOperator.NE;
|
|
13
|
+
mReverseOperator[FilterOperator.Contains] = FilterOperator.NotContains;
|
|
14
|
+
mReverseOperator[FilterOperator.EndsWith] = FilterOperator.NotEndsWith;
|
|
15
|
+
mReverseOperator[FilterOperator.StartsWith] = FilterOperator.NotStartsWith;
|
|
16
|
+
mReverseOperator[FilterOperator.BT] = FilterOperator.NB;
|
|
17
|
+
|
|
18
|
+
mReverseOperator[FilterOperator.NE] = FilterOperator.EQ;
|
|
19
|
+
mReverseOperator[FilterOperator.NotContains] = FilterOperator.Contains;
|
|
20
|
+
mReverseOperator[FilterOperator.NotEndsWith] = FilterOperator.EndsWith;
|
|
21
|
+
mReverseOperator[FilterOperator.NotStartsWith] = FilterOperator.StartsWith;
|
|
22
|
+
mReverseOperator[FilterOperator.NB] = FilterOperator.BT;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getFiltersForDataFetching(sKey, keySpecificSelectedResult) {
|
|
26
|
+
const aFilters = [];
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < keySpecificSelectedResult.length; ++i) {
|
|
29
|
+
const result = keySpecificSelectedResult[i];
|
|
30
|
+
if (result.operator === FilterOperator.BT || result.operator === FilterOperator.NB) {
|
|
31
|
+
aFilters.push(new Filter({
|
|
32
|
+
path: sKey,
|
|
33
|
+
operator: result.operator,
|
|
34
|
+
value1: result.selectedValues[0],
|
|
35
|
+
value2: result.selectedValues[1]
|
|
36
|
+
}));
|
|
37
|
+
} else {
|
|
38
|
+
for (let j = 0; j < result.selectedValues.length; ++j) {
|
|
39
|
+
aFilters.push(new Filter({
|
|
40
|
+
path: sKey,
|
|
41
|
+
operator: result.operator,
|
|
42
|
+
value1: result.selectedValues[j]
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return aFilters;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isComparitveOperator(sFilter) {
|
|
51
|
+
return sFilter === FilterOperator.BT || sFilter === FilterOperator.NB ||
|
|
52
|
+
sFilter === FilterOperator.GT || sFilter === FilterOperator.LT ||
|
|
53
|
+
sFilter === FilterOperator.GE || sFilter === FilterOperator.LE;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isNegationOperator(sOperator) {
|
|
57
|
+
return sOperator === FilterOperator.NE || sOperator === FilterOperator.NotContains ||
|
|
58
|
+
sOperator === FilterOperator.NotEndsWith || sOperator === FilterOperator.NotStartsWith ||
|
|
59
|
+
sOperator === FilterOperator.NB;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getkeySpecifiedResultFromFilters(oFilter) {
|
|
63
|
+
let values = [];
|
|
64
|
+
if (oFilter.getOperator() === FilterOperator.BT || oFilter.getOperator() === FilterOperator.NB) {
|
|
65
|
+
values = [{
|
|
66
|
+
value: oFilter.getValue1(),
|
|
67
|
+
description: oFilter.getValue1()
|
|
68
|
+
},{
|
|
69
|
+
value: oFilter.getValue2(),
|
|
70
|
+
description: oFilter.getValue2()
|
|
71
|
+
}];
|
|
72
|
+
} else {
|
|
73
|
+
values.push({
|
|
74
|
+
value: oFilter.getValue1(),
|
|
75
|
+
description: oFilter.getValue1()
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
operator: oFilter.getOperator(),
|
|
80
|
+
selectedValues: values
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function fetchRecordsFromValueList(oValueList, oFilter, sKey, oSFBModel,oTemplateUtils) {
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
let oValueListDefaultBinding = oValueList[""];
|
|
87
|
+
let sValueListEntity = oValueListDefaultBinding.CollectionPath.String;
|
|
88
|
+
|
|
89
|
+
if (Array.isArray(oValueListDefaultBinding.Parameters)) {
|
|
90
|
+
let oParameter = oValueListDefaultBinding.Parameters.find(oParam => (oParam.RecordType === "com.sap.vocabularies.Common.v1.ValueListParameterInOut" && oParam.LocalDataProperty.PropertyPath === sKey));
|
|
91
|
+
if (oParameter) {
|
|
92
|
+
sKey = oParameter.ValueListProperty.String;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let bIsNotOperator = isNegationOperator(oFilter.getOperator());
|
|
97
|
+
if (bIsNotOperator) {
|
|
98
|
+
oFilter = new Filter({
|
|
99
|
+
path: sKey,
|
|
100
|
+
operator: mReverseOperator[oFilter.getOperator()],
|
|
101
|
+
value1: oFilter.getValue1()
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
oFilter = new Filter({
|
|
105
|
+
path: sKey,
|
|
106
|
+
operator: oFilter.getOperator(),
|
|
107
|
+
value1: oFilter.getValue1()
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
oSFBModel.read("/" + sValueListEntity, {
|
|
112
|
+
filters: [oFilter],
|
|
113
|
+
success: async function(oResponse) {
|
|
114
|
+
const aResults = oResponse.results;
|
|
115
|
+
let aResponse;
|
|
116
|
+
try {
|
|
117
|
+
if (aResults.length > 0) {
|
|
118
|
+
aResponse = await getDescriptionForResponse(oResponse.results, sValueListEntity, sKey, oSFBModel,oTemplateUtils,oFilter);
|
|
119
|
+
} else {
|
|
120
|
+
aResponse = await fetchRecordsFromValueListUsingFuzzySearch(sValueListEntity, oFilter, sKey, oSFBModel,oTemplateUtils);
|
|
121
|
+
}
|
|
122
|
+
resolve({
|
|
123
|
+
operator: (bIsNotOperator) ? mReverseOperator[oFilter.getOperator()] : oFilter.getOperator(),
|
|
124
|
+
selectedValues: aResponse
|
|
125
|
+
});
|
|
126
|
+
} catch (error) {
|
|
127
|
+
reject(error);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
error: async function(oError) {
|
|
131
|
+
//If the error is because of some property validation, we can try to do a fuzzy search
|
|
132
|
+
try {
|
|
133
|
+
const aResponse = await fetchRecordsFromValueListUsingFuzzySearch(sValueListEntity, oFilter, sKey, oSFBModel,oTemplateUtils);
|
|
134
|
+
resolve({
|
|
135
|
+
operator: (bIsNotOperator) ? mReverseOperator[oFilter.getOperator()] : oFilter.getOperator(),
|
|
136
|
+
selectedValues: aResponse
|
|
137
|
+
});
|
|
138
|
+
} catch (error) {
|
|
139
|
+
reject(error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function fetchRecordsFromValueListUsingFuzzySearch(sValueListEntity, oFilter, sKey, oSFBModel,oTemplateUtils) {
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
oSFBModel.read("/" + sValueListEntity, {
|
|
149
|
+
urlParameters: {
|
|
150
|
+
search: oFilter.getValue1()
|
|
151
|
+
},
|
|
152
|
+
success: async function(oResponse) {
|
|
153
|
+
let aResults = oResponse.results;
|
|
154
|
+
if (aResults.length == 0) {
|
|
155
|
+
//If it dosent have any records, the return the original value
|
|
156
|
+
resolve([{
|
|
157
|
+
value: oFilter.getValue1(),
|
|
158
|
+
description: oFilter.getValue1()
|
|
159
|
+
}]);
|
|
160
|
+
} else {
|
|
161
|
+
try {
|
|
162
|
+
aResults = await getDescriptionForResponse(aResults, sValueListEntity, sKey, oSFBModel,oTemplateUtils,oFilter);
|
|
163
|
+
resolve(aResults);
|
|
164
|
+
} catch (oError) {
|
|
165
|
+
reject(oError);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
error: function(oError) {
|
|
170
|
+
reject(oError);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function performClientSideSearch(aResults, oFilter,sKey,sDescriptionField) {
|
|
177
|
+
if (!sKey || !sDescriptionField) {
|
|
178
|
+
return aResults;
|
|
179
|
+
}
|
|
180
|
+
if (oFilter.getOperator() === FilterOperator.EQ || oFilter.getOperator() === FilterOperator.NE) {
|
|
181
|
+
const aFilteredResults = aResults.filter(result => result[sKey].toString().toLowerCase() === oFilter.getValue1().toString().toLowerCase() || result[sDescriptionField].toString().toLowerCase() === oFilter.getValue1().toString().toLowerCase());
|
|
182
|
+
return aFilteredResults.length > 0 ? aFilteredResults : aResults;
|
|
183
|
+
}
|
|
184
|
+
return aResults;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function getDescriptionForResponse(aResults, sValueListEntity, sKey, oSFBModel, oTemplateUtils,oFilter) {
|
|
188
|
+
return new Promise((resolve, reject) => {
|
|
189
|
+
const aResultsWithTextArrangement = [];
|
|
190
|
+
|
|
191
|
+
let oSFBMetaModel = oSFBModel.getMetaModel();
|
|
192
|
+
let oValueHelpEntity = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sValueListEntity);
|
|
193
|
+
let oValueHelpProperty = oSFBMetaModel.getODataProperty(oValueHelpEntity, sKey);
|
|
194
|
+
let sTextArrangementPath = AnnotationHelper.getTextArrangementPath(oValueHelpProperty);
|
|
195
|
+
let sTextArrangement = AnnotationHelper.getTextArrangementForEasyFilter(oValueHelpEntity, oValueHelpProperty);
|
|
196
|
+
let navigationProperty = null;
|
|
197
|
+
let sEntityForTextDescription = sValueListEntity;
|
|
198
|
+
|
|
199
|
+
if (sTextArrangementPath && sTextArrangementPath.split("/").length > 1) {
|
|
200
|
+
navigationProperty = sTextArrangementPath.split("/")[0];
|
|
201
|
+
sEntityForTextDescription = oSFBMetaModel.getODataAssociationSetEnd(oValueHelpEntity, navigationProperty).entitySet;
|
|
202
|
+
sTextArrangementPath = sTextArrangementPath.split("/")[1];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
aResults = performClientSideSearch(aResults, oFilter,sKey,sTextArrangementPath);
|
|
206
|
+
|
|
207
|
+
if (sValueListEntity === sEntityForTextDescription) {
|
|
208
|
+
aResults.forEach((result) => {
|
|
209
|
+
aResultsWithTextArrangement.push({
|
|
210
|
+
value: result[sKey],
|
|
211
|
+
description: AnnotationHelper.getTextArrangementFinalString(result, sKey, sTextArrangementPath, sTextArrangement)
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
resolve(aResultsWithTextArrangement);
|
|
215
|
+
} else {
|
|
216
|
+
let aAllMatchedResults = aResults.map((result) => {
|
|
217
|
+
return result[sKey];
|
|
218
|
+
});
|
|
219
|
+
let aMatchedFilterResults = aAllMatchedResults.map((matchedResult) => {
|
|
220
|
+
return new Filter({
|
|
221
|
+
path: sKey,
|
|
222
|
+
operator: FilterOperator.EQ,
|
|
223
|
+
value1: matchedResult
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// The below code only be executed when the textDescription and ValueList entities are different
|
|
228
|
+
oSFBModel.read("/" + sEntityForTextDescription, {
|
|
229
|
+
filters: aMatchedFilterResults,
|
|
230
|
+
success: function(oResponse) {
|
|
231
|
+
let aResults = oResponse.results;
|
|
232
|
+
|
|
233
|
+
aMatchedFilterResults.forEach((oFilter) => {
|
|
234
|
+
let result = aResults.find((res) => res[sKey] === oFilter.getValue1());
|
|
235
|
+
aResultsWithTextArrangement.push({
|
|
236
|
+
value: oFilter.getValue1(),
|
|
237
|
+
description: (result) ? AnnotationHelper.getTextArrangementFinalString(result, sKey, sTextArrangementPath, sTextArrangement) : oFilter.getValue1()
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
resolve(aResultsWithTextArrangement);
|
|
241
|
+
},
|
|
242
|
+
error: function(oError) {
|
|
243
|
+
reject(oError);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The primary responsibility of this function is to convert the given values into their corresponding
|
|
252
|
+
* IDs and Descriptions, respecting the defined TextArrangement.
|
|
253
|
+
*
|
|
254
|
+
* This process is carried out in two phases:
|
|
255
|
+
*
|
|
256
|
+
* Fetching the ID:
|
|
257
|
+
* 1) Make a $filter call using the provided value and operator.
|
|
258
|
+
* - If this returns results, we proceed to fetch the corresponding descriptions for these IDs.
|
|
259
|
+
* 2) If no results are returned, make a $search (fuzzy search) call instead.
|
|
260
|
+
*
|
|
261
|
+
* Fetching the Description:
|
|
262
|
+
* 1) The description is determined by the sap:text/com.sap.vocabularies.UI.v1.TextArrangement
|
|
263
|
+
* annotation of the ValueHelp entity, not from the main entity.
|
|
264
|
+
* 2) To fetch the description, we use a $filter call, since the IDs were already retrieved in the first step.
|
|
265
|
+
*
|
|
266
|
+
* Edge cases with negation operators:
|
|
267
|
+
* 1) For negation operators such as NB, NotStartsWith, etc., we make a batch call using the
|
|
268
|
+
* positive equivalent of these operators (e.g., BT, StartsWith).
|
|
269
|
+
* 2) After receiving the results, we return them with the original negation operator
|
|
270
|
+
* (e.g., NB, NotStartsWith).
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
function fetchDataForKey(sKey, keySpecificSelectedResult, oState, oController, oTemplateUtils) {
|
|
274
|
+
return new Promise(async(resolve, reject) => {
|
|
275
|
+
try {
|
|
276
|
+
const aFinalResponse = [];
|
|
277
|
+
const oOwnerFilterControl = oState.oSmartFilterbar;
|
|
278
|
+
const sEntitySet = oController.getOwnerComponent().getEntitySet();
|
|
279
|
+
const oEntityType = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sEntitySet);
|
|
280
|
+
const oSFBModel = oOwnerFilterControl.getModel();
|
|
281
|
+
const oSFBMetaModel = oSFBModel.getMetaModel();
|
|
282
|
+
const aFilters = getFiltersForDataFetching(sKey, keySpecificSelectedResult);
|
|
283
|
+
const oProperty = oSFBMetaModel.getODataProperty(oEntityType, sKey);
|
|
284
|
+
const sPropertyPath = oSFBMetaModel.getODataProperty(oEntityType, sKey, true);
|
|
285
|
+
const isValueHelpTableAvailable = AnnotationHelper.isValueHelpTableAvailable(oProperty);
|
|
286
|
+
|
|
287
|
+
if (!isValueHelpTableAvailable) {
|
|
288
|
+
// When there is no valueList associate, just return the original value in CodeList type
|
|
289
|
+
aFilters.forEach(oFilter => aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter)));
|
|
290
|
+
resolve(aFinalResponse);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Get value help lists from metadata
|
|
294
|
+
const oPropertyContext = oSFBMetaModel.createBindingContext(sPropertyPath);
|
|
295
|
+
const oValueList = await oSFBMetaModel.getODataValueLists(oPropertyContext);
|
|
296
|
+
|
|
297
|
+
// Process each filter in parallel
|
|
298
|
+
const pPromises = [];
|
|
299
|
+
|
|
300
|
+
for (const oFilter of aFilters) {
|
|
301
|
+
if (isComparitveOperator(oFilter.getOperator())) {
|
|
302
|
+
// For comparative operators, just add the original values
|
|
303
|
+
aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter));
|
|
304
|
+
} else {
|
|
305
|
+
// For other operators, fetch records from value list
|
|
306
|
+
pPromises.push(fetchRecordsFromValueList(oValueList, oFilter, sKey, oSFBModel, oTemplateUtils));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Wait for all promises to resolve
|
|
311
|
+
if (pPromises.length > 0) {
|
|
312
|
+
const aResponses = await Promise.all(pPromises);
|
|
313
|
+
aResponses.forEach(aResponse => {
|
|
314
|
+
aFinalResponse.push(aResponse);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
resolve(aFinalResponse);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
reject(error); // Re-throw to allow caller to handle
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
fetchDataForKey: fetchDataForKey,
|
|
327
|
+
getFiltersForDataFetching: getFiltersForDataFetching,
|
|
328
|
+
isComparitveOperator: isComparitveOperator,
|
|
329
|
+
isNegationOperator: isNegationOperator,
|
|
330
|
+
getReverseOperator: function(operator) {
|
|
331
|
+
return mReverseOperator[operator];
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
});
|
|
@@ -3223,7 +3223,7 @@ sap.ui.define(["sap/ui/base/Object",
|
|
|
3223
3223
|
* @param {sap.suite.ui.generic.template.lib.AppComponent} oAppComponent The AppComponent instance
|
|
3224
3224
|
* @public
|
|
3225
3225
|
* @extends sap.ui.base.Object
|
|
3226
|
-
* @version 1.139.
|
|
3226
|
+
* @version 1.139.1
|
|
3227
3227
|
* @since 1.30.0
|
|
3228
3228
|
* @alias sap.suite.ui.generic.template.lib.NavigationController
|
|
3229
3229
|
*/
|
|
@@ -582,7 +582,7 @@ sap.ui.define([
|
|
|
582
582
|
const getFieldProps = function (sField) {
|
|
583
583
|
return {
|
|
584
584
|
"sProperty": sField,
|
|
585
|
-
"sLabel": mPropertyByFieldName[sField]["sap:label"],
|
|
585
|
+
"sLabel": (mPropertyByFieldName[sField]["com.sap.vocabularies.Common.v1.Label"] || "").String || mPropertyByFieldName[sField]["sap:label"] || "",
|
|
586
586
|
"sValue": oItemContext.getProperty(sField),
|
|
587
587
|
"bHidden": !aVisibleColumns.has(sField)
|
|
588
588
|
};
|