diff --git a/bookshop/srv/admin-service.cds b/bookshop/srv/admin-service.cds index 50154109..37b02eb7 100644 --- a/bookshop/srv/admin-service.cds +++ b/bookshop/srv/admin-service.cds @@ -2,4 +2,5 @@ using { sap.capire.bookshop as my } from '../db/schema'; service AdminService @(path:'/admin') { entity Authors as projection on my.Authors; entity Books as projection on my.Books; + entity Genres as projection on my.Genres; } diff --git a/fiori/app/admin-books/fiori-service.cds b/fiori/app/admin-books/fiori-service.cds index 3307a0ea..6be07610 100644 --- a/fiori/app/admin-books/fiori-service.cds +++ b/fiori/app/admin-books/fiori-service.cds @@ -1,4 +1,4 @@ -using { AdminService } from '../services'; +using { AdminService } from '@capire/bookstore'; using from '../common'; // to help UI linter get the complete annotations @@ -50,7 +50,7 @@ annotate AdminService.Books with { genre @(Common: { Label : 'Genre', ValueList: { - CollectionPath : 'GenreHierarchy', + CollectionPath : 'Genres', Parameters : [ { $Type : 'Common.ValueListParameterDisplayOnly', @@ -67,7 +67,7 @@ annotate AdminService.Books with { }); } -annotate AdminService.GenreHierarchy with @UI: { +annotate AdminService.Genres with @UI: { PresentationVariant #VH: { $Type : 'UI.PresentationVariantType', Visualizations : ['@UI.LineItem'], @@ -81,7 +81,7 @@ annotate AdminService.GenreHierarchy with @UI: { }; // Hide ID because of the ValueHelp -annotate AdminService.GenreHierarchy with { +annotate AdminService.Genres with { ID @UI.Hidden; }; diff --git a/fiori/app/common.cds b/fiori/app/common.cds index 50c775cb..39a3ae8e 100644 --- a/fiori/app/common.cds +++ b/fiori/app/common.cds @@ -69,6 +69,63 @@ annotate my.Books with { image @title: '{i18n>Image}'; } +//////////////////////////////////////////////////////////////////////////// +// +// Computed Fields for Tree Tables +// +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 +// +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 @@ -94,12 +151,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' - }, ], + } }); //////////////////////////////////////////////////////////////////////////// diff --git a/fiori/app/genres/fiori-service.cds b/fiori/app/genres/fiori-service.cds index 8b137891..e1961cf0 100644 --- a/fiori/app/genres/fiori-service.cds +++ b/fiori/app/genres/fiori-service.cds @@ -1 +1,3 @@ - +/* +All annotations needed for UI5 Tree Table View are located in '../common' +*/ diff --git a/fiori/app/genres/webapp/manifest.json b/fiori/app/genres/webapp/manifest.json index 571ec44a..a43f4a83 100644 --- a/fiori/app/genres/webapp/manifest.json +++ b/fiori/app/genres/webapp/manifest.json @@ -24,7 +24,7 @@ "parameters": {}, "additionalParameters": "allowed" }, - "semanticObject": "GenreHierarchy", + "semanticObject": "Genres", "action": "display" } } @@ -61,27 +61,27 @@ "routes": [ { "pattern": ":?query:", - "name": "GenreHierarchyList", - "target": "GenreHierarchyList" + "name": "GenresList", + "target": "GenresList" }, { - "pattern": "GenreHierarchy({key}):?query:", - "name": "GenreHierarchyDetails", - "target": "GenreHierarchyDetails" + "pattern": "Genres({key}):?query:", + "name": "GenresDetails", + "target": "GenresDetails" } ], "targets": { - "GenreHierarchyList": { + "GenresList": { "type": "Component", - "id": "GenreHierarchyList", + "id": "GenresList", "name": "sap.fe.templates.ListReport", "options": { "settings": { - "contextPath": "/GenreHierarchy", + "contextPath": "/Genres", "navigation": { - "GenreHierarchy": { + "Genres": { "detail": { - "route": "GenreHierarchyDetails" + "route": "GenresDetails" } } }, @@ -96,13 +96,13 @@ } } }, - "GenreHierarchyDetails": { + "GenresDetails": { "type": "Component", - "id": "GenreHierarchyDetails", + "id": "GenresDetails", "name": "sap.fe.templates.ObjectPage", "options": { "settings": { - "contextPath": "/GenreHierarchy" + "contextPath": "/Genres" } } } diff --git a/fiori/app/services.cds b/fiori/app/services.cds index c0d10d04..adbf7f60 100644 --- a/fiori/app/services.cds +++ b/fiori/app/services.cds @@ -1,32 +1,6 @@ /* This model controls what gets served to Fiori frontends... */ -using { sap.capire.bookshop } from '../db/hierarchy'; -using { AdminService } from '@capire/bookstore'; - -extend service AdminService with { - @readonly - @cds.search: {name} - entity GenreHierarchy as projection on bookshop.Genres; -} - -annotate AdminService.GenreHierarchy with @Aggregation.RecursiveHierarchy #GenreHierarchy: { - $Type : 'Aggregation.RecursiveHierarchyType', - NodeProperty : ID, // identifies a node - ParentNavigationProperty: parent // navigates to a node's parent -}; - -annotate AdminService.GenreHierarchy with @Hierarchy.RecursiveHierarchy #GenreHierarchy: { - $Type : 'Hierarchy.RecursiveHierarchyType', - LimitedDescendantCount: LimitedDescendantCount, - DistanceFromRoot : DistanceFromRoot, - DrillState : DrillState, - Matched : Matched, - MatchedDescendantCount: MatchedDescendantCount, - LimitedRank : LimitedRank -}; - - using from './admin-authors/fiori-service'; using from './admin-books/fiori-service'; using from './browse/fiori-service'; diff --git a/fiori/db/hierarchy.cds b/fiori/db/hierarchy.cds deleted file mode 100644 index 35593b92..00000000 --- a/fiori/db/hierarchy.cds +++ /dev/null @@ -1,32 +0,0 @@ -namespace sap.capire.bookshop; -using { sap.capire.bookshop.Genres } from '@capire/bookshop'; - -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 sap.capire.bookshop.Genres with Hierarchy; \ No newline at end of file