diff --git a/app/featureShowcase/layouts_RootEntities.cds b/app/featureShowcase/layouts_RootEntities.cds index 37909d1..ca2f08c 100644 --- a/app/featureShowcase/layouts_RootEntities.cds +++ b/app/featureShowcase/layouts_RootEntities.cds @@ -12,6 +12,11 @@ annotate service.RootEntities with @( //Search-Term: #SemanticKey Common.SemanticKey : [stringProperty], //field in bold, editing status displayed, when possible and it effects navigation UI.Identification : [ + { + $Type : 'UI.DataFieldForAction', + Action : 'service1.copy', //Reference to the action of the CAP service + Label : '{i18n>copy}', + }, { //Search-Term: #OPHeaderAction $Type : 'UI.DataFieldForAction', //Action in the RootEntities of the object page next to the edit button @@ -122,6 +127,12 @@ annotate service.RootEntities with @( Target : 'contact/@Communication.Contact', Label : '{i18n>contactQuickView}' }, + { + //Action button in the table toolbar + $Type : 'UI.DataFieldForAction', + Action : 'service1.copy', //Reference to the action of the CAP service + Label : '{i18n>copy}', + }, { //Action button in the table toolbar $Type : 'UI.DataFieldForAction', @@ -804,4 +815,4 @@ annotate service.RootEntities with @( } ] }, -); \ No newline at end of file +); diff --git a/app/featureShowcase/webapp/manifest.json b/app/featureShowcase/webapp/manifest.json index 1f297b9..1617ff1 100644 --- a/app/featureShowcase/webapp/manifest.json +++ b/app/featureShowcase/webapp/manifest.json @@ -120,7 +120,7 @@ "name": "sap.fe.templates.ListReport", "options": { "settings": { - "entitySet": "RootEntities", + "contextPath": "/RootEntities", "variantManagement": "Page", "enhanceI18n": "i18n/customI18N.properties", "navigation": { @@ -259,7 +259,7 @@ "name": "sap.fe.templates.ObjectPage", "options": { "settings": { - "entitySet": "RootEntities", + "contextPath": "/RootEntities", "enhanceI18n": "i18n/customI18N.properties", "sectionLayout": "Tabs", "variantManagement": "Control", @@ -551,4 +551,4 @@ "registrationIds": [], "archeType": "transactional" } -} \ No newline at end of file +} diff --git a/app/i18n/i18n.properties b/app/i18n/i18n.properties index aba511d..ab4e690 100644 --- a/app/i18n/i18n.properties +++ b/app/i18n/i18n.properties @@ -14,6 +14,7 @@ sumTargetValue=Sum of target values connectedField=Connected fields +copy=Copy changeCriticality=Change Criticality (Bound) unboundAction=Show input (Unbound) subSection=Subsection @@ -122,4 +123,4 @@ stars=Stars currencyForFieldWithPrice=Currency region=Region description2=Second description -MultiInputField=Multi input field \ No newline at end of file +MultiInputField=Multi input field diff --git a/srv/service.cds b/srv/service.cds index 8c384d1..1010316 100644 --- a/srv/service.cds +++ b/srv/service.cds @@ -13,6 +13,7 @@ service service1 @(path : '/srv1') { TargetProperties : ['_it/criticality_code','_it/fieldWithCriticality'] } ) + action copy() returns RootEntities; action changeCriticality ( //Value Helper for the Input Parameter //Search-Term: #ValueHelpParameter diff --git a/srv/service.js b/srv/service.js index fb06c89..6be3c88 100644 --- a/srv/service.js +++ b/srv/service.js @@ -81,6 +81,21 @@ module.exports = async (srv) => { // Actions //============================================================================================================= + srv.on("copy",RootEntities, async (req) => { + //Req.params contains IDs and Draft IDs of the entity + const headerID = req.params[0].ID; + console.log("Copy Action called"); + //Update the current RootEntity with the new value for ciritcality_code and fieldWithCriticality + const newRootEntity = await SELECT.one.from(RootEntities,headerID); + newRootEntity.ID = cds.utils.uuid(); + newRootEntity.stringProperty = newRootEntity.stringProperty + " (Copy)"; + newRootEntity.HasActiveEntity = true; + newRootEntity.IsActiveEntity = true; + await INSERT.into(RootEntities).entries(newRootEntity); + return newRootEntity; + //return UPDATE(RootEntities,headerID).with({criticality_code : criticality_code, fieldWithCriticality : determineFieldWithCriticalityValue(criticality_code)}); + }); + srv.on("changeCriticality",RootEntities, async (req) => { //Req.data contains the parameter values of the action //Req.params contains IDs and Draft IDs of the entity @@ -272,4 +287,4 @@ module.exports = async (srv) => { await DELETE.from(ChartDataEntities); await DELETE.from(GrandChildEntities); } -}; \ No newline at end of file +};