diff --git a/app/_i18n/i18n.properties b/app/_i18n/i18n.properties index 8cdd0a3..225b4a7 100644 --- a/app/_i18n/i18n.properties +++ b/app/_i18n/i18n.properties @@ -13,3 +13,8 @@ Order = Order Orders = Orders Price = Price Reviews = Reviews +ReviewText = Review Text +Rating = Rating +Pages = Pages +ISBN = ISBN +Publication = Publication diff --git a/app/admin-books/fiori-service.cds b/app/admin-books/fiori-service.cds index ea08f2e..f8f6b76 100644 --- a/app/admin-books/fiori-service.cds +++ b/app/admin-books/fiori-service.cds @@ -39,6 +39,12 @@ annotate AdminService.Books with @(UI: { Label : '{i18n>Admin}', Target: '@UI.FieldGroup#Admin' }, + // hint: add Publication section to Manage Books app's page view + { + $Type : 'UI.ReferenceFacet', + Label : '{i18n>Publication}', + Target: '@UI.FieldGroup#Publication' + } ], FieldGroup #General: {Data: [ {Value: title}, @@ -59,9 +65,28 @@ annotate AdminService.Books with @(UI: { {Value: createdAt}, {Value: modifiedBy}, {Value: modifiedAt} + ]}, + // hint: adds Pages and ISBN display to the Publication section + FieldGroup #Publication: {Data: [ + {Value: pages, Label:'{i18n>Pages}'}, + {Value: isbn, Label:'{i18n>ISBN}'} ]} }); +// hint: define data that is displayed in the list display's extended row mode +annotate AdminService.Books with @(UI: { + SelectionFields: [ title, author_ID, isbn ], + LineItem: [ + { Value:title, Label:'{i18n>Title}' }, + { Value:author.name, Label:'{i18n>Author}' }, + { Value:genre.name, Label:'{i18n>Genre}' }, + { Value:pages, Label:'{i18n>Pages}' }, // hint: display Pages + { Value:isbn, Label:'{i18n>ISBN}' }, // hint: display ISBN + { Value:price, Label:'{i18n>Price}' }, + { Value:currency.symbol, Label:'{i18n>Currency}' }, + { Value:stock, Label:'{i18n>Stock}' } + ] +}); //////////////////////////////////////////////////////////// // @@ -123,3 +148,11 @@ annotate AdminService.Books with { annotate AdminService.Books with { genre @Common.ValueListWithFixedValues; } + +// hint: this was needed to make the path not found at 'reviews/@UI.LineItem' go away +annotate AdminService.Reviews with @(UI: { + LineItem: [ + { Value: text, Label: '{i18n>ReviewText}' }, + { Value: rating, Label: '{i18n>Rating}' } + ] +}); diff --git a/app/browse/fiori-service.cds b/app/browse/fiori-service.cds index ddcc960..d35a7d9 100644 --- a/app/browse/fiori-service.cds +++ b/app/browse/fiori-service.cds @@ -16,10 +16,27 @@ annotate CatalogService.Books with @(UI : { Label : '{i18n>Description}', Target: '@UI.FieldGroup#Descr' }, ], - Facets: [{ - $Type : 'UI.ReferenceFacet', - Label : '{i18n>Details}', - Target: '@UI.FieldGroup#Price' + Facets: [{ + $Type: 'UI.ReferenceFacet', + Label: '{i18n>Description}', + Target: '@UI.FieldGroup#Descr' + }, + { + $Type: 'UI.ReferenceFacet', + Label: '{i18n>Details}', + Target: '@UI.FieldGroup#Price' + }, + { + $Type: 'UI.ReferenceFacet', + Label: '{i18n>Publication}', + Target: '@UI.FieldGroup#Publication' + }, + + // hint: new facet -> navigates to the reviews entity of this book + { + $Type: 'UI.ReferenceFacet', + Label: '{i18n>Reviews}', + Target: 'reviews/@UI.LineItem' }, ], FieldGroup #Descr: {Data : [{Value : descr}, ]}, FieldGroup #Price: {Data : [ @@ -29,6 +46,12 @@ annotate CatalogService.Books with @(UI : { Label: '{i18n>Currency}' }, ]}, + + // hint: shows pages & isbn on the object page + FieldGroup #Publication: { Data: [ + { Value: pages, Label: '{i18n>Pages}' }, + { Value: isbn, Label: '{i18n>ISBN}' } + ]} }); //////////////////////////////////////////////////////////////////////////// @@ -39,19 +62,33 @@ annotate CatalogService.Books with @(UI : { SelectionFields: [ ID, price, - currency_code + currency_code, + // hint: adds isbn search field + isbn ], LineItem: [ - { - Value: ID, - Label: '{i18n>Title}' + { + Value: ID, + Label: '{i18n>Title}' }, - { + { Value: author, - Label: '{i18n>Author}' + Label: '{i18n>Author}' }, - {Value: genre.name}, - {Value: price}, - {Value: currency.symbol}, + { Value: genre.name }, + { Value: price }, + // hint: adds Pages + { Value: pages, Label: '{i18n>Pages}' }, + // hint: adds ISBN + { Value: isbn, Label: '{i18n>ISBN}' } ] }); + +// hint: adding this removes the `Path does not exist.CDS (annotations)` error +annotate CatalogService.Reviews with @(UI: { + LineItem: [ + { Value: rating, Label: '{i18n>Rating}' }, + { Value: text, Label: '{i18n>Review}' }, + { Value: createdAt, Label: '{i18n>Date}' } + ] +}); diff --git a/app/common.cds b/app/common.cds index f645e10..9abbcc7 100644 --- a/app/common.cds +++ b/app/common.cds @@ -70,6 +70,8 @@ annotate my.Books with { stock @title: '{i18n>Stock}'; descr @title: '{i18n>Description}' @UI.MultiLineText; image @title: '{i18n>Image}'; + // hint: labels the search field with value from i18n + isbn @title: '{i18n>ISBN}'; } //////////////////////////////////////////////////////////////////////////// diff --git a/db/data/sap.capire.bookshop-Books.csv b/db/data/sap.capire.bookshop-Books.csv index fa6cca8..47871a4 100644 --- a/db/data/sap.capire.bookshop-Books.csv +++ b/db/data/sap.capire.bookshop-Books.csv @@ -1,6 +1,6 @@ -ID,title,descr,author_ID,stock,price,currency_code,genre_ID -201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11 -207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11 -251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16 -252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,16 -271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13 +ID,title,descr,author_ID,stock,price,currency_code,genre_ID,pages,isbn +201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11,416,9780141439556 +207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11,532,9780141441146 +251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16,64,9780142437778 +252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,16,48,9781503274010 +271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13,288,9780330026625 diff --git a/db/schema.cds b/db/schema.cds index 77ebec5..ac354c6 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -16,8 +16,11 @@ entity Books : managed { price : Decimal; currency : Currency; image : LargeBinary @Core.MediaType: 'image/png'; - reviews : Association to many Reviews + reviews : Association to many Reviews on reviews.book = $self; + + pages : Integer @assert.range: [(0),_]; // hint: adds validation, must be > 0 + isbn : String(20) @assert.format: '^(?=(?:\D*\d){10}(?:(?:\D*\d){3})?$)[\d-]+$'; // hint: https://stackoverflow.com/questions/41271613/use-regex-to-verify-an-isbn-number } entity Reviews : managed { diff --git a/srv/cat-service.cds b/srv/cat-service.cds index 714bab3..707244b 100644 --- a/srv/cat-service.cds +++ b/srv/cat-service.cds @@ -7,9 +7,15 @@ service CatalogService { /** For display in details pages */ @readonly entity Books as projection on my.Books { *, - author.name as author + author.name as author, + reviews } excluding { createdBy, modifiedBy }; + entity Reviews as projection on my.Reviews { + *, + book + }; + @requires: 'authenticated-user' action submitOrder ( book : Books:ID @mandatory,