diff --git a/app/labels.cds b/app/labels.cds index fb8b1d87..b3a34843 100644 --- a/app/labels.cds +++ b/app/labels.cds @@ -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; } diff --git a/app/travel_processor/field-control.cds b/app/travel_processor/field-control.cds index 720922ad..d33841d4 100644 --- a/app/travel_processor/field-control.cds +++ b/app/travel_processor/field-control.cds @@ -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 @( @@ -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 @( @@ -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; }; diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index 9b18017f..1399a6eb 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -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', @@ -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 } @@ -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 }, diff --git a/db/master-data.cds b/db/master-data.cds index 950fada3..302c2afb 100644 --- a/db/master-data.cds +++ b/db/master-data.cds @@ -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; diff --git a/db/schema.cds b/db/schema.cds index 01c7ec2c..7449abb0 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -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: [ @@ -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; @@ -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; };