@sapui5/sap.fe.core 1.97.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 +7 -4
- package/src/sap/fe/core/.library +1 -1
- package/src/sap/fe/core/AnnotationHelper.js +309 -405
- package/src/sap/fe/core/AnnotationHelper.ts +315 -0
- package/src/sap/fe/core/AppComponent.js +389 -397
- package/src/sap/fe/core/AppComponent.ts +403 -0
- package/src/sap/fe/core/AppStateHandler.js +198 -181
- package/src/sap/fe/core/AppStateHandler.ts +171 -0
- package/src/sap/fe/core/BaseController.js +83 -58
- package/src/sap/fe/core/BaseController.ts +68 -0
- package/src/sap/fe/core/BusyLocker.js +105 -121
- package/src/sap/fe/core/BusyLocker.ts +98 -0
- package/src/sap/fe/core/CommonUtils.js +2164 -2379
- package/src/sap/fe/core/CommonUtils.ts +2177 -0
- package/src/sap/fe/core/ExtensionAPI.js +279 -266
- package/src/sap/fe/core/ExtensionAPI.ts +250 -0
- package/src/sap/fe/core/PageController.js +218 -125
- package/src/sap/fe/core/PageController.ts +129 -0
- package/src/sap/fe/core/RouterProxy.js +924 -807
- package/src/sap/fe/core/RouterProxy.ts +840 -0
- package/src/sap/fe/core/Synchronization.js +41 -35
- package/src/sap/fe/core/Synchronization.ts +29 -0
- package/src/sap/fe/core/TemplateComponent.js +173 -155
- package/src/sap/fe/core/TemplateComponent.ts +173 -0
- package/src/sap/fe/core/TemplateModel.js +79 -54
- package/src/sap/fe/core/TemplateModel.ts +63 -0
- package/src/sap/fe/core/TransactionHelper.js +1560 -1579
- package/src/sap/fe/core/TransactionHelper.ts +1717 -0
- 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 +521 -581
- package/src/sap/fe/core/actions/draft.ts +566 -0
- package/src/sap/fe/core/actions/messageHandling.js +564 -511
- package/src/sap/fe/core/actions/messageHandling.ts +552 -0
- package/src/sap/fe/core/actions/nonDraft.js +17 -19
- package/src/sap/fe/core/actions/nonDraft.ts +12 -0
- package/src/sap/fe/core/actions/operations.js +1093 -1211
- package/src/sap/fe/core/actions/operations.ts +1192 -0
- package/src/sap/fe/core/actions/sticky.js +114 -104
- package/src/sap/fe/core/actions/sticky.ts +119 -0
- package/src/sap/fe/core/controllerextensions/ControllerExtensionMetadata.js +70 -66
- package/src/sap/fe/core/controllerextensions/ControllerExtensionMetadata.ts +65 -0
- package/src/sap/fe/core/controllerextensions/EditFlow.js +1594 -1701
- package/src/sap/fe/core/controllerextensions/EditFlow.ts +1672 -0
- package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.js +80 -54
- package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.ts +61 -0
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.js +719 -505
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.ts +783 -0
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +797 -813
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +803 -0
- package/src/sap/fe/core/controllerextensions/InternalRouting.js +1005 -973
- package/src/sap/fe/core/controllerextensions/InternalRouting.ts +978 -0
- package/src/sap/fe/core/controllerextensions/KPIManagement.js +530 -476
- package/src/sap/fe/core/controllerextensions/KPIManagement.ts +137 -46
- package/src/sap/fe/core/controllerextensions/MassEdit.js +144 -0
- package/src/sap/fe/core/controllerextensions/MassEdit.ts +156 -0
- package/src/sap/fe/core/controllerextensions/MessageHandler.js +234 -232
- package/src/sap/fe/core/controllerextensions/MessageHandler.ts +225 -0
- package/src/sap/fe/core/controllerextensions/PageReady.js +302 -337
- package/src/sap/fe/core/controllerextensions/PageReady.ts +23 -17
- package/src/sap/fe/core/controllerextensions/Paginator.js +189 -148
- package/src/sap/fe/core/controllerextensions/Paginator.ts +163 -0
- package/src/sap/fe/core/controllerextensions/Placeholder.js +158 -146
- package/src/sap/fe/core/controllerextensions/Placeholder.ts +151 -0
- package/src/sap/fe/core/controllerextensions/Routing.js +145 -106
- package/src/sap/fe/core/controllerextensions/Routing.ts +132 -0
- package/src/sap/fe/core/controllerextensions/RoutingListener.js +8 -6
- package/src/sap/fe/core/controllerextensions/RoutingListener.ts +3 -0
- package/src/sap/fe/core/controllerextensions/Share.js +220 -244
- package/src/sap/fe/core/controllerextensions/Share.ts +231 -0
- package/src/sap/fe/core/controllerextensions/SideEffects.js +593 -634
- package/src/sap/fe/core/controllerextensions/SideEffects.ts +29 -27
- package/src/sap/fe/core/controllerextensions/ViewState.js +789 -806
- package/src/sap/fe/core/controllerextensions/ViewState.ts +805 -0
- package/src/sap/fe/core/controls/ActionParameterDialog.fragment.xml +4 -3
- package/src/sap/fe/core/controls/ActionPartial.fragment.xml +2 -2
- package/src/sap/fe/core/controls/CommandExecution.js +68 -66
- package/src/sap/fe/core/controls/CommandExecution.ts +72 -0
- package/src/sap/fe/core/controls/ConditionalWrapper.js +91 -75
- package/src/sap/fe/core/controls/ConditionalWrapper.ts +83 -0
- package/src/sap/fe/core/controls/CustomQuickViewPage.js +131 -125
- package/src/sap/fe/core/controls/CustomQuickViewPage.ts +126 -0
- package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.js +105 -110
- package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.ts +101 -0
- package/src/sap/fe/core/controls/FieldWrapper.js +122 -140
- package/src/sap/fe/core/controls/FieldWrapper.ts +115 -0
- package/src/sap/fe/core/controls/FilterBar.js +163 -159
- package/src/sap/fe/core/controls/FilterBar.ts +143 -0
- package/src/sap/fe/core/controls/FormElementWrapper.js +46 -44
- package/src/sap/fe/core/controls/FormElementWrapper.ts +40 -0
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.js +38 -42
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.ts +31 -0
- package/src/sap/fe/core/controls/NonComputedVisibleKeyFieldsDialog.fragment.xml +2 -1
- package/src/sap/fe/core/controls/filterbar/FilterContainer.js +127 -116
- package/src/sap/fe/core/controls/filterbar/FilterContainer.ts +98 -0
- package/src/sap/fe/core/controls/filterbar/VisualFilter.js +242 -255
- package/src/sap/fe/core/controls/filterbar/VisualFilter.ts +245 -0
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.js +151 -141
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.ts +125 -0
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.js +336 -322
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.ts +337 -0
- package/src/sap/fe/core/controls/massEdit/MassEditDialog.fragment.xml +106 -0
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.js +79 -0
- package/src/sap/fe/core/controls/massEdit/MassEditHandlers.ts +70 -0
- package/src/sap/fe/core/converters/ConverterContext.js +348 -367
- package/src/sap/fe/core/converters/ConverterContext.ts +33 -19
- package/src/sap/fe/core/converters/ManifestSettings.js +12 -1
- package/src/sap/fe/core/converters/ManifestSettings.ts +16 -1
- package/src/sap/fe/core/converters/ManifestWrapper.js +354 -354
- package/src/sap/fe/core/converters/ManifestWrapper.ts +34 -6
- package/src/sap/fe/core/converters/MetaModelConverter.js +72 -9
- package/src/sap/fe/core/converters/MetaModelConverter.ts +75 -16
- package/src/sap/fe/core/converters/TemplateConverter.js +1 -1
- package/src/sap/fe/core/converters/TemplateConverter.ts +4 -3
- package/src/sap/fe/core/converters/annotations/DataField.js +28 -14
- package/src/sap/fe/core/converters/annotations/DataField.ts +38 -14
- package/src/sap/fe/core/converters/common/AnnotationConverter.js +33 -21
- package/src/sap/fe/core/converters/controls/Common/Action.js +11 -2
- package/src/sap/fe/core/converters/controls/Common/Action.ts +8 -2
- package/src/sap/fe/core/converters/controls/Common/Chart.js +5 -3
- package/src/sap/fe/core/converters/controls/Common/Chart.ts +11 -3
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.js +3 -3
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.ts +2 -2
- package/src/sap/fe/core/converters/controls/Common/Form.js +21 -11
- package/src/sap/fe/core/converters/controls/Common/Form.ts +28 -6
- package/src/sap/fe/core/converters/controls/Common/KPI.js +69 -4
- package/src/sap/fe/core/converters/controls/Common/KPI.ts +75 -2
- package/src/sap/fe/core/converters/controls/Common/Table.js +507 -408
- package/src/sap/fe/core/converters/controls/Common/Table.ts +618 -500
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.js +592 -0
- package/src/sap/fe/core/converters/controls/Common/table/StandardActions.ts +718 -0
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.js +465 -59
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.ts +462 -72
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.js +2 -2
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.ts +1 -1
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +17 -9
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +24 -9
- package/src/sap/fe/core/converters/helpers/Aggregation.js +118 -121
- package/src/sap/fe/core/converters/helpers/Aggregation.ts +28 -5
- 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/IssueManager.js +7 -1
- package/src/sap/fe/core/converters/helpers/IssueManager.ts +6 -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 +28 -7
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.ts +23 -6
- package/src/sap/fe/core/converters/templates/ListReportConverter.js +20 -7
- package/src/sap/fe/core/converters/templates/ListReportConverter.ts +36 -14
- 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 +93 -90
- 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/CriticalityFormatter.js +1 -1
- package/src/sap/fe/core/formatters/CriticalityFormatter.ts +1 -1
- package/src/sap/fe/core/formatters/FPMFormatter.js +1 -1
- package/src/sap/fe/core/formatters/FPMFormatter.ts +4 -10
- package/src/sap/fe/core/formatters/KPIFormatter.js +1 -1
- package/src/sap/fe/core/formatters/KPIFormatter.ts +3 -1
- package/src/sap/fe/core/formatters/TableFormatter.js +91 -29
- package/src/sap/fe/core/formatters/TableFormatter.ts +94 -28
- package/src/sap/fe/core/formatters/ValueFormatter.js +30 -5
- package/src/sap/fe/core/formatters/ValueFormatter.ts +30 -7
- package/src/sap/fe/core/fpm/Component.js +51 -54
- package/src/sap/fe/core/fpm/Component.ts +48 -0
- package/src/sap/fe/core/helpers/AppStartupHelper.js +373 -0
- package/src/sap/fe/core/helpers/AppStartupHelper.ts +417 -0
- package/src/sap/fe/core/helpers/BindingExpression.js +489 -442
- package/src/sap/fe/core/helpers/BindingExpression.ts +486 -469
- package/src/sap/fe/core/helpers/ClassSupport.js +212 -76
- package/src/sap/fe/core/helpers/ClassSupport.ts +198 -71
- package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.js +64 -59
- package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.ts +52 -0
- package/src/sap/fe/core/helpers/EditState.js +81 -84
- package/src/sap/fe/core/helpers/EditState.ts +81 -0
- package/src/sap/fe/core/helpers/ExcelFormatHelper.js +62 -48
- package/src/sap/fe/core/helpers/ExcelFormatHelper.ts +49 -0
- package/src/sap/fe/core/helpers/FPMHelper.js +52 -56
- package/src/sap/fe/core/helpers/FPMHelper.ts +62 -0
- package/src/sap/fe/core/helpers/KeepAliveHelper.js +4 -5
- package/src/sap/fe/core/helpers/KeepAliveHelper.ts +10 -10
- package/src/sap/fe/core/helpers/MassEditHelper.js +604 -0
- package/src/sap/fe/core/helpers/MassEditHelper.ts +699 -0
- package/src/sap/fe/core/helpers/ModelHelper.js +253 -225
- package/src/sap/fe/core/helpers/ModelHelper.ts +250 -0
- package/src/sap/fe/core/helpers/PasteHelper.js +210 -132
- package/src/sap/fe/core/helpers/PasteHelper.ts +196 -0
- package/src/sap/fe/core/helpers/SemanticDateOperators.js +336 -313
- package/src/sap/fe/core/helpers/SemanticDateOperators.ts +334 -0
- package/src/sap/fe/core/helpers/SemanticKeyHelper.js +66 -67
- package/src/sap/fe/core/helpers/SemanticKeyHelper.ts +73 -0
- package/src/sap/fe/core/helpers/StableIdHelper.js +4 -7
- package/src/sap/fe/core/helpers/StableIdHelper.ts +2 -6
- package/src/sap/fe/core/jsx-runtime/jsx.js +1 -1
- package/src/sap/fe/core/jsx-runtime/jsx.ts +1 -1
- package/src/sap/fe/core/library.js +427 -425
- package/src/sap/fe/core/library.support.js +23 -27
- 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 +64 -0
- package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.ts +69 -0
- package/src/sap/fe/core/messagebundle.properties +78 -13
- package/src/sap/fe/core/messagebundle_ar.properties +58 -7
- package/src/sap/fe/core/messagebundle_bg.properties +58 -7
- package/src/sap/fe/core/messagebundle_ca.properties +58 -7
- package/src/sap/fe/core/messagebundle_cs.properties +59 -8
- package/src/sap/fe/core/messagebundle_cy.properties +58 -7
- package/src/sap/fe/core/messagebundle_da.properties +58 -7
- package/src/sap/fe/core/messagebundle_de.properties +58 -7
- package/src/sap/fe/core/messagebundle_el.properties +58 -7
- package/src/sap/fe/core/messagebundle_en.properties +57 -6
- package/src/sap/fe/core/messagebundle_en_GB.properties +57 -6
- package/src/sap/fe/core/messagebundle_en_US_sappsd.properties +61 -6
- package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +58 -7
- package/src/sap/fe/core/messagebundle_en_US_saptrc.properties +58 -7
- package/src/sap/fe/core/messagebundle_es.properties +58 -7
- package/src/sap/fe/core/messagebundle_es_MX.properties +58 -7
- package/src/sap/fe/core/messagebundle_et.properties +58 -7
- package/src/sap/fe/core/messagebundle_fi.properties +60 -9
- package/src/sap/fe/core/messagebundle_fr.properties +64 -13
- package/src/sap/fe/core/messagebundle_fr_CA.properties +59 -8
- package/src/sap/fe/core/messagebundle_hi.properties +58 -7
- package/src/sap/fe/core/messagebundle_hr.properties +58 -7
- package/src/sap/fe/core/messagebundle_hu.properties +59 -8
- package/src/sap/fe/core/messagebundle_id.properties +61 -10
- package/src/sap/fe/core/messagebundle_it.properties +58 -7
- package/src/sap/fe/core/messagebundle_iw.properties +58 -7
- package/src/sap/fe/core/messagebundle_ja.properties +58 -7
- package/src/sap/fe/core/messagebundle_kk.properties +58 -7
- package/src/sap/fe/core/messagebundle_ko.properties +58 -7
- package/src/sap/fe/core/messagebundle_lt.properties +58 -7
- package/src/sap/fe/core/messagebundle_lv.properties +59 -8
- package/src/sap/fe/core/messagebundle_ms.properties +58 -7
- package/src/sap/fe/core/messagebundle_nl.properties +58 -7
- package/src/sap/fe/core/messagebundle_no.properties +58 -7
- package/src/sap/fe/core/messagebundle_pl.properties +58 -7
- package/src/sap/fe/core/messagebundle_pt.properties +59 -8
- package/src/sap/fe/core/messagebundle_pt_PT.properties +58 -7
- package/src/sap/fe/core/messagebundle_ro.properties +58 -7
- package/src/sap/fe/core/messagebundle_ru.properties +58 -7
- package/src/sap/fe/core/messagebundle_sh.properties +58 -7
- package/src/sap/fe/core/messagebundle_sk.properties +58 -7
- package/src/sap/fe/core/messagebundle_sl.properties +58 -7
- package/src/sap/fe/core/messagebundle_sv.properties +59 -8
- package/src/sap/fe/core/messagebundle_th.properties +58 -7
- package/src/sap/fe/core/messagebundle_tr.properties +60 -9
- package/src/sap/fe/core/messagebundle_uk.properties +58 -7
- package/src/sap/fe/core/messagebundle_vi.properties +58 -7
- package/src/sap/fe/core/messagebundle_zh_CN.properties +58 -7
- package/src/sap/fe/core/messagebundle_zh_TW.properties +58 -7
- package/src/sap/fe/core/services/AsyncComponentServiceFactory.js +45 -71
- package/src/sap/fe/core/services/AsyncComponentServiceFactory.ts +3 -1
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.js +231 -202
- package/src/sap/fe/core/services/CacheHandlerServiceFactory.ts +212 -0
- package/src/sap/fe/core/services/EnvironmentServiceFactory.js +67 -92
- package/src/sap/fe/core/services/EnvironmentServiceFactory.ts +10 -6
- package/src/sap/fe/core/services/NavigationServiceFactory.js +351 -300
- package/src/sap/fe/core/services/NavigationServiceFactory.ts +313 -0
- package/src/sap/fe/core/services/ResourceModelServiceFactory.js +114 -81
- package/src/sap/fe/core/services/ResourceModelServiceFactory.ts +83 -0
- package/src/sap/fe/core/services/RoutingServiceFactory.js +927 -1152
- package/src/sap/fe/core/services/RoutingServiceFactory.ts +898 -0
- package/src/sap/fe/core/services/ShellServicesFactory.js +649 -707
- package/src/sap/fe/core/services/ShellServicesFactory.ts +52 -15
- package/src/sap/fe/core/services/SideEffectsServiceFactory.js +569 -637
- package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +78 -102
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.js +429 -478
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.ts +460 -0
- package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.js +10 -8
- package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.ts +8 -0
- package/src/sap/fe/core/support/AnnotationIssue.support.js +15 -3
- package/src/sap/fe/core/support/AnnotationIssue.support.ts +16 -2
- package/src/sap/fe/core/support/CollectionFacetUnsupportedLevel.support.js +2 -2
- package/src/sap/fe/core/support/CollectionFacetUnsupportedLevel.support.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/support/InvalidAnnotationColumnKey.support.js +38 -0
- package/src/sap/fe/core/support/InvalidAnnotationColumnKey.support.ts +18 -0
- package/src/sap/fe/core/templating/DataModelPathHelper.js +97 -127
- package/src/sap/fe/core/templating/DataModelPathHelper.ts +112 -135
- package/src/sap/fe/core/templating/DisplayModeFormatter.js +114 -0
- package/src/sap/fe/core/templating/DisplayModeFormatter.ts +86 -0
- package/src/sap/fe/core/templating/FieldControlHelper.js +8 -8
- package/src/sap/fe/core/templating/FieldControlHelper.ts +25 -7
- package/src/sap/fe/core/templating/FilterHelper.js +140 -78
- package/src/sap/fe/core/templating/FilterHelper.ts +149 -78
- package/src/sap/fe/core/templating/PropertyHelper.js +3 -3
- package/src/sap/fe/core/templating/PropertyHelper.ts +2 -2
- package/src/sap/fe/core/templating/UIFormatters.js +76 -135
- package/src/sap/fe/core/templating/UIFormatters.ts +76 -99
- package/src/sap/fe/core/type/Email.js +1 -1
- package/src/sap/fe/core/type/Email.ts +4 -6
- package/ui5.yaml +0 -3
- package/src/sap/fe/core/controls/filterbar.d.js +0 -8
- package/src/sap/fe/core/controls/filterbar.d.ts +0 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import Dialog from "sap/m/Dialog";
|
|
2
|
+
import Button from "sap/m/Button";
|
|
3
|
+
import Text from "sap/m/Text";
|
|
4
|
+
import MessageBox from "sap/m/MessageBox";
|
|
5
|
+
import messageHandling from "sap/fe/core/actions/messageHandling";
|
|
6
|
+
import CommonUtils from "sap/fe/core/CommonUtils";
|
|
7
|
+
import Log from "sap/base/Log";
|
|
8
|
+
import AppComponent from "sap/fe/core/AppComponent";
|
|
9
|
+
import { SideEffectsService } from "sap/fe/core/services/SideEffectsServiceFactory";
|
|
10
|
+
import ResourceBundle from "sap/base/i18n/ResourceBundle";
|
|
11
|
+
import View from "sap/ui/core/mvc/View";
|
|
12
|
+
import Context from "sap/ui/model/odata/v4/Context";
|
|
13
|
+
import ODataMetaModel from "sap/ui/model/odata/v4/ODataMetaModel";
|
|
14
|
+
import ResourceModel from "sap/ui/model/resource/ResourceModel";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Interface for callbacks used in the functions
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @author SAP SE
|
|
21
|
+
* @since 1.54.0
|
|
22
|
+
* @interface
|
|
23
|
+
* @name sap.fe.core.actions.draft.ICallback
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Callback to approve or reject the creation of a draft
|
|
29
|
+
* @name sap.fe.core.actions.draft.ICallback.beforeCreateDraftFromActiveDocument
|
|
30
|
+
* @function
|
|
31
|
+
* @static
|
|
32
|
+
* @abstract
|
|
33
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the active document for the new draft
|
|
34
|
+
* @returns {(boolean|Promise)} Approval of draft creation [true|false] or Promise that resolves with the boolean value
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Callback after a draft was successully created
|
|
41
|
+
* @name sap.fe.core.actions.draft.ICallback.afterCreateDraftFromActiveDocument
|
|
42
|
+
* @function
|
|
43
|
+
* @static
|
|
44
|
+
* @abstract
|
|
45
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the new draft
|
|
46
|
+
* @param {sap.ui.model.odata.v4.Context} oActiveDocumentContext Context of the active document for the new draft
|
|
47
|
+
* @returns {sap.ui.model.odata.v4.Context} oActiveDocumentContext
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Callback to approve or reject overwriting an unsaved draft of another user
|
|
54
|
+
* @name sap.fe.core.actions.draft.ICallback.whenDecisionToOverwriteDocumentIsRequired
|
|
55
|
+
* @function
|
|
56
|
+
* @public
|
|
57
|
+
* @static
|
|
58
|
+
* @abstract
|
|
59
|
+
*
|
|
60
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the active document for the new draft
|
|
61
|
+
* @returns {(boolean|Promise)} Approval to overwrite unsaved draft [true|false] or Promise that resolves with the boolean value
|
|
62
|
+
*
|
|
63
|
+
* @ui5-restricted
|
|
64
|
+
*/
|
|
65
|
+
/* Constants for draft operations */
|
|
66
|
+
const draftOperations = {
|
|
67
|
+
EDIT: "EditAction",
|
|
68
|
+
ACTIVATION: "ActivationAction",
|
|
69
|
+
DISCARD: "DiscardAction",
|
|
70
|
+
PREPARE: "PreparationAction"
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Static functions for the draft programming model
|
|
74
|
+
*
|
|
75
|
+
* @namespace
|
|
76
|
+
* @alias sap.fe.core.actions.draft
|
|
77
|
+
* @private
|
|
78
|
+
* @experimental This module is only for experimental use! <br/><b>This is only a POC and maybe deleted</b>
|
|
79
|
+
* @since 1.54.0
|
|
80
|
+
*/
|
|
81
|
+
const draft = {
|
|
82
|
+
createDraftFromActiveDocument: createDraftFromActiveDocument,
|
|
83
|
+
activateDocument: activateDocument,
|
|
84
|
+
deleteDraft: deleteDraft
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Determines action name for a draft operation.
|
|
88
|
+
*
|
|
89
|
+
* @param {sap.ui.model.odata.v4.Context} oContext The context that should be bound to the operation
|
|
90
|
+
* @param {string} sOperation The operation name
|
|
91
|
+
* @returns {string} The name of the draft operation
|
|
92
|
+
*/
|
|
93
|
+
function getActionName(oContext: any, sOperation: string) {
|
|
94
|
+
const oModel = oContext.getModel(),
|
|
95
|
+
oMetaModel = oModel.getMetaModel(),
|
|
96
|
+
sEntitySetPath = oMetaModel.getMetaPath(oContext.getPath());
|
|
97
|
+
|
|
98
|
+
return oMetaModel.getObject(sEntitySetPath + "@com.sap.vocabularies.Common.v1.DraftRoot/" + sOperation);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates an operation context binding for the given context and operation.
|
|
102
|
+
*
|
|
103
|
+
* @param {sap.ui.model.odata.v4.Context} oContext The context that should be bound to the operation
|
|
104
|
+
* @param {string} sOperation The operation (action or function import)
|
|
105
|
+
* @param oOptions Options to create the operation context
|
|
106
|
+
* @returns {sap.ui.model.odata.v4.ODataContextBinding} The context binding of the bound operation
|
|
107
|
+
*/
|
|
108
|
+
function createOperation(oContext: any, sOperation: string, oOptions?: any) {
|
|
109
|
+
const sOperationName = getActionName(oContext, sOperation);
|
|
110
|
+
|
|
111
|
+
return oContext.getModel().bindContext(sOperationName + "(...)", oContext, oOptions);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if optional draft prepare action exists.
|
|
115
|
+
*
|
|
116
|
+
* @param {sap.ui.model.odata.v4.Context} oContext The context that should be bound to the operation
|
|
117
|
+
* @returns {boolean} True if a a prepare action exists
|
|
118
|
+
*/
|
|
119
|
+
function hasPrepareAction(oContext: any) {
|
|
120
|
+
return !!getActionName(oContext, draftOperations.PREPARE);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Creates a new draft from an active document.
|
|
124
|
+
*
|
|
125
|
+
* @function
|
|
126
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the action should be performed
|
|
127
|
+
* @param {boolean} bPreserveChanges If true - existing changes from another user that are not locked are preserved and an error message (http status 409) is send from the backend, otherwise false - existing changes from another user that are not locked are overwritten</li>
|
|
128
|
+
* @returns {Promise.<sap.ui.model.odata.v4.Context>} Resolve function returns the context of the operation
|
|
129
|
+
* @private
|
|
130
|
+
* @ui5-restricted
|
|
131
|
+
*/
|
|
132
|
+
function executeDraftEditAction(oContext: any, bPreserveChanges: boolean) {
|
|
133
|
+
if (oContext.getProperty("IsActiveEntity")) {
|
|
134
|
+
const oOptions = { $$inheritExpandSelect: true };
|
|
135
|
+
const oOperation = createOperation(oContext, draftOperations.EDIT, oOptions);
|
|
136
|
+
oOperation.setParameter("PreserveChanges", bPreserveChanges);
|
|
137
|
+
const sGroupId = "direct";
|
|
138
|
+
const localI18nRef = sap.ui.getCore().getLibraryResourceBundle("sap.fe.core") as ResourceBundle;
|
|
139
|
+
const sActionName = localI18nRef.getText("C_COMMON_OBJECT_PAGE_EDIT");
|
|
140
|
+
const oEditPromise = oOperation
|
|
141
|
+
.execute(sGroupId, undefined, CommonUtils.fnOnStrictHandlingFailed.bind(draft, sGroupId, sActionName, oContext.getModel()))
|
|
142
|
+
.then(function(oDraftDocumentContext: any) {
|
|
143
|
+
return oDraftDocumentContext;
|
|
144
|
+
});
|
|
145
|
+
oOperation.getModel().submitBatch(sGroupId);
|
|
146
|
+
return oEditPromise;
|
|
147
|
+
} else {
|
|
148
|
+
throw new Error("You cannot edit this draft document");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Activates a draft document. The draft will replace the sibling entity and will be deleted by the back end.
|
|
154
|
+
*
|
|
155
|
+
* @function
|
|
156
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the action should be performed
|
|
157
|
+
* @param {object} oAppComponent The AppComponent
|
|
158
|
+
* @param {string} [sGroupId] The optional batch group in which the operation is to be executed
|
|
159
|
+
* @returns {Promise.<sap.ui.model.odata.v4.Context>} Resolve function returns the context of the operation
|
|
160
|
+
* @private
|
|
161
|
+
* @ui5-restricted
|
|
162
|
+
*/
|
|
163
|
+
function executeDraftActivationAction(oContext: any, oAppComponent: AppComponent, sGroupId?: string) {
|
|
164
|
+
const bHasPrepareAction = hasPrepareAction(oContext);
|
|
165
|
+
|
|
166
|
+
// According to the draft spec if the service contains a prepare action and we trigger both prepare and
|
|
167
|
+
// activate in one $batch the activate action is called with iF-Match=*
|
|
168
|
+
const bIgnoreEtag = bHasPrepareAction;
|
|
169
|
+
|
|
170
|
+
if (!oContext.getProperty("IsActiveEntity")) {
|
|
171
|
+
const oOperation = createOperation(oContext, draftOperations.ACTIVATION, { $$inheritExpandSelect: true });
|
|
172
|
+
const localI18nRef = sap.ui.getCore().getLibraryResourceBundle("sap.fe.core") as ResourceBundle;
|
|
173
|
+
const sActionName = localI18nRef.getText("C_OP_OBJECT_PAGE_SAVE");
|
|
174
|
+
return oOperation
|
|
175
|
+
.execute(
|
|
176
|
+
sGroupId,
|
|
177
|
+
bIgnoreEtag,
|
|
178
|
+
sGroupId ? CommonUtils.fnOnStrictHandlingFailed.bind(draft, sGroupId, sActionName, oContext.getModel()) : undefined
|
|
179
|
+
) //3rd parameter<------
|
|
180
|
+
.then(function(oActiveDocumentContext: any) {
|
|
181
|
+
return oActiveDocumentContext;
|
|
182
|
+
})
|
|
183
|
+
.catch(
|
|
184
|
+
//if ACTIVATE action fails then we request either the sideEffects against PREPARE action (if annotated) or the messages as fallback:
|
|
185
|
+
function() {
|
|
186
|
+
if (bHasPrepareAction) {
|
|
187
|
+
const sActionName = getActionName(oContext, draftOperations.PREPARE),
|
|
188
|
+
oSideEffectsService = oAppComponent.getSideEffectsService(),
|
|
189
|
+
oBindingParameters = oSideEffectsService.getODataActionSideEffects(sActionName, oContext),
|
|
190
|
+
aTargetPaths = oBindingParameters && oBindingParameters.pathExpressions;
|
|
191
|
+
if (aTargetPaths && aTargetPaths.length > 0) {
|
|
192
|
+
oSideEffectsService.requestSideEffects(aTargetPaths, oContext).catch(function(oError: any) {
|
|
193
|
+
Log.error("Error while requesting side effects", oError);
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
requestMessages(oContext, oSideEffectsService).catch(function(oError: any) {
|
|
197
|
+
Log.error("Error while requesting messages", oError);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return Promise.reject();
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
} else {
|
|
205
|
+
throw new Error("The activation action cannot be executed on an active document");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Execute a preparation action.
|
|
210
|
+
*
|
|
211
|
+
* @function
|
|
212
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the action should be performed
|
|
213
|
+
* @param {string} groupId The optional batch group in which we want to execute the operation
|
|
214
|
+
* @returns {Promise.<sap.ui.model.odata.v4.Context>} Resolve function returns the context of the operation
|
|
215
|
+
* @private
|
|
216
|
+
* @ui5-restricted
|
|
217
|
+
*/
|
|
218
|
+
function executeDraftPreparationAction(oContext: Context, groupId?: string) {
|
|
219
|
+
if (!oContext.getProperty("IsActiveEntity")) {
|
|
220
|
+
const oOperation = createOperation(oContext, draftOperations.PREPARE);
|
|
221
|
+
|
|
222
|
+
// TODO: side effects qualifier shall be even deprecated to be checked
|
|
223
|
+
oOperation.setParameter("SideEffectsQualifier", "");
|
|
224
|
+
|
|
225
|
+
const sGroupId = groupId || oOperation.getGroupId();
|
|
226
|
+
return oOperation
|
|
227
|
+
.execute(sGroupId)
|
|
228
|
+
.then(function() {
|
|
229
|
+
return oOperation;
|
|
230
|
+
})
|
|
231
|
+
.catch(function(oError: any) {
|
|
232
|
+
Log.error("Error while executing the operation", oError);
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
throw new Error("The preparation action cannot be executed on an active document");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Determines the message path for a context.
|
|
240
|
+
*
|
|
241
|
+
* @function
|
|
242
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the path shall be determined
|
|
243
|
+
* @returns {string} Message path, empty if not annotated
|
|
244
|
+
* @private
|
|
245
|
+
* @ui5-restricted
|
|
246
|
+
*/
|
|
247
|
+
function getMessagesPath(oContext: Context): string {
|
|
248
|
+
const oModel = oContext.getModel(),
|
|
249
|
+
oMetaModel = oModel.getMetaModel() as ODataMetaModel,
|
|
250
|
+
sEntitySetPath = oMetaModel.getMetaPath(oContext.getPath());
|
|
251
|
+
return oMetaModel.getObject(sEntitySetPath + "/@com.sap.vocabularies.Common.v1.Messages/$Path");
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Requests the messages if annotated for a given context.
|
|
255
|
+
*
|
|
256
|
+
* @function
|
|
257
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the messages shall be requested
|
|
258
|
+
* @param {object} oSideEffectsService Service for the SideEffects on SAP Fiori elements
|
|
259
|
+
* @returns {Promise} Promise which is resolved once messages were requested
|
|
260
|
+
* @private
|
|
261
|
+
* @ui5-restricted
|
|
262
|
+
*/
|
|
263
|
+
function requestMessages(oContext: any, oSideEffectsService: SideEffectsService) {
|
|
264
|
+
const sMessagesPath = getMessagesPath(oContext);
|
|
265
|
+
if (sMessagesPath) {
|
|
266
|
+
return oSideEffectsService.requestSideEffects([{ $PropertyPath: sMessagesPath }] as any, oContext);
|
|
267
|
+
}
|
|
268
|
+
return Promise.resolve();
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Executes discard of a draft function using HTTP Post.
|
|
272
|
+
*
|
|
273
|
+
* @function
|
|
274
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context for which the action should be performed
|
|
275
|
+
* @returns {Promise.<sap.ui.model.odata.v4.Context>} Resolve function returns the context of the operation
|
|
276
|
+
* @private
|
|
277
|
+
* @ui5-restricted
|
|
278
|
+
*/
|
|
279
|
+
function executeDraftDiscardAction(oContext: any): Promise<boolean> {
|
|
280
|
+
if (!oContext.getProperty("IsActiveEntity")) {
|
|
281
|
+
const oDiscardOperation = createOperation(oContext, draftOperations.DISCARD);
|
|
282
|
+
const localI18nRef = sap.ui.getCore().getLibraryResourceBundle("sap.fe.core") as ResourceBundle;
|
|
283
|
+
const sGroupId = "direct";
|
|
284
|
+
const sActionName = localI18nRef.getText("C_TRANSACTION_HELPER_DRAFT_DISCARD_BUTTON");
|
|
285
|
+
const oDiscardPromise = oDiscardOperation.execute(
|
|
286
|
+
sGroupId,
|
|
287
|
+
undefined,
|
|
288
|
+
CommonUtils.fnOnStrictHandlingFailed.bind(draft, sGroupId, sActionName, oContext.getModel())
|
|
289
|
+
);
|
|
290
|
+
oContext.getModel().submitBatch(sGroupId);
|
|
291
|
+
return oDiscardPromise;
|
|
292
|
+
} else {
|
|
293
|
+
throw new Error("The discard action cannot be executed on an active document");
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Creates a draft document from an existing document.
|
|
298
|
+
*
|
|
299
|
+
* The function supports several hooks as there is a certain coreography defined.
|
|
300
|
+
*
|
|
301
|
+
* @function
|
|
302
|
+
* @name sap.fe.core.actions.draft#createDraftFromActiveDocument
|
|
303
|
+
* @memberof sap.fe.core.actions.draft
|
|
304
|
+
* @static
|
|
305
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the active document for the new draft
|
|
306
|
+
* @param {AppComponent} oAppComponent The AppComponent
|
|
307
|
+
* @param {object} mParameters The parameters
|
|
308
|
+
* @param {boolean} [mParameters.oView] The view
|
|
309
|
+
* @param {boolean} [mParameters.bPreserveChanges] Preserve changes of an existing draft of another user
|
|
310
|
+
* @param {sap.fe.core.actions.draft.ICallback.beforeCreateDraftFromActiveDocument} [mParameters.fnBeforeCreateDraftFromActiveDocument] Callback that allows veto before create request is executed
|
|
311
|
+
* @param {sap.fe.core.actions.draft.ICallback.afterCreateDraftFromActiveDocument} [mParameters.fnAfterCreateDraftFromActiveDocument] Callback for postprocessiong after draft document was created
|
|
312
|
+
* @param {sap.fe.core.actions.draft.ICallback.whenDecisionToOverwriteDocumentIsRequired} [mParameters.fnWhenDecisionToOverwriteDocumentIsRequired] Callback for deciding on overwriting an unsaved change by another user
|
|
313
|
+
* @returns {Promise} Promise resolves with the {@link sap.ui.model.odata.v4.Context context} of the new draft document
|
|
314
|
+
* @private
|
|
315
|
+
* @ui5-restricted
|
|
316
|
+
*/
|
|
317
|
+
function createDraftFromActiveDocument(
|
|
318
|
+
oContext: any,
|
|
319
|
+
oAppComponent: AppComponent,
|
|
320
|
+
mParameters: {
|
|
321
|
+
oView: View;
|
|
322
|
+
bPreserveChanges?: boolean | undefined;
|
|
323
|
+
fnBeforeCreateDraftFromActiveDocument?: any;
|
|
324
|
+
fnAfterCreateDraftFromActiveDocument?: any;
|
|
325
|
+
fnWhenDecisionToOverwriteDocumentIsRequired?: any;
|
|
326
|
+
}
|
|
327
|
+
) {
|
|
328
|
+
const mParam = mParameters || {},
|
|
329
|
+
localI18nRef = sap.ui.getCore().getLibraryResourceBundle("sap.fe.core") as ResourceBundle,
|
|
330
|
+
bRunPreserveChangesFlow =
|
|
331
|
+
typeof mParam.bPreserveChanges === "undefined" || (typeof mParam.bPreserveChanges === "boolean" && mParam.bPreserveChanges); //default true
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Overwrite or reject based on fnWhenDecisionToOverwriteDocumentIsRequired.
|
|
335
|
+
*
|
|
336
|
+
* @param {*} bOverwrite Overwrite the change or not
|
|
337
|
+
* @returns {Promise} Resolves with result of {@link sap.fe.core.actions#executeDraftEditAction}
|
|
338
|
+
*/
|
|
339
|
+
function overwriteOnDemand(bOverwrite: any) {
|
|
340
|
+
if (bOverwrite) {
|
|
341
|
+
//Overwrite existing changes
|
|
342
|
+
const oModel = oContext.getModel();
|
|
343
|
+
const draftDataContext = oModel.bindContext(oContext.getPath() + "/DraftAdministrativeData").getBoundContext();
|
|
344
|
+
let oResourceBundle: ResourceBundle;
|
|
345
|
+
|
|
346
|
+
return ((mParameters.oView.getModel("sap.fe.i18n") as ResourceModel).getResourceBundle() as Promise<ResourceBundle>)
|
|
347
|
+
.then(function(_oResourceBundle: any) {
|
|
348
|
+
oResourceBundle = _oResourceBundle;
|
|
349
|
+
return draftDataContext.requestObject();
|
|
350
|
+
})
|
|
351
|
+
.then(function(draftAdminData: any) {
|
|
352
|
+
if (draftAdminData) {
|
|
353
|
+
// remove all unbound transition messages as we show a special dialog
|
|
354
|
+
messageHandling.removeUnboundTransitionMessages();
|
|
355
|
+
let sInfo = draftAdminData.InProcessByUserDescription || draftAdminData.InProcessByUser;
|
|
356
|
+
const sEntitySet = (mParameters.oView.getViewData() as any).entitySet;
|
|
357
|
+
if (sInfo) {
|
|
358
|
+
const sLockedByUserMsg = CommonUtils.getTranslatedText(
|
|
359
|
+
"C_DRAFT_OBJECT_PAGE_DRAFT_LOCKED_BY_USER",
|
|
360
|
+
oResourceBundle,
|
|
361
|
+
sInfo,
|
|
362
|
+
sEntitySet
|
|
363
|
+
);
|
|
364
|
+
MessageBox.error(sLockedByUserMsg);
|
|
365
|
+
throw new Error(sLockedByUserMsg);
|
|
366
|
+
} else {
|
|
367
|
+
sInfo = draftAdminData.CreatedByUserDescription || draftAdminData.CreatedByUser;
|
|
368
|
+
const sUnsavedChangesMsg = CommonUtils.getTranslatedText(
|
|
369
|
+
"C_DRAFT_OBJECT_PAGE_DRAFT_UNSAVED_CHANGES",
|
|
370
|
+
oResourceBundle,
|
|
371
|
+
sInfo,
|
|
372
|
+
sEntitySet
|
|
373
|
+
);
|
|
374
|
+
return showMessageBox(sUnsavedChangesMsg).then(function() {
|
|
375
|
+
return executeDraftEditAction(oContext, false);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return Promise.reject(new Error("Draft creation aborted for document: " + oContext.getPath()));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function showMessageBox(sUnsavedChangesMsg: any) {
|
|
385
|
+
return new Promise(function(resolve: (value: any) => void, reject: (reason?: any) => void) {
|
|
386
|
+
const oDialog = new Dialog({
|
|
387
|
+
title: localI18nRef.getText("C_DRAFT_OBJECT_PAGE_WARNING"),
|
|
388
|
+
state: "Warning",
|
|
389
|
+
content: new Text({
|
|
390
|
+
text: sUnsavedChangesMsg
|
|
391
|
+
}),
|
|
392
|
+
beginButton: new Button({
|
|
393
|
+
text: localI18nRef.getText("C_COMMON_OBJECT_PAGE_EDIT"),
|
|
394
|
+
type: "Emphasized",
|
|
395
|
+
press: function() {
|
|
396
|
+
oDialog.close();
|
|
397
|
+
resolve(true);
|
|
398
|
+
}
|
|
399
|
+
}),
|
|
400
|
+
endButton: new Button({
|
|
401
|
+
text: localI18nRef.getText("C_COMMON_OBJECT_PAGE_CANCEL"),
|
|
402
|
+
press: function() {
|
|
403
|
+
oDialog.close();
|
|
404
|
+
reject("Draft creation aborted for document: " + oContext.getPath());
|
|
405
|
+
}
|
|
406
|
+
}),
|
|
407
|
+
afterClose: function() {
|
|
408
|
+
oDialog.destroy();
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
oDialog.addStyleClass("sapUiContentPadding");
|
|
412
|
+
oDialog.open();
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (!oContext) {
|
|
417
|
+
return Promise.reject(new Error("Binding context to active document is required"));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return Promise.resolve(
|
|
421
|
+
mParam.fnBeforeCreateDraftFromActiveDocument
|
|
422
|
+
? mParam.fnBeforeCreateDraftFromActiveDocument(oContext, bRunPreserveChangesFlow)
|
|
423
|
+
: true
|
|
424
|
+
)
|
|
425
|
+
.then(function(bExecute: any) {
|
|
426
|
+
if (!bExecute) {
|
|
427
|
+
throw new Error("Draft creation was aborted by extension for document: " + oContext.getPath());
|
|
428
|
+
}
|
|
429
|
+
return executeDraftEditAction(oContext, bRunPreserveChangesFlow).catch(function(oResponse: any) {
|
|
430
|
+
//Only call back if error 409
|
|
431
|
+
if (bRunPreserveChangesFlow && oResponse.status === 409) {
|
|
432
|
+
return Promise.resolve(
|
|
433
|
+
mParam.fnWhenDecisionToOverwriteDocumentIsRequired ? mParam.fnWhenDecisionToOverwriteDocumentIsRequired() : true
|
|
434
|
+
).then(overwriteOnDemand);
|
|
435
|
+
} else {
|
|
436
|
+
throw new Error(oResponse);
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
})
|
|
440
|
+
.then(function(oDraftContext: any) {
|
|
441
|
+
return Promise.resolve(
|
|
442
|
+
mParam.fnAfterCreateDraftFromActiveDocument
|
|
443
|
+
? mParam.fnAfterCreateDraftFromActiveDocument(oContext, oDraftContext)
|
|
444
|
+
: oDraftContext
|
|
445
|
+
);
|
|
446
|
+
})
|
|
447
|
+
.then(function(oDraftContext: any) {
|
|
448
|
+
const sEditActionName = getActionName(oDraftContext, draftOperations.EDIT);
|
|
449
|
+
const oSideEffects = oAppComponent.getSideEffectsService().getODataActionSideEffects(sEditActionName, oDraftContext);
|
|
450
|
+
if (oSideEffects?.triggerActions?.length) {
|
|
451
|
+
return oAppComponent
|
|
452
|
+
.getSideEffectsService()
|
|
453
|
+
.requestSideEffectsForODataAction(oSideEffects, oDraftContext)
|
|
454
|
+
.then(() => {
|
|
455
|
+
return oDraftContext;
|
|
456
|
+
});
|
|
457
|
+
} else {
|
|
458
|
+
return oDraftContext;
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
.catch(function(exc: any) {
|
|
462
|
+
return Promise.reject(exc);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Creates an active document from a draft document.
|
|
467
|
+
*
|
|
468
|
+
* The function supports several hooks as there is a certain choreography defined.
|
|
469
|
+
*
|
|
470
|
+
* @function
|
|
471
|
+
* @name sap.fe.core.actions.draft#activateDocument
|
|
472
|
+
* @memberof sap.fe.core.actions.draft
|
|
473
|
+
* @static
|
|
474
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the active document for the new draft
|
|
475
|
+
* @param {object} oAppComponent The AppComponent
|
|
476
|
+
* @param {object} mParameters The parameters
|
|
477
|
+
* @param {sap.fe.core.actions.draft.ICallback.fnBeforeActivateDocument} [mParameters.fnBeforeActivateDocument] Callback that allows veto before create request is executed
|
|
478
|
+
* @param {sap.fe.core.actions.draft.ICallback.fnAfterActivateDocument} [mParameters.fnAfterActivateDocument] Callback for postprocessiong after document was activated.
|
|
479
|
+
* @returns {Promise} Promise resolves with the {@link sap.ui.model.odata.v4.Context context} of the new draft document
|
|
480
|
+
* @private
|
|
481
|
+
* @ui5-restricted
|
|
482
|
+
*/
|
|
483
|
+
function activateDocument(
|
|
484
|
+
oContext: any,
|
|
485
|
+
oAppComponent: AppComponent,
|
|
486
|
+
mParameters: { fnBeforeActivateDocument?: any; fnAfterActivateDocument?: any }
|
|
487
|
+
) {
|
|
488
|
+
const mParam = mParameters || {};
|
|
489
|
+
|
|
490
|
+
if (!oContext) {
|
|
491
|
+
return Promise.reject(new Error("Binding context to draft document is required"));
|
|
492
|
+
}
|
|
493
|
+
return Promise.resolve(mParam.fnBeforeActivateDocument ? mParam.fnBeforeActivateDocument(oContext) : true)
|
|
494
|
+
.then(function(bExecute: any) {
|
|
495
|
+
if (!bExecute) {
|
|
496
|
+
return Promise.reject(new Error("Activation of the document was aborted by extension for document: " + oContext.getPath()));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (!hasPrepareAction(oContext)) {
|
|
500
|
+
return executeDraftActivationAction(oContext, oAppComponent);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/* activation requires preparation */
|
|
504
|
+
const sBatchGroup = "draft";
|
|
505
|
+
// we use the same batchGroup to force prepare and activate in a same batch but with different changeset
|
|
506
|
+
const oPreparePromise = executeDraftPreparationAction(oContext, sBatchGroup);
|
|
507
|
+
oContext.getModel().submitBatch(sBatchGroup);
|
|
508
|
+
|
|
509
|
+
const oActivatePromise = executeDraftActivationAction(oContext, oAppComponent, sBatchGroup);
|
|
510
|
+
|
|
511
|
+
return Promise.all([oPreparePromise, oActivatePromise])
|
|
512
|
+
.then(function(values: [any, any]) {
|
|
513
|
+
return values[1];
|
|
514
|
+
})
|
|
515
|
+
.catch(function(exc: any) {
|
|
516
|
+
return Promise.reject(exc);
|
|
517
|
+
});
|
|
518
|
+
})
|
|
519
|
+
.then(function(oActiveDocumentContext: any) {
|
|
520
|
+
return Promise.resolve(
|
|
521
|
+
mParam.fnAfterActivateDocument ? mParam.fnAfterActivateDocument(oContext, oActiveDocumentContext) : oActiveDocumentContext
|
|
522
|
+
);
|
|
523
|
+
})
|
|
524
|
+
.catch(function(exc: any) {
|
|
525
|
+
return Promise.reject(exc);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* HTTP POST call when DraftAction is present for Draft Delete; HTTP DELETE for Draft(when no DraftAction)
|
|
530
|
+
* and Active Instance uses DELETE always.
|
|
531
|
+
*
|
|
532
|
+
* @function
|
|
533
|
+
* @name sap.fe.core.actions.draft#deleteDraft
|
|
534
|
+
* @memberof sap.fe.core.actions.draft
|
|
535
|
+
* @static
|
|
536
|
+
* @param {sap.ui.model.odata.v4.Context} oContext Context of the document to be discarded
|
|
537
|
+
* @private
|
|
538
|
+
* @returns {Promise}
|
|
539
|
+
* @ui5-restricted
|
|
540
|
+
*/
|
|
541
|
+
function deleteDraft(oContext: any): Promise<boolean> {
|
|
542
|
+
const sDiscardAction = getActionName(oContext, draftOperations.DISCARD),
|
|
543
|
+
bIsActiveEntity = oContext.getObject().IsActiveEntity;
|
|
544
|
+
|
|
545
|
+
if (bIsActiveEntity || (!bIsActiveEntity && !sDiscardAction)) {
|
|
546
|
+
//Use Delete in case of active entity and no discard action available for draft
|
|
547
|
+
if (oContext.hasPendingChanges()) {
|
|
548
|
+
return oContext
|
|
549
|
+
.getBinding()
|
|
550
|
+
.resetChanges()
|
|
551
|
+
.then(function() {
|
|
552
|
+
return oContext.delete();
|
|
553
|
+
})
|
|
554
|
+
.catch(function(error: any) {
|
|
555
|
+
return Promise.reject(error);
|
|
556
|
+
});
|
|
557
|
+
} else {
|
|
558
|
+
return oContext.delete();
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
//Use Discard Post Action if it is a draft entity and discard action exists
|
|
562
|
+
return executeDraftDiscardAction(oContext);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export default draft;
|