Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigate to new Enity after copy action #32

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/featureShowcase/layouts_RootEntities.cds
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -804,4 +815,4 @@ annotate service.RootEntities with @(
}
]
},
);
);
6 changes: 3 additions & 3 deletions app/featureShowcase/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"name": "sap.fe.templates.ListReport",
"options": {
"settings": {
"entitySet": "RootEntities",
"contextPath": "/RootEntities",
"variantManagement": "Page",
"enhanceI18n": "i18n/customI18N.properties",
"navigation": {
Expand Down Expand Up @@ -259,7 +259,7 @@
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "RootEntities",
"contextPath": "/RootEntities",
"enhanceI18n": "i18n/customI18N.properties",
"sectionLayout": "Tabs",
"variantManagement": "Control",
Expand Down Expand Up @@ -551,4 +551,4 @@
"registrationIds": [],
"archeType": "transactional"
}
}
}
3 changes: 2 additions & 1 deletion app/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sumTargetValue=Sum of target values

connectedField=Connected fields

copy=Copy
changeCriticality=Change Criticality (Bound)
unboundAction=Show input (Unbound)
subSection=Subsection
Expand Down Expand Up @@ -122,4 +123,4 @@ stars=Stars
currencyForFieldWithPrice=Currency
region=Region
description2=Second description
MultiInputField=Multi input field
MultiInputField=Multi input field
1 change: 1 addition & 0 deletions srv/service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion srv/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//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
Expand Down Expand Up @@ -272,4 +287,4 @@ module.exports = async (srv) => {
await DELETE.from(ChartDataEntities);
await DELETE.from(GrandChildEntities);
}
};
};