@sapui5/sap.fe.core 1.103.0 → 1.106.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 +5 -5
- package/src/sap/fe/core/.library +1 -1
- package/src/sap/fe/core/ActionRuntime.js +121 -0
- package/src/sap/fe/core/ActionRuntime.ts +122 -0
- package/src/sap/fe/core/AppComponent.js +24 -11
- package/src/sap/fe/core/AppComponent.ts +17 -5
- package/src/sap/fe/core/AppStateHandler.js +74 -62
- package/src/sap/fe/core/AppStateHandler.ts +24 -29
- package/src/sap/fe/core/BaseController.js +2 -2
- package/src/sap/fe/core/CommonUtils.js +147 -180
- package/src/sap/fe/core/CommonUtils.ts +166 -193
- package/src/sap/fe/core/ExtensionAPI.js +2 -2
- package/src/sap/fe/core/PageController.js +2 -2
- package/src/sap/fe/core/TemplateComponent.js +21 -10
- package/src/sap/fe/core/TemplateComponent.ts +3 -0
- package/src/sap/fe/core/TemplateModel.js +2 -2
- package/src/sap/fe/core/buildingBlocks/AttributeModel.js +11 -3
- package/src/sap/fe/core/buildingBlocks/AttributeModel.ts +7 -1
- package/src/sap/fe/core/buildingBlocks/BuildingBlock.js +194 -43
- package/src/sap/fe/core/buildingBlocks/BuildingBlock.ts +162 -24
- package/src/sap/fe/core/buildingBlocks/BuildingBlockFormatter.js +14 -0
- package/src/sap/fe/core/buildingBlocks/BuildingBlockFormatter.ts +5 -0
- package/src/sap/fe/core/buildingBlocks/BuildingBlockRuntime.js +609 -227
- package/src/sap/fe/core/buildingBlocks/BuildingBlockRuntime.ts +268 -119
- package/src/sap/fe/core/buildingBlocks/TraceInfo.js +111 -76
- package/src/sap/fe/core/buildingBlocks/TraceInfo.ts +96 -76
- package/src/sap/fe/core/controllerextensions/BusyLocker.js +1 -1
- package/src/sap/fe/core/controllerextensions/EditFlow.js +723 -637
- package/src/sap/fe/core/controllerextensions/EditFlow.ts +361 -398
- package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.js +2 -2
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.js +83 -55
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.ts +42 -44
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +29 -27
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +35 -30
- package/src/sap/fe/core/controllerextensions/InternalRouting.js +171 -74
- package/src/sap/fe/core/controllerextensions/InternalRouting.ts +167 -76
- package/src/sap/fe/core/controllerextensions/KPIManagement.js +5 -21
- package/src/sap/fe/core/controllerextensions/KPIManagement.ts +2 -17
- package/src/sap/fe/core/controllerextensions/MassEdit.js +3 -3
- package/src/sap/fe/core/controllerextensions/MassEdit.ts +1 -1
- package/src/sap/fe/core/controllerextensions/MessageHandler.js +2 -2
- package/src/sap/fe/core/controllerextensions/PageReady.js +3 -3
- package/src/sap/fe/core/controllerextensions/PageReady.ts +5 -1
- package/src/sap/fe/core/controllerextensions/Paginator.js +13 -13
- package/src/sap/fe/core/controllerextensions/Paginator.ts +11 -11
- package/src/sap/fe/core/controllerextensions/Placeholder.js +2 -2
- package/src/sap/fe/core/controllerextensions/Routing.js +2 -2
- package/src/sap/fe/core/controllerextensions/RoutingListener.js +1 -1
- package/src/sap/fe/core/controllerextensions/Share.js +154 -123
- package/src/sap/fe/core/controllerextensions/Share.ts +93 -95
- package/src/sap/fe/core/controllerextensions/SideEffects.js +157 -97
- package/src/sap/fe/core/controllerextensions/SideEffects.ts +151 -95
- package/src/sap/fe/core/controllerextensions/ViewState.js +151 -80
- package/src/sap/fe/core/controllerextensions/ViewState.ts +95 -93
- package/src/sap/fe/core/controllerextensions/collaboration/ActivityBase.js +1 -1
- package/src/sap/fe/core/controllerextensions/collaboration/ActivitySync.js +9 -9
- package/src/sap/fe/core/controllerextensions/collaboration/ActivitySync.ts +6 -7
- package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.js +26 -11
- package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.ts +30 -11
- package/src/sap/fe/core/controllerextensions/collaboration/Manage.js +57 -40
- package/src/sap/fe/core/controllerextensions/collaboration/Manage.ts +55 -47
- package/src/sap/fe/core/controllerextensions/collaboration/ManageDialog.fragment.xml +31 -32
- package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.js +1376 -914
- package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.ts +654 -714
- package/src/sap/fe/core/controllerextensions/editFlow/draft.js +372 -326
- package/src/sap/fe/core/controllerextensions/editFlow/draft.ts +210 -276
- package/src/sap/fe/core/controllerextensions/editFlow/draftDataLossPopup.js +309 -0
- package/src/sap/fe/core/controllerextensions/editFlow/draftDataLossPopup.ts +320 -0
- package/src/sap/fe/core/controllerextensions/editFlow/operations.js +670 -521
- package/src/sap/fe/core/controllerextensions/editFlow/operations.ts +537 -535
- package/src/sap/fe/core/controllerextensions/editFlow/sticky.js +85 -65
- package/src/sap/fe/core/controllerextensions/editFlow/sticky.ts +16 -21
- package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.js +25 -13
- package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.ts +53 -43
- package/src/sap/fe/core/controllerextensions/routing/RouterProxy.js +18 -27
- package/src/sap/fe/core/controllerextensions/routing/RouterProxy.ts +9 -15
- package/src/sap/fe/core/controls/ActionParameterDialog.fragment.xml +19 -3
- package/src/sap/fe/core/controls/ActionParameterDialogFieldValueHelp.fragment.xml +35 -0
- package/src/sap/fe/core/controls/ActionParameterDialogValueHelp.fragment.xml +26 -16
- package/src/sap/fe/core/controls/Any.js +1 -1
- package/src/sap/fe/core/controls/CommandExecution.js +2 -2
- package/src/sap/fe/core/controls/ConditionalWrapper.js +2 -2
- package/src/sap/fe/core/controls/CustomFilterFieldContentWrapper.js +5 -5
- package/src/sap/fe/core/controls/CustomFilterFieldContentWrapper.ts +0 -3
- package/src/sap/fe/core/controls/CustomQuickViewPage.js +2 -2
- package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.js +1 -1
- package/src/sap/fe/core/controls/FieldWrapper.js +2 -2
- package/src/sap/fe/core/controls/FileWrapper.js +8 -3
- package/src/sap/fe/core/controls/FileWrapper.ts +5 -1
- package/src/sap/fe/core/controls/FilterBar.js +2 -2
- package/src/sap/fe/core/controls/FormElementWrapper.js +2 -2
- package/src/sap/fe/core/controls/MassEditSelect.js +1 -1
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.js +1 -1
- package/src/sap/fe/core/controls/NonComputedVisibleKeyFieldsDialog.fragment.xml +48 -17
- package/src/sap/fe/core/controls/filterbar/FilterContainer.js +2 -2
- package/src/sap/fe/core/controls/filterbar/VisualFilter.js +2 -2
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.js +2 -2
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.js +3 -3
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.ts +2 -2
- package/src/sap/fe/core/controls/massEdit/MassEditField.fragment.xml +22 -35
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.js +2 -2
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.ts +1 -1
- package/src/sap/fe/core/converters/ConverterContext.js +23 -2
- package/src/sap/fe/core/converters/ConverterContext.ts +34 -9
- package/src/sap/fe/core/converters/ManifestSettings.js +19 -18
- package/src/sap/fe/core/converters/ManifestSettings.ts +53 -47
- package/src/sap/fe/core/converters/ManifestWrapper.js +1 -1
- package/src/sap/fe/core/converters/MetaModelConverter.js +32 -10
- package/src/sap/fe/core/converters/MetaModelConverter.ts +42 -19
- package/src/sap/fe/core/converters/TemplateConverter.js +1 -1
- package/src/sap/fe/core/converters/annotations/DataField.js +5 -2
- package/src/sap/fe/core/converters/annotations/DataField.ts +5 -1
- package/src/sap/fe/core/converters/common/AnnotationConverter.js +69 -23
- package/src/sap/fe/core/converters/controls/Common/Action.js +98 -51
- package/src/sap/fe/core/converters/controls/Common/Action.ts +121 -44
- package/src/sap/fe/core/converters/controls/Common/Chart.js +31 -34
- package/src/sap/fe/core/converters/controls/Common/Chart.ts +26 -34
- package/src/sap/fe/core/converters/controls/Common/Criticality.js +1 -1
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.js +43 -7
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.ts +60 -33
- package/src/sap/fe/core/converters/controls/Common/Form.js +8 -6
- package/src/sap/fe/core/converters/controls/Common/Form.ts +11 -14
- package/src/sap/fe/core/converters/controls/Common/KPI.js +1 -1
- package/src/sap/fe/core/converters/controls/Common/KPI.ts +16 -15
- package/src/sap/fe/core/converters/controls/Common/Table.js +188 -157
- package/src/sap/fe/core/converters/controls/Common/Table.ts +279 -230
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.js +1 -1
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.ts +4 -4
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.js +57 -21
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.ts +71 -18
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.js +30 -8
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.ts +24 -7
- package/src/sap/fe/core/converters/controls/ObjectPage/Avatar.js +1 -1
- package/src/sap/fe/core/converters/controls/ObjectPage/HeaderFacet.js +43 -34
- package/src/sap/fe/core/converters/controls/ObjectPage/HeaderFacet.ts +37 -25
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +85 -49
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +74 -50
- package/src/sap/fe/core/converters/helpers/Aggregation.js +54 -4
- package/src/sap/fe/core/converters/helpers/Aggregation.ts +56 -8
- package/src/sap/fe/core/converters/helpers/BindingHelper.js +1 -1
- package/src/sap/fe/core/converters/helpers/ConfigurableObject.js +6 -4
- package/src/sap/fe/core/converters/helpers/ConfigurableObject.ts +10 -2
- package/src/sap/fe/core/converters/helpers/DataFieldHelper.js +182 -0
- package/src/sap/fe/core/converters/helpers/DataFieldHelper.ts +167 -0
- package/src/sap/fe/core/converters/helpers/ID.js +3 -1
- package/src/sap/fe/core/converters/helpers/ID.ts +1 -0
- package/src/sap/fe/core/converters/helpers/IssueManager.js +1 -1
- package/src/sap/fe/core/converters/helpers/Key.js +1 -1
- package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.js +1 -1
- package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.ts +2 -3
- package/src/sap/fe/core/converters/objectPage/FormMenuActions.js +1 -1
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.js +8 -14
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.ts +6 -9
- package/src/sap/fe/core/converters/templates/ListReportConverter.js +31 -31
- package/src/sap/fe/core/converters/templates/ListReportConverter.ts +54 -47
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.js +44 -15
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.ts +64 -30
- package/src/sap/fe/core/designtime/AppComponent.designtime.js +1 -1
- package/src/sap/fe/core/formatters/CollaborationFormatter.js +1 -1
- package/src/sap/fe/core/formatters/FPMFormatter.js +1 -1
- package/src/sap/fe/core/formatters/KPIFormatter.js +1 -1
- package/src/sap/fe/core/formatters/StandardFormatter.js +13 -6
- package/src/sap/fe/core/formatters/StandardFormatter.ts +20 -14
- package/src/sap/fe/core/formatters/TableFormatter.js +1 -1
- package/src/sap/fe/core/formatters/TableFormatterTypes.js +1 -1
- package/src/sap/fe/core/formatters/ValueFormatter.js +1 -1
- package/src/sap/fe/core/fpm/Component.js +33 -7
- package/src/sap/fe/core/fpm/Component.ts +14 -0
- package/src/sap/fe/core/helpers/AnnotationEnum.js +1 -1
- package/src/sap/fe/core/helpers/AppStartupHelper.js +5 -4
- package/src/sap/fe/core/helpers/AppStartupHelper.ts +4 -3
- package/src/sap/fe/core/helpers/BindingToolkit.js +56 -24
- package/src/sap/fe/core/helpers/BindingToolkit.ts +67 -21
- package/src/sap/fe/core/helpers/ClassSupport.js +31 -3
- package/src/sap/fe/core/helpers/ClassSupport.ts +24 -1
- package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.js +1 -1
- package/src/sap/fe/core/helpers/EditState.js +1 -1
- package/src/sap/fe/core/helpers/ExcelFormatHelper.js +1 -1
- package/src/sap/fe/core/helpers/FPMHelper.js +1 -1
- package/src/sap/fe/core/helpers/KeepAliveHelper.js +1 -1
- package/src/sap/fe/core/helpers/KeepAliveRefreshTypes.js +1 -1
- package/src/sap/fe/core/helpers/LoaderUtils.js +39 -0
- package/src/sap/fe/core/helpers/LoaderUtils.ts +14 -0
- package/src/sap/fe/core/helpers/MassEditHelper.js +475 -99
- package/src/sap/fe/core/helpers/MassEditHelper.ts +468 -155
- package/src/sap/fe/core/helpers/MessageStrip.js +81 -0
- package/src/sap/fe/core/helpers/MessageStrip.ts +79 -0
- package/src/sap/fe/core/helpers/ModelHelper.js +1 -1
- package/src/sap/fe/core/helpers/PasteHelper.js +1 -1
- package/src/sap/fe/core/helpers/SemanticDateOperators.js +82 -36
- package/src/sap/fe/core/helpers/SemanticDateOperators.ts +52 -36
- package/src/sap/fe/core/helpers/SemanticKeyHelper.js +1 -1
- package/src/sap/fe/core/helpers/SideEffectsHelper.js +146 -0
- package/src/sap/fe/core/helpers/SideEffectsHelper.ts +128 -0
- package/src/sap/fe/core/helpers/StableIdHelper.js +1 -1
- package/src/sap/fe/core/helpers/Synchronization.js +1 -1
- package/src/sap/fe/core/helpers/ToES6Promise.js +32 -0
- package/src/sap/fe/core/helpers/ToES6Promise.ts +19 -0
- package/src/sap/fe/core/jsx-runtime/Fragment.js +16 -0
- package/src/sap/fe/core/jsx-runtime/Fragment.ts +3 -0
- package/src/sap/fe/core/jsx-runtime/ViewLoader.js +109 -0
- package/src/sap/fe/core/jsx-runtime/ViewLoader.tsx +47 -0
- package/src/sap/fe/core/jsx-runtime/jsx-control.js +119 -0
- package/src/sap/fe/core/jsx-runtime/jsx-control.ts +98 -0
- package/src/sap/fe/core/jsx-runtime/jsx-xml.js +105 -0
- package/src/sap/fe/core/jsx-runtime/jsx-xml.ts +89 -0
- package/src/sap/fe/core/jsx-runtime/jsx.js +12 -90
- package/src/sap/fe/core/jsx-runtime/jsx.ts +24 -85
- package/src/sap/fe/core/jsx-runtime/jsxs.js +1 -1
- package/src/sap/fe/core/jsx-runtime/useMDXComponents.js +179 -0
- package/src/sap/fe/core/jsx-runtime/useMDXComponents.tsx +150 -0
- package/src/sap/fe/core/library.js +2 -2
- package/src/sap/fe/core/library.support.js +1 -1
- package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.js +1 -1
- package/src/sap/fe/core/messagebundle.properties +4 -41
- package/src/sap/fe/core/messagebundle_ar.properties +22 -45
- package/src/sap/fe/core/messagebundle_bg.properties +22 -45
- package/src/sap/fe/core/messagebundle_ca.properties +22 -45
- package/src/sap/fe/core/messagebundle_cs.properties +22 -45
- package/src/sap/fe/core/messagebundle_cy.properties +21 -44
- package/src/sap/fe/core/messagebundle_da.properties +22 -45
- package/src/sap/fe/core/messagebundle_de.properties +22 -45
- package/src/sap/fe/core/messagebundle_el.properties +22 -45
- package/src/sap/fe/core/messagebundle_en.properties +21 -44
- package/src/sap/fe/core/messagebundle_en_GB.properties +21 -44
- package/src/sap/fe/core/messagebundle_en_US_sappsd.properties +21 -42
- package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +20 -40
- package/src/sap/fe/core/messagebundle_en_US_saptrc.properties +21 -42
- package/src/sap/fe/core/messagebundle_es.properties +22 -45
- package/src/sap/fe/core/messagebundle_es_MX.properties +22 -45
- package/src/sap/fe/core/messagebundle_et.properties +22 -45
- package/src/sap/fe/core/messagebundle_fi.properties +22 -45
- package/src/sap/fe/core/messagebundle_fr.properties +21 -44
- package/src/sap/fe/core/messagebundle_fr_CA.properties +20 -43
- package/src/sap/fe/core/messagebundle_hi.properties +22 -45
- package/src/sap/fe/core/messagebundle_hr.properties +22 -45
- package/src/sap/fe/core/messagebundle_hu.properties +22 -45
- package/src/sap/fe/core/messagebundle_id.properties +22 -45
- package/src/sap/fe/core/messagebundle_it.properties +22 -45
- package/src/sap/fe/core/messagebundle_iw.properties +22 -45
- package/src/sap/fe/core/messagebundle_ja.properties +22 -45
- package/src/sap/fe/core/messagebundle_kk.properties +22 -45
- package/src/sap/fe/core/messagebundle_ko.properties +27 -50
- package/src/sap/fe/core/messagebundle_lt.properties +22 -45
- package/src/sap/fe/core/messagebundle_lv.properties +22 -45
- package/src/sap/fe/core/messagebundle_ms.properties +22 -45
- package/src/sap/fe/core/messagebundle_nl.properties +24 -47
- package/src/sap/fe/core/messagebundle_no.properties +22 -45
- package/src/sap/fe/core/messagebundle_pl.properties +23 -46
- package/src/sap/fe/core/messagebundle_pt.properties +23 -46
- package/src/sap/fe/core/messagebundle_pt_PT.properties +22 -45
- package/src/sap/fe/core/messagebundle_ro.properties +22 -45
- package/src/sap/fe/core/messagebundle_ru.properties +22 -45
- package/src/sap/fe/core/messagebundle_sh.properties +22 -45
- package/src/sap/fe/core/messagebundle_sk.properties +22 -45
- package/src/sap/fe/core/messagebundle_sl.properties +22 -45
- package/src/sap/fe/core/messagebundle_sv.properties +22 -45
- package/src/sap/fe/core/messagebundle_th.properties +20 -43
- package/src/sap/fe/core/messagebundle_tr.properties +22 -45
- package/src/sap/fe/core/messagebundle_uk.properties +22 -45
- package/src/sap/fe/core/messagebundle_vi.properties +22 -45
- package/src/sap/fe/core/messagebundle_zh_CN.properties +22 -45
- package/src/sap/fe/core/messagebundle_zh_TW.properties +22 -45
- package/src/sap/fe/core/services/AsyncComponentServiceFactory.js +2 -2
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.js +102 -74
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.ts +62 -63
- package/src/sap/fe/core/services/EnvironmentServiceFactory.js +2 -2
- package/src/sap/fe/core/services/NavigationServiceFactory.js +11 -8
- package/src/sap/fe/core/services/NavigationServiceFactory.ts +10 -7
- package/src/sap/fe/core/services/ResourceModelServiceFactory.js +2 -2
- package/src/sap/fe/core/services/RoutingServiceFactory.js +2 -2
- package/src/sap/fe/core/services/ShellServicesFactory.js +22 -2
- package/src/sap/fe/core/services/ShellServicesFactory.ts +19 -0
- package/src/sap/fe/core/services/SideEffectsServiceFactory.js +4 -4
- package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +2 -2
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.js +251 -200
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.ts +160 -144
- package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.js +2 -2
- package/src/sap/fe/core/support/AnnotationIssue.support.js +1 -1
- package/src/sap/fe/core/support/CollectionFacetMissingID.support.js +1 -1
- package/src/sap/fe/core/support/CollectionFacetUnsupportedLevel.support.js +1 -1
- package/src/sap/fe/core/support/CommonHelper.js +1 -1
- package/src/sap/fe/core/support/Diagnostics.js +1 -1
- package/src/sap/fe/core/support/InvalidAnnotationColumnKey.support.js +1 -1
- package/src/sap/fe/core/templating/CommonFormatters.js +4 -3
- package/src/sap/fe/core/templating/CommonFormatters.ts +5 -1
- package/src/sap/fe/core/templating/CriticalityFormatters.js +1 -1
- package/src/sap/fe/core/templating/DataFieldFormatters.js +1 -1
- package/src/sap/fe/core/templating/DataModelPathHelper.js +8 -1
- package/src/sap/fe/core/templating/DataModelPathHelper.ts +5 -2
- package/src/sap/fe/core/templating/DisplayModeFormatter.js +1 -1
- package/src/sap/fe/core/templating/EntitySetHelper.js +4 -5
- package/src/sap/fe/core/templating/EntitySetHelper.ts +4 -3
- package/src/sap/fe/core/templating/FieldControlHelper.js +1 -1
- package/src/sap/fe/core/templating/FilterHelper.js +34 -15
- package/src/sap/fe/core/templating/FilterHelper.ts +28 -12
- package/src/sap/fe/core/templating/FilterTemplating.js +1 -1
- package/src/sap/fe/core/templating/PropertyFormatters.js +1 -1
- package/src/sap/fe/core/templating/PropertyHelper.js +1 -1
- package/src/sap/fe/core/templating/UIFormatters.js +5 -3
- package/src/sap/fe/core/templating/UIFormatters.ts +7 -5
- package/src/sap/fe/core/type/DateTimeWithTimezone.js +2 -2
- package/src/sap/fe/core/type/Email.js +2 -2
|
@@ -6,6 +6,7 @@ import BusyLocker from "sap/fe/core/controllerextensions/BusyLocker";
|
|
|
6
6
|
import draft from "sap/fe/core/controllerextensions/editFlow/draft";
|
|
7
7
|
import operations from "sap/fe/core/controllerextensions/editFlow/operations";
|
|
8
8
|
import sticky from "sap/fe/core/controllerextensions/editFlow/sticky";
|
|
9
|
+
import type MessageHandler from "sap/fe/core/controllerextensions/MessageHandler";
|
|
9
10
|
import messageHandling from "sap/fe/core/controllerextensions/messageHandler/messageHandling";
|
|
10
11
|
import FPMHelper from "sap/fe/core/helpers/FPMHelper";
|
|
11
12
|
import type { InternalModelContext } from "sap/fe/core/helpers/ModelHelper";
|
|
@@ -27,8 +28,11 @@ import XMLPreprocessor from "sap/ui/core/util/XMLPreprocessor";
|
|
|
27
28
|
import XMLTemplateProcessor from "sap/ui/core/XMLTemplateProcessor";
|
|
28
29
|
import type Context from "sap/ui/model/Context";
|
|
29
30
|
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
31
|
+
import type ODataV4Context from "sap/ui/model/odata/v4/Context";
|
|
30
32
|
import type ODataMetaModel from "sap/ui/model/odata/v4/ODataMetaModel";
|
|
33
|
+
import type ODataModel from "sap/ui/model/odata/v4/ODataModel";
|
|
31
34
|
import type { CoreEx, ODataListBinding, V4Context } from "types/extension_types";
|
|
35
|
+
import toES6Promise from "../../helpers/ToES6Promise";
|
|
32
36
|
|
|
33
37
|
const CreationMode = FELibrary.CreationMode;
|
|
34
38
|
const ProgrammingModel = FELibrary.ProgrammingModel;
|
|
@@ -122,17 +126,16 @@ class TransactionHelper {
|
|
|
122
126
|
* @ui5-restricted
|
|
123
127
|
* @final
|
|
124
128
|
*/
|
|
125
|
-
createDocument(
|
|
129
|
+
async createDocument(
|
|
126
130
|
oMainListBinding: ODataListBinding,
|
|
127
131
|
mInParameters: { data?: any; busyMode?: string | undefined; keepTransientContextOnFailed?: any; inactive?: boolean } | undefined,
|
|
128
132
|
oResourceBundle: any,
|
|
129
|
-
messageHandler:
|
|
133
|
+
messageHandler: MessageHandler,
|
|
130
134
|
bFromCopyPaste: boolean = false,
|
|
131
135
|
oView: any
|
|
132
|
-
) {
|
|
136
|
+
): Promise<ODataV4Context> {
|
|
133
137
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
134
|
-
const
|
|
135
|
-
oModel = oMainListBinding.getModel(),
|
|
138
|
+
const oModel = oMainListBinding.getModel(),
|
|
136
139
|
oMetaModel = oModel.getMetaModel(),
|
|
137
140
|
sMetaPath = oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath()),
|
|
138
141
|
sCreateHash = this._getAppComponent().getRouterProxy().getHash(),
|
|
@@ -141,7 +144,6 @@ class TransactionHelper {
|
|
|
141
144
|
sNewAction = !oMainListBinding.isRelative()
|
|
142
145
|
? this._getNewAction(oStartupParameters, sCreateHash, oMetaModel, sMetaPath)
|
|
143
146
|
: undefined;
|
|
144
|
-
let oCreationPromise;
|
|
145
147
|
const mBindingParameters: any = { "$$patchWithoutSideEffects": true };
|
|
146
148
|
const sMessagesPath = oMetaModel.getObject(`${sMetaPath}/@com.sap.vocabularies.Common.v1.Messages/$Path`);
|
|
147
149
|
let sBusyPath = "/busy";
|
|
@@ -151,7 +153,7 @@ class TransactionHelper {
|
|
|
151
153
|
`${ModelHelper.getTargetEntitySet(oMetaModel.getContext(sMetaPath))}@com.sap.vocabularies.Common.v1.DefaultValuesFunction`
|
|
152
154
|
);
|
|
153
155
|
let bFunctionOnNavProp;
|
|
154
|
-
let oNewDocumentContext:
|
|
156
|
+
let oNewDocumentContext: ODataV4Context | undefined;
|
|
155
157
|
if (sFunctionName) {
|
|
156
158
|
if (
|
|
157
159
|
oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Common.v1.DefaultValuesFunction`) &&
|
|
@@ -167,11 +169,11 @@ class TransactionHelper {
|
|
|
167
169
|
}
|
|
168
170
|
const mParameters = getParameters(mInParameters);
|
|
169
171
|
if (!oMainListBinding) {
|
|
170
|
-
|
|
172
|
+
throw new Error("Binding required for new document creation");
|
|
171
173
|
}
|
|
172
174
|
const sProgrammingModel = this.getProgrammingModel(oMainListBinding);
|
|
173
175
|
if (sProgrammingModel !== ProgrammingModel.Draft && sProgrammingModel !== ProgrammingModel.Sticky) {
|
|
174
|
-
|
|
176
|
+
throw new Error("Create document only allowed for draft or sticky session supported services");
|
|
175
177
|
}
|
|
176
178
|
if (mParameters.busyMode === "Local") {
|
|
177
179
|
// in case of local busy mode we use the list binding name
|
|
@@ -181,142 +183,122 @@ class TransactionHelper {
|
|
|
181
183
|
mParameters.beforeCreateCallBack = bFromCopyPaste ? null : mParameters.beforeCreateCallBack;
|
|
182
184
|
BusyLocker.lock(this.oLockObject, sBusyPath);
|
|
183
185
|
const oResourceBundleCore = (Core as CoreEx).getLibraryResourceBundle("sap.fe.core");
|
|
184
|
-
|
|
185
|
-
oCreationPromise = this.callAction(
|
|
186
|
-
sNewAction,
|
|
187
|
-
{
|
|
188
|
-
contexts: oMainListBinding.getHeaderContext(),
|
|
189
|
-
showActionParameterDialog: true,
|
|
190
|
-
label: this._getSpecificCreateActionDialogLabel(oMetaModel, sMetaPath, sNewAction, oResourceBundleCore),
|
|
191
|
-
bindingParameters: mBindingParameters,
|
|
192
|
-
parentControl: mParameters.parentControl,
|
|
193
|
-
bIsCreateAction: true
|
|
194
|
-
},
|
|
195
|
-
null,
|
|
196
|
-
messageHandler
|
|
197
|
-
);
|
|
198
|
-
} else {
|
|
199
|
-
const bIsNewPageCreation =
|
|
200
|
-
mParameters.creationMode !== CreationMode.CreationRow && mParameters.creationMode !== CreationMode.Inline;
|
|
201
|
-
const aNonComputedVisibleKeyFields = bIsNewPageCreation
|
|
202
|
-
? CommonUtils.getNonComputedVisibleFields(oMetaModel, sMetaPath, oView)
|
|
203
|
-
: [];
|
|
204
|
-
sFunctionName = bFromCopyPaste ? null : sFunctionName;
|
|
205
|
-
let sFunctionPath, oFunctionContext;
|
|
206
|
-
if (sFunctionName) {
|
|
207
|
-
//bound to the source entity:
|
|
208
|
-
if (bFunctionOnNavProp) {
|
|
209
|
-
sFunctionPath =
|
|
210
|
-
oMainListBinding.getContext() &&
|
|
211
|
-
`${oMetaModel.getMetaPath(oMainListBinding.getContext().getPath())}/${sFunctionName}`;
|
|
212
|
-
oFunctionContext = oMainListBinding.getContext();
|
|
213
|
-
} else {
|
|
214
|
-
sFunctionPath =
|
|
215
|
-
oMainListBinding.getHeaderContext() &&
|
|
216
|
-
`${oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath())}/${sFunctionName}`;
|
|
217
|
-
oFunctionContext = oMainListBinding.getHeaderContext();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const oFunction = sFunctionPath && (oMetaModel.createBindingContext(sFunctionPath) as any);
|
|
221
|
-
if (oFunction && oFunction.getObject() && oFunction.getObject()[0].$IsBound) {
|
|
222
|
-
oCreationPromise = operations.callBoundFunction(sFunctionName, oFunctionContext, oModel);
|
|
223
|
-
} else {
|
|
224
|
-
oCreationPromise = operations.callFunctionImport(sFunctionName, oModel);
|
|
225
|
-
}
|
|
186
|
+
let oResult: any;
|
|
226
187
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
188
|
+
try {
|
|
189
|
+
if (sNewAction) {
|
|
190
|
+
oResult = await this.callAction(
|
|
191
|
+
sNewAction,
|
|
192
|
+
{
|
|
193
|
+
contexts: oMainListBinding.getHeaderContext(),
|
|
194
|
+
showActionParameterDialog: true,
|
|
195
|
+
label: this._getSpecificCreateActionDialogLabel(oMetaModel, sMetaPath, sNewAction, oResourceBundleCore),
|
|
196
|
+
bindingParameters: mBindingParameters,
|
|
197
|
+
parentControl: mParameters.parentControl,
|
|
198
|
+
bIsCreateAction: true
|
|
199
|
+
},
|
|
200
|
+
null,
|
|
201
|
+
messageHandler
|
|
202
|
+
);
|
|
203
|
+
} else {
|
|
204
|
+
const bIsNewPageCreation =
|
|
205
|
+
mParameters.creationMode !== CreationMode.CreationRow && mParameters.creationMode !== CreationMode.Inline;
|
|
206
|
+
const aNonComputedVisibleKeyFields = bIsNewPageCreation
|
|
207
|
+
? CommonUtils.getNonComputedVisibleFields(oMetaModel, sMetaPath, oView)
|
|
208
|
+
: [];
|
|
209
|
+
sFunctionName = bFromCopyPaste ? null : sFunctionName;
|
|
210
|
+
let sFunctionPath, oFunctionContext;
|
|
211
|
+
if (sFunctionName) {
|
|
212
|
+
//bound to the source entity:
|
|
213
|
+
if (bFunctionOnNavProp) {
|
|
214
|
+
sFunctionPath =
|
|
215
|
+
oMainListBinding.getContext() &&
|
|
216
|
+
`${oMetaModel.getMetaPath(oMainListBinding.getContext().getPath())}/${sFunctionName}`;
|
|
217
|
+
oFunctionContext = oMainListBinding.getContext();
|
|
231
218
|
} else {
|
|
232
|
-
|
|
219
|
+
sFunctionPath =
|
|
220
|
+
oMainListBinding.getHeaderContext() &&
|
|
221
|
+
`${oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath())}/${sFunctionName}`;
|
|
222
|
+
oFunctionContext = oMainListBinding.getHeaderContext();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const oFunction = sFunctionPath && (oMetaModel.createBindingContext(sFunctionPath) as any);
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
let oData: any;
|
|
229
|
+
try {
|
|
230
|
+
const oContext =
|
|
231
|
+
oFunction && oFunction.getObject() && oFunction.getObject()[0].$IsBound
|
|
232
|
+
? await operations.callBoundFunction(sFunctionName, oFunctionContext, oModel)
|
|
233
|
+
: await operations.callFunctionImport(sFunctionName, oModel);
|
|
234
|
+
if (oContext) {
|
|
235
|
+
oData = oContext.getObject();
|
|
236
|
+
}
|
|
237
|
+
} catch (oError: any) {
|
|
238
|
+
Log.error(`Error while executing the function ${sFunctionName}`, oError);
|
|
239
|
+
throw oError;
|
|
233
240
|
}
|
|
234
|
-
})
|
|
235
|
-
.catch(function (oError: any) {
|
|
236
|
-
Log.error(`Error while executing the function ${sFunctionName}`, oError);
|
|
237
|
-
throw oError;
|
|
238
|
-
})
|
|
239
|
-
.then(function (oData: any) {
|
|
240
241
|
mParameters.data = oData ? Object.assign({}, oData, mParameters.data) : mParameters.data;
|
|
241
242
|
if (mParameters.data) {
|
|
242
243
|
delete mParameters.data["@odata.context"];
|
|
243
244
|
}
|
|
244
245
|
if (aNonComputedVisibleKeyFields.length > 0) {
|
|
245
|
-
|
|
246
|
-
$$updateGroupId: "submitLater"
|
|
247
|
-
}) as ODataListBinding;
|
|
248
|
-
oTransientListBinding.refreshInternal = function () {
|
|
249
|
-
/* */
|
|
250
|
-
};
|
|
251
|
-
oNewDocumentContext = oTransientListBinding.create(mParameters.data, true);
|
|
252
|
-
return that._launchDialogWithKeyFields(
|
|
246
|
+
oResult = await this._launchDialogWithKeyFields(
|
|
253
247
|
oMainListBinding,
|
|
254
|
-
oTransientListBinding,
|
|
255
|
-
oNewDocumentContext,
|
|
256
248
|
aNonComputedVisibleKeyFields,
|
|
257
249
|
oModel,
|
|
258
250
|
mParameters,
|
|
259
251
|
messageHandler
|
|
260
252
|
);
|
|
253
|
+
oNewDocumentContext = oResult.newContext;
|
|
261
254
|
} else {
|
|
262
|
-
let onBeforeCreatePromise;
|
|
263
255
|
if (mParameters.beforeCreateCallBack) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
onBeforeCreatePromise = Promise.resolve();
|
|
269
|
-
}
|
|
270
|
-
return onBeforeCreatePromise.then(function () {
|
|
271
|
-
oNewDocumentContext = oMainListBinding.create(
|
|
272
|
-
mParameters.data,
|
|
273
|
-
true,
|
|
274
|
-
mParameters.createAtEnd,
|
|
275
|
-
mParameters.inactive
|
|
256
|
+
await toES6Promise(
|
|
257
|
+
mParameters.beforeCreateCallBack({
|
|
258
|
+
contextPath: oMainListBinding && oMainListBinding.getPath()
|
|
259
|
+
})
|
|
276
260
|
);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
oNewDocumentContext = oMainListBinding.create(
|
|
264
|
+
mParameters.data,
|
|
265
|
+
true,
|
|
266
|
+
mParameters.createAtEnd,
|
|
267
|
+
mParameters.inactive
|
|
268
|
+
);
|
|
269
|
+
if (!mParameters.inactive) {
|
|
270
|
+
oResult = await this.onAfterCreateCompletion(oMainListBinding, oNewDocumentContext, mParameters);
|
|
271
|
+
}
|
|
281
272
|
}
|
|
282
|
-
})
|
|
283
|
-
.catch(function (oError: any) {
|
|
273
|
+
} catch (oError: any) {
|
|
284
274
|
Log.error("Error while creating the new document", oError);
|
|
285
275
|
throw oError;
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
return oCreationPromise
|
|
289
|
-
.then(function (oResult: any) {
|
|
290
|
-
if (!oMainListBinding.isRelative()) {
|
|
291
|
-
// the create mode shall currently only be set on creating a root document
|
|
292
|
-
that._bCreateMode = true;
|
|
293
|
-
}
|
|
294
|
-
oNewDocumentContext = oNewDocumentContext || (oResult && oResult.response);
|
|
295
|
-
// TODO: where does this one coming from???
|
|
296
|
-
if (oResult && oResult.bConsiderDocumentModified) {
|
|
297
|
-
that.handleDocumentModifications();
|
|
298
276
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (!oMainListBinding.isRelative()) {
|
|
280
|
+
// the create mode shall currently only be set on creating a root document
|
|
281
|
+
this._bCreateMode = true;
|
|
282
|
+
}
|
|
283
|
+
oNewDocumentContext = oNewDocumentContext || (oResult && oResult.response);
|
|
284
|
+
// TODO: where does this one coming from???
|
|
285
|
+
if (oResult && oResult.bConsiderDocumentModified) {
|
|
286
|
+
this.handleDocumentModifications();
|
|
287
|
+
}
|
|
288
|
+
await messageHandler.showMessageDialog();
|
|
289
|
+
return oNewDocumentContext!;
|
|
290
|
+
} catch (oError: any) {
|
|
291
|
+
await messageHandler.showMessageDialog();
|
|
292
|
+
if (oError && oError.bDeleteTransientContext && oNewDocumentContext?.isTransient()) {
|
|
293
|
+
// This is a workaround suggested by model as Context.delete results in an error
|
|
294
|
+
// TODO: remove the $direct once model resolves this issue
|
|
295
|
+
// this line shows the expected console error Uncaught (in promise) Error: Request canceled: POST Travel; group: submitLater
|
|
296
|
+
oNewDocumentContext.delete("$direct");
|
|
297
|
+
}
|
|
298
|
+
throw oError;
|
|
299
|
+
} finally {
|
|
300
|
+
BusyLocker.unlock(this.oLockObject, sBusyPath);
|
|
301
|
+
}
|
|
320
302
|
}
|
|
321
303
|
/**
|
|
322
304
|
* Find the active contexts of the documents, only for the draft roots.
|
|
@@ -402,10 +384,8 @@ class TransactionHelper {
|
|
|
402
384
|
* @param messageHandler
|
|
403
385
|
* @returns A Promise resolved once the document are deleted
|
|
404
386
|
*/
|
|
405
|
-
deleteDocument(vInContexts: V4Context, mParameters: any, oResourceBundle: any, messageHandler:
|
|
406
|
-
let
|
|
407
|
-
fnResolve: Function,
|
|
408
|
-
aDeletableContexts: any[] = [],
|
|
387
|
+
deleteDocument(vInContexts: V4Context, mParameters: any, oResourceBundle: any, messageHandler: MessageHandler) {
|
|
388
|
+
let aDeletableContexts: any[] = [],
|
|
409
389
|
isCheckBoxVisible = false,
|
|
410
390
|
isLockedTextVisible = false,
|
|
411
391
|
cannotBeDeletedTextVisible = false,
|
|
@@ -418,7 +398,6 @@ class TransactionHelper {
|
|
|
418
398
|
let oDeleteMessage: any = {
|
|
419
399
|
title: oResourceBundleCore.getText("C_COMMON_DELETE")
|
|
420
400
|
};
|
|
421
|
-
messageHandling.removeBoundTransitionMessages();
|
|
422
401
|
BusyLocker.lock(this.oLockObject);
|
|
423
402
|
let vContexts: V4Context[];
|
|
424
403
|
if (Array.isArray(vInContexts)) {
|
|
@@ -426,8 +405,10 @@ class TransactionHelper {
|
|
|
426
405
|
} else {
|
|
427
406
|
vContexts = [vInContexts];
|
|
428
407
|
}
|
|
429
|
-
|
|
430
|
-
|
|
408
|
+
|
|
409
|
+
return new Promise<void>((resolve, reject) => {
|
|
410
|
+
try {
|
|
411
|
+
const sProgrammingModel = this.getProgrammingModel(vContexts[0]);
|
|
431
412
|
if (mParameters) {
|
|
432
413
|
if (!mParameters.numberOfSelectedContexts) {
|
|
433
414
|
if (sProgrammingModel === ProgrammingModel.Draft) {
|
|
@@ -454,7 +435,7 @@ class TransactionHelper {
|
|
|
454
435
|
),
|
|
455
436
|
{
|
|
456
437
|
title: oResourceBundleCore.getText("C_COMMON_DELETE"),
|
|
457
|
-
onClose:
|
|
438
|
+
onClose: reject
|
|
458
439
|
}
|
|
459
440
|
);
|
|
460
441
|
return;
|
|
@@ -464,7 +445,7 @@ class TransactionHelper {
|
|
|
464
445
|
mParameters = getParameters(mParameters);
|
|
465
446
|
if (mParameters.title) {
|
|
466
447
|
if (mParameters.description) {
|
|
467
|
-
aParams = [mParameters.title
|
|
448
|
+
aParams = [mParameters.title + " ", mParameters.description];
|
|
468
449
|
} else {
|
|
469
450
|
aParams = [mParameters.title, ""];
|
|
470
451
|
}
|
|
@@ -477,7 +458,9 @@ class TransactionHelper {
|
|
|
477
458
|
} else {
|
|
478
459
|
oDeleteMessage.text = CommonUtils.getTranslatedText(
|
|
479
460
|
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
|
|
480
|
-
oResourceBundle
|
|
461
|
+
oResourceBundle,
|
|
462
|
+
null,
|
|
463
|
+
mParameters.entitySetName
|
|
481
464
|
);
|
|
482
465
|
}
|
|
483
466
|
aDeletableContexts = vContexts;
|
|
@@ -488,23 +471,19 @@ class TransactionHelper {
|
|
|
488
471
|
if (mParameters.numberOfSelectedContexts === 1 && mParameters.numberOfSelectedContexts === vContexts.length) {
|
|
489
472
|
aDeletableContexts = vContexts;
|
|
490
473
|
const oLineContextData = vContexts[0].getObject();
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
that._oAppComponent.getMetaModel(),
|
|
495
|
-
vContexts[0].getPath(),
|
|
496
|
-
mParameters.entitySetName
|
|
497
|
-
);
|
|
474
|
+
const oTable = mParameters.parentControl;
|
|
475
|
+
const sKey = oTable && oTable.getParent().getIdentifierColumn();
|
|
476
|
+
if (sKey) {
|
|
498
477
|
const sKeyValue = sKey ? oLineContextData[sKey] : undefined;
|
|
499
478
|
const sDescription =
|
|
500
479
|
mParameters.description && mParameters.description.path
|
|
501
480
|
? oLineContextData[mParameters.description.path]
|
|
502
481
|
: undefined;
|
|
503
|
-
if (
|
|
482
|
+
if (sKeyValue) {
|
|
504
483
|
if (sDescription) {
|
|
505
|
-
aParams = [
|
|
484
|
+
aParams = [sKeyValue + " ", sDescription];
|
|
506
485
|
} else {
|
|
507
|
-
aParams = [
|
|
486
|
+
aParams = [sKeyValue, ""];
|
|
508
487
|
}
|
|
509
488
|
oDeleteMessage.text = CommonUtils.getTranslatedText(
|
|
510
489
|
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO",
|
|
@@ -523,7 +502,9 @@ class TransactionHelper {
|
|
|
523
502
|
} else {
|
|
524
503
|
oDeleteMessage.text = CommonUtils.getTranslatedText(
|
|
525
504
|
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
|
|
526
|
-
oResourceBundle
|
|
505
|
+
oResourceBundle,
|
|
506
|
+
null,
|
|
507
|
+
mParameters.entitySetName
|
|
527
508
|
);
|
|
528
509
|
}
|
|
529
510
|
} else {
|
|
@@ -600,7 +581,7 @@ class TransactionHelper {
|
|
|
600
581
|
//setting the locked text if locked objects exist
|
|
601
582
|
isLockedTextVisible = true;
|
|
602
583
|
oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
|
|
603
|
-
"
|
|
584
|
+
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED",
|
|
604
585
|
oResourceBundle,
|
|
605
586
|
[mParameters.numberOfSelectedContexts]
|
|
606
587
|
);
|
|
@@ -609,7 +590,7 @@ class TransactionHelper {
|
|
|
609
590
|
//setting the locked text if locked objects exist
|
|
610
591
|
isLockedTextVisible = true;
|
|
611
592
|
oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
|
|
612
|
-
"
|
|
593
|
+
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED",
|
|
613
594
|
oResourceBundle,
|
|
614
595
|
[mParameters.lockedContexts.length, mParameters.numberOfSelectedContexts]
|
|
615
596
|
);
|
|
@@ -660,7 +641,7 @@ class TransactionHelper {
|
|
|
660
641
|
sNonDeletableContextText +
|
|
661
642
|
" " +
|
|
662
643
|
CommonUtils.getTranslatedText(
|
|
663
|
-
"
|
|
644
|
+
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED",
|
|
664
645
|
oResourceBundle,
|
|
665
646
|
[mParameters.lockedContexts.length, mParameters.numberOfSelectedContexts]
|
|
666
647
|
);
|
|
@@ -670,7 +651,7 @@ class TransactionHelper {
|
|
|
670
651
|
sNonDeletableContextText +
|
|
671
652
|
" " +
|
|
672
653
|
CommonUtils.getTranslatedText(
|
|
673
|
-
"
|
|
654
|
+
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED",
|
|
674
655
|
oResourceBundle,
|
|
675
656
|
[mParameters.numberOfSelectedContexts]
|
|
676
657
|
);
|
|
@@ -706,58 +687,54 @@ class TransactionHelper {
|
|
|
706
687
|
]
|
|
707
688
|
});
|
|
708
689
|
const sTitle = oResourceBundleCore.getText("C_COMMON_DELETE");
|
|
709
|
-
const fnConfirm = function () {
|
|
690
|
+
const fnConfirm = async function () {
|
|
710
691
|
bDialogConfirmed = true;
|
|
711
692
|
BusyLocker.lock(that.oLockObject);
|
|
712
693
|
const aContexts = aDeletableContexts;
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
//make sure to fetch the active contexts before deleting the drafts
|
|
723
|
-
return Promise.all(
|
|
694
|
+
|
|
695
|
+
try {
|
|
696
|
+
if (mParameters.beforeDeleteCallBack) {
|
|
697
|
+
await mParameters.beforeDeleteCallBack({ contexts: aContexts });
|
|
698
|
+
}
|
|
699
|
+
const activeContexts = await that.findActiveDraftRootContexts(aContexts, mParameters.bFindActiveContexts);
|
|
700
|
+
|
|
701
|
+
try {
|
|
702
|
+
await Promise.all(
|
|
724
703
|
aContexts.map(function (oContext: any) {
|
|
725
704
|
//delete the draft
|
|
726
|
-
|
|
705
|
+
const bEnableStrictHandling = aContexts.length === 1 ? true : false;
|
|
706
|
+
return draft.deleteDraft(oContext, that._oAppComponent, bEnableStrictHandling);
|
|
727
707
|
})
|
|
728
|
-
)
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
708
|
+
);
|
|
709
|
+
} catch (oError: any) {
|
|
710
|
+
await messageHandler.showMessages();
|
|
711
|
+
// re-throw error to enforce rejecting the general promise
|
|
712
|
+
throw oError;
|
|
713
|
+
}
|
|
714
|
+
const checkBox = {
|
|
715
|
+
"isCheckBoxVisible": isCheckBoxVisible,
|
|
716
|
+
"isCheckBoxSelected": isCheckBoxSelected
|
|
717
|
+
};
|
|
718
|
+
if (activeContexts && activeContexts.length) {
|
|
719
|
+
await Promise.all(
|
|
720
|
+
activeContexts.map(function (oContext: any) {
|
|
721
|
+
return oContext.delete();
|
|
734
722
|
})
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
|
|
751
|
-
return messageHandler.showMessageDialog().then(fnResolve);
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
})
|
|
755
|
-
.catch(function () {
|
|
756
|
-
fnReject();
|
|
757
|
-
})
|
|
758
|
-
.finally(function () {
|
|
759
|
-
BusyLocker.unlock(that.oLockObject);
|
|
760
|
-
});
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
|
|
726
|
+
await messageHandler.showMessageDialog();
|
|
727
|
+
resolve();
|
|
728
|
+
} else {
|
|
729
|
+
that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
|
|
730
|
+
await messageHandler.showMessageDialog();
|
|
731
|
+
resolve();
|
|
732
|
+
}
|
|
733
|
+
} catch (oError: any) {
|
|
734
|
+
reject();
|
|
735
|
+
} finally {
|
|
736
|
+
BusyLocker.unlock(that.oLockObject);
|
|
737
|
+
}
|
|
761
738
|
};
|
|
762
739
|
const oDialog = new Dialog({
|
|
763
740
|
title: sTitle,
|
|
@@ -770,8 +747,9 @@ class TransactionHelper {
|
|
|
770
747
|
text: oResourceBundleCore.getText("C_COMMON_DELETE"),
|
|
771
748
|
type: "Emphasized",
|
|
772
749
|
press: function () {
|
|
750
|
+
messageHandling.removeBoundTransitionMessages();
|
|
773
751
|
oDialog.close();
|
|
774
|
-
|
|
752
|
+
fnConfirm();
|
|
775
753
|
}
|
|
776
754
|
}),
|
|
777
755
|
endButton: new Button({
|
|
@@ -784,27 +762,19 @@ class TransactionHelper {
|
|
|
784
762
|
oDialog.destroy();
|
|
785
763
|
// if dialog is closed unconfirmed (e.g. via "Cancel" or Escape button), ensure to reject promise
|
|
786
764
|
if (!bDialogConfirmed) {
|
|
787
|
-
|
|
765
|
+
reject();
|
|
788
766
|
}
|
|
789
767
|
}
|
|
790
768
|
} as any);
|
|
791
769
|
if (mParameters.noDialog) {
|
|
792
|
-
|
|
770
|
+
fnConfirm();
|
|
793
771
|
} else {
|
|
794
772
|
oDialog.addStyleClass("sapUiContentPadding");
|
|
795
773
|
oDialog.open();
|
|
796
774
|
}
|
|
797
|
-
}
|
|
798
|
-
.finally(function () {
|
|
775
|
+
} finally {
|
|
799
776
|
BusyLocker.unlock(that.oLockObject);
|
|
800
|
-
}
|
|
801
|
-
.catch(function () {
|
|
802
|
-
Log.warning("Couldn't get Programming model");
|
|
803
|
-
fnReject();
|
|
804
|
-
});
|
|
805
|
-
return new Promise(function (resolve: (value: any) => void, reject: (reason?: any) => void) {
|
|
806
|
-
fnReject = reject;
|
|
807
|
-
fnResolve = resolve;
|
|
777
|
+
}
|
|
808
778
|
});
|
|
809
779
|
}
|
|
810
780
|
/**
|
|
@@ -819,44 +789,39 @@ class TransactionHelper {
|
|
|
819
789
|
* @ui5-restricted
|
|
820
790
|
* @final
|
|
821
791
|
*/
|
|
822
|
-
editDocument(oContext: V4Context, oView: View, messageHandler:
|
|
792
|
+
async editDocument(oContext: V4Context, oView: View, messageHandler: MessageHandler): Promise<V4Context> {
|
|
823
793
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
824
794
|
const that = this;
|
|
825
795
|
const sProgrammingModel = this.getProgrammingModel(oContext);
|
|
826
|
-
let oEditPromise;
|
|
827
796
|
if (!oContext) {
|
|
828
|
-
|
|
797
|
+
throw new Error("Binding context to active document is required");
|
|
798
|
+
}
|
|
799
|
+
if (sProgrammingModel !== ProgrammingModel.Draft && sProgrammingModel !== ProgrammingModel.Sticky) {
|
|
800
|
+
throw new Error("Edit is only allowed for draft or sticky session supported services");
|
|
829
801
|
}
|
|
830
802
|
this._bIsModified = false;
|
|
831
803
|
BusyLocker.lock(that.oLockObject);
|
|
832
804
|
// before triggering the edit action we'll have to remove all bound transition messages
|
|
833
805
|
messageHandler.removeTransitionMessages();
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
806
|
+
|
|
807
|
+
try {
|
|
808
|
+
const oNewContext: V4Context =
|
|
809
|
+
sProgrammingModel === ProgrammingModel.Draft
|
|
810
|
+
? await draft.createDraftFromActiveDocument(oContext, this._getAppComponent(), {
|
|
811
|
+
bPreserveChanges: true,
|
|
812
|
+
oView: oView
|
|
813
|
+
} as any)
|
|
814
|
+
: await sticky.editDocumentInStickySession(oContext, this._getAppComponent());
|
|
815
|
+
|
|
816
|
+
this._bCreateMode = false;
|
|
817
|
+
await messageHandler.showMessageDialog();
|
|
818
|
+
return oNewContext;
|
|
819
|
+
} catch (err: any) {
|
|
820
|
+
await messageHandler.showMessages({ concurrentEditFlag: true });
|
|
821
|
+
throw err;
|
|
822
|
+
} finally {
|
|
842
823
|
BusyLocker.unlock(that.oLockObject);
|
|
843
|
-
return Promise.reject(new Error("Edit is only allowed for draft or sticky session supported services"));
|
|
844
824
|
}
|
|
845
|
-
return oEditPromise
|
|
846
|
-
.then(function (oNewContext: any) {
|
|
847
|
-
that._bCreateMode = false;
|
|
848
|
-
return messageHandler.showMessageDialog().then(function () {
|
|
849
|
-
return oNewContext;
|
|
850
|
-
});
|
|
851
|
-
})
|
|
852
|
-
.catch(function (err: any) {
|
|
853
|
-
return messageHandler.showMessages({ concurrentEditFlag: true }).then(function () {
|
|
854
|
-
return Promise.reject(err);
|
|
855
|
-
});
|
|
856
|
-
})
|
|
857
|
-
.finally(function () {
|
|
858
|
-
BusyLocker.unlock(that.oLockObject);
|
|
859
|
-
});
|
|
860
825
|
}
|
|
861
826
|
/**
|
|
862
827
|
* Cancel 'edit' mode of a document.
|
|
@@ -873,134 +838,90 @@ class TransactionHelper {
|
|
|
873
838
|
* @ui5-restricted
|
|
874
839
|
* @final
|
|
875
840
|
*/
|
|
876
|
-
cancelDocument(
|
|
841
|
+
async cancelDocument(
|
|
877
842
|
oContext: V4Context,
|
|
878
843
|
mInParameters: { cancelButton: any; skipDiscardPopover: boolean } | undefined,
|
|
879
844
|
oResourceBundle: any,
|
|
880
|
-
messageHandler:
|
|
881
|
-
) {
|
|
882
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
883
|
-
const that = this;
|
|
884
|
-
let sProgrammingModel: typeof ProgrammingModel;
|
|
845
|
+
messageHandler: MessageHandler
|
|
846
|
+
): Promise<V4Context | boolean> {
|
|
885
847
|
//context must always be passed - mandatory parameter
|
|
886
848
|
if (!oContext) {
|
|
887
|
-
|
|
849
|
+
throw new Error("No context exists. Pass a meaningful context");
|
|
888
850
|
}
|
|
889
|
-
BusyLocker.lock(
|
|
851
|
+
BusyLocker.lock(this.oLockObject);
|
|
890
852
|
const mParameters = getParameters(mInParameters);
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (draftAdminData) {
|
|
903
|
-
that._bIsModified = !(draftAdminData.CreationDateTime === draftAdminData.LastChangeDateTime);
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
})
|
|
909
|
-
.then(function () {
|
|
910
|
-
if (!mParameters.skipDiscardPopover) {
|
|
911
|
-
return that._showDiscardPopover(oCancelButton, that._bIsModified, oResourceBundle);
|
|
912
|
-
} else {
|
|
913
|
-
return Promise.resolve();
|
|
914
|
-
}
|
|
915
|
-
})
|
|
916
|
-
.then(function () {
|
|
917
|
-
if (mParameters.beforeCancelCallBack) {
|
|
918
|
-
onBeforeCancelPromise = mParameters.beforeCancelCallBack({ context: oContext });
|
|
919
|
-
} else {
|
|
920
|
-
onBeforeCancelPromise = Promise.resolve();
|
|
853
|
+
const oModel = oContext.getModel();
|
|
854
|
+
const sProgrammingModel = this.getProgrammingModel(oContext);
|
|
855
|
+
|
|
856
|
+
try {
|
|
857
|
+
let returnedValue: V4Context | boolean = false;
|
|
858
|
+
|
|
859
|
+
if (sProgrammingModel === ProgrammingModel.Draft && !this._bIsModified) {
|
|
860
|
+
const draftDataContext = oModel.bindContext(`${oContext.getPath()}/DraftAdministrativeData`).getBoundContext();
|
|
861
|
+
const draftAdminData = await draftDataContext.requestObject();
|
|
862
|
+
if (draftAdminData) {
|
|
863
|
+
this._bIsModified = !(draftAdminData.CreationDateTime === draftAdminData.LastChangeDateTime);
|
|
921
864
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
function (sPath: any) {
|
|
944
|
-
sCanonicalPath = sPath;
|
|
945
|
-
if (oParamsContext && oParamsContext.hasPendingChanges()) {
|
|
946
|
-
oParamsContext.getBinding().resetChanges();
|
|
947
|
-
}
|
|
948
|
-
oDeletePromise = draft.deleteDraft(oParamsContext);
|
|
949
|
-
return oDeletePromise;
|
|
950
|
-
},
|
|
951
|
-
function () {
|
|
952
|
-
draft.deleteDraft(oParamsContext);
|
|
953
|
-
}
|
|
954
|
-
)
|
|
955
|
-
.then(function () {
|
|
956
|
-
//oParamsContext.delete() in the previous promise doesnt return anything upon success.
|
|
957
|
-
if (!sCanonicalPath) {
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
if (oActiveContext.getPath() !== sCanonicalPath) {
|
|
961
|
-
// the active context is using the sibling entity - this path is not accessible anymore as we deleted the draft
|
|
962
|
-
// document - therefore we need to create a new context with the canonical path
|
|
963
|
-
oActiveContext = oModel.bindContext(sCanonicalPath).getBoundContext();
|
|
964
|
-
}
|
|
965
|
-
return oActiveContext;
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
case ProgrammingModel.Sticky:
|
|
970
|
-
return sticky.discardDocument(oContext).then(function (discardedContext: any) {
|
|
971
|
-
if (discardedContext) {
|
|
972
|
-
if (discardedContext.hasPendingChanges()) {
|
|
973
|
-
discardedContext.getBinding().resetChanges();
|
|
974
|
-
}
|
|
975
|
-
if (!that._bCreateMode) {
|
|
976
|
-
discardedContext.refresh();
|
|
977
|
-
return discardedContext;
|
|
978
|
-
}
|
|
865
|
+
}
|
|
866
|
+
if (!mParameters.skipDiscardPopover) {
|
|
867
|
+
await this._showDiscardPopover(mParameters.cancelButton, this._bIsModified, oResourceBundle);
|
|
868
|
+
}
|
|
869
|
+
if (mParameters.beforeCancelCallBack) {
|
|
870
|
+
await mParameters.beforeCancelCallBack({ context: oContext });
|
|
871
|
+
}
|
|
872
|
+
switch (sProgrammingModel) {
|
|
873
|
+
case ProgrammingModel.Draft:
|
|
874
|
+
const bHasActiveEntity = await oContext.requestObject("HasActiveEntity");
|
|
875
|
+
if (!bHasActiveEntity) {
|
|
876
|
+
if (oContext && oContext.hasPendingChanges()) {
|
|
877
|
+
oContext.getBinding().resetChanges();
|
|
878
|
+
}
|
|
879
|
+
returnedValue = await draft.deleteDraft(oContext, this._oAppComponent);
|
|
880
|
+
} else {
|
|
881
|
+
const oSiblingContext = oModel.bindContext(`${oContext.getPath()}/SiblingEntity`).getBoundContext();
|
|
882
|
+
try {
|
|
883
|
+
const sCanonicalPath = await oSiblingContext.requestCanonicalPath();
|
|
884
|
+
if (oContext && oContext.hasPendingChanges()) {
|
|
885
|
+
oContext.getBinding().resetChanges();
|
|
979
886
|
}
|
|
980
|
-
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
887
|
+
returnedValue = oModel.bindContext(sCanonicalPath).getBoundContext();
|
|
888
|
+
} finally {
|
|
889
|
+
await draft.deleteDraft(oContext, this._oAppComponent);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
break;
|
|
893
|
+
|
|
894
|
+
case ProgrammingModel.Sticky:
|
|
895
|
+
const discardedContext = await sticky.discardDocument(oContext);
|
|
896
|
+
if (discardedContext) {
|
|
897
|
+
if (discardedContext.hasPendingChanges()) {
|
|
898
|
+
discardedContext.getBinding().resetChanges();
|
|
899
|
+
}
|
|
900
|
+
if (!this._bCreateMode) {
|
|
901
|
+
discardedContext.refresh();
|
|
902
|
+
returnedValue = discardedContext;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
break;
|
|
906
|
+
|
|
907
|
+
default:
|
|
908
|
+
throw new Error("Cancel document only allowed for draft or sticky session supported services");
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
this._bIsModified = false;
|
|
912
|
+
// remove existing bound transition messages
|
|
913
|
+
messageHandler.removeTransitionMessages();
|
|
914
|
+
// show unbound messages
|
|
915
|
+
await messageHandler.showMessages();
|
|
916
|
+
return returnedValue;
|
|
917
|
+
} catch (err: any) {
|
|
918
|
+
await messageHandler.showMessages();
|
|
919
|
+
throw err;
|
|
920
|
+
} finally {
|
|
921
|
+
BusyLocker.unlock(this.oLockObject);
|
|
922
|
+
}
|
|
1003
923
|
}
|
|
924
|
+
|
|
1004
925
|
/**
|
|
1005
926
|
* Saves the document.
|
|
1006
927
|
*
|
|
@@ -1015,55 +936,54 @@ class TransactionHelper {
|
|
|
1015
936
|
* @ui5-restricted
|
|
1016
937
|
* @final
|
|
1017
938
|
*/
|
|
1018
|
-
saveDocument(
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
939
|
+
async saveDocument(
|
|
940
|
+
oContext: V4Context,
|
|
941
|
+
oResourceBundle: any,
|
|
942
|
+
bExecuteSideEffectsOnError: any,
|
|
943
|
+
aBindings: any,
|
|
944
|
+
messageHandler: MessageHandler
|
|
945
|
+
): Promise<V4Context> {
|
|
1023
946
|
if (!oContext) {
|
|
1024
947
|
return Promise.reject(new Error("Binding context to draft document is required"));
|
|
1025
948
|
}
|
|
949
|
+
const sProgrammingModel = this.getProgrammingModel(oContext);
|
|
950
|
+
if (sProgrammingModel !== ProgrammingModel.Sticky && sProgrammingModel !== ProgrammingModel.Draft) {
|
|
951
|
+
throw new Error("Save is only allowed for draft or sticky session supported services");
|
|
952
|
+
}
|
|
1026
953
|
// in case of saving / activating the bound transition messages shall be removed before the PATCH/POST
|
|
1027
954
|
// is sent to the backend
|
|
1028
955
|
messageHandler.removeTransitionMessages();
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
aBindings.forEach(function (oListBinding: any) {
|
|
1054
|
-
if (!CommonUtils.hasTransientContext(oListBinding) && bExecuteSideEffectsOnError) {
|
|
1055
|
-
const oAppComponent = that._getAppComponent();
|
|
1056
|
-
oAppComponent.getSideEffectsService().requestSideEffectsForNavigationProperty(oListBinding.getPath(), oContext);
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
return messageHandler.showMessages().then(function () {
|
|
1061
|
-
return Promise.reject(err);
|
|
956
|
+
|
|
957
|
+
try {
|
|
958
|
+
BusyLocker.lock(this.oLockObject);
|
|
959
|
+
const oActiveDocument =
|
|
960
|
+
sProgrammingModel === ProgrammingModel.Draft
|
|
961
|
+
? await draft.activateDocument(oContext, this._getAppComponent(), {}, messageHandler)
|
|
962
|
+
: await sticky.activateDocument(oContext, this._getAppComponent());
|
|
963
|
+
|
|
964
|
+
const bNewObject = sProgrammingModel === ProgrammingModel.Sticky ? this._bCreateMode : !oContext.getObject().HasActiveEntity;
|
|
965
|
+
MessageToast.show(
|
|
966
|
+
bNewObject
|
|
967
|
+
? CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_CREATED", oResourceBundle)
|
|
968
|
+
: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_SAVED", oResourceBundle)
|
|
969
|
+
);
|
|
970
|
+
this._bIsModified = false;
|
|
971
|
+
return oActiveDocument;
|
|
972
|
+
} catch (err: any) {
|
|
973
|
+
if (aBindings && aBindings.length > 0) {
|
|
974
|
+
/* The sideEffects are executed only for table items in transient state */
|
|
975
|
+
aBindings.forEach((oListBinding: any) => {
|
|
976
|
+
if (!CommonUtils.hasTransientContext(oListBinding) && bExecuteSideEffectsOnError) {
|
|
977
|
+
const oAppComponent = this._getAppComponent();
|
|
978
|
+
oAppComponent.getSideEffectsService().requestSideEffectsForNavigationProperty(oListBinding.getPath(), oContext);
|
|
979
|
+
}
|
|
1062
980
|
});
|
|
1063
|
-
}
|
|
1064
|
-
.
|
|
1065
|
-
|
|
1066
|
-
|
|
981
|
+
}
|
|
982
|
+
await messageHandler.showMessages();
|
|
983
|
+
throw err;
|
|
984
|
+
} finally {
|
|
985
|
+
BusyLocker.unlock(this.oLockObject);
|
|
986
|
+
}
|
|
1067
987
|
}
|
|
1068
988
|
/**
|
|
1069
989
|
* Calls a bound or unbound action.
|
|
@@ -1085,14 +1005,14 @@ class TransactionHelper {
|
|
|
1085
1005
|
* @ui5-restricted
|
|
1086
1006
|
* @final
|
|
1087
1007
|
*/
|
|
1088
|
-
callAction(sActionName: string, mParameters: any, oView: View | null, messageHandler:
|
|
1008
|
+
async callAction(sActionName: string, mParameters: any, oView: View | null, messageHandler: MessageHandler): Promise<any> {
|
|
1089
1009
|
mParameters = getParameters(mParameters);
|
|
1090
1010
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1091
1011
|
const that = this;
|
|
1092
|
-
let oContext, oModel: any
|
|
1012
|
+
let oContext, oModel: any;
|
|
1093
1013
|
const mBindingParameters = mParameters.bindingParameters;
|
|
1094
1014
|
if (!sActionName) {
|
|
1095
|
-
|
|
1015
|
+
throw new Error("Provide name of action to be executed");
|
|
1096
1016
|
}
|
|
1097
1017
|
// action imports are not directly obtained from the metaModel by it is present inside the entityContainer
|
|
1098
1018
|
// and the acions it refers to present outside the entitycontainer, hence to obtain kind of the action
|
|
@@ -1109,28 +1029,20 @@ class TransactionHelper {
|
|
|
1109
1029
|
oModel = mParameters.model;
|
|
1110
1030
|
}
|
|
1111
1031
|
if (!oModel) {
|
|
1112
|
-
|
|
1032
|
+
throw new Error("Pass a context for a bound action or pass the model for an unbound action");
|
|
1113
1033
|
}
|
|
1114
1034
|
// get the binding parameters $select and $expand for the side effect on this action
|
|
1115
1035
|
// also gather additional property paths to be requested such as text associations
|
|
1116
1036
|
const oAppComponent = that._getAppComponent();
|
|
1117
1037
|
const mSideEffectsParameters = oAppComponent.getSideEffectsService().getODataActionSideEffects(sActionName, oContext) || {};
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
},
|
|
1127
|
-
onContinue: function () {
|
|
1128
|
-
// Users continues the action with the bound contexts
|
|
1129
|
-
oApplicableContextDialog.close();
|
|
1130
|
-
resolve(mParameters.applicableContext);
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
const fnOpenAndFillDialog = function () {
|
|
1038
|
+
|
|
1039
|
+
const displayUnapplicableContextsDialog = (): Promise<V4Context[] | void> => {
|
|
1040
|
+
if (!mParameters.notApplicableContext || mParameters.notApplicableContext.length === 0) {
|
|
1041
|
+
return Promise.resolve(mParameters.contexts);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return new Promise(async (resolve, reject) => {
|
|
1045
|
+
const fnOpenAndFillDialog = function (oDlg: Dialog) {
|
|
1134
1046
|
let oDialogContent;
|
|
1135
1047
|
const nNotApplicable = mParameters.notApplicableContext.length,
|
|
1136
1048
|
aNotApplicableItems = [];
|
|
@@ -1140,52 +1052,76 @@ class TransactionHelper {
|
|
|
1140
1052
|
}
|
|
1141
1053
|
const oNotApplicableItemsModel = new JSONModel(aNotApplicableItems);
|
|
1142
1054
|
const oTotals = new JSONModel({ total: nNotApplicable, label: mParameters.label });
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1055
|
+
oDlg.setModel(oNotApplicableItemsModel, "notApplicable");
|
|
1056
|
+
oDlg.setModel(oTotals, "totals");
|
|
1057
|
+
oDlg.open();
|
|
1146
1058
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1059
|
+
// Show the contexts that are not applicable and will not therefore be processed
|
|
1060
|
+
const sFragmentName = "sap.fe.core.controls.ActionPartial";
|
|
1061
|
+
const oDialogFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment");
|
|
1062
|
+
const oMetaModel = oModel.getMetaModel();
|
|
1063
|
+
const sCanonicalPath = mParameters.contexts[0].getCanonicalPath();
|
|
1064
|
+
const sEntitySet = `${sCanonicalPath.substr(0, sCanonicalPath.indexOf("("))}/`;
|
|
1065
|
+
const oDialogLabelModel = new JSONModel({
|
|
1066
|
+
title: mParameters.label
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
try {
|
|
1070
|
+
const oFragment = await XMLPreprocessor.process(
|
|
1071
|
+
oDialogFragment,
|
|
1072
|
+
{ name: sFragmentName },
|
|
1073
|
+
{
|
|
1074
|
+
bindingContexts: {
|
|
1075
|
+
entityType: oMetaModel.createBindingContext(sEntitySet),
|
|
1076
|
+
label: oDialogLabelModel.createBindingContext("/")
|
|
1077
|
+
},
|
|
1078
|
+
models: {
|
|
1079
|
+
entityType: oMetaModel,
|
|
1080
|
+
metaModel: oMetaModel,
|
|
1081
|
+
label: oDialogLabelModel
|
|
1171
1082
|
}
|
|
1172
|
-
|
|
1173
|
-
)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
// eslint-disable-next-line prefer-const
|
|
1086
|
+
let oDialog: Dialog;
|
|
1087
|
+
const oController = {
|
|
1088
|
+
onClose: function () {
|
|
1089
|
+
// User cancels action
|
|
1090
|
+
oDialog.close();
|
|
1091
|
+
resolve();
|
|
1092
|
+
},
|
|
1093
|
+
onContinue: function () {
|
|
1094
|
+
// Users continues the action with the bound contexts
|
|
1095
|
+
oDialog.close();
|
|
1096
|
+
resolve(mParameters.applicableContext);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
oDialog = (await Fragment.load({ definition: oFragment, controller: oController })) as Dialog;
|
|
1100
|
+
oController.onClose = function () {
|
|
1101
|
+
// User cancels action
|
|
1102
|
+
oDialog.close();
|
|
1103
|
+
resolve();
|
|
1104
|
+
};
|
|
1105
|
+
oController.onContinue = function () {
|
|
1106
|
+
// Users continues the action with the bound contexts
|
|
1107
|
+
oDialog.close();
|
|
1108
|
+
resolve(mParameters.applicableContext);
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
mParameters.parentControl.addDependent(oDialog);
|
|
1112
|
+
fnOpenAndFillDialog(oDialog);
|
|
1113
|
+
} catch (oError) {
|
|
1114
|
+
reject(oError);
|
|
1185
1115
|
}
|
|
1186
|
-
})
|
|
1116
|
+
});
|
|
1117
|
+
};
|
|
1118
|
+
|
|
1119
|
+
try {
|
|
1120
|
+
let oResult: any;
|
|
1121
|
+
if (oContext && oModel) {
|
|
1122
|
+
const contextToProcess = await displayUnapplicableContextsDialog();
|
|
1187
1123
|
if (contextToProcess) {
|
|
1188
|
-
|
|
1124
|
+
oResult = await operations.callBoundAction(sActionName, contextToProcess, oModel, oAppComponent, {
|
|
1189
1125
|
invocationGrouping: mParameters.invocationGrouping,
|
|
1190
1126
|
label: mParameters.label,
|
|
1191
1127
|
showActionParameterDialog: true,
|
|
@@ -1207,44 +1143,38 @@ class TransactionHelper {
|
|
|
1207
1143
|
bGetBoundContext: mParameters.bGetBoundContext,
|
|
1208
1144
|
bObjectPage: mParameters.bObjectPage,
|
|
1209
1145
|
messageHandler: messageHandler,
|
|
1210
|
-
defaultValuesExtensionFunction: mParameters.defaultValuesExtensionFunction
|
|
1146
|
+
defaultValuesExtensionFunction: mParameters.defaultValuesExtensionFunction,
|
|
1147
|
+
selectedItems: mParameters.contexts
|
|
1211
1148
|
});
|
|
1212
1149
|
} else {
|
|
1213
|
-
|
|
1150
|
+
oResult = null;
|
|
1214
1151
|
}
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
messageHandler: messageHandler,
|
|
1233
|
-
bObjectPage: mParameters.bObjectPage
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
return oPromise
|
|
1237
|
-
.then(function (oResult: any) {
|
|
1238
|
-
// Succeeded
|
|
1239
|
-
return that._handleActionResponse(messageHandler, mParameters, sActionName).then(function () {
|
|
1240
|
-
return oResult;
|
|
1241
|
-
});
|
|
1242
|
-
})
|
|
1243
|
-
.catch(function (err: any) {
|
|
1244
|
-
return that._handleActionResponse(messageHandler, mParameters, sActionName).then(function () {
|
|
1245
|
-
return Promise.reject(err);
|
|
1152
|
+
} else {
|
|
1153
|
+
oResult = await operations.callActionImport(sActionName, oModel, oAppComponent, {
|
|
1154
|
+
label: mParameters.label,
|
|
1155
|
+
showActionParameterDialog: true,
|
|
1156
|
+
bindingParameters: mBindingParameters,
|
|
1157
|
+
entitySetName: mParameters.entitySetName,
|
|
1158
|
+
onSubmitted: function () {
|
|
1159
|
+
BusyLocker.lock(that.oLockObject);
|
|
1160
|
+
},
|
|
1161
|
+
onResponse: function () {
|
|
1162
|
+
BusyLocker.unlock(that.oLockObject);
|
|
1163
|
+
},
|
|
1164
|
+
parentControl: mParameters.parentControl,
|
|
1165
|
+
internalModelContext: mParameters.internalModelContext,
|
|
1166
|
+
operationAvailableMap: mParameters.operationAvailableMap,
|
|
1167
|
+
messageHandler: messageHandler,
|
|
1168
|
+
bObjectPage: mParameters.bObjectPage
|
|
1246
1169
|
});
|
|
1247
|
-
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
await this._handleActionResponse(messageHandler, mParameters, sActionName);
|
|
1173
|
+
return oResult;
|
|
1174
|
+
} catch (err: any) {
|
|
1175
|
+
await this._handleActionResponse(messageHandler, mParameters, sActionName);
|
|
1176
|
+
throw err;
|
|
1177
|
+
}
|
|
1248
1178
|
}
|
|
1249
1179
|
/**
|
|
1250
1180
|
* Handles messages for action call.
|
|
@@ -1259,7 +1189,7 @@ class TransactionHelper {
|
|
|
1259
1189
|
* @ui5-restricted
|
|
1260
1190
|
* @final
|
|
1261
1191
|
*/
|
|
1262
|
-
_handleActionResponse(messageHandler:
|
|
1192
|
+
_handleActionResponse(messageHandler: MessageHandler, mParameters: any, sActionName: string) {
|
|
1263
1193
|
const aTransientMessages = messageHandling.getMessages(true, true);
|
|
1264
1194
|
if (aTransientMessages.length > 0 && mParameters && mParameters.internalModelContext) {
|
|
1265
1195
|
mParameters.internalModelContext.setProperty("sActionName", mParameters.label ? mParameters.label : sActionName);
|
|
@@ -1394,7 +1324,7 @@ class TransactionHelper {
|
|
|
1394
1324
|
return this._oAppComponent;
|
|
1395
1325
|
}
|
|
1396
1326
|
|
|
1397
|
-
_onFieldChange(oEvent: any, oCreateButton: any, messageHandler:
|
|
1327
|
+
_onFieldChange(oEvent: any, oCreateButton: any, messageHandler: MessageHandler, fnValidateRequiredProperties: Function) {
|
|
1398
1328
|
messageHandler.removeTransitionMessages();
|
|
1399
1329
|
const oField = oEvent.getSource();
|
|
1400
1330
|
const oFieldPromise = oEvent.getParameter("promise");
|
|
@@ -1404,6 +1334,7 @@ class TransactionHelper {
|
|
|
1404
1334
|
// Setting value of field as '' in case of value help and validating other fields
|
|
1405
1335
|
oField.setValue(value);
|
|
1406
1336
|
fnValidateRequiredProperties();
|
|
1337
|
+
|
|
1407
1338
|
return oField.getValue();
|
|
1408
1339
|
})
|
|
1409
1340
|
.catch(function (value: any) {
|
|
@@ -1424,10 +1355,7 @@ class TransactionHelper {
|
|
|
1424
1355
|
? CommonUtils.getTranslatedText(
|
|
1425
1356
|
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_NON_DELETABLE",
|
|
1426
1357
|
oResourceBundle,
|
|
1427
|
-
[
|
|
1428
|
-
mParameters.numberOfSelectedContexts - vContexts.concat(mParameters.unSavedContexts).length,
|
|
1429
|
-
mParameters.numberOfSelectedContexts
|
|
1430
|
-
]
|
|
1358
|
+
[mParameters.numberOfSelectedContexts]
|
|
1431
1359
|
)
|
|
1432
1360
|
: CommonUtils.getTranslatedText(
|
|
1433
1361
|
"C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_NON_DELETABLE",
|
|
@@ -1440,28 +1368,34 @@ class TransactionHelper {
|
|
|
1440
1368
|
}
|
|
1441
1369
|
|
|
1442
1370
|
_launchDialogWithKeyFields(
|
|
1443
|
-
oListBinding:
|
|
1444
|
-
oTransientListBinding: any,
|
|
1445
|
-
oTransientContext: any,
|
|
1371
|
+
oListBinding: ODataListBinding,
|
|
1446
1372
|
mFields: any,
|
|
1447
|
-
oModel:
|
|
1373
|
+
oModel: ODataModel,
|
|
1448
1374
|
mParameters: any,
|
|
1449
|
-
messageHandler:
|
|
1375
|
+
messageHandler: MessageHandler
|
|
1450
1376
|
) {
|
|
1451
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1452
|
-
const that = this;
|
|
1453
1377
|
let oDialog: Dialog;
|
|
1454
1378
|
const oParentControl = mParameters.parentControl,
|
|
1455
1379
|
bSuccess = false;
|
|
1456
|
-
|
|
1380
|
+
|
|
1381
|
+
// Crate a fake (transient) listBinding and context, just for the binding context of the dialog
|
|
1382
|
+
const oTransientListBinding = oModel.bindList(oListBinding.getPath(), oListBinding.getContext(), [], [], {
|
|
1383
|
+
$$updateGroupId: "submitLater"
|
|
1384
|
+
}) as ODataListBinding;
|
|
1385
|
+
oTransientListBinding.refreshInternal = function () {
|
|
1386
|
+
/* */
|
|
1387
|
+
};
|
|
1388
|
+
const oTransientContext = oTransientListBinding.create(mParameters.data, true);
|
|
1389
|
+
|
|
1390
|
+
return new Promise(async (resolve, reject) => {
|
|
1457
1391
|
const sFragmentName = "sap/fe/core/controls/NonComputedVisibleKeyFieldsDialog";
|
|
1458
1392
|
const oFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment"),
|
|
1459
1393
|
oResourceBundle = oParentControl.getController().oResourceBundle,
|
|
1460
1394
|
oMetaModel = oModel.getMetaModel(),
|
|
1461
1395
|
aImmutableFields: any[] = [],
|
|
1462
|
-
oAppComponent =
|
|
1463
|
-
sPath = oListBinding.isRelative() ? oListBinding.getResolvedPath() : oListBinding.getPath(),
|
|
1464
|
-
oEntitySetContext = oMetaModel.createBindingContext(sPath),
|
|
1396
|
+
oAppComponent = this._getAppComponent(),
|
|
1397
|
+
sPath = (oListBinding.isRelative() ? oListBinding.getResolvedPath() : oListBinding.getPath()) as string,
|
|
1398
|
+
oEntitySetContext = oMetaModel.createBindingContext(sPath) as Context,
|
|
1465
1399
|
sMetaPath = oMetaModel.getMetaPath(sPath);
|
|
1466
1400
|
for (const i in mFields) {
|
|
1467
1401
|
aImmutableFields.push(oMetaModel.createBindingContext(`${sMetaPath}/${mFields[i]}`));
|
|
@@ -1471,243 +1405,249 @@ class TransactionHelper {
|
|
|
1471
1405
|
const aRequiredProperties = CommonUtils.getRequiredPropertiesFromInsertRestrictions(sMetaPath, oMetaModel);
|
|
1472
1406
|
const oRequiredPropertyPathsCtxModel = new JSONModel(aRequiredProperties);
|
|
1473
1407
|
const oRequiredPropertyPathsCtx = oRequiredPropertyPathsCtxModel.createBindingContext("/") as Context;
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
{
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
requiredProperties: oRequiredPropertyPathsCtxModel
|
|
1489
|
-
}
|
|
1408
|
+
const oNewFragment = await XMLPreprocessor.process(
|
|
1409
|
+
oFragment,
|
|
1410
|
+
{ name: sFragmentName },
|
|
1411
|
+
{
|
|
1412
|
+
bindingContexts: {
|
|
1413
|
+
entitySet: oEntitySetContext,
|
|
1414
|
+
fields: oImmutableCtx,
|
|
1415
|
+
requiredProperties: oRequiredPropertyPathsCtx
|
|
1416
|
+
},
|
|
1417
|
+
models: {
|
|
1418
|
+
entitySet: oEntitySetContext.getModel(),
|
|
1419
|
+
fields: oImmutableCtx.getModel(),
|
|
1420
|
+
metaModel: oMetaModel,
|
|
1421
|
+
requiredProperties: oRequiredPropertyPathsCtxModel
|
|
1490
1422
|
}
|
|
1491
|
-
|
|
1492
|
-
)
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1423
|
+
}
|
|
1424
|
+
);
|
|
1425
|
+
|
|
1426
|
+
let aFormElements: any[] = [];
|
|
1427
|
+
const mFieldValueMap: any = {};
|
|
1428
|
+
// eslint-disable-next-line prefer-const
|
|
1429
|
+
let oCreateButton: Button;
|
|
1430
|
+
|
|
1431
|
+
const validateRequiredProperties = async function () {
|
|
1432
|
+
let bEnabled = false;
|
|
1433
|
+
try {
|
|
1434
|
+
const aResults = await Promise.all(
|
|
1498
1435
|
aFormElements
|
|
1499
1436
|
.map(function (oFormElement: any) {
|
|
1500
1437
|
return oFormElement.getFields()[0];
|
|
1501
1438
|
})
|
|
1502
1439
|
.filter(function (oField: any) {
|
|
1503
|
-
// The continue button should remain disabled in case of
|
|
1504
|
-
return oField.getRequired() ||
|
|
1440
|
+
// The continue button should remain disabled in case of empty required fields.
|
|
1441
|
+
return oField.getRequired() || oField.getValueState() === ValueState.Error;
|
|
1505
1442
|
})
|
|
1506
|
-
.map(function (oField: any) {
|
|
1443
|
+
.map(async function (oField: any) {
|
|
1507
1444
|
const sFieldId = oField.getId();
|
|
1508
1445
|
if (sFieldId in mFieldValueMap) {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
});
|
|
1446
|
+
try {
|
|
1447
|
+
const vValue = await mFieldValueMap[sFieldId];
|
|
1448
|
+
return oField.getValue() === "" ? undefined : vValue;
|
|
1449
|
+
} catch (err) {
|
|
1450
|
+
return undefined;
|
|
1451
|
+
}
|
|
1516
1452
|
}
|
|
1517
|
-
return oField.
|
|
1453
|
+
return oField.getValue() === "" ? undefined : oField.getValue();
|
|
1518
1454
|
})
|
|
1519
|
-
)
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
createParameters: aValues
|
|
1585
|
-
});
|
|
1586
|
-
} else {
|
|
1587
|
-
onBeforeCreatePromise = Promise.resolve();
|
|
1588
|
-
}
|
|
1589
|
-
return onBeforeCreatePromise;
|
|
1590
|
-
})
|
|
1591
|
-
.then(function () {
|
|
1592
|
-
const oPromise = that.onAfterCreateCompletion(
|
|
1593
|
-
oTransientListBinding,
|
|
1594
|
-
oTransientContext,
|
|
1595
|
-
mParameters
|
|
1596
|
-
);
|
|
1597
|
-
oModel.submitBatch("submitLater");
|
|
1598
|
-
return oPromise;
|
|
1599
|
-
})
|
|
1600
|
-
.then(function (oResponse: any) {
|
|
1601
|
-
if (!oResponse || (oResponse && oResponse.bKeepDialogOpen !== true)) {
|
|
1602
|
-
oDialog.setBindingContext(null as any);
|
|
1603
|
-
oDialog.close();
|
|
1604
|
-
resolve(oResponse);
|
|
1605
|
-
}
|
|
1606
|
-
})
|
|
1607
|
-
.catch(function (oError: any) {
|
|
1608
|
-
reject(oError);
|
|
1455
|
+
);
|
|
1456
|
+
bEnabled = aResults.every(function (vValue: any) {
|
|
1457
|
+
if (Array.isArray(vValue)) {
|
|
1458
|
+
vValue = vValue[0];
|
|
1459
|
+
}
|
|
1460
|
+
return vValue !== undefined && vValue !== null && vValue !== "";
|
|
1461
|
+
});
|
|
1462
|
+
} catch (err) {
|
|
1463
|
+
bEnabled = false;
|
|
1464
|
+
}
|
|
1465
|
+
oCreateButton.setEnabled(bEnabled);
|
|
1466
|
+
};
|
|
1467
|
+
const oController = {
|
|
1468
|
+
/*
|
|
1469
|
+
fired on focus out from field or on selecting a value from the valuehelp.
|
|
1470
|
+
the create button is enabled when a value is added.
|
|
1471
|
+
liveChange is not fired when value is added from valuehelp.
|
|
1472
|
+
value validation is not done for create button enablement.
|
|
1473
|
+
*/
|
|
1474
|
+
handleChange: (oEvent: any) => {
|
|
1475
|
+
const sFieldId = oEvent.getParameter("id");
|
|
1476
|
+
mFieldValueMap[sFieldId] = this._onFieldChange(oEvent, oCreateButton, messageHandler, validateRequiredProperties);
|
|
1477
|
+
},
|
|
1478
|
+
/*
|
|
1479
|
+
fired on key press. the create button is enabled when a value is added.
|
|
1480
|
+
liveChange is not fired when value is added from valuehelp.
|
|
1481
|
+
value validation is not done for create button enablement.
|
|
1482
|
+
*/
|
|
1483
|
+
handleLiveChange: (oEvent: any) => {
|
|
1484
|
+
const sFieldId = oEvent.getParameter("id");
|
|
1485
|
+
const vValue = oEvent.getParameter("value");
|
|
1486
|
+
mFieldValueMap[sFieldId] = vValue;
|
|
1487
|
+
validateRequiredProperties();
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
const oDialogContent: any = await Fragment.load({
|
|
1492
|
+
definition: oNewFragment,
|
|
1493
|
+
controller: oController
|
|
1494
|
+
});
|
|
1495
|
+
oDialog = new Dialog({
|
|
1496
|
+
title: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE", oResourceBundle),
|
|
1497
|
+
content: [oDialogContent],
|
|
1498
|
+
beginButton: {
|
|
1499
|
+
text: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE_BUTTON", oResourceBundle),
|
|
1500
|
+
type: "Emphasized",
|
|
1501
|
+
press: async (oEvent: any) => {
|
|
1502
|
+
const createButton = oEvent.getSource();
|
|
1503
|
+
createButton.setEnabled(false);
|
|
1504
|
+
BusyLocker.lock(oDialog);
|
|
1505
|
+
mParameters.bIsCreateDialog = true;
|
|
1506
|
+
try {
|
|
1507
|
+
const aValues = await Promise.all(
|
|
1508
|
+
Object.keys(mFieldValueMap).map(async function (sKey: string) {
|
|
1509
|
+
const oValue = await mFieldValueMap[sKey];
|
|
1510
|
+
const oDialogValue: any = {};
|
|
1511
|
+
oDialogValue[sKey] = oValue;
|
|
1512
|
+
return oDialogValue;
|
|
1513
|
+
})
|
|
1514
|
+
);
|
|
1515
|
+
if (mParameters.beforeCreateCallBack) {
|
|
1516
|
+
await toES6Promise(
|
|
1517
|
+
mParameters.beforeCreateCallBack({
|
|
1518
|
+
contextPath: oListBinding && oListBinding.getPath(),
|
|
1519
|
+
createParameters: aValues
|
|
1609
1520
|
})
|
|
1610
|
-
|
|
1611
|
-
BusyLocker.unlock(oDialog);
|
|
1612
|
-
createButton.setEnabled(true);
|
|
1613
|
-
messageHandler.showMessages();
|
|
1614
|
-
});
|
|
1521
|
+
);
|
|
1615
1522
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1523
|
+
const transientData = oTransientContext.getObject();
|
|
1524
|
+
const createData: any = {};
|
|
1525
|
+
Object.keys(transientData).forEach(function (sPropertyPath: string) {
|
|
1526
|
+
const oProperty = oMetaModel.getObject(`${sMetaPath}/${sPropertyPath}`);
|
|
1527
|
+
// ensure navigation properties are not part of the payload, deep create not supported
|
|
1528
|
+
if (oProperty && oProperty.$kind === "NavigationProperty") {
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
createData[sPropertyPath] = transientData[sPropertyPath];
|
|
1532
|
+
});
|
|
1533
|
+
const oNewDocumentContext = oListBinding.create(
|
|
1534
|
+
createData,
|
|
1535
|
+
true,
|
|
1536
|
+
mParameters.createAtEnd,
|
|
1537
|
+
mParameters.inactive
|
|
1538
|
+
);
|
|
1539
|
+
|
|
1540
|
+
const oPromise = this.onAfterCreateCompletion(oListBinding, oNewDocumentContext, mParameters);
|
|
1541
|
+
let oResponse: any = await oPromise;
|
|
1542
|
+
if (!oResponse || (oResponse && oResponse.bKeepDialogOpen !== true)) {
|
|
1543
|
+
oResponse = oResponse ?? {};
|
|
1544
|
+
oDialog.setBindingContext(null as any);
|
|
1620
1545
|
oDialog.close();
|
|
1546
|
+
oResponse.newContext = oNewDocumentContext;
|
|
1547
|
+
resolve(oResponse);
|
|
1621
1548
|
}
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
(oDialog
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
reject({
|
|
1629
|
-
bDeleteTransientContext: true,
|
|
1630
|
-
navigateBackFromTransientState: true
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1549
|
+
} catch (oError: any) {
|
|
1550
|
+
reject(oError);
|
|
1551
|
+
} finally {
|
|
1552
|
+
BusyLocker.unlock(oDialog);
|
|
1553
|
+
createButton.setEnabled(true);
|
|
1554
|
+
messageHandler.showMessages();
|
|
1633
1555
|
}
|
|
1634
|
-
} as any);
|
|
1635
|
-
aFormElements = oDialogContent
|
|
1636
|
-
.getAggregation("form")
|
|
1637
|
-
.getAggregation("formContainers")[0]
|
|
1638
|
-
.getAggregation("formElements");
|
|
1639
|
-
if (oParentControl && oParentControl.addDependent) {
|
|
1640
|
-
// if there is a parent control specified add the dialog as dependent
|
|
1641
|
-
oParentControl.addDependent(oDialog);
|
|
1642
1556
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
)
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
.catch(function (oError: any) {
|
|
1660
|
-
return messageHandler.showMessages().then(function () {
|
|
1661
|
-
return Promise.reject(oError);
|
|
1662
|
-
});
|
|
1557
|
+
},
|
|
1558
|
+
endButton: {
|
|
1559
|
+
text: CommonUtils.getTranslatedText("C_COMMON_ACTION_PARAMETER_DIALOG_CANCEL", oResourceBundle),
|
|
1560
|
+
press: function () {
|
|
1561
|
+
oDialog.close();
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
afterClose: function () {
|
|
1565
|
+
// show footer as per UX guidelines when dialog is not open
|
|
1566
|
+
(oDialog.getBindingContext("internal") as InternalModelContext)?.setProperty("isCreateDialogOpen", false);
|
|
1567
|
+
oDialog.destroy();
|
|
1568
|
+
oTransientListBinding.destroy();
|
|
1569
|
+
if (!bSuccess) {
|
|
1570
|
+
reject({
|
|
1571
|
+
bDeleteTransientContext: true,
|
|
1572
|
+
navigateBackFromTransientState: true
|
|
1663
1573
|
});
|
|
1664
|
-
|
|
1665
|
-
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
} as any);
|
|
1577
|
+
aFormElements = oDialogContent?.getAggregation("form").getAggregation("formContainers")[0].getAggregation("formElements");
|
|
1578
|
+
if (oParentControl && oParentControl.addDependent) {
|
|
1579
|
+
// if there is a parent control specified add the dialog as dependent
|
|
1580
|
+
oParentControl.addDependent(oDialog);
|
|
1581
|
+
}
|
|
1582
|
+
oCreateButton = oDialog.getBeginButton();
|
|
1583
|
+
oDialog.setBindingContext(oTransientContext);
|
|
1584
|
+
try {
|
|
1585
|
+
await CommonUtils.setUserDefaults(
|
|
1586
|
+
oAppComponent,
|
|
1587
|
+
aImmutableFields,
|
|
1588
|
+
oTransientContext,
|
|
1589
|
+
false,
|
|
1590
|
+
mParameters.createAction,
|
|
1591
|
+
mParameters.data
|
|
1592
|
+
);
|
|
1593
|
+
validateRequiredProperties();
|
|
1594
|
+
// footer must not be visible when the dialog is open as per UX guidelines
|
|
1595
|
+
(oDialog.getBindingContext("internal") as InternalModelContext).setProperty("isCreateDialogOpen", true);
|
|
1596
|
+
oDialog.open();
|
|
1597
|
+
} catch (oError: any) {
|
|
1598
|
+
await messageHandler.showMessages();
|
|
1599
|
+
throw oError;
|
|
1600
|
+
}
|
|
1666
1601
|
});
|
|
1667
1602
|
}
|
|
1668
1603
|
onAfterCreateCompletion(oListBinding: any, oNewDocumentContext: any, mParameters: any) {
|
|
1669
|
-
let fnResolve: Function
|
|
1670
|
-
const oPromise = new Promise(
|
|
1604
|
+
let fnResolve: Function;
|
|
1605
|
+
const oPromise = new Promise<boolean>((resolve) => {
|
|
1671
1606
|
fnResolve = resolve;
|
|
1672
|
-
fnReject = reject;
|
|
1673
1607
|
});
|
|
1674
|
-
|
|
1675
|
-
const
|
|
1676
|
-
// Workaround suggested by OData model v4 colleagues
|
|
1677
|
-
const fnCreateCompleted = function (oEvent: any) {
|
|
1608
|
+
|
|
1609
|
+
const fnCreateCompleted = (oEvent: any) => {
|
|
1678
1610
|
const oContext = oEvent.getParameter("context"),
|
|
1679
1611
|
bSuccess = oEvent.getParameter("success");
|
|
1680
1612
|
if (oContext === oNewDocumentContext) {
|
|
1681
|
-
oListBinding.detachCreateCompleted(fnCreateCompleted,
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1613
|
+
oListBinding.detachCreateCompleted(fnCreateCompleted, this);
|
|
1614
|
+
fnResolve(bSuccess);
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
const fnSafeContextCreated = () => {
|
|
1618
|
+
oNewDocumentContext
|
|
1619
|
+
.created()
|
|
1620
|
+
.then(undefined, function () {
|
|
1621
|
+
Log.trace("transient creation context deleted");
|
|
1622
|
+
})
|
|
1623
|
+
.catch(function (contextError: any) {
|
|
1624
|
+
Log.trace("transient creation context deletion error", contextError);
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1686
1627
|
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1628
|
+
oListBinding.attachCreateCompleted(fnCreateCompleted, this);
|
|
1629
|
+
|
|
1630
|
+
return oPromise.then((bSuccess: boolean) => {
|
|
1631
|
+
if (!bSuccess) {
|
|
1632
|
+
const oError: any = { bDeleteTransientContext: false };
|
|
1633
|
+
if (!mParameters.keepTransientContextOnFailed) {
|
|
1634
|
+
// Cancel the pending POST and delete the context in the listBinding
|
|
1635
|
+
fnSafeContextCreated(); // To avoid a 'request cancelled' error in the console
|
|
1636
|
+
oListBinding.resetChanges();
|
|
1637
|
+
oListBinding.getModel().resetChanges(oListBinding.getUpdateGroupId());
|
|
1638
|
+
|
|
1639
|
+
if (!mParameters.bIsCreateDialog) {
|
|
1640
|
+
// if current state is transient (...), browser will come back to previous state
|
|
1641
|
+
oError.navigateBackFromTransientState = true;
|
|
1642
|
+
oError.bDeleteTransientContext = true;
|
|
1643
|
+
throw oError;
|
|
1702
1644
|
}
|
|
1703
|
-
fnResolve({ bKeepDialogOpen: true });
|
|
1704
|
-
} else {
|
|
1705
|
-
return oContext.created().then(fnResolve);
|
|
1706
1645
|
}
|
|
1646
|
+
return { bKeepDialogOpen: true };
|
|
1647
|
+
} else {
|
|
1648
|
+
return oNewDocumentContext.created();
|
|
1707
1649
|
}
|
|
1708
|
-
};
|
|
1709
|
-
oListBinding.attachCreateCompleted(fnCreateCompleted, this);
|
|
1710
|
-
return oPromise;
|
|
1650
|
+
});
|
|
1711
1651
|
}
|
|
1712
1652
|
/**
|
|
1713
1653
|
* Retrieves the name of the NewAction to be executed.
|