From e8c6d1177542e84ac1e2cda0137b2daae4ea49c8 Mon Sep 17 00:00:00 2001 From: Tatiana Medvedeva Date: Thu, 26 Jan 2023 12:47:53 +0000 Subject: [PATCH] solution of the exercise --- .../ext/fragment/ServingTimeOfMeals.fragment.xml | 12 ++++++++++++ .../webapp/ext/fragment/ServingTimeOfMeals.js | 13 +++++++++++++ app/travel_processor/webapp/i18n/i18n.properties | 15 +++++++++++++++ app/travel_processor/webapp/manifest.json | 16 +++++++++++++++- ...e.cap.travel-MealOptionDeliveryPreference.csv | 4 ++++ db/schema.cds | 11 ++++++++++- 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.fragment.xml create mode 100644 app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.js create mode 100644 db/data/sap.fe.cap.travel-MealOptionDeliveryPreference.csv diff --git a/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.fragment.xml b/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.fragment.xml new file mode 100644 index 00000000..519ce605 --- /dev/null +++ b/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.fragment.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.js b/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.js new file mode 100644 index 00000000..a6110263 --- /dev/null +++ b/app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.js @@ -0,0 +1,13 @@ +sap.ui.define([ + "sap/m/MessageToast" +], function(MessageToast) { + 'use strict'; + + return { + onSelectionChange: function(oEvent) { + var sNewDeliveryPreferenceCode = oEvent.getParameter("item").getKey(); + var oSegmBtn = oEvent.getSource(); + oSegmBtn.getBindingContext().setProperty("DeliveryPreference_code", sNewDeliveryPreferenceCode); + } + }; +}); diff --git a/app/travel_processor/webapp/i18n/i18n.properties b/app/travel_processor/webapp/i18n/i18n.properties index f00379ae..ebc4f8fd 100644 --- a/app/travel_processor/webapp/i18n/i18n.properties +++ b/app/travel_processor/webapp/i18n/i18n.properties @@ -7,3 +7,18 @@ title=Manage Travels #YDES: Application description description=Manage Travels + +#XCOL: Custom column header text +servingTimeOfMeals=Serving Time of Meals + +#XTIT: Delivery preference of the Meal during the flight +deliveryPreference=Delivery Preference + +#XTIT: Early time of meal delivery during the flight +early=early + +#XTIT: Mid time of meal delivery during the flight +mid=mid + +#XTIT: Later time of meal delivery during the flight +late=late \ No newline at end of file diff --git a/app/travel_processor/webapp/manifest.json b/app/travel_processor/webapp/manifest.json index 938fddc6..8a320742 100644 --- a/app/travel_processor/webapp/manifest.json +++ b/app/travel_processor/webapp/manifest.json @@ -204,7 +204,21 @@ "options": { "settings": { "entitySet": "Booking", - "editableHeaderContent": false + "editableHeaderContent": false, + "controlConfiguration": { + "to_BookSupplement/@com.sap.vocabularies.UI.v1.LineItem": { + "columns": { + "ServingTimeOfMeals": { + "header": "{i18n>servingTimeOfMeals}", + "position": { + "anchor": "DataField::Price", + "placement": "After" + }, + "template": "sap.fe.cap.travel.ext.fragment.ServingTimeOfMeals" + } + } + } + } } } } diff --git a/db/data/sap.fe.cap.travel-MealOptionDeliveryPreference.csv b/db/data/sap.fe.cap.travel-MealOptionDeliveryPreference.csv new file mode 100644 index 00000000..4ccd1d76 --- /dev/null +++ b/db/data/sap.fe.cap.travel-MealOptionDeliveryPreference.csv @@ -0,0 +1,4 @@ +code;name;descr +S;SoonAfterTakeoff;Delivery as early as possible after the take-off +M;Midflight;Not too early not too late +L;Late;Late in the flight while still allowing you to finish the meal or drink before the landing \ No newline at end of file diff --git a/db/schema.cds b/db/schema.cds index e17ae5eb..07fb2b84 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -48,6 +48,7 @@ entity BookingSupplement : managed { key BookSupplUUID : UUID; BookingSupplementID : Integer @Core.Computed; Price : Decimal(16, 3); + DeliveryPreference : Association to MealOptionDeliveryPreference; CurrencyCode : Currency; to_Booking : Association to Booking; to_Travel : Association to Travel; @@ -107,4 +108,12 @@ entity SupplementScope { TargetValue : Integer @Common.Label: 'Target Value'; DeviationRangeLowValue : Integer @Common.Label: 'Deviation Range Threshold'; ToleranceRangeLowValue : Integer @Common.Label: 'Tolerance Range Threshold'; -} +}; + +entity MealOptionDeliveryPreference: CodeList { + key code : String enum { + SoonAfterTakeoff = 'S'; + Midflight = 'M'; + Late = 'L'; + } default 'M' +};