@sapui5/sap.suite.ui.generic.template 1.138.1 → 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 +2 -3
- package/src/sap/suite/ui/generic/template/.library +1 -1
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/Component.js +0 -7
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/control/visualfilterbar/SmartVisualFilterBar.js +5 -2
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/control/visualfilterbar/VisualFilterProvider.js +5 -6
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/controller/ControllerImplementation.js +2 -13
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/controller/DropDownController.js +3 -1
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n.properties +0 -3
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/util/AnnotationHelper.js +0 -9
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/view/fragments/ContentContainer.fragment.xml +0 -7
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/view/fragments/ContentViewButtons.fragment.xml +0 -6
- package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/ListReport/i18n/i18n_en_US_saprigi.properties +2 -0
- package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
- package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -3
- package/src/sap/suite/ui/generic/template/ObjectPage/controller/MessageSortingHandler.js +51 -49
- package/src/sap/suite/ui/generic/template/ObjectPage/controller/MultipleViewsHandler.js +1 -1
- 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/Actions.fragment.xml +2 -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/genericUtilities/controlHelper.js +4 -2
- package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +4 -1
- package/src/sap/suite/ui/generic/template/js/AnnotationHelper.js +106 -15
- package/src/sap/suite/ui/generic/template/lib/AdaptiveCardHelper.js +2 -2
- package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/Application.js +2 -2
- package/src/sap/suite/ui/generic/template/lib/CRUDManager.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/CommonEventHandlers.js +16 -12
- package/src/sap/suite/ui/generic/template/lib/CommonUtils.js +1 -2
- package/src/sap/suite/ui/generic/template/lib/ContactCardDetailHelper.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/ContextBookkeeping.js +3 -6
- package/src/sap/suite/ui/generic/template/lib/ContextMenuHandler.js +16 -2
- package/src/sap/suite/ui/generic/template/lib/FlexibleColumnLayoutHandler.js +3 -1
- package/src/sap/suite/ui/generic/template/lib/SideEffectUtil.js +3 -4
- package/src/sap/suite/ui/generic/template/lib/StatePreserver.js +1 -1
- package/src/sap/suite/ui/generic/template/lib/ViewDependencyHelper.js +7 -2
- package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterBarHandler.js +48 -193
- package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterDataFetcherHelper.js +334 -0
- package/src/sap/suite/ui/generic/template/lib/filterHelper.js +5 -7
- package/src/sap/suite/ui/generic/template/lib/i18n/i18n_en_US_saprigi.properties +108 -1
- package/src/sap/suite/ui/generic/template/lib/i18n/i18n_id.properties +1 -1
- package/src/sap/suite/ui/generic/template/lib/insights/InsightsHandler.js +1 -2
- package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +26 -19
- package/src/sap/suite/ui/generic/template/lib/presentationControl/SmartTableHandler.js +5 -3
- package/src/sap/suite/ui/generic/template/library.js +1 -1
- package/src/sap/suite/ui/generic/template/listTemplates/controller/DetailController.js +6 -2
- package/src/sap/suite/ui/generic/template/listTemplates/controller/IappStateHandler.js +1 -1
- package/src/sap/suite/ui/generic/template/listTemplates/controller/ToolbarController.js +2 -10
- package/src/sap/suite/ui/generic/template/listTemplates/semanticDateRangeTypeHelper.js +1 -1
- package/src/sap/suite/ui/generic/template/themes/base/ALPConstants.less +14 -14
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/ALPConstants.less +14 -14
- package/src/sap/suite/ui/generic/template/themes/sap_bluecrystal_base/ALPConstants.less +14 -14
- package/src/sap/suite/ui/generic/template/themes/sap_hcb/ALPConstants.less +14 -14
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/controller/AnalyticGridController.js +0 -38
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/alr_readme.txt +0 -23
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/crosstab_library.css +0 -20
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/readme.txt +0 -4
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/sort_asc.gif +0 -0
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/sort_desc.gif +0 -0
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/sort_none.gif +0 -0
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/treenode_collapse.gif +0 -0
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/style/img/treenode_expand.gif +0 -0
- package/src/sap/suite/ui/generic/template/AnalyticalListPage/view/fragments/AnalyticGrid.fragment.xml +0 -21
- package/src/sap/suite/ui/generic/template/themes/base/alr_zen.css +0 -127
- package/src/sap/suite/ui/generic/template/themes/base/crosstab_library.css +0 -20
- package/src/sap/suite/ui/generic/template/themes/base/img/readme.txt +0 -4
- package/src/sap/suite/ui/generic/template/themes/base/img/sort_asc.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/base/img/sort_desc.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/base/img/sort_none.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/base/img/treenode_collapse.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/base/img/treenode_expand.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/alr_zen.css +0 -136
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/crosstab_library.css +0 -20
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/readme.txt +0 -4
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/sort_asc.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/sort_desc.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/sort_none.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/treenode_collapse.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_belize_base/img/treenode_expand.gif +0 -0
- package/src/sap/suite/ui/generic/template/themes/sap_bluecrystal_base/alr_zen.css +0 -136
- package/src/sap/suite/ui/generic/template/themes/sap_bluecrystal_base/crosstab_library.css +0 -20
|
@@ -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
|
|
@@ -423,12 +451,14 @@ sap.ui.define([
|
|
|
423
451
|
*/
|
|
424
452
|
function fnShowValueHelp(oEvent) {
|
|
425
453
|
var oSmartFilterbar = oState.oSmartFilterbar;
|
|
454
|
+
var sKey = oEvent.getParameter("key");
|
|
426
455
|
fnValueHelpPromiseResolve = oEvent.getParameter("resolve");
|
|
427
456
|
oSmartFilterbar.associateValueLists();
|
|
428
457
|
try {
|
|
429
|
-
oSmartFilterbar.
|
|
458
|
+
oSmartFilterbar.ensureLoadedValueHelp(sKey);
|
|
459
|
+
oSmartFilterbar.openValueHelpRequestForFilterItem(sKey);
|
|
430
460
|
} catch (error) {
|
|
431
|
-
oLogger.error("Value help cannot be triggered for the field " +
|
|
461
|
+
oLogger.error("Value help cannot be triggered for the field " + sKey);
|
|
432
462
|
}
|
|
433
463
|
}
|
|
434
464
|
|
|
@@ -504,184 +534,10 @@ sap.ui.define([
|
|
|
504
534
|
}
|
|
505
535
|
}
|
|
506
536
|
|
|
507
|
-
function getFiltersForDataFetching(key,keySpecificSelectedResult) {
|
|
508
|
-
const aFilters = [];
|
|
509
|
-
|
|
510
|
-
for (var i = 0; i < keySpecificSelectedResult.length;++i) {
|
|
511
|
-
const result = keySpecificSelectedResult[i];
|
|
512
|
-
if (result.operator === FilterOperator.BT || result.operator === FilterOperator.NB) {
|
|
513
|
-
aFilters.push(new Filter({
|
|
514
|
-
path: key,
|
|
515
|
-
operator: result.operator,
|
|
516
|
-
value1: result.selectedValues[0],
|
|
517
|
-
value2: result.selectedValues[1]
|
|
518
|
-
}));
|
|
519
|
-
} else {
|
|
520
|
-
for (var i = 0;i < result.selectedValues.length;++i) {
|
|
521
|
-
aFilters.push(new Filter({
|
|
522
|
-
path: key,
|
|
523
|
-
operator: result.operator,
|
|
524
|
-
value1: result.selectedValues[i]
|
|
525
|
-
}));
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return aFilters;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
537
|
function onDataFetcher(key,keySpecificSelectedResult,totalAIResponse) {
|
|
533
|
-
return
|
|
534
|
-
|
|
535
|
-
var aFinalResponse = [];
|
|
536
|
-
var oOwnerFilterControl = oState.oSmartFilterbar;
|
|
537
|
-
var sEntitySet = oController.getOwnerComponent().getEntitySet();
|
|
538
|
-
var oEntityType = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sEntitySet);
|
|
539
|
-
var oSFBModel = oOwnerFilterControl.getModel();
|
|
540
|
-
var oSFBMetaModel = oSFBModel.getMetaModel();
|
|
541
|
-
var aFilters = getFiltersForDataFetching(key,keySpecificSelectedResult);
|
|
542
|
-
var oProperty = oSFBMetaModel.getODataProperty(oEntityType, key);
|
|
543
|
-
var sPropertyPath = oSFBMetaModel.getODataProperty(oEntityType, key,true);
|
|
544
|
-
var isValueHelpTableAvailable = AnnotationHelper.isValueHelpTableAvailable(oProperty);
|
|
545
|
-
|
|
546
|
-
if (isValueHelpTableAvailable) {
|
|
547
|
-
var oPropertyContext = oSFBMetaModel.createBindingContext(sPropertyPath);
|
|
548
|
-
var oVHPromise = oSFBMetaModel.getODataValueLists(oPropertyContext);
|
|
549
|
-
var filtersLength = aFilters.length;
|
|
550
|
-
// //Every Search on a value, create a seperate call to backend,but they are grouped into one batch
|
|
551
|
-
// //We need to ensure that once all calls are completed inside the batch to resolve the promise, else the system would be waiting indefenitely
|
|
552
|
-
var ctr = 0;
|
|
553
|
-
let fnForDescription = (oResponse,aMatchedFilterResults,sTextArrangementPath,sTextArrangement) => {
|
|
554
|
-
++ctr;
|
|
555
|
-
var aResults = oResponse.results;
|
|
556
|
-
|
|
557
|
-
//Check the description is present and follow the textArrangement annotation as well
|
|
558
|
-
//If the value is not present ,make the ID and Description same
|
|
559
|
-
aMatchedFilterResults.forEach((oFilter)=>{
|
|
560
|
-
var result = aResults.find((res)=>res[key] === oFilter.getValue1());
|
|
561
|
-
if (result) {
|
|
562
|
-
aFinalResponse.push({
|
|
563
|
-
operator: FilterOperator.EQ,
|
|
564
|
-
selectedValues: [{
|
|
565
|
-
value: result[key],
|
|
566
|
-
description: AnnotationHelper.getTextArrangementFinalString(result,key,sTextArrangementPath.split("/")[1],sTextArrangement)
|
|
567
|
-
}]
|
|
568
|
-
});
|
|
569
|
-
} else {
|
|
570
|
-
//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
|
|
571
|
-
aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter));
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
if (ctr === filtersLength) {
|
|
576
|
-
resolve(aFinalResponse);
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
let fnSuccessForValueList = (oResponse,oFilter,sValueListEntity) => {
|
|
583
|
-
var oValueHelpEntity = oTemplateUtils.oCommonUtils.getMetaModelEntityType(sValueListEntity);
|
|
584
|
-
var oValueHelpProperty = oSFBMetaModel.getODataProperty(oValueHelpEntity, key);
|
|
585
|
-
var aResults = oResponse.results;
|
|
586
|
-
var sTextArrangementPath = AnnotationHelper.getTextArrangementPath(oValueHelpProperty);
|
|
587
|
-
var sTextArrangement = AnnotationHelper.getTextArrangementForEasyFilter(oValueHelpEntity,oValueHelpProperty);
|
|
588
|
-
var navigationProperty = null;
|
|
589
|
-
var sEntityForTextDescription = null;
|
|
590
|
-
|
|
591
|
-
if (sTextArrangementPath && sTextArrangementPath.split("/").length > 1) {
|
|
592
|
-
navigationProperty = sTextArrangementPath.split("/")[0];
|
|
593
|
-
sEntityForTextDescription = oSFBMetaModel.getODataAssociationSetEnd(oValueHelpEntity,navigationProperty).entitySet;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
//We are triggering the below call, only for fetching of the TextDescription.If its a different entity than ValueList only then trigger it
|
|
597
|
-
if (aResults.length === 0) {
|
|
598
|
-
++ctr;
|
|
599
|
-
aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter));
|
|
600
|
-
} else if (aResults.length !== 0 && sEntityForTextDescription && sValueListEntity !== sEntityForTextDescription) {
|
|
601
|
-
var aAllMatchedResults = aResults.map((result)=>{
|
|
602
|
-
return result[key];
|
|
603
|
-
});
|
|
604
|
-
var aMatchedFilterResults = aAllMatchedResults.map((matchedResult)=>{
|
|
605
|
-
return new Filter({
|
|
606
|
-
path: key,
|
|
607
|
-
operator: FilterOperator.EQ,
|
|
608
|
-
value1:matchedResult
|
|
609
|
-
});
|
|
610
|
-
});
|
|
611
|
-
// The below code only be executed when the textDescription and ValueList entities are different
|
|
612
|
-
oSFBModel.read("/" + sEntityForTextDescription, {
|
|
613
|
-
filters: aMatchedFilterResults,
|
|
614
|
-
success : function(response) {
|
|
615
|
-
fnForDescription(response,aMatchedFilterResults);
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
} else {
|
|
619
|
-
//The below condition is when valueList entity and navigation property entity are same
|
|
620
|
-
++ctr;
|
|
621
|
-
aResults.forEach((result)=>{
|
|
622
|
-
aFinalResponse.push({
|
|
623
|
-
operator: FilterOperator.EQ,
|
|
624
|
-
selectedValues: [{
|
|
625
|
-
value: result[key],
|
|
626
|
-
description: AnnotationHelper.getTextArrangementFinalString(result,key,
|
|
627
|
-
sTextArrangementPath,sTextArrangement)
|
|
628
|
-
}]
|
|
629
|
-
});
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
if (ctr === filtersLength) {
|
|
634
|
-
resolve(aFinalResponse);
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
oVHPromise.then((oValueList)=>{
|
|
639
|
-
var oValueListDefaultBinding = oValueList[""];
|
|
640
|
-
var sValueListEntity = oValueListDefaultBinding.CollectionPath.String;
|
|
641
|
-
//Get All Records using $search
|
|
642
|
-
aFilters.forEach((oFilter)=>{
|
|
643
|
-
oSFBModel.read("/" + sValueListEntity, {
|
|
644
|
-
urlParameters : {
|
|
645
|
-
search: oFilter.getValue1()
|
|
646
|
-
},
|
|
647
|
-
success : function(response) {
|
|
648
|
-
fnSuccessForValueList(response,oFilter,sValueListEntity);
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
} else {
|
|
655
|
-
//When there is no valueList associate, just return the original value in CodeList type
|
|
656
|
-
aFilters.forEach((oFilter)=>aFinalResponse.push(getkeySpecifiedResultFromFilters(oFilter)));
|
|
657
|
-
resolve(aFinalResponse);
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
function getkeySpecifiedResultFromFilters(oFilter) {
|
|
663
|
-
var values = [];
|
|
664
|
-
if (oFilter.getOperator() === FilterOperator.BT || oFilter.getOperator() === FilterOperator.NB) {
|
|
665
|
-
var values = [{
|
|
666
|
-
value: oFilter.getValue1(),
|
|
667
|
-
description: oFilter.getValue1()
|
|
668
|
-
},{
|
|
669
|
-
value: oFilter.getValue2(),
|
|
670
|
-
description: oFilter.getValue2()
|
|
671
|
-
}];
|
|
672
|
-
} else {
|
|
673
|
-
values.push({
|
|
674
|
-
value: oFilter.getValue1(),
|
|
675
|
-
description: oFilter.getValue1()
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
return {
|
|
679
|
-
operator: oFilter.getOperator(),
|
|
680
|
-
selectedValues: values
|
|
681
|
-
};
|
|
538
|
+
return EasyFilterDataFetcherHelper.fetchDataForKey(key, keySpecificSelectedResult, oState, oController, oTemplateUtils);
|
|
682
539
|
}
|
|
683
540
|
|
|
684
|
-
|
|
685
541
|
return {
|
|
686
542
|
getEasyFilterBar : fnGetEasyFilterBar,
|
|
687
543
|
initialiseEasyFilterBar : fnInitialiseEasyFilterBar,
|
|
@@ -695,8 +551,7 @@ sap.ui.define([
|
|
|
695
551
|
onShowValueHelp: fnShowValueHelp,
|
|
696
552
|
onFilterChange : fnOnFilterChange,
|
|
697
553
|
handleVariantLoad : fnHandleVariantLoad,
|
|
698
|
-
onDataFetcher
|
|
699
|
-
getkeySpecifiedResultFromFilters
|
|
554
|
+
onDataFetcher
|
|
700
555
|
};
|
|
701
556
|
}
|
|
702
557
|
|
|
@@ -705,5 +560,5 @@ sap.ui.define([
|
|
|
705
560
|
extend(this, getMethods(oState, oController, oTemplateUtils));
|
|
706
561
|
}
|
|
707
562
|
});
|
|
708
|
-
|
|
563
|
+
|
|
709
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
|
+
});
|
|
@@ -12,7 +12,7 @@ sap.ui.define([
|
|
|
12
12
|
* Remove extra information from variant object keep only SelectionOptions and Parameters
|
|
13
13
|
*
|
|
14
14
|
* @param {object} oValue Variant value
|
|
15
|
-
* @returns {object} Updated value of selection variant after
|
|
15
|
+
* @returns {object} Updated value of selection variant after removing the extra info
|
|
16
16
|
*/
|
|
17
17
|
function removeExtraInfoVariant(oValue) {
|
|
18
18
|
if (oValue) {
|
|
@@ -28,7 +28,7 @@ sap.ui.define([
|
|
|
28
28
|
delete oValue.ParameterContextUrl;
|
|
29
29
|
return oValue;
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -271,11 +271,9 @@ sap.ui.define([
|
|
|
271
271
|
var sRangeText = "";
|
|
272
272
|
|
|
273
273
|
if (Array.isArray(aFilterLabel)) {
|
|
274
|
-
aFilterLabel.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
});
|
|
274
|
+
sRangeText = aFilterLabel.find(function(sText) {
|
|
275
|
+
return sText && sText.includes(oRange.Low);
|
|
276
|
+
}) || "";
|
|
279
277
|
} else if (typeof aFilterLabel === "string") {
|
|
280
278
|
sRangeText = aFilterLabel;
|
|
281
279
|
}
|