Skip to content

Commit 8e129e4

Browse files
authored
Merge pull request #12 from capire/flows
feat: status-transition flows
2 parents d37c5bb + 4ee8eeb commit 8e129e4

16 files changed

+4292
-27
lines changed

.cdsrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"[flow]": {
3+
"folders": {
4+
"flow": "xmpls/flow/"
5+
}
6+
}
7+
}

_i18n/i18n_en.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Agency=Agency
33
AgencyName=Agency Name
44
AvgPrice=Average Price
55
BeginDate=Starting Date
6+
BlockTravel=Block Travel
67
Booking=Booking
78
BookingDate=Booking Date
89
BookingDetails=Booking Details
@@ -36,6 +37,8 @@ Prices=Prices
3637
ProductID=Product
3738
ProductPrice=Product Price
3839
RejectTravel=Reject Travel
40+
ReopenTravel=Reopen Travel
41+
ReviewTravel=Review Travel
3942
Status=Status
4043
Street=Street
4144
Title=Title
@@ -45,4 +48,5 @@ Travel=Travel
4548
TravelAgency=Travel Agency
4649
Travels=Travels
4750
TravelStatus=Travel Status
51+
UnblockTravel=Unblock Travel
4852
WebAddress=Web Address

app/labels.cds

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ annotate schema.TravelStatus {
2727
@Common.Text: name
2828
@UI.ValueCriticality: [
2929
{ Criticality: 3, Value: 'A', },
30-
{ Criticality: 2, Value: 'O', },
31-
{ Criticality: 1, Value: 'X', }
30+
{ Criticality: 2, Value: 'O', },
31+
{ Criticality: 2, Value: 'P', },
32+
{ Criticality: 1, Value: 'B', },
33+
{ Criticality: 1, Value: 'X', }
3234
]
3335
}
3436

@@ -74,6 +76,15 @@ annotate schema.Passengers with @title: '{i18n>Passenger}' {
7476
}
7577

7678

79+
using { TravelService } from '../srv/travel-service';
80+
81+
annotate TravelService.Travels with actions {
82+
rejectTravel @title: '{i18n>RejectTravel}';
83+
acceptTravel @title: '{i18n>AcceptTravel}';
84+
deductDiscount @title: '{i18n>DeductDiscount}';
85+
};
86+
87+
7788
using sap.capire.flights.data;
7889

7990
annotate data.Airlines with @title: '{i18n>Airline}' {

app/travels/field-control.cds

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,11 @@ annotate TravelService.Travels with @(Common : {
2424
EndDate @Common.FieldControl : Status.fieldControl;
2525
Agency @Common.FieldControl : Status.fieldControl;
2626
Customer @Common.FieldControl : Status.fieldControl;
27-
2827
} actions {
29-
rejectTravel @(
30-
Core.OperationAvailable : ( $self.Status.code != #Canceled ), // FIXME: wrong error in editor
31-
Common.SideEffects.TargetProperties : ['in/Status/code','in/Status_code'],
32-
);
33-
acceptTravel @(
34-
Core.OperationAvailable : ( $self.Status.code != #Accepted ), // FIXME: wrong error in editor
35-
Common.SideEffects.TargetProperties : ['in/Status/code','in/Status_code'],
36-
);
3728
deductDiscount @(
38-
Core.OperationAvailable : ( $self.Status.code == #Open ),
3929
Common.SideEffects.TargetProperties : ['in/TotalPrice', 'in/BookingFee'],
4030
);
41-
}
31+
};
4232

4333
annotate TravelService.Travels @Common.SideEffects#ReactonItemCreationOrDeletion : {
4434
SourceEntities : [ Bookings ],

app/travels/layouts.cds

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ using { TravelService } from '../../srv/travel-service';
77
annotate TravelService.Travels with @UI : {
88

99
Identification : [
10-
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.acceptTravel', Label : '{i18n>AcceptTravel}' },
11-
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.rejectTravel', Label : '{i18n>RejectTravel}' },
12-
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.deductDiscount', Label : '{i18n>DeductDiscount}' }
10+
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.deductDiscount', Label : '{i18n>DeductDiscount}' },
1311
],
1412

1513
HeaderInfo : {
@@ -34,9 +32,6 @@ annotate TravelService.Travels with @UI : {
3432
],
3533

3634
LineItem : [
37-
38-
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.acceptTravel', Label : '{i18n>AcceptTravel}' },
39-
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.rejectTravel', Label : '{i18n>RejectTravel}' },
4035
{ $Type : 'UI.DataFieldForAction', Action : 'TravelService.deductDiscount', Label : '{i18n>DeductDiscount}' },
4136

4237
{ Value : ID, @UI.Importance : #High },
@@ -50,8 +45,8 @@ annotate TravelService.Travels with @UI : {
5045
{ Value : (Status.code),
5146
Criticality : (
5247
Status.code == #Accepted ? 3 :
53-
Status.code == #Open ? 2 :
54-
Status.code == #Canceled ? 1 : 0
48+
Status.code == #Open OR Status.code == #InReview ? 2 :
49+
Status.code == #Canceled OR Status.code == #Blocked ? 1 : 0
5550
),
5651
@UI.Importance : #High,
5752
@HTML5.CssDefaults: {width:'10em'}
@@ -74,8 +69,8 @@ annotate TravelService.Travels with @UI : {
7469
{ Value : (Status.code),
7570
Criticality : (
7671
Status.code == #Accepted ? 3 :
77-
Status.code == #Open ? 2 :
78-
Status.code == #Canceled ? 1 : 0
72+
Status.code == #Open OR Status.code == #InReview ? 2 :
73+
Status.code == #Canceled OR Status.code == #Blocked ? 1 : 0
7974
),
8075
},
8176
{ Value : BeginDate },
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
code;name
22
O;Open
3+
P;InReview
4+
B;Blocked
35
A;Accepted
46
X;Canceled

0 commit comments

Comments
 (0)