Skip to content

Commit

Permalink
solution of the exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaMedvedeva authored and hitesh-parmar committed Apr 14, 2023
1 parent d955ad8 commit e8c6d11
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m">
<SegmentedButton core:require="{handler: 'sap/fe/cap/travel/ext/fragment/ServingTimeOfMeals'}" id="SB1"
selectionChange="handler.onSelectionChange"
enabled="{ui>/isEditable}"
selectedKey="{= ${DeliveryPreference_code}}">
<items>
<SegmentedButtonItem id="_IDGenSegmentedButtonItem1" text="{i18n>early}" key="S" />
<SegmentedButtonItem id="_IDGenSegmentedButtonItem2" text="{i18n>mid}" key="M" />
<SegmentedButtonItem id="_IDGenSegmentedButtonItem3" text="{i18n>late}" key="L" />
</items>
</SegmentedButton>
</core:FragmentDefinition>
13 changes: 13 additions & 0 deletions app/travel_processor/webapp/ext/fragment/ServingTimeOfMeals.js
Original file line number Diff line number Diff line change
@@ -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);
}
};
});
15 changes: 15 additions & 0 deletions app/travel_processor/webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion app/travel_processor/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions db/data/sap.fe.cap.travel-MealOptionDeliveryPreference.csv
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
};

0 comments on commit e8c6d11

Please sign in to comment.