Compare commits
4 Commits
gdpr-with-
...
dreiklang
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c49454f44 | ||
|
|
d570ad20b2 | ||
|
|
d891a1b905 | ||
|
|
9f604b9d13 |
@@ -19,7 +19,7 @@ extend Books with {
|
||||
// Extend Orders with Books as Products
|
||||
//
|
||||
|
||||
using { sap.capire.orders.Orders_Items } from '@capire/orders';
|
||||
extend Orders_Items with {
|
||||
using { sap.capire.orders.Orders } from '@capire/orders';
|
||||
extend Orders.Items with {
|
||||
book : Association to Books on product.ID = book.ID
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
cds.requires.messaging.kind = file-based-messaging
|
||||
PORT = 4006
|
||||
PORT = 4006
|
||||
# cds.odata.flavor = x4
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
using { OrdersService } from '../../srv/orders-service';
|
||||
using { sap.common } from '@capire/common';
|
||||
|
||||
|
||||
@odata.draft.enabled
|
||||
@@ -68,7 +69,7 @@ annotate OrdersService.Orders with @(
|
||||
|
||||
|
||||
|
||||
annotate OrdersService.Orders_Items with @(
|
||||
annotate OrdersService.Orders.Items with @(
|
||||
UI: {
|
||||
LineItem: [
|
||||
{Value: product_ID, Label:'Product ID'},
|
||||
@@ -77,13 +78,22 @@ annotate OrdersService.Orders_Items with @(
|
||||
{Value: amount, Label:'Quantity'},
|
||||
],
|
||||
Identification: [ //Is the main field group
|
||||
{Value: product_ID, Label:'Product ID'},
|
||||
{Value: title, Label:'Product Title'},
|
||||
{Value: amount, Label:'Amount'},
|
||||
{Value: title, Label:'Product'},
|
||||
{Value: price, Label:'Unit Price'},
|
||||
],
|
||||
Facets: [
|
||||
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: '@UI.Identification'},
|
||||
],
|
||||
HeaderInfo: {
|
||||
TypeName: 'Order Item', TypeNamePlural: 'Order Items',
|
||||
Title: {
|
||||
Label: 'Product ID ', //A label is possible but it is not considered on the ObjectPage yet
|
||||
Value: product_ID
|
||||
},
|
||||
Description: {Value: createdBy}
|
||||
},
|
||||
},
|
||||
) {
|
||||
amount @(
|
||||
|
||||
@@ -3,17 +3,17 @@ namespace sap.capire.orders;
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String @title:'Order Number'; //> readable key
|
||||
Items : Composition of many Orders_Items on Items.up_ = $self;
|
||||
Items : Composition of many Orders.Items on Items.up_ = $self;
|
||||
buyer : User;
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
entity Orders_Items {
|
||||
entity Orders.Items {
|
||||
/*key*/ up_ : Association to Orders; // REVISIT: 'key' doesn't work due to bug in runtime
|
||||
key ID : UUID;
|
||||
up_ : Association to Orders;
|
||||
product : Association to Products @assert.integrity:false; // REVISIT: this is a temporary workaround for a glitch in cds-runtime
|
||||
product : Association to Products;
|
||||
amount : Integer;
|
||||
title : String; //> intentionally replicated as snapshot from product.title
|
||||
title : String; //> intentionally replicated as snapshot from product.title or alike
|
||||
price : Double;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "@capire/orders",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@capire/common": "*",
|
||||
"@sap/cds": "^5"
|
||||
}
|
||||
}
|
||||
31
orders/requests.http
Normal file
31
orders/requests.http
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
@Orders = http://localhost:4006/orders/Orders
|
||||
|
||||
|
||||
### Read Orders
|
||||
GET {{Orders}}?
|
||||
###
|
||||
GET {{Orders}}?$expand=Items
|
||||
###
|
||||
GET {{Orders}}(ID={{Order1}},IsActiveEntity=true)/Items
|
||||
|
||||
|
||||
|
||||
@Order1 = 64e718c9-ff99-47f1-8ca3-950c850777d4
|
||||
@Order3 = e939604c-ab83-4d4f-bdb6-95fe30b3773e
|
||||
|
||||
### Create order, still inactive
|
||||
POST {{Orders}}
|
||||
Content-Type: application/json
|
||||
|
||||
{"ID": "{{Order3}}"}
|
||||
|
||||
### Get inactive order. We have to specify `IsActiveEntity`.
|
||||
GET {{Orders}}(ID={{Order3}},IsActiveEntity=false)
|
||||
|
||||
### Activate order using `.../<servicename>.draftActivate`
|
||||
POST {{Orders}}(ID={{Order3}},IsActiveEntity=false)/OrdersService.draftActivate
|
||||
Content-Type: application/json
|
||||
|
||||
### Get active order
|
||||
GET {{Orders}}(ID={{Order3}},IsActiveEntity=true)
|
||||
@@ -3,7 +3,7 @@ class OrdersService extends cds.ApplicationService {
|
||||
|
||||
/** register custom handlers */
|
||||
init(){
|
||||
const { Orders_Items:OrderItems } = this.entities
|
||||
const { 'Orders.Items':OrderItems } = this.entities
|
||||
|
||||
this.before ('UPDATE', 'Orders', async function(req) {
|
||||
const { ID, Items } = req.data
|
||||
|
||||
Reference in New Issue
Block a user