diff --git a/bookshop/db/data/sap.capire.bookshop-Books.csv b/bookshop/db/data/sap.capire.bookshop-Books.csv index 40d402c1c..d9cc9ee2e 100644 --- a/bookshop/db/data/sap.capire.bookshop-Books.csv +++ b/bookshop/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,15 -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 \ No newline at end of file +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,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa +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,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa +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,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa +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,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa +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,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa diff --git a/bookshop/db/data/sap.capire.bookshop-Books.texts.csv b/bookshop/db/data/sap.capire.bookshop-Books.texts.csv index 1037f364f..97d60e650 100644 --- a/bookshop/db/data/sap.capire.bookshop-Books.texts.csv +++ b/bookshop/db/data/sap.capire.bookshop-Books.texts.csv @@ -1,5 +1,5 @@ -ID,locale,title,descr -201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts." -201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal." -207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte" -252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit." +ID_texts,ID,locale,title,descr +d2a65a27-9f2a-480f-bc38-84ee8ec5c13e,201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts." +8c42c706-a979-41cf-9ffe-91e6cf1383a0,201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal." +9e1c4c81-dc90-4600-85b1-e9dd4bf12ce0,207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte" +9be0524b-4cb9-4fc1-9dc2-d65b1c13cf53,252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit." diff --git a/bookshop/db/data/sap.capire.bookshop-Genres.csv b/bookshop/db/data/sap.capire.bookshop-Genres.csv index a3070faeb..8e22e9b28 100644 --- a/bookshop/db/data/sap.capire.bookshop-Genres.csv +++ b/bookshop/db/data/sap.capire.bookshop-Genres.csv @@ -1,16 +1,43 @@ ID,parent_ID,name -10,,Fiction -11,10,Drama -12,10,Poetry -13,10,Fantasy -14,10,Science Fiction -15,10,Romance -16,10,Mystery -17,10,Thriller -18,10,Dystopia -19,10,Fairy Tale -20,,Non-Fiction -21,20,Biography -22,21,Autobiography -23,20,Essay -24,20,Speech +10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Fiction +11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Drama +12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Poetry +13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fantasy +131aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fairy Tale +132aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Epic Fantasy +133aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,High Fantasy +134aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Gothic +14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Science Fiction +141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian and Dystopian +1411aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian +1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Dystopian +14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cyberpunk +141211aa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Steampunk +142aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Space Opera +143aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Time Travel +144aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tech Noir +15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romance +151aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Contemporary Romance +152aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Historical Romance +153aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romantic Suspense +16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Mystery +161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Crime +1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Thriller +16111aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Police Procedural +16112aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Legal Thriller +16113aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Medical Thriller +16114aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Spy Thriller +1612aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Detective +1613aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Suspense +162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Noir +1621aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Nordic Noir +1622aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tart Noir +163aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cozy Mystery +17aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Adventure +18aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Short Story +19aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Graphic Novel +20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Non-Fiction +21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Biography +22aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Autobiography +23aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Essay +24aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Speech diff --git a/bookshop/db/schema.cds b/bookshop/db/schema.cds index 597186b1d..7519ea951 100644 --- a/bookshop/db/schema.cds +++ b/bookshop/db/schema.cds @@ -25,9 +25,14 @@ entity Authors : managed { /** Hierarchically organized Code List for Genres */ entity Genres : sap.common.CodeList { - key ID : Integer; + key ID : UUID; parent : Association to Genres; children : Composition of many Genres on children.parent = $self; } type Price : Decimal(9,2); + + +// ------------------------------------------------------------------ +// temporary workaround for reuse in fiori sample and hana deployment +annotate Books with @fiori.draft.enabled; diff --git a/fiori/.env b/fiori/.env new file mode 100644 index 000000000..378269b76 --- /dev/null +++ b/fiori/.env @@ -0,0 +1 @@ +cds.requires.[hybrid].messaging.kind=file-based-messaging \ No newline at end of file diff --git a/fiori/app/_i18n/i18n_en.properties b/fiori/app/_i18n/i18n_en.properties index 5d164a342..809011add 100644 --- a/fiori/app/_i18n/i18n_en.properties +++ b/fiori/app/_i18n/i18n_en.properties @@ -1,7 +1,7 @@ Age = Age Lifetime = Lifetime -SubGenres = Sub Genres +SubGenres = Subgenre NumCode = Numeric Code MinorUnit = Minor Unit diff --git a/fiori/app/admin-books/fiori-service.cds b/fiori/app/admin-books/fiori-service.cds index dc820ea9c..6be07610f 100644 --- a/fiori/app/admin-books/fiori-service.cds +++ b/fiori/app/admin-books/fiori-service.cds @@ -1,6 +1,8 @@ using { AdminService } from '@capire/bookstore'; using from '../common'; // to help UI linter get the complete annotations + + //////////////////////////////////////////////////////////////////////////// // // Books Object Page @@ -40,7 +42,48 @@ annotate AdminService.Books with @( } ); +//////////////////////////////////////////////////////////////////////////// +// +// Value Help for Tree Table +// +annotate AdminService.Books with { + genre @(Common: { + Label : 'Genre', + ValueList: { + CollectionPath : 'Genres', + Parameters : [ + { + $Type : 'Common.ValueListParameterDisplayOnly', + ValueListProperty: 'name', + }, + { + $Type : 'Common.ValueListParameterInOut', + LocalDataProperty: genre_ID, + ValueListProperty: 'ID', + } + ], + PresentationVariantQualifier: 'VH', + } + }); +} + +annotate AdminService.Genres with @UI: { + PresentationVariant #VH: { + $Type : 'UI.PresentationVariantType', + Visualizations : ['@UI.LineItem'], + RecursiveHierarchyQualifier: 'GenreHierarchy' + }, + LineItem : [{ + $Type: 'UI.DataField', + Value: name, + Label :'{i18n>Name}' + }], +}; +// Hide ID because of the ValueHelp +annotate AdminService.Genres with { + ID @UI.Hidden; +}; //////////////////////////////////////////////////////////// // @@ -82,5 +125,3 @@ extend service AdminService { // Workaround for Fiori popup for asking user to enter a new UUID on Create annotate AdminService.Books with { ID @Core.Computed; } -// Show Genre as drop down, not a dialog -annotate AdminService.Books with { genre @Common.ValueListWithFixedValues; } diff --git a/fiori/app/appconfig/fioriSandboxConfig.json b/fiori/app/appconfig/fioriSandboxConfig.json index f1b089426..aae8e77ab 100644 --- a/fiori/app/appconfig/fioriSandboxConfig.json +++ b/fiori/app/appconfig/fioriSandboxConfig.json @@ -18,6 +18,14 @@ "title": "Browse Books", "targetURL": "#Books-display" } + }, + { + "id": "BrowseGenres", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Browse Genres", + "targetURL": "#Genres-display" + } } ] }, @@ -106,6 +114,24 @@ "url": "/admin-authors/webapp" } }, + "BrowseGenres": { + "semanticObject": "Genres", + "action": "display", + "title": "Browse Genres", + "signature": { + "parameters": { + "Genre.ID": { + "renameTo": "ID" + } + }, + "additionalParameters": "ignored" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=genres", + "url": "/genres/webapp" + } + }, "ManageBooks": { "semanticObject": "Books", "action": "manage", diff --git a/fiori/app/common.cds b/fiori/app/common.cds index 3e5f748a6..e4ebc121b 100644 --- a/fiori/app/common.cds +++ b/fiori/app/common.cds @@ -69,28 +69,81 @@ annotate my.Books with { image @title: '{i18n>Image}'; } +//////////////////////////////////////////////////////////////////////////// +// +// Computed Fields for Tree Tables +// +// DISCLAIMER: The below are an alpha version implementation and will change in final release !!! +// +aspect Hierarchy { + LimitedDescendantCount : Integer64 = null; + DistanceFromRoot : Integer64 = null; + DrillState : String = null; + Matched : Boolean = null; + MatchedDescendantCount : Integer64 = null; + LimitedRank : Integer64 = null; +} + +annotate Hierarchy with @Capabilities.FilterRestrictions.NonFilterableProperties: [ + 'LimitedDescendantCount', + 'DistanceFromRoot', + 'DrillState', + 'Matched', + 'MatchedDescendantCount', + 'LimitedRank' +]; + +annotate Hierarchy with @Capabilities.SortRestrictions.NonSortableProperties: [ + 'LimitedDescendantCount', + 'DistanceFromRoot', + 'DrillState', + 'Matched', + 'MatchedDescendantCount', + 'LimitedRank' +]; + +extend my.Genres with Hierarchy; + +//////////////////////////////////////////////////////////////////////////// +// +// Genres Tree Table Annotations +// +// DISCLAIMER: The below are an alpha version implementation and will change in final release !!! +// +annotate my.Genres with @Aggregation.RecursiveHierarchy #GenreHierarchy: { + $Type : 'Aggregation.RecursiveHierarchyType', + NodeProperty : ID, // identifies a node + ParentNavigationProperty: parent // navigates to a node's parent +}; + +annotate my.Genres with @Hierarchy.RecursiveHierarchy #GenreHierarchy: { + $Type : 'Hierarchy.RecursiveHierarchyType', + LimitedDescendantCount: LimitedDescendantCount, + DistanceFromRoot : DistanceFromRoot, + DrillState : DrillState, + Matched : Matched, + MatchedDescendantCount: MatchedDescendantCount, + LimitedRank : LimitedRank +}; + +annotate my.Genres with @( + readonly, + cds.search: {name} +); //////////////////////////////////////////////////////////////////////////// // // Genres List // annotate my.Genres with @( - Common.SemanticKey : [name], - UI : { - SelectionFields : [name], - LineItem : [ - { Value: name }, - { - Value : parent.name, - Label: 'Main Genre' - }, - ], - } + Common.SemanticKey : [name], + UI : { + SelectionFields : [name], + LineItem : [ + { Value : name, Label : '{i18n>Name}' }, + ], + } ); -annotate my.Genres with { - ID @Common.Text : name @Common.TextArrangement : #TextOnly; -} - //////////////////////////////////////////////////////////////////////////// // // Genre Details @@ -102,12 +155,7 @@ annotate my.Genres with @(UI : { TypeNamePlural : '{i18n>Genres}', Title : { Value: name }, Description : { Value: ID } - }, - Facets : [{ - $Type : 'UI.ReferenceFacet', - Label : '{i18n>SubGenres}', - Target : 'children/@UI.LineItem' - }, ], + } }); //////////////////////////////////////////////////////////////////////////// @@ -115,7 +163,6 @@ annotate my.Genres with @(UI : { // Genres Elements // annotate my.Genres with { - ID @title: '{i18n>ID}'; name @title: '{i18n>Genre}'; } diff --git a/fiori/app/genres/fiori-service.cds b/fiori/app/genres/fiori-service.cds new file mode 100644 index 000000000..e1961cf0a --- /dev/null +++ b/fiori/app/genres/fiori-service.cds @@ -0,0 +1,3 @@ +/* +All annotations needed for UI5 Tree Table View are located in '../common' +*/ diff --git a/fiori/app/genres/webapp/Component.js b/fiori/app/genres/webapp/Component.js new file mode 100644 index 000000000..63ffcefd8 --- /dev/null +++ b/fiori/app/genres/webapp/Component.js @@ -0,0 +1,3 @@ +sap.ui.define(["sap/fe/core/AppComponent"], ac => ac.extend("genres.Component", { + metadata:{ manifest:'json' } +})) diff --git a/fiori/app/genres/webapp/i18n/i18n.properties b/fiori/app/genres/webapp/i18n/i18n.properties new file mode 100644 index 000000000..42da06717 --- /dev/null +++ b/fiori/app/genres/webapp/i18n/i18n.properties @@ -0,0 +1,4 @@ +#XTIT +appTitle=Browse Genres +#XTXT +appDescription=Genres as Tree View diff --git a/fiori/app/genres/webapp/i18n/i18n_de.properties b/fiori/app/genres/webapp/i18n/i18n_de.properties new file mode 100644 index 000000000..e8714e92e --- /dev/null +++ b/fiori/app/genres/webapp/i18n/i18n_de.properties @@ -0,0 +1,2 @@ +appTitle=Zeige Genres +appDescription=Genres als Baumansicht diff --git a/fiori/app/genres/webapp/manifest.json b/fiori/app/genres/webapp/manifest.json new file mode 100644 index 000000000..a43f4a838 --- /dev/null +++ b/fiori/app/genres/webapp/manifest.json @@ -0,0 +1,124 @@ +{ + "_version": "1.8.0", + "sap.app": { + "id": "genres", + "type": "application", + "title": "{{appTitle}}", + "description": "{{appDescription}}", + "applicationVersion": { + "version": "1.0.0" + }, + "dataSources": { + "AdminService": { + "uri": "admin/", + "type": "OData", + "settings": { + "odataVersion": "4.0" + } + } + }, + "crossNavigation": { + "inbounds": { + "Genres-display": { + "signature": { + "parameters": {}, + "additionalParameters": "allowed" + }, + "semanticObject": "Genres", + "action": "display" + } + } + } + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.122.0", + "libs": { + "sap.fe.templates": {} + } + }, + "models": { + "i18n": { + "type": "sap.ui.model.resource.ResourceModel", + "uri": "i18n/i18n.properties" + }, + "": { + "dataSource": "AdminService", + "settings": { + "synchronizationMode": "None", + "operationMode": "Server", + "autoExpandSelect": true, + "earlyRequests": true, + "groupProperties": { + "default": { + "submit": "Auto" + } + } + } + } + }, + "routing": { + "routes": [ + { + "pattern": ":?query:", + "name": "GenresList", + "target": "GenresList" + }, + { + "pattern": "Genres({key}):?query:", + "name": "GenresDetails", + "target": "GenresDetails" + } + ], + "targets": { + "GenresList": { + "type": "Component", + "id": "GenresList", + "name": "sap.fe.templates.ListReport", + "options": { + "settings": { + "contextPath": "/Genres", + "navigation": { + "Genres": { + "detail": { + "route": "GenresDetails" + } + } + }, + "controlConfiguration": { + "@com.sap.vocabularies.UI.v1.LineItem": { + "tableSettings": { + "hierarchyQualifier": "GenreHierarchy", + "type": "TreeTable" + } + } + } + } + } + }, + "GenresDetails": { + "type": "Component", + "id": "GenresDetails", + "name": "sap.fe.templates.ObjectPage", + "options": { + "settings": { + "contextPath": "/Genres" + } + } + } + } + }, + "contentDensities": { + "compact": true, + "cozy": true + } + }, + "sap.ui": { + "technology": "UI5", + "fullWidth": false + }, + "sap.fiori": { + "registrationIds": [], + "archeType": "transactional" + } +} diff --git a/fiori/db/common.cds b/fiori/db/common.cds deleted file mode 100644 index 38438e78d..000000000 --- a/fiori/db/common.cds +++ /dev/null @@ -1,14 +0,0 @@ -namespace sap.capire.bookshop; - -using { sap.capire.bookshop } from '@capire/bookstore/srv/mashup'; - -entity GenreHierarchy : bookshop.Genres { - hierarchyLevel : Integer default 0; - drillState : String default 'leaf'; - parent : Association to GenreHierarchy; - children : Composition of many GenreHierarchy on children.parent = $self; -} - -extend service CatalogService with { - @readonly entity GenreHierarchy as projection on bookshop.GenreHierarchy; -} diff --git a/fiori/db/data/sap.capire.bookshop-GenreHierarchy.csv b/fiori/db/data/sap.capire.bookshop-GenreHierarchy.csv deleted file mode 100644 index f0d3743e4..000000000 --- a/fiori/db/data/sap.capire.bookshop-GenreHierarchy.csv +++ /dev/null @@ -1,16 +0,0 @@ -ID;parent_ID;name;hierarchyLevel;drillState -10;;Fiction;0;expanded -11;10;Drama;1;leaf -12;10;Poetry;1;leaf -13;10;Fantasy;1;leaf -14;10;Science Fiction;1;leaf -15;10;Romance;1;leaf -16;10;Mystery;1;leaf -17;10;Thriller;1;leaf -18;10;Dystopia;1;leaf -20;;Non-Fiction;0;expanded -19;10;Fairy Tale;1;leaf -21;20;Biography;1;expanded -22;21;Autobiography;2;leaf -23;20;Essay;1;leaf -24;20;Speech;1;leaf diff --git a/fiori/server.js b/fiori/server.js new file mode 100644 index 000000000..312762d4e --- /dev/null +++ b/fiori/server.js @@ -0,0 +1,32 @@ +const cds = require('@sap/cds/lib') +if (cds.requires.db?.kind === 'sqlite') { + cds.on ('serving:AdminService', srv => srv.prepend(() => { + const {Genres} = srv.entities + // Register a simplistic handler for hierarchical queries + srv.on('READ', Genres, (req,next) => { + const q = req.query + // Expand query on a single row + if (q.SELECT.recurse?.where?.[0].ref[0] === 'Distance') { + q.SELECT.where[0] = 'parent_ID' + // Initial query + } else if (!q.SELECT.search && !is_count(q)) { + q.SELECT.where ??= [ 'parent_ID is null' ] + } + // Use scalar subselect for DrillState + q.SELECT.from.as = 'g' + q.SELECT.columns = q.SELECT.columns.map (c => { + if (c.ref == 'DrillState') return { xpr:[` + CASE WHEN ( SELECT count(1) from ${Genres} where parent_ID = g.ID ) > 0 + THEN 'collapsed' ELSE 'leaf' END` + ], as: 'DrillState' } + else return c + }) + // Suppress error message: Feature "recurse" queries not supported. + delete q.SELECT.__proto__.recurse + delete q.SELECT.recurse + return next() + }) + })) +} + +const is_count = q => q.SELECT.columns?.length === 1 && q.SELECT.columns[0].func === 'count' diff --git a/test/odata.test.js b/test/odata.test.js index d7603c8de..446d62e69 100644 --- a/test/odata.test.js +++ b/test/odata.test.js @@ -17,8 +17,8 @@ describe('cap/samples - Bookshop APIs', () => { }) it('serves ListOfBooks?$expand=genre,currency', async () => { - const Mystery = { ID: 16, name: 'Mystery', descr: null, parent_ID: 10 } - const Romance = { ID: 15, name: 'Romance', descr: null, parent_ID: 10 } + const Mystery = { name: 'Mystery' } + const Romance = { name: 'Romance' } const USD = { code: 'USD', name: 'US Dollar', descr: null, symbol: '$' } const { data } = await GET `/browse/ListOfBooks ${{ params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` },