@sapui5/sap.fe.core 1.99.0 → 1.100.0
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 +4 -2
- package/src/sap/fe/core/.library +1 -1
- package/src/sap/fe/core/AnnotationHelper.js +1 -69
- package/src/sap/fe/core/AnnotationHelper.ts +0 -70
- package/src/sap/fe/core/AppComponent.js +388 -399
- package/src/sap/fe/core/AppComponent.ts +403 -0
- package/src/sap/fe/core/AppStateHandler.js +127 -158
- package/src/sap/fe/core/BaseController.js +82 -58
- package/src/sap/fe/core/BaseController.ts +68 -0
- package/src/sap/fe/core/CommonUtils.js +111 -20
- package/src/sap/fe/core/CommonUtils.ts +131 -32
- package/src/sap/fe/core/ExtensionAPI.js +278 -274
- package/src/sap/fe/core/ExtensionAPI.ts +250 -0
- package/src/sap/fe/core/PageController.js +157 -29
- package/src/sap/fe/core/PageController.ts +60 -32
- package/src/sap/fe/core/RouterProxy.js +694 -756
- package/src/sap/fe/core/RouterProxy.ts +11 -9
- package/src/sap/fe/core/Synchronization.js +21 -31
- package/src/sap/fe/core/TemplateComponent.js +1 -1
- package/src/sap/fe/core/TemplateComponent.ts +10 -3
- package/src/sap/fe/core/TemplateModel.js +20 -38
- package/src/sap/fe/core/TemplateModel.ts +1 -1
- package/src/sap/fe/core/TransactionHelper.js +1354 -1370
- package/src/sap/fe/core/TransactionHelper.ts +33 -22
- package/src/sap/fe/core/actions/collaboration/ActivitySync.js +392 -0
- package/src/sap/fe/core/actions/collaboration/ActivitySync.ts +355 -0
- package/src/sap/fe/core/actions/collaboration/CollaborationCommon.js +136 -0
- package/src/sap/fe/core/actions/collaboration/CollaborationCommon.ts +119 -0
- package/src/sap/fe/core/actions/collaboration/Manage.js +262 -0
- package/src/sap/fe/core/actions/collaboration/Manage.ts +244 -0
- package/src/sap/fe/core/actions/collaboration/ManageDialog.fragment.xml +103 -0
- package/src/sap/fe/core/actions/collaboration/UserDetails.fragment.xml +13 -0
- package/src/sap/fe/core/actions/draft.js +30 -68
- package/src/sap/fe/core/actions/draft.ts +44 -71
- package/src/sap/fe/core/actions/messageHandling.js +55 -36
- package/src/sap/fe/core/actions/messageHandling.ts +66 -46
- package/src/sap/fe/core/actions/operations.js +34 -15
- package/src/sap/fe/core/actions/operations.ts +48 -18
- package/src/sap/fe/core/actions/sticky.js +17 -4
- package/src/sap/fe/core/actions/sticky.ts +21 -4
- package/src/sap/fe/core/controllerextensions/ControllerExtensionMetadata.js +69 -66
- package/src/sap/fe/core/controllerextensions/ControllerExtensionMetadata.ts +65 -0
- package/src/sap/fe/core/controllerextensions/EditFlow.js +1593 -1669
- package/src/sap/fe/core/controllerextensions/EditFlow.ts +1672 -0
- package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.js +79 -54
- package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.ts +61 -0
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.js +718 -779
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.ts +783 -0
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +796 -816
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +803 -0
- package/src/sap/fe/core/controllerextensions/InternalRouting.js +1004 -1005
- package/src/sap/fe/core/controllerextensions/InternalRouting.ts +978 -0
- package/src/sap/fe/core/controllerextensions/KPIManagement.js +487 -521
- package/src/sap/fe/core/controllerextensions/KPIManagement.ts +2 -2
- package/src/sap/fe/core/controllerextensions/MassEdit.js +141 -169
- package/src/sap/fe/core/controllerextensions/MassEdit.ts +156 -0
- package/src/sap/fe/core/controllerextensions/MessageHandler.js +233 -244
- package/src/sap/fe/core/controllerextensions/MessageHandler.ts +225 -0
- package/src/sap/fe/core/controllerextensions/PageReady.js +301 -336
- package/src/sap/fe/core/controllerextensions/PageReady.ts +12 -10
- package/src/sap/fe/core/controllerextensions/Paginator.js +188 -175
- package/src/sap/fe/core/controllerextensions/Paginator.ts +163 -0
- package/src/sap/fe/core/controllerextensions/Placeholder.js +157 -149
- package/src/sap/fe/core/controllerextensions/Placeholder.ts +151 -0
- package/src/sap/fe/core/controllerextensions/Routing.js +144 -125
- package/src/sap/fe/core/controllerextensions/Routing.ts +132 -0
- package/src/sap/fe/core/controllerextensions/RoutingListener.js +7 -6
- package/src/sap/fe/core/controllerextensions/RoutingListener.ts +3 -0
- package/src/sap/fe/core/controllerextensions/Share.js +230 -268
- package/src/sap/fe/core/controllerextensions/Share.ts +231 -0
- package/src/sap/fe/core/controllerextensions/SideEffects.js +592 -633
- package/src/sap/fe/core/controllerextensions/SideEffects.ts +8 -7
- package/src/sap/fe/core/controllerextensions/ViewState.js +788 -806
- package/src/sap/fe/core/controllerextensions/ViewState.ts +805 -0
- package/src/sap/fe/core/controls/ActionParameterDialog.fragment.xml +2 -2
- package/src/sap/fe/core/controls/ActionPartial.fragment.xml +2 -2
- package/src/sap/fe/core/controls/CommandExecution.js +67 -66
- package/src/sap/fe/core/controls/CommandExecution.ts +72 -0
- package/src/sap/fe/core/controls/ConditionalWrapper.js +90 -75
- package/src/sap/fe/core/controls/ConditionalWrapper.ts +83 -0
- package/src/sap/fe/core/controls/CustomQuickViewPage.js +130 -125
- package/src/sap/fe/core/controls/CustomQuickViewPage.ts +126 -0
- package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.js +103 -112
- package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.ts +101 -0
- package/src/sap/fe/core/controls/FieldWrapper.js +122 -135
- package/src/sap/fe/core/controls/FieldWrapper.ts +115 -0
- package/src/sap/fe/core/controls/FilterBar.js +162 -159
- package/src/sap/fe/core/controls/FilterBar.ts +143 -0
- package/src/sap/fe/core/controls/FormElementWrapper.js +45 -39
- package/src/sap/fe/core/controls/FormElementWrapper.ts +40 -0
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.js +37 -42
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.ts +31 -0
- package/src/sap/fe/core/controls/filterbar/FilterContainer.js +126 -116
- package/src/sap/fe/core/controls/filterbar/FilterContainer.ts +98 -0
- package/src/sap/fe/core/controls/filterbar/VisualFilter.js +241 -255
- package/src/sap/fe/core/controls/filterbar/VisualFilter.ts +245 -0
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.js +150 -141
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.ts +125 -0
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.js +335 -322
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.ts +337 -0
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.js +74 -74
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.ts +70 -0
- package/src/sap/fe/core/converters/ConverterContext.js +348 -379
- package/src/sap/fe/core/converters/ConverterContext.ts +19 -16
- package/src/sap/fe/core/converters/ManifestSettings.js +12 -1
- package/src/sap/fe/core/converters/ManifestSettings.ts +12 -1
- package/src/sap/fe/core/converters/ManifestWrapper.js +354 -378
- package/src/sap/fe/core/converters/ManifestWrapper.ts +10 -0
- package/src/sap/fe/core/converters/MetaModelConverter.js +6 -4
- package/src/sap/fe/core/converters/MetaModelConverter.ts +5 -2
- package/src/sap/fe/core/converters/TemplateConverter.js +1 -1
- package/src/sap/fe/core/converters/TemplateConverter.ts +2 -1
- package/src/sap/fe/core/converters/annotations/DataField.js +26 -12
- package/src/sap/fe/core/converters/annotations/DataField.ts +37 -13
- package/src/sap/fe/core/converters/controls/Common/Form.js +2 -2
- package/src/sap/fe/core/converters/controls/Common/Form.ts +4 -2
- package/src/sap/fe/core/converters/controls/Common/KPI.js +1 -1
- package/src/sap/fe/core/converters/controls/Common/KPI.ts +3 -2
- package/src/sap/fe/core/converters/controls/Common/Table.js +130 -23
- package/src/sap/fe/core/converters/controls/Common/Table.ts +134 -29
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.js +118 -53
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.ts +156 -93
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.js +161 -207
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.ts +148 -206
- package/src/sap/fe/core/converters/helpers/Aggregation.js +115 -133
- package/src/sap/fe/core/converters/helpers/BindingHelper.js +20 -6
- package/src/sap/fe/core/converters/helpers/BindingHelper.ts +16 -4
- package/src/sap/fe/core/converters/helpers/ConfigurableObject.js +12 -1
- package/src/sap/fe/core/converters/helpers/ConfigurableObject.ts +11 -0
- package/src/sap/fe/core/converters/helpers/Key.js +42 -57
- package/src/sap/fe/core/converters/helpers/Key.ts +1 -1
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.js +25 -4
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.ts +20 -3
- package/src/sap/fe/core/converters/templates/ListReportConverter.js +10 -4
- package/src/sap/fe/core/converters/templates/ListReportConverter.ts +15 -4
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.js +7 -5
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.ts +5 -1
- package/src/sap/fe/core/designtime/AppComponent.designtime.js +92 -98
- package/src/sap/fe/core/designtime/AppComponent.designtime.ts +91 -0
- package/src/sap/fe/core/formatters/CollaborationFormatter.js +104 -0
- package/src/sap/fe/core/formatters/CollaborationFormatter.ts +60 -0
- package/src/sap/fe/core/formatters/TableFormatter.js +53 -2
- package/src/sap/fe/core/formatters/TableFormatter.ts +51 -0
- package/src/sap/fe/core/fpm/Component.js +50 -54
- package/src/sap/fe/core/fpm/Component.ts +48 -0
- package/src/sap/fe/core/helpers/AppStartupHelper.js +323 -309
- package/src/sap/fe/core/helpers/AppStartupHelper.ts +363 -337
- package/src/sap/fe/core/helpers/BindingExpression.js +7 -7
- package/src/sap/fe/core/helpers/BindingExpression.ts +7 -7
- package/src/sap/fe/core/helpers/ClassSupport.js +186 -62
- package/src/sap/fe/core/helpers/ClassSupport.ts +168 -52
- package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.js +5 -4
- package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.ts +1 -5
- package/src/sap/fe/core/helpers/FPMHelper.js +1 -1
- package/src/sap/fe/core/helpers/FPMHelper.ts +1 -1
- package/src/sap/fe/core/helpers/MassEditHelper.js +601 -684
- package/src/sap/fe/core/helpers/MassEditHelper.ts +699 -0
- package/src/sap/fe/core/helpers/ModelHelper.js +25 -1
- package/src/sap/fe/core/helpers/ModelHelper.ts +23 -0
- package/src/sap/fe/core/helpers/SemanticDateOperators.js +5 -1
- package/src/sap/fe/core/helpers/SemanticDateOperators.ts +4 -0
- package/src/sap/fe/core/library.js +426 -451
- package/src/sap/fe/core/library.support.js +22 -33
- package/src/sap/fe/core/library.support.ts +23 -0
- package/src/sap/fe/core/library.ts +420 -0
- package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.js +5 -3
- package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.ts +4 -1
- package/src/sap/fe/core/messagebundle.properties +22 -5
- package/src/sap/fe/core/messagebundle_ar.properties +27 -7
- package/src/sap/fe/core/messagebundle_bg.properties +27 -7
- package/src/sap/fe/core/messagebundle_ca.properties +27 -7
- package/src/sap/fe/core/messagebundle_cs.properties +27 -7
- package/src/sap/fe/core/messagebundle_cy.properties +27 -7
- package/src/sap/fe/core/messagebundle_da.properties +27 -7
- package/src/sap/fe/core/messagebundle_de.properties +27 -7
- package/src/sap/fe/core/messagebundle_el.properties +27 -7
- package/src/sap/fe/core/messagebundle_en.properties +27 -7
- package/src/sap/fe/core/messagebundle_en_GB.properties +27 -7
- package/src/sap/fe/core/messagebundle_en_US_sappsd.properties +27 -7
- package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +27 -7
- package/src/sap/fe/core/messagebundle_en_US_saptrc.properties +27 -7
- package/src/sap/fe/core/messagebundle_es.properties +27 -7
- package/src/sap/fe/core/messagebundle_es_MX.properties +27 -7
- package/src/sap/fe/core/messagebundle_et.properties +27 -7
- package/src/sap/fe/core/messagebundle_fi.properties +28 -8
- package/src/sap/fe/core/messagebundle_fr.properties +28 -8
- package/src/sap/fe/core/messagebundle_fr_CA.properties +29 -9
- package/src/sap/fe/core/messagebundle_hi.properties +27 -7
- package/src/sap/fe/core/messagebundle_hr.properties +27 -7
- package/src/sap/fe/core/messagebundle_hu.properties +27 -7
- package/src/sap/fe/core/messagebundle_id.properties +27 -7
- package/src/sap/fe/core/messagebundle_it.properties +27 -7
- package/src/sap/fe/core/messagebundle_iw.properties +27 -7
- package/src/sap/fe/core/messagebundle_ja.properties +26 -6
- package/src/sap/fe/core/messagebundle_kk.properties +27 -7
- package/src/sap/fe/core/messagebundle_ko.properties +27 -7
- package/src/sap/fe/core/messagebundle_lt.properties +27 -7
- package/src/sap/fe/core/messagebundle_lv.properties +28 -8
- package/src/sap/fe/core/messagebundle_ms.properties +27 -7
- package/src/sap/fe/core/messagebundle_nl.properties +27 -7
- package/src/sap/fe/core/messagebundle_no.properties +27 -7
- package/src/sap/fe/core/messagebundle_pl.properties +27 -7
- package/src/sap/fe/core/messagebundle_pt.properties +28 -8
- package/src/sap/fe/core/messagebundle_pt_PT.properties +27 -7
- package/src/sap/fe/core/messagebundle_ro.properties +27 -7
- package/src/sap/fe/core/messagebundle_ru.properties +27 -7
- package/src/sap/fe/core/messagebundle_sh.properties +27 -7
- package/src/sap/fe/core/messagebundle_sk.properties +27 -7
- package/src/sap/fe/core/messagebundle_sl.properties +27 -7
- package/src/sap/fe/core/messagebundle_sv.properties +27 -7
- package/src/sap/fe/core/messagebundle_th.properties +26 -6
- package/src/sap/fe/core/messagebundle_tr.properties +30 -10
- package/src/sap/fe/core/messagebundle_uk.properties +27 -7
- package/src/sap/fe/core/messagebundle_vi.properties +27 -7
- package/src/sap/fe/core/messagebundle_zh_CN.properties +27 -7
- package/src/sap/fe/core/messagebundle_zh_TW.properties +27 -7
- package/src/sap/fe/core/services/AsyncComponentServiceFactory.js +45 -71
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.js +154 -192
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.ts +4 -4
- package/src/sap/fe/core/services/EnvironmentServiceFactory.js +66 -92
- package/src/sap/fe/core/services/EnvironmentServiceFactory.ts +1 -1
- package/src/sap/fe/core/services/NavigationServiceFactory.js +284 -339
- package/src/sap/fe/core/services/NavigationServiceFactory.ts +10 -13
- package/src/sap/fe/core/services/ResourceModelServiceFactory.js +67 -102
- package/src/sap/fe/core/services/ResourceModelServiceFactory.ts +5 -2
- package/src/sap/fe/core/services/RoutingServiceFactory.js +754 -814
- package/src/sap/fe/core/services/RoutingServiceFactory.ts +13 -13
- package/src/sap/fe/core/services/ShellServicesFactory.js +649 -736
- package/src/sap/fe/core/services/ShellServicesFactory.ts +7 -4
- package/src/sap/fe/core/services/SideEffectsServiceFactory.js +567 -592
- package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +22 -3
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.js +354 -386
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.ts +21 -14
- package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.js +1 -1
- package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.ts +1 -1
- package/src/sap/fe/core/support/CommonHelper.js +1 -1
- package/src/sap/fe/core/support/CommonHelper.ts +1 -1
- package/src/sap/fe/core/support/Diagnostics.js +36 -48
- package/src/sap/fe/core/templating/DataModelPathHelper.js +93 -85
- package/src/sap/fe/core/templating/DataModelPathHelper.ts +104 -95
- package/src/sap/fe/core/templating/FilterHelper.js +25 -32
- package/src/sap/fe/core/templating/FilterHelper.ts +36 -35
- package/src/sap/fe/core/templating/PropertyHelper.js +2 -2
- package/src/sap/fe/core/templating/PropertyHelper.ts +1 -1
- package/src/sap/fe/core/templating/UIFormatters.js +32 -26
- package/src/sap/fe/core/templating/UIFormatters.ts +37 -24
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
import Dialog from "sap/m/Dialog";
|
|
2
|
+
import XMLTemplateProcessor from "sap/ui/core/XMLTemplateProcessor";
|
|
3
|
+
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
4
|
+
import Fragment from "sap/ui/core/Fragment";
|
|
5
|
+
import XMLPreprocessor from "sap/ui/core/util/XMLPreprocessor";
|
|
6
|
+
import Log from "sap/base/Log";
|
|
7
|
+
import CommonUtils from "sap/fe/core/CommonUtils";
|
|
8
|
+
import Table from "sap/ui/mdc/Table";
|
|
9
|
+
import ResourceBundle from "sap/base/i18n/ResourceBundle";
|
|
10
|
+
import Button from "sap/m/Button";
|
|
11
|
+
import PageController from "sap/fe/core/PageController";
|
|
12
|
+
import { convertMetaModelContext, getInvolvedDataModelObjects } from "../converters/MetaModelConverter";
|
|
13
|
+
import { getTextBinding } from "sap/fe/macros/field/FieldTemplating";
|
|
14
|
+
import { getEditableExpression, getRequiredExpression } from "../templating/UIFormatters";
|
|
15
|
+
import { isReadOnlyExpression } from "../templating/FieldControlHelper";
|
|
16
|
+
import { hasValueHelpWithFixedValues } from "sap/fe/core/templating/PropertyHelper";
|
|
17
|
+
|
|
18
|
+
/* This class contains helpers to be used for mass edit functionality */
|
|
19
|
+
type TextArrangementInfo = {
|
|
20
|
+
textArrangement: string;
|
|
21
|
+
valuePath: string;
|
|
22
|
+
descriptionPath?: string;
|
|
23
|
+
value: string;
|
|
24
|
+
description: string;
|
|
25
|
+
fullText: string;
|
|
26
|
+
};
|
|
27
|
+
const aValidDataTypes = [
|
|
28
|
+
"Edm.Boolean",
|
|
29
|
+
"Edm.Byte",
|
|
30
|
+
"Edm.Decimal",
|
|
31
|
+
"Edm.Double",
|
|
32
|
+
"Edm.Float",
|
|
33
|
+
"Edm.Guid",
|
|
34
|
+
"Edm.Int16",
|
|
35
|
+
"Edm.Int32",
|
|
36
|
+
"Edm.Int64",
|
|
37
|
+
"Edm.SByte",
|
|
38
|
+
"Edm.Single",
|
|
39
|
+
"Edm.String"
|
|
40
|
+
];
|
|
41
|
+
const MassEditHelper = {
|
|
42
|
+
/**
|
|
43
|
+
* Initializes the value at final or deepest level path with a blank array.
|
|
44
|
+
* Return an empty array pointing to the final or deepest level path.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} sPath Property path
|
|
47
|
+
* @param {Array} aValues Array instance where the default data needs to be added
|
|
48
|
+
* @returns {Array}
|
|
49
|
+
*/
|
|
50
|
+
initLastLevelOfPropertyPath: function(sPath: string, aValues: any) {
|
|
51
|
+
let aFinalPath: any;
|
|
52
|
+
let index = 0;
|
|
53
|
+
const aPaths = sPath.split("/");
|
|
54
|
+
let sFullPath = "";
|
|
55
|
+
aPaths.forEach(function(sPropertyPath: string) {
|
|
56
|
+
if (!aValues[sPropertyPath] && index === 0) {
|
|
57
|
+
aValues[sPropertyPath] = {};
|
|
58
|
+
aFinalPath = aValues[sPropertyPath];
|
|
59
|
+
sFullPath = sFullPath + sPropertyPath;
|
|
60
|
+
index++;
|
|
61
|
+
} else if (!aFinalPath[sPropertyPath]) {
|
|
62
|
+
sFullPath = sFullPath + "/" + sPropertyPath;
|
|
63
|
+
if (sFullPath !== sPath) {
|
|
64
|
+
aFinalPath[sPropertyPath] = {};
|
|
65
|
+
aFinalPath = aFinalPath[sPropertyPath];
|
|
66
|
+
} else {
|
|
67
|
+
aFinalPath[sPropertyPath] = [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return aFinalPath;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Method to get unique values for given array values.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} sValue Property value
|
|
78
|
+
* @param {number} index Index of the property value
|
|
79
|
+
* @param {Array} self Instance of the array
|
|
80
|
+
* @returns {boolean}
|
|
81
|
+
*/
|
|
82
|
+
getUniqueValues: function(sValue: string, index: number, self: any[]) {
|
|
83
|
+
if (sValue) {
|
|
84
|
+
return self.indexOf(sValue) === index;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gets the property value for a multi-level path (for example: _Materials/Material_Details gets the value of Material_Details under _Materials Object).
|
|
90
|
+
* Returns the propertyValue, which can be of any type (string, number, etc..).
|
|
91
|
+
*
|
|
92
|
+
* @param {string} sDataPropertyPath Property path
|
|
93
|
+
* @param {object} oValues Object of property values
|
|
94
|
+
* @returns {*}
|
|
95
|
+
*/
|
|
96
|
+
getValueForMultiLevelPath: function(sDataPropertyPath: string, oValues: any) {
|
|
97
|
+
if (sDataPropertyPath && sDataPropertyPath.indexOf("/") > 0) {
|
|
98
|
+
const aPropertyPaths = sDataPropertyPath.split("/");
|
|
99
|
+
let Result: any;
|
|
100
|
+
aPropertyPaths.forEach(function(sPath: string) {
|
|
101
|
+
Result = oValues && oValues[sPath] ? oValues[sPath] : Result && Result[sPath];
|
|
102
|
+
});
|
|
103
|
+
return Result;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Gets the key path for the key of a combo box that must be selected initially when the dialog opens:
|
|
109
|
+
* => If propertyValue for all selected contexts is different, then < Keep Existing Values > is preselected.
|
|
110
|
+
* => If propertyValue for all selected contexts is the same, then the propertyValue is preselected.
|
|
111
|
+
* => If propertyValue for all selected contexts is empty, then < Leave Blank > is preselected.
|
|
112
|
+
*
|
|
113
|
+
*
|
|
114
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
115
|
+
* @param {string} sDataPropertyPath Data property path
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
getDefaultSelectionPathComboBox: function(aContexts: any[], sDataPropertyPath: string) {
|
|
119
|
+
if (sDataPropertyPath && aContexts.length > 0) {
|
|
120
|
+
const oSelectedContext = aContexts,
|
|
121
|
+
aPropertyValues: any[] = [];
|
|
122
|
+
oSelectedContext.forEach(function(oContext: any) {
|
|
123
|
+
const oDataObject = oContext.getObject();
|
|
124
|
+
const sMultiLevelPathCondition =
|
|
125
|
+
sDataPropertyPath.indexOf("/") > -1 && oDataObject.hasOwnProperty(sDataPropertyPath.split("/")[0]);
|
|
126
|
+
if (oContext && (oDataObject.hasOwnProperty(sDataPropertyPath) || sMultiLevelPathCondition)) {
|
|
127
|
+
aPropertyValues.push(oContext.getObject(sDataPropertyPath));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const aUniquePropertyValues = aPropertyValues.filter(MassEditHelper.getUniqueValues);
|
|
131
|
+
if (aUniquePropertyValues.length > 1) {
|
|
132
|
+
return "Default/" + sDataPropertyPath;
|
|
133
|
+
} else if (aUniquePropertyValues.length === 0) {
|
|
134
|
+
return "Empty/" + sDataPropertyPath;
|
|
135
|
+
} else if (aUniquePropertyValues.length === 1) {
|
|
136
|
+
return sDataPropertyPath;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Checks hidden annotation value [both static and path based] for table's selected context.
|
|
143
|
+
*
|
|
144
|
+
* @param {*} hiddenValue Hidden annotation value / path for field
|
|
145
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
146
|
+
* @returns {boolean}
|
|
147
|
+
*/
|
|
148
|
+
getHiddenValueForContexts: function(hiddenValue: any, aContexts: any[]) {
|
|
149
|
+
if (hiddenValue && hiddenValue.$Path) {
|
|
150
|
+
return !aContexts.some(function(oSelectedContext: any) {
|
|
151
|
+
return oSelectedContext.getObject(hiddenValue.$Path) === false;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return hiddenValue;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Initializes a JSON Model for properties of dialog fields [label, visiblity, dataproperty, etc.].
|
|
159
|
+
*
|
|
160
|
+
* @param {object} oTable Instance of Table
|
|
161
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
162
|
+
* @param {Array} aDataArray Array containing data related to the dialog used by both the static and the runtime model
|
|
163
|
+
* @returns {object}
|
|
164
|
+
*/
|
|
165
|
+
prepareDataForDialog: function(oTable: Table, aContexts: any[], aDataArray: any[]) {
|
|
166
|
+
const oMetaModel = oTable && (oTable.getModel().getMetaModel() as any),
|
|
167
|
+
sCurrentEntitySetName = oTable.data("metaPath"),
|
|
168
|
+
aTableFields = MassEditHelper.getTableFields(oTable),
|
|
169
|
+
oEntityTypeContext = oMetaModel.getContext(sCurrentEntitySetName + "/@"),
|
|
170
|
+
oDataModelObjectPath = getInvolvedDataModelObjects(oEntityTypeContext);
|
|
171
|
+
|
|
172
|
+
const oDataFieldModel = new JSONModel();
|
|
173
|
+
let oResult;
|
|
174
|
+
let sLabelText;
|
|
175
|
+
let bValueHelpEnabled;
|
|
176
|
+
let sUnitPropertyPath;
|
|
177
|
+
let bValueHelpEnabledForUnit;
|
|
178
|
+
let bIsImmutable;
|
|
179
|
+
let bIsComputed;
|
|
180
|
+
let bChartProperty;
|
|
181
|
+
let oTextBinding;
|
|
182
|
+
let bValidDataType;
|
|
183
|
+
let bInValidInputType;
|
|
184
|
+
|
|
185
|
+
aTableFields.forEach(function(oColumnInfo: any) {
|
|
186
|
+
const sDataPropertyPath = oColumnInfo.dataProperty;
|
|
187
|
+
if (sDataPropertyPath) {
|
|
188
|
+
let oPropertyInfo = sDataPropertyPath && oMetaModel.getObject(sCurrentEntitySetName + "/" + sDataPropertyPath + "@");
|
|
189
|
+
bValueHelpEnabled =
|
|
190
|
+
sDataPropertyPath &&
|
|
191
|
+
oMetaModel.getObject(sCurrentEntitySetName + "/" + sDataPropertyPath + "@") &&
|
|
192
|
+
oMetaModel.getObject(sCurrentEntitySetName + "/" + sDataPropertyPath + "@")[
|
|
193
|
+
"@com.sap.vocabularies.Common.v1.ValueList"
|
|
194
|
+
];
|
|
195
|
+
sUnitPropertyPath =
|
|
196
|
+
(oPropertyInfo && oPropertyInfo["@Org.OData.Measures.V1.Unit"] && oPropertyInfo["@Org.OData.Measures.V1.Unit"].$Path) ||
|
|
197
|
+
(oPropertyInfo &&
|
|
198
|
+
oPropertyInfo["@Org.OData.Measures.V1.ISOCurrency"] &&
|
|
199
|
+
oPropertyInfo["@Org.OData.Measures.V1.ISOCurrency"].$Path);
|
|
200
|
+
sLabelText = oColumnInfo.label || (oPropertyInfo && oPropertyInfo["@com.sap.vocabularies.Common.v1.Label"]);
|
|
201
|
+
bValueHelpEnabledForUnit =
|
|
202
|
+
sUnitPropertyPath &&
|
|
203
|
+
oMetaModel.getObject(sCurrentEntitySetName + "/" + sUnitPropertyPath + "@") &&
|
|
204
|
+
oMetaModel.getObject(sCurrentEntitySetName + "/" + sUnitPropertyPath + "@")[
|
|
205
|
+
"@com.sap.vocabularies.Common.v1.ValueList"
|
|
206
|
+
];
|
|
207
|
+
if (oDataModelObjectPath) {
|
|
208
|
+
oDataModelObjectPath.targetObject = oDataModelObjectPath.targetEntityType.entityProperties.filter(function(
|
|
209
|
+
oProperty: any
|
|
210
|
+
) {
|
|
211
|
+
return oProperty.name === sDataPropertyPath;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
oDataModelObjectPath.targetObject = oDataModelObjectPath.targetObject[0] || {};
|
|
215
|
+
oTextBinding = getTextBinding(oDataModelObjectPath, {}, true) || {};
|
|
216
|
+
const oFieldContext = oMetaModel.getContext(oColumnInfo.annotationPath),
|
|
217
|
+
oDataFieldConverted = convertMetaModelContext(oFieldContext),
|
|
218
|
+
oPropertyContext = oMetaModel.getContext(sCurrentEntitySetName + "/" + sDataPropertyPath + "@"),
|
|
219
|
+
oInterface = oPropertyContext && oPropertyContext.getInterface();
|
|
220
|
+
bIsImmutable =
|
|
221
|
+
oPropertyContext && oPropertyContext.getProperty() && oPropertyContext.getProperty()["@Org.OData.Core.V1.Immutable"];
|
|
222
|
+
bIsComputed =
|
|
223
|
+
oPropertyContext && oPropertyContext.getProperty() && oPropertyContext.getProperty()["@Org.OData.Core.V1.Computed"];
|
|
224
|
+
const bHiddenField =
|
|
225
|
+
MassEditHelper.getHiddenValueForContexts(
|
|
226
|
+
oFieldContext && oFieldContext.getObject()["@com.sap.vocabularies.UI.v1.Hidden"],
|
|
227
|
+
aContexts
|
|
228
|
+
) || false;
|
|
229
|
+
oInterface.context = {
|
|
230
|
+
getModel: function() {
|
|
231
|
+
return oInterface.getModel();
|
|
232
|
+
},
|
|
233
|
+
getPath: function() {
|
|
234
|
+
return sCurrentEntitySetName + "/" + sDataPropertyPath;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
oPropertyInfo =
|
|
238
|
+
(oDataFieldConverted && oDataFieldConverted.Value && oDataFieldConverted.Value.$target) ||
|
|
239
|
+
(oDataFieldConverted && oDataFieldConverted.Target && oDataFieldConverted.Target.$target);
|
|
240
|
+
// Datafield is not included in the FieldControl calculation, needs to be implemented
|
|
241
|
+
const isReadOnly = isReadOnlyExpression(oPropertyInfo);
|
|
242
|
+
bChartProperty = oPropertyInfo && oPropertyInfo.term && oPropertyInfo.term === "com.sap.vocabularies.UI.v1.Chart";
|
|
243
|
+
bValidDataType = oPropertyInfo && aValidDataTypes.indexOf(oPropertyInfo.type) !== -1;
|
|
244
|
+
bInValidInputType =
|
|
245
|
+
(oColumnInfo &&
|
|
246
|
+
oColumnInfo.inputType &&
|
|
247
|
+
(oColumnInfo.inputType === "sap.m.RatingIndicator" || oColumnInfo.inputType === "sap.ui.mdc.MultiValueField")) ||
|
|
248
|
+
hasValueHelpWithFixedValues(oPropertyInfo);
|
|
249
|
+
if (
|
|
250
|
+
sDataPropertyPath &&
|
|
251
|
+
!bHiddenField &&
|
|
252
|
+
!bIsImmutable &&
|
|
253
|
+
!bIsComputed &&
|
|
254
|
+
!bChartProperty &&
|
|
255
|
+
bValidDataType &&
|
|
256
|
+
!bInValidInputType &&
|
|
257
|
+
oColumnInfo.inputType &&
|
|
258
|
+
getEditableExpression(oPropertyInfo, oDataFieldConverted, oDataModelObjectPath) !== "false"
|
|
259
|
+
) {
|
|
260
|
+
oResult = {
|
|
261
|
+
"label": sLabelText + ":",
|
|
262
|
+
"visible":
|
|
263
|
+
sDataPropertyPath &&
|
|
264
|
+
!bHiddenField &&
|
|
265
|
+
!bIsImmutable &&
|
|
266
|
+
!bIsComputed &&
|
|
267
|
+
getEditableExpression(oPropertyInfo, oDataFieldConverted, oDataModelObjectPath),
|
|
268
|
+
"dataProperty": sDataPropertyPath,
|
|
269
|
+
"isValueHelpEnabled": bValueHelpEnabled ? bValueHelpEnabled : false,
|
|
270
|
+
"unitProperty": sUnitPropertyPath ? sUnitPropertyPath : false,
|
|
271
|
+
"isValueHelpEnabledForUnit": bValueHelpEnabledForUnit ? bValueHelpEnabledForUnit : false,
|
|
272
|
+
"propertyPathForValueHelp": sCurrentEntitySetName + "/" + sDataPropertyPath,
|
|
273
|
+
"propertyPathForValueHelpUnit": sCurrentEntitySetName + "/" + sUnitPropertyPath,
|
|
274
|
+
"isFieldRequired": getRequiredExpression(oPropertyInfo, oDataFieldConverted, true),
|
|
275
|
+
"defaultSelectionPath": sDataPropertyPath
|
|
276
|
+
? MassEditHelper.getDefaultSelectionPathComboBox(aContexts, sDataPropertyPath)
|
|
277
|
+
: false,
|
|
278
|
+
"defaultSelectionUnitPath": sUnitPropertyPath
|
|
279
|
+
? MassEditHelper.getDefaultSelectionPathComboBox(aContexts, sUnitPropertyPath)
|
|
280
|
+
: false,
|
|
281
|
+
"entitySet": sCurrentEntitySetName,
|
|
282
|
+
"textBinding": oTextBinding,
|
|
283
|
+
"nullable": oPropertyInfo.nullable !== undefined ? oPropertyInfo.nullable : true,
|
|
284
|
+
"isPropertyReadOnly": isReadOnly !== undefined ? isReadOnly : false
|
|
285
|
+
};
|
|
286
|
+
aDataArray.push(oResult);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
oDataFieldModel.setData(aDataArray);
|
|
291
|
+
return oDataFieldModel;
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
getInputTypeForColumn: function(oColumn: any) {
|
|
295
|
+
return (
|
|
296
|
+
oColumn.getTemplate().getContent &&
|
|
297
|
+
oColumn.getTemplate().getContent() &&
|
|
298
|
+
oColumn.getTemplate().getContent().getContentEdit &&
|
|
299
|
+
oColumn
|
|
300
|
+
.getTemplate()
|
|
301
|
+
.getContent()
|
|
302
|
+
.getContentEdit() &&
|
|
303
|
+
oColumn
|
|
304
|
+
.getTemplate()
|
|
305
|
+
.getContent()
|
|
306
|
+
.getContentEdit()[0] &&
|
|
307
|
+
oColumn
|
|
308
|
+
.getTemplate()
|
|
309
|
+
.getContent()
|
|
310
|
+
.getContentEdit()[0]
|
|
311
|
+
.getMetadata()
|
|
312
|
+
.getName()
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
getTableFields: function(oTable: any) {
|
|
317
|
+
const aColumns = (oTable && oTable.getColumns()) || [];
|
|
318
|
+
return aColumns.map(function(oColumn: any) {
|
|
319
|
+
const sDataProperty = oColumn && oColumn.getDataProperty(),
|
|
320
|
+
aRealtedColumnInfo =
|
|
321
|
+
oTable.data("columns") &&
|
|
322
|
+
oTable.data("columns").customData.filter(function(oColumnInfo: any) {
|
|
323
|
+
return oColumnInfo.name === sDataProperty && oColumnInfo.type === "Annotation";
|
|
324
|
+
});
|
|
325
|
+
return {
|
|
326
|
+
"dataProperty": sDataProperty,
|
|
327
|
+
"label": oColumn.getHeader(),
|
|
328
|
+
"annotationPath": aRealtedColumnInfo && aRealtedColumnInfo[0] && aRealtedColumnInfo[0].annotationPath,
|
|
329
|
+
"inputType": MassEditHelper.getInputTypeForColumn(oColumn)
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
getDefaultTextsForDialog: function(oResourceBundle: any, iSelectedContexts: any, oTable: any) {
|
|
335
|
+
// The confirm button text is "Save" for table in Display mode and "Apply" for table in edit mode. This can be later exposed if needed.
|
|
336
|
+
const bDisplayMode = oTable.data("displayModePropertyBinding") === "true";
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
"keepExistingPrefix": "< Keep",
|
|
340
|
+
"leaveBlankValue": "< Leave Blank >",
|
|
341
|
+
"clearFieldValue": "< Clear Values >",
|
|
342
|
+
"massEditTitle": oResourceBundle.getText("C_MASS_EDIT_DIALOG_TITLE", iSelectedContexts.toString()),
|
|
343
|
+
"applyButtonText": bDisplayMode
|
|
344
|
+
? oResourceBundle.getText("C_MASS_EDIT_SAVE_BUTTON_TEXT")
|
|
345
|
+
: oResourceBundle.getText("C_MASS_EDIT_APPLY_BUTTON_TEXT"),
|
|
346
|
+
"cancelButtonText": oResourceBundle.getText("C_MASS_EDIT_CANCEL_BUTTON_TEXT")
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Adds a suffix to the 'keep existing' property of the comboBox.
|
|
352
|
+
*
|
|
353
|
+
* @param {string} sInputType InputType of the field
|
|
354
|
+
* @returns {string}
|
|
355
|
+
*/
|
|
356
|
+
getSuffixForKeepExisiting: function(sInputType: string) {
|
|
357
|
+
let sResult = "Values";
|
|
358
|
+
|
|
359
|
+
switch (sInputType) {
|
|
360
|
+
//TODO - Add for other control types as well (Radio Button, Email, Input, MDC Fields, Image etc.)
|
|
361
|
+
case "sap.m.DatePicker":
|
|
362
|
+
sResult = "Dates";
|
|
363
|
+
break;
|
|
364
|
+
case "sap.m.CheckBox":
|
|
365
|
+
sResult = "Settings";
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
return sResult;
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Adds default values to the model [Keep Existing Values, Leave Blank].
|
|
373
|
+
*
|
|
374
|
+
* @param {Array} aValues Array instance where the default data needs to be added
|
|
375
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
376
|
+
* @param {object} oDefaultValues Default values from Application Manifest
|
|
377
|
+
* @param {object} oPropertyInfo Property information
|
|
378
|
+
* @param {boolean} bUOMField
|
|
379
|
+
*/
|
|
380
|
+
setDefaultValuesToDialog: function(aValues: any[], aContexts: any[], oDefaultValues: any, oPropertyInfo: any, bUOMField?: boolean) {
|
|
381
|
+
const sPropertyPath = oPropertyInfo.dataProperty,
|
|
382
|
+
sInputType = oPropertyInfo.inputType,
|
|
383
|
+
bPropertyRequired = oPropertyInfo.isFieldRequired;
|
|
384
|
+
const sSuffixForKeepExisting = MassEditHelper.getSuffixForKeepExisiting(sInputType);
|
|
385
|
+
//TODO - Add <<Use Value Help or control implmentation>> and related key by checking if value help is enabled for property or Unit.
|
|
386
|
+
//TODO - Add option Apply to Empty Fields only for Both Value Help and controls.
|
|
387
|
+
const bValueExistsForPropertyPath = aContexts.some(function(oSelectedContext: any) {
|
|
388
|
+
return oSelectedContext.getObject(sPropertyPath);
|
|
389
|
+
});
|
|
390
|
+
if (bValueExistsForPropertyPath) {
|
|
391
|
+
if (bPropertyRequired !== "true" && !bUOMField) {
|
|
392
|
+
aValues.unshift({ text: oDefaultValues.clearFieldValue, key: "ClearFieldValue/" + sPropertyPath });
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
aValues.unshift({ text: oDefaultValues.leaveBlankValue, key: "Empty/" + sPropertyPath });
|
|
396
|
+
}
|
|
397
|
+
aValues.unshift({
|
|
398
|
+
text: oDefaultValues.keepExistingPrefix + " " + sSuffixForKeepExisting + " >",
|
|
399
|
+
key: "Default/" + sPropertyPath
|
|
400
|
+
});
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
getTextArrangementInfo: function(
|
|
404
|
+
sProperty: any,
|
|
405
|
+
oTextBinding: any,
|
|
406
|
+
sCurrentEntitySet: any,
|
|
407
|
+
oSelectedContext: any
|
|
408
|
+
): TextArrangementInfo | undefined {
|
|
409
|
+
const oMetaModel = oSelectedContext.getModel().getMetaModel();
|
|
410
|
+
const sDisplayMode = CommonUtils.computeDisplayMode(oMetaModel.getObject(sCurrentEntitySet + "/" + sProperty + "@"));
|
|
411
|
+
let sDescriptionPath, sValue, sDescriptionValue, sFullText;
|
|
412
|
+
if (oTextBinding && (oTextBinding.path || (oTextBinding.parameters && oTextBinding.parameters.length)) && sProperty) {
|
|
413
|
+
if (oTextBinding.path) {
|
|
414
|
+
if (sDisplayMode === "Description") {
|
|
415
|
+
sValue = oSelectedContext.getObject(sProperty);
|
|
416
|
+
sDescriptionValue = oSelectedContext.getObject(oTextBinding.path);
|
|
417
|
+
sFullText = sDescriptionValue;
|
|
418
|
+
} else if (sDisplayMode === "Value") {
|
|
419
|
+
sValue = oSelectedContext.getObject(sProperty);
|
|
420
|
+
sFullText = sValue;
|
|
421
|
+
}
|
|
422
|
+
} else if (oTextBinding.parameters) {
|
|
423
|
+
oTextBinding.parameters.forEach(function(oProps: any) {
|
|
424
|
+
if (oProps.path && oProps.path !== sProperty) {
|
|
425
|
+
sDescriptionPath = oProps.path;
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
sValue = oSelectedContext.getObject(sProperty);
|
|
429
|
+
sDescriptionValue = oSelectedContext.getObject(sDescriptionPath);
|
|
430
|
+
if (sDisplayMode === "ValueDescription" && sValue && sDescriptionValue) {
|
|
431
|
+
sFullText = sValue + " (" + sDescriptionValue + ")";
|
|
432
|
+
} else if (sDisplayMode === "DescriptionValue" && sDescriptionValue && sValue) {
|
|
433
|
+
sFullText = sDescriptionValue + " (" + sValue + ")";
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
"textArrangement": sDisplayMode,
|
|
438
|
+
"valuePath": sProperty,
|
|
439
|
+
"descriptionPath": sDescriptionPath,
|
|
440
|
+
"value": sValue,
|
|
441
|
+
"description": sDescriptionValue,
|
|
442
|
+
"fullText": sFullText
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
return undefined;
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Initializes a runtime model:
|
|
450
|
+
* => The model consists of values shown in the comboBox of the dialog (Leave Blank, Keep Existing Values, or any property value for the selected context, etc.)
|
|
451
|
+
* => The model will capture runtime changes in the results property (the value entered in the comboBox).
|
|
452
|
+
*
|
|
453
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
454
|
+
* @param {Array} aDataArray Array containing data related to the dialog used by both the static and the runtime model
|
|
455
|
+
* @param {object} oDefaultValues Default values from i18n
|
|
456
|
+
* @returns {object}
|
|
457
|
+
*/
|
|
458
|
+
setRuntimeModelOnDialog: function(aContexts: any[], aDataArray: any[], oDefaultValues: any) {
|
|
459
|
+
const aValues: any[] = [];
|
|
460
|
+
const aUnitData: any[] = [];
|
|
461
|
+
const aResults: any[] = [];
|
|
462
|
+
const aReadOnlyFieldInfo: any[] = [];
|
|
463
|
+
const oDistinctValueMap: any = {};
|
|
464
|
+
let sPropertyName;
|
|
465
|
+
aDataArray.forEach(function(oData: any) {
|
|
466
|
+
let oTextInfo;
|
|
467
|
+
if (oData.dataProperty && oData.dataProperty.indexOf("/") > -1) {
|
|
468
|
+
const aFinalPath = MassEditHelper.initLastLevelOfPropertyPath(oData.dataProperty, aValues);
|
|
469
|
+
const aPropertyPaths = oData.dataProperty.split("/");
|
|
470
|
+
let sPropertyKey;
|
|
471
|
+
for (let i = 0; i < aContexts.length; i++) {
|
|
472
|
+
const sMultiLevelPathValue = aContexts[i].getObject(oData.dataProperty);
|
|
473
|
+
sPropertyKey = oData.dataProperty + "/" + sMultiLevelPathValue;
|
|
474
|
+
if (!oDistinctValueMap[sPropertyKey] && aFinalPath[aPropertyPaths[aPropertyPaths.length - 1]]) {
|
|
475
|
+
oTextInfo = MassEditHelper.getTextArrangementInfo(
|
|
476
|
+
oData.dataProperty,
|
|
477
|
+
oData.textBinding,
|
|
478
|
+
oData.entitySet,
|
|
479
|
+
aContexts[i]
|
|
480
|
+
);
|
|
481
|
+
aFinalPath[aPropertyPaths[aPropertyPaths.length - 1]].push({
|
|
482
|
+
"text": (oTextInfo && oTextInfo.fullText) || sMultiLevelPathValue,
|
|
483
|
+
"key": oData.dataProperty,
|
|
484
|
+
"textInfo": oTextInfo
|
|
485
|
+
});
|
|
486
|
+
oDistinctValueMap[sPropertyKey] = sMultiLevelPathValue;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
aValues[oData.dataProperty] = aValues[oData.dataProperty] || [];
|
|
491
|
+
if (oData.unitProperty) {
|
|
492
|
+
aUnitData[oData.unitProperty] = aUnitData[oData.unitProperty] || [];
|
|
493
|
+
}
|
|
494
|
+
for (let i = 0; i < aContexts.length; i++) {
|
|
495
|
+
const oDataObject = aContexts[i].getObject();
|
|
496
|
+
sPropertyName = oData.dataProperty + "/" + oDataObject[oData.dataProperty];
|
|
497
|
+
if (oData.dataProperty && oDataObject[oData.dataProperty] && !oDistinctValueMap[sPropertyName]) {
|
|
498
|
+
oTextInfo = MassEditHelper.getTextArrangementInfo(
|
|
499
|
+
oData.dataProperty,
|
|
500
|
+
oData.textBinding,
|
|
501
|
+
oData.entitySet,
|
|
502
|
+
aContexts[i]
|
|
503
|
+
);
|
|
504
|
+
aValues[oData.dataProperty].push({
|
|
505
|
+
"text": (oTextInfo && oTextInfo.fullText) || oDataObject[oData.dataProperty],
|
|
506
|
+
"key": oData.dataProperty,
|
|
507
|
+
"textInfo": oTextInfo
|
|
508
|
+
});
|
|
509
|
+
oDistinctValueMap[sPropertyName] = oDataObject[oData.dataProperty];
|
|
510
|
+
}
|
|
511
|
+
if (oData.unitProperty && oDataObject[oData.unitProperty]) {
|
|
512
|
+
sPropertyName = oData.unitProperty + "/" + oDataObject[oData.unitProperty];
|
|
513
|
+
if (!oDistinctValueMap[sPropertyName]) {
|
|
514
|
+
oTextInfo = MassEditHelper.getTextArrangementInfo(
|
|
515
|
+
oData.unitProperty,
|
|
516
|
+
oData.textBinding,
|
|
517
|
+
oData.entitySet,
|
|
518
|
+
aContexts[i]
|
|
519
|
+
);
|
|
520
|
+
aUnitData[oData.unitProperty].push({
|
|
521
|
+
"text": (oTextInfo && oTextInfo.fullText) || oDataObject[oData.unitProperty],
|
|
522
|
+
"key": oData.unitProperty,
|
|
523
|
+
"textInfo": oTextInfo
|
|
524
|
+
});
|
|
525
|
+
oDistinctValueMap[sPropertyName] = oDataObject[oData.unitProperty];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
aDataArray.forEach(function(oData: any) {
|
|
532
|
+
if (oData.dataProperty.indexOf("/") > -1) {
|
|
533
|
+
const sMultiLevelPropPathValue = MassEditHelper.getValueForMultiLevelPath(oData.dataProperty, aValues);
|
|
534
|
+
if (!sMultiLevelPropPathValue) {
|
|
535
|
+
sMultiLevelPropPathValue.push({ text: oDefaultValues.leaveBlankValue, key: "Empty/" + oData.dataProperty });
|
|
536
|
+
} else {
|
|
537
|
+
MassEditHelper.setDefaultValuesToDialog(sMultiLevelPropPathValue, aContexts, oDefaultValues, oData);
|
|
538
|
+
}
|
|
539
|
+
} else if (aValues[oData.dataProperty] && aValues[oData.dataProperty].length) {
|
|
540
|
+
MassEditHelper.setDefaultValuesToDialog(aValues[oData.dataProperty], aContexts, oDefaultValues, oData);
|
|
541
|
+
}
|
|
542
|
+
if (aUnitData[oData.unitProperty] && aUnitData[oData.unitProperty].length) {
|
|
543
|
+
MassEditHelper.setDefaultValuesToDialog(aUnitData[oData.unitProperty], aContexts, oDefaultValues, oData, true);
|
|
544
|
+
} else if (
|
|
545
|
+
(oData.dataProperty && aValues[oData.dataProperty] && !aValues[oData.dataProperty].length) ||
|
|
546
|
+
(oData.unitProperty && aUnitData[oData.unitProperty] && !aUnitData[oData.unitProperty].length)
|
|
547
|
+
) {
|
|
548
|
+
const bClearFieldOrBlankValueExists =
|
|
549
|
+
aValues[oData.dataProperty] &&
|
|
550
|
+
aValues[oData.dataProperty].some(function(obj: any) {
|
|
551
|
+
return obj.text === "< Clear Values >" || obj.text === "< Leave Blank >";
|
|
552
|
+
});
|
|
553
|
+
if (oData.dataProperty && !bClearFieldOrBlankValueExists) {
|
|
554
|
+
aValues[oData.dataProperty].push({ text: oDefaultValues.leaveBlankValue, key: "Empty/" + oData.dataProperty });
|
|
555
|
+
}
|
|
556
|
+
const bClearFieldOrBlankUnitValueExists =
|
|
557
|
+
aUnitData[oData.unitProperty] &&
|
|
558
|
+
aUnitData[oData.unitProperty].some(function(obj: any) {
|
|
559
|
+
return obj.text === "< Clear Values >" || obj.text === "< Leave Blank >";
|
|
560
|
+
});
|
|
561
|
+
if (oData.unitProperty && !bClearFieldOrBlankUnitValueExists) {
|
|
562
|
+
aUnitData[oData.unitProperty].push({
|
|
563
|
+
text: oDefaultValues.leaveBlankValue,
|
|
564
|
+
key: "Empty/" + oData.unitProperty
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (oData.isPropertyReadOnly && typeof oData.isPropertyReadOnly === "boolean") {
|
|
569
|
+
aReadOnlyFieldInfo.push({ "property": oData.dataProperty, value: oData.isPropertyReadOnly, type: "Default" });
|
|
570
|
+
} else if (
|
|
571
|
+
oData.isPropertyReadOnly &&
|
|
572
|
+
oData.isPropertyReadOnly.operands &&
|
|
573
|
+
oData.isPropertyReadOnly.operands[0] &&
|
|
574
|
+
oData.isPropertyReadOnly.operands[0].operand1 &&
|
|
575
|
+
oData.isPropertyReadOnly.operands[0].operand2
|
|
576
|
+
) {
|
|
577
|
+
// This needs to be refactored in accordance with the ReadOnlyExpression change
|
|
578
|
+
aReadOnlyFieldInfo.push({
|
|
579
|
+
"property": oData.dataProperty,
|
|
580
|
+
propertyPath: oData.isPropertyReadOnly.operands[0].operand1.path,
|
|
581
|
+
propertyValue: oData.isPropertyReadOnly.operands[0].operand2.value,
|
|
582
|
+
type: "Path"
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
const oData = { "values": aValues, "unitData": aUnitData, "results": aResults, "readablePropertyData": aReadOnlyFieldInfo };
|
|
587
|
+
const oDialogDataModel = new JSONModel(oData);
|
|
588
|
+
return oDialogDataModel;
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Create the mass edit dialog.
|
|
593
|
+
*
|
|
594
|
+
* @param {object} oTable Instance of Table
|
|
595
|
+
* @param {Array} aContexts Contexts for mass edit
|
|
596
|
+
* @param {object} oController Controller for the view
|
|
597
|
+
* @returns {object} Promise returning instance of dialog.
|
|
598
|
+
*/
|
|
599
|
+
createDialog: function(oTable: Table, aContexts: any[], oController: PageController) {
|
|
600
|
+
const sFragmentName = "sap/fe/core/controls/massEdit/MassEditDialog",
|
|
601
|
+
aDataArray: any[] = [],
|
|
602
|
+
oResourceBundle = sap.ui.getCore().getLibraryResourceBundle("sap.fe.core") as ResourceBundle,
|
|
603
|
+
oDefaultValues = MassEditHelper.getDefaultTextsForDialog(oResourceBundle, aContexts.length, oTable),
|
|
604
|
+
oDataFieldModel = MassEditHelper.prepareDataForDialog(oTable, aContexts, aDataArray),
|
|
605
|
+
oDialogDataModel = MassEditHelper.setRuntimeModelOnDialog(aContexts, aDataArray, oDefaultValues);
|
|
606
|
+
|
|
607
|
+
return new Promise(function(resolve: (value: any) => void, reject: (reason?: any) => void) {
|
|
608
|
+
const oFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment");
|
|
609
|
+
return Promise.resolve(
|
|
610
|
+
XMLPreprocessor.process(
|
|
611
|
+
oFragment,
|
|
612
|
+
{ name: sFragmentName },
|
|
613
|
+
{
|
|
614
|
+
bindingContexts: {
|
|
615
|
+
dataFieldModel: oDataFieldModel.createBindingContext("/")
|
|
616
|
+
},
|
|
617
|
+
models: {
|
|
618
|
+
dataFieldModel: oDataFieldModel
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
)
|
|
622
|
+
)
|
|
623
|
+
.then(function(oFragment: any) {
|
|
624
|
+
return Fragment.load({ definition: oFragment }).then(function(oDialogContent: any) {
|
|
625
|
+
const oDialog = new Dialog({
|
|
626
|
+
title: oDefaultValues.massEditTitle,
|
|
627
|
+
content: [oDialogContent],
|
|
628
|
+
beginButton: new Button({
|
|
629
|
+
text: oDefaultValues.applyButtonText,
|
|
630
|
+
type: "Emphasized",
|
|
631
|
+
press: function(oEvent: any) {
|
|
632
|
+
const oDialog = oEvent.getSource().getParent();
|
|
633
|
+
const oModel = oDialog.getModel("fieldsInfo");
|
|
634
|
+
const aResults = oModel.getProperty("/results");
|
|
635
|
+
const aPropertyReadableInfo = oModel.getProperty("/readablePropertyData");
|
|
636
|
+
const changePromise: any[] = [];
|
|
637
|
+
let bReadOnlyField = false;
|
|
638
|
+
|
|
639
|
+
aContexts.forEach(function(oSelectedContext: any) {
|
|
640
|
+
aResults.forEach(function(oResult: any) {
|
|
641
|
+
//TODO - Add save implementation for Value Help.
|
|
642
|
+
if (aPropertyReadableInfo) {
|
|
643
|
+
bReadOnlyField = aPropertyReadableInfo.some(function(oPropertyInfo: any) {
|
|
644
|
+
if (oResult.keyValue === oPropertyInfo.property) {
|
|
645
|
+
if (oPropertyInfo.type === "Default") {
|
|
646
|
+
return oPropertyInfo.value === true;
|
|
647
|
+
} else if (
|
|
648
|
+
oPropertyInfo.type === "Path" &&
|
|
649
|
+
oPropertyInfo.propertyValue &&
|
|
650
|
+
oPropertyInfo.propertyPath
|
|
651
|
+
) {
|
|
652
|
+
return (
|
|
653
|
+
oSelectedContext.getObject(oPropertyInfo.propertyPath) ===
|
|
654
|
+
oPropertyInfo.propertyValue
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
if (oResult.keyValue && oResult.value !== "Default" && !bReadOnlyField) {
|
|
661
|
+
changePromise.push(oSelectedContext.setProperty(oResult.keyValue, oResult.value));
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
});
|
|
665
|
+
return Promise.all(changePromise)
|
|
666
|
+
.then(function(oRes: any[]) {
|
|
667
|
+
const oListBinding = oTable.getRowBinding(),
|
|
668
|
+
oExtensionAPI = oController && (oController.getExtensionAPI() as any);
|
|
669
|
+
return oExtensionAPI.refresh(oListBinding.getPath()).then(function() {
|
|
670
|
+
oDialog.close();
|
|
671
|
+
oDialog.destroy();
|
|
672
|
+
return oRes;
|
|
673
|
+
});
|
|
674
|
+
})
|
|
675
|
+
.catch(function(oError: any) {
|
|
676
|
+
//TODO - Add error handling part for the Dialog
|
|
677
|
+
Log.error("Mass Edit: Something went wrong in updating entries.", oError);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}),
|
|
681
|
+
endButton: new Button({
|
|
682
|
+
text: oDefaultValues.cancelButtonText,
|
|
683
|
+
press: function(oEvent: any) {
|
|
684
|
+
const oDialog = oEvent.getSource().getParent();
|
|
685
|
+
oDialog.close();
|
|
686
|
+
oDialog.destroy();
|
|
687
|
+
}
|
|
688
|
+
})
|
|
689
|
+
});
|
|
690
|
+
oDialog.setModel(oDialogDataModel, "fieldsInfo");
|
|
691
|
+
resolve(oDialog);
|
|
692
|
+
});
|
|
693
|
+
})
|
|
694
|
+
.catch(reject);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
export default MassEditHelper;
|