Skip to content
Draft
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
3 changes: 2 additions & 1 deletion app/labels.cds
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ annotate schema.Travel with @title: '{i18n>Travel}' {
GoGreen @title: '{i18n>GoGreen}';
GreenFee @title: '{i18n>GreenFee}' @Measures.ISOCurrency: (CurrencyCode.code);
TreesPlanted @title: '{i18n>TreesPlanted}';
TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name @Common.TextArrangement: #TextOnly;
TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name
@Common.TextArrangement: #TextOnly;
to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName;
to_Agency @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name;
}
Expand Down
71 changes: 49 additions & 22 deletions app/travel_processor/field-control.cds
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ annotate TravelService.Travel with @(Common : {
SideEffects #GoGreen:{
SourceProperties: [GoGreen],
TargetProperties: ['TotalPrice', 'GreenFee', 'TreesPlanted']
},
SideEffects #Exp:{
SourceProperties: [field_BCtr, field_BCtrCalc],
TargetProperties: ['field_B']
}
}){
BookingFee @Common.FieldControl : TravelStatus.fieldControl;
BeginDate @Common.FieldControl : TravelStatus.fieldControl;
EndDate @Common.FieldControl : TravelStatus.fieldControl;
to_Agency @Common.FieldControl : TravelStatus.fieldControl;
to_Customer @Common.FieldControl : TravelStatus.fieldControl;
BookingFee @Common.FieldControl : TravelStatus_ctrl;
BeginDate @Common.FieldControl : TravelStatus_ctrl;
EndDate @Common.FieldControl : TravelStatus_ctrl;
to_Agency @Common.FieldControl : TravelStatus_ctrl;
to_Customer @Common.FieldControl : TravelStatus_ctrl;

// field_A @Common.FieldControl: (field_ACtr = 'readonly' ? 1 : (field_ACtr = 'inapplicable' ? 0 : (field_ACtr = 'mandatory' ? 7 : 3)))
// @readonly: (field_ACtr = 'readonly')
// @mandatory: (field_ACtr = 'mandatory')
// @enabled: (field_ACtr != 'inapplicable');
field_A @Common.FieldControl: (field_ACtr = 'readonly' and to_Agency.City = 'Sydney' ? 1 : 3);
field_B @Common.FieldControl: field_BCtrCalc;

} actions {
rejectTravel @(
Expand All @@ -48,26 +59,42 @@ annotate TravelService.Travel with @(Common : {
}

annotate TravelService.Travel @(
Common.SideEffects#ReactonItemCreationOrDeletion : {
SourceEntities : [
to_Booking
],
TargetProperties : ['TotalPrice'
]
}
Common.SideEffects#ReactonItemCreationOrDeletion : {
SourceEntities : [to_Booking],
TargetProperties : ['TotalPrice']
}
);

annotate TravelService.Booking with @UI.CreateHidden : (to_Travel.TravelStatus.code != #Open);
annotate TravelService.Booking with @UI.DeleteHidden : (to_Travel.TravelStatus.code != #Open);

// ok
// annotate TravelService.Booking with @UI.CreateHidden : (not to_Travel.TravelStatus.createDeleteHidden);
// annotate TravelService.Booking with @UI.DeleteHidden : (not to_Travel.TravelStatus.createDeleteHidden);

// ok
// annotate TravelService.Booking with @UI.CreateHidden : { $edmJson: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} };
// annotate TravelService.Booking with @UI.DeleteHidden : { $edmJson: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} };

// ok
// annotate TravelService.Booking with @UI.CreateHidden : { $edmJson: {$Not: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} } };
// annotate TravelService.Booking with @UI.DeleteHidden : { $edmJson: {$Not: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} } };


// code;createDeleteHidden;insertDeleteRestriction
// O; false; true
// A; true; false
// X; true; false


annotate TravelService.Booking {
BookingDate @Core.Computed;
ConnectionID @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
FlightDate @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
FlightPrice @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
BookingStatus @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
to_Carrier @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
to_Customer @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
ConnectionID @Common.FieldControl : to_Travel.TravelStatus_ctrl;
FlightDate @Common.FieldControl : to_Travel.TravelStatus_ctrl;
FlightPrice @Common.FieldControl : to_Travel.TravelStatus_ctrl;
BookingStatus @Common.FieldControl : to_Travel.TravelStatus_ctrl;
to_Carrier @Common.FieldControl : to_Travel.TravelStatus_ctrl;
to_Customer @Common.FieldControl : to_Travel.TravelStatus_ctrl;
};

annotate TravelService.Booking with @(
Expand All @@ -88,8 +115,8 @@ annotate TravelService.Booking with @(


annotate TravelService.BookingSupplement {
Price @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
to_Supplement @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
to_Booking @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
to_Travel @Common.FieldControl : to_Travel.TravelStatus.fieldControl;
Price @Common.FieldControl : to_Travel.TravelStatus_ctrl;
to_Supplement @Common.FieldControl : to_Travel.TravelStatus_ctrl;
to_Booking @Common.FieldControl : to_Travel.TravelStatus_ctrl;
to_Travel @Common.FieldControl : to_Travel.TravelStatus_ctrl;
};
22 changes: 21 additions & 1 deletion app/travel_processor/layouts.cds
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ annotate TravelService.Travel with @UI : {
Target : '@UI.FieldGroup#TravelData',
Label : '{i18n>GeneralInformation}'
},
{ // experimental A
$Type : 'UI.ReferenceFacet',
ID : 'ExperimentalDataA',
Target : '@UI.FieldGroup#ExperimentalDataA',
Label : 'FC via edmXpr'
},
{ // experimental B
$Type : 'UI.ReferenceFacet',
ID : 'ExperimentalDataB',
Target : '@UI.FieldGroup#ExperimentalDataB',
Label : 'FC via CalcElem'
},
{ // price information
$Type : 'UI.ReferenceFacet',
ID : 'PriceData',
Expand Down Expand Up @@ -108,6 +120,14 @@ annotate TravelService.Travel with @UI : {
Label : '{i18n>Status}' // label only necessary if differs from title of element
}
]},
FieldGroup #ExperimentalDataA : {Data : [
{ $Type : 'UI.DataField', Value : field_A },
{ $Type : 'UI.DataField', Value : field_ACtr }
]},
FieldGroup #ExperimentalDataB : {Data : [
{ $Type : 'UI.DataField', Value : field_B },
{ $Type : 'UI.DataField', Value : field_BCtr }
]},
FieldGroup #DateData : {Data : [
{ $Type : 'UI.DataField', Value : BeginDate },
{ $Type : 'UI.DataField', Value : EndDate }
Expand Down Expand Up @@ -160,7 +180,7 @@ annotate TravelService.Booking with @UI : {
{ Value : BookingID },
{ Value : BookingDate },
{ Value : (to_Customer.CustomerID) },
{ Value : (to_Carrier.AirlineID ) },
{ Value : (to_Carrier.AirlineID) },
{ Value : ConnectionID, Label : '{i18n>FlightNumber}' },
{ Value : FlightDate },
{ Value : FlightPrice },
Expand Down
1 change: 1 addition & 0 deletions db/master-data.cds
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ entity FlightConnection : MasterData {
// and will be replaced with the generated FK
key ConnectionID : String(4);
key AirlineID : String(3);

DepartureAirport : Association to Airport;
DestinationAirport : Association to Airport;
DepartureTime : Time;
Expand Down
20 changes: 18 additions & 2 deletions db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ entity Travel : managed {
TotalPrice : Decimal(16,3) @readonly;
CurrencyCode : Currency default 'EUR';
Description : String(1024);
TravelStatus : Association to TravelStatus default 'O' @readonly;

TravelStatus : Association to TravelStatus default 'O' @readonly;

TravelStatus_ctrl: Int16 @odata.Type:'Edm.Byte' /*enum {Inapplicable = 0; ReadOnly = 1; Optional = 3; Mandatory = 7;}*/
= (TravelStatus.code = 'A' ? 1 : 7 );

to_Agency : Association to TravelAgency @mandatory;
to_Customer : Association to Passenger @mandatory;
to_Booking : Composition of many Booking on to_Booking.to_Travel = $self;

field_A: String @label: 'controlled A';
field_ACtr : String @label: 'controlling A';

field_B: String @label: 'controlled B';
field_BCtr : String @label: 'controlling B';
field_BCtrCalc : Int16 @odata.Type:'Edm.Byte' = (field_BCtr = 'readonly' ? 1 : (field_BCtr = 'inapplicable' ? 0 : (field_BCtr = 'mandatory' ? 7 : 3)));
};

annotate Travel with @Capabilities.FilterRestrictions.FilterExpressionRestrictions: [
Expand All @@ -38,11 +50,14 @@ entity Booking : managed {
FlightDate : Date @mandatory;
FlightPrice : Decimal(16,3) @mandatory;
CurrencyCode : Currency;

BookingStatus : Association to BookingStatus default 'N' @mandatory;
to_BookSupplement : Composition of many BookingSupplement on to_BookSupplement.to_Booking = $self;

to_Carrier : Association to Airline @mandatory;
to_Customer : Association to Passenger @mandatory;
to_Travel : Association to Travel;

to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier.AirlineID
and to_Flight.FlightDate = FlightDate
and to_Flight.ConnectionID = ConnectionID;
Expand All @@ -53,8 +68,9 @@ entity BookingSupplement : managed {
BookingSupplementID : Integer @Core.Computed;
Price : Decimal(16,3) @mandatory;
CurrencyCode : Currency;

to_Booking : Association to Booking;
to_Travel : Association to Travel;
to_Travel : Association to Travel;
to_Supplement : Association to Supplement @mandatory;
};

Expand Down