This commit is contained in:
Daniel
2020-03-02 00:08:49 +01:00
parent d9df2930cb
commit 26d7fc767c
71 changed files with 141 additions and 34 deletions

View File

@@ -1,13 +1,15 @@
using AdminService from '@sap/capire-bookshop/srv/admin-service';
using AdminService from '@capire/bookshop/srv/admin-service';
////////////////////////////////////////////////////////////////////////////
//
// Books Object Page
//
annotate AdminService.Books with @(
UI: {
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>General}', Target: '@UI.FieldGroup#General'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Translations}', Target: 'texts/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Admin}', Target: '@UI.FieldGroup#Admin'},
],
@@ -15,6 +17,7 @@ annotate AdminService.Books with @(
Data: [
{Value: title},
{Value: author_ID},
{Value: genre_ID},
{Value: descr},
]
},
@@ -35,3 +38,35 @@ annotate AdminService.Books with @(
}
}
);
////////////////////////////////////////////////////////////
//
// Draft for Localized Data
//
annotate sap.capire.bookshop.Books with @fiori.draft.enabled;
annotate AdminService.Books with @odata.draft.enabled;
annotate AdminService.Books_texts with @(
UI: {
Identification: [{Value:title}],
SelectionFields: [ locale, title ],
LineItem: [
{Value: locale, Label: 'Locale'},
{Value: title, Label: 'Title'},
{Value: descr, Label: 'Description'},
]
}
);
// Add Value Help for Locales
annotate AdminService.Books_texts {
locale @ValueList:{entity:'Languages',type:#fixed}
}
// In addition we need to expose Languages through AdminService
using { sap } from '@sap/cds/common';
extend service AdminService {
entity Languages as projection on sap.common.Languages;
}

View File

@@ -1,4 +1,4 @@
using CatalogService from '@sap/capire-bookshop/srv/cat-service';
using CatalogService from '@capire/bookshop/srv/cat-service';
////////////////////////////////////////////////////////////////////////////
//
@@ -40,6 +40,7 @@ annotate CatalogService.Books with @(
LineItem: [
{Value: title},
{Value: author, Label:'{i18n>Author}'},
{Value: genre.name},
{Value: price},
{Value: currency.symbol, Label:' '},
]

View File

@@ -2,7 +2,7 @@
Common Annotations shared by all apps
*/
using { sap.capire.bookshop as my } from '@sap/capire-bookshop/db/schema';
using { sap.capire.bookshop as my } from '@capire/bookshop/db/schema';
////////////////////////////////////////////////////////////////////////////
@@ -17,6 +17,7 @@ annotate my.Books with @(
{Value: ID},
{Value: title},
{Value: author.name, Label:'{i18n>Author}'},
{Value: genre.name},
{Value: stock},
{Value: price},
{Value: currency.symbol, Label:' '},
@@ -57,12 +58,16 @@ annotate my.Books with @(
annotate my.Books with {
ID @title:'{i18n>ID}' @UI.HiddenFilter;
title @title:'{i18n>Title}';
genre @title:'{i18n>Genre}';
author @title:'{i18n>AuthorID}';
price @title:'{i18n>Price}';
stock @title:'{i18n>Stock}';
descr @UI.MultiLineText;
}
annotate my.Genres with {
name @title: '{i18n>Genre}';
}
////////////////////////////////////////////////////////////////////////////
//

View File

@@ -7,4 +7,4 @@ using from './browse/fiori-service';
using from './orders/fiori-service';
using from './common';
using from '@sap/capire-common';
using from '@capire/common';

View File

@@ -1,4 +1,4 @@
using AdminService from '@sap/capire-bookshop/srv/admin-service';
using AdminService from '@capire/bookshop/srv/admin-service';
annotate AdminService.Books with {
price @Common.FieldControl: #ReadOnly;

3
fiori/db/schema.cds Normal file
View File

@@ -0,0 +1,3 @@
// Proxy for importing schema from bookshop sample
using from '@capire/bookshop/db/schema';
namespace sap.capire.bookshop;

View File

@@ -1,11 +1,12 @@
{
"name": "@sap/capire-fiori",
"name": "@capire/fiori",
"version": "1.0.0",
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
"license": "SAP SAMPLE CODE LICENSE",
"dependencies": {
"@sap/capire-bookshop": "*",
"@sap/capire-common": "*",
"@capire/bookshop": "*",
"@capire/genres": "*",
"@capire/common": "*",
"@sap/cds": "*",
"express": "*"
},

View File

@@ -0,0 +1,5 @@
// Proxy for importing services from bookshop sample
using from '@capire/bookshop/srv/admin-service';
using from '@capire/bookshop/srv/cat-service';
annotate AdminService with @impl:'srv/admin-service.js';

View File

@@ -0,0 +1,8 @@
const cds = require('@sap/cds')
module.exports = cds.service.impl (async function() {
const {Books} = cds.entities
const {ID} = await SELECT.one.from(Books).columns('max(ID) as ID')
let newID = ID - ID % 100 + 100
this.before ('NEW','Books', req => req.data.ID = ++newID)
})