Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate Hierarchy Functions #416

Merged
merged 33 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
16c919d
WIP: Demonstrate Hierarchy Functions (#388)
etimr Nov 13, 2024
cb392f7
Fix: ValueHelp Dialog (#397)
etimr Nov 26, 2024
2d8f6f8
Fix value help (#398)
agoerler Nov 26, 2024
1a037e3
Update fiori-service.cds
agoerler Nov 26, 2024
357611e
UI: Hide ID in ValueHelp (#399)
etimr Nov 26, 2024
7b6179e
Update to 3.5.0 & avoid parent_id/node_id projection
agoerler Nov 26, 2024
c7f50a8
Demonstrate custom logic for Tree Tables (#393)
etimr Nov 27, 2024
2897b41
Merge remote-tracking branch 'origin/feature-tree-table' into avoidRe…
agoerler Nov 27, 2024
45e6b03
Support of ExpandLevels (#403)
etimr Nov 28, 2024
7bf5397
cleanup
agoerler Nov 28, 2024
4b5892d
Merge remote-tracking branch 'origin/feature-tree-table' into avoidRe…
agoerler Nov 28, 2024
cd01357
No projection (#401)
agoerler Nov 28, 2024
3cd209a
fix sorter
agoerler Nov 28, 2024
a8ea2f2
Merge remote-tracking branch 'origin/feature-tree-table' into avoidRe…
agoerler Nov 28, 2024
7e2153e
added tests for GenreHierarchy
OlenaTi Nov 29, 2024
ae813c2
test in hybrid mode
agoerler Dec 2, 2024
b8d8285
Test: added tests for GenreHierarchy (#404)
etimr Dec 2, 2024
3902076
update test
agoerler Dec 2, 2024
9fe4f93
Merge remote-tracking branch 'origin/feature-tree-table' into tree-ta…
agoerler Dec 2, 2024
3a19bc0
Merge remote-tracking branch 'origin/main' into feature-tree-table
agoerler Dec 3, 2024
903852e
parnt -> parent
agoerler Dec 16, 2024
a6078cd
Merge remote-tracking branch 'origin/main' into feature-tree-table
agoerler Dec 16, 2024
17354c9
fix annotation
agoerler Dec 16, 2024
ee8b025
Added Tree Tables to Readme (#414)
etimr Dec 17, 2024
81bd62e
Test: added additional tests for GenreHierarchy (#413)
etimr Dec 17, 2024
a9db367
fix import
agoerler Dec 17, 2024
333d2da
more genres (#412)
eugene-andreev Dec 17, 2024
b7953a0
update to 3.6.0-m2451
agoerler Dec 17, 2024
1c85e8a
remove DEBUG
etimr Dec 18, 2024
8fd4aad
3.6.0
eugene-andreev Dec 18, 2024
0e45154
formatting
agoerler Dec 19, 2024
88c34df
Merge branch 'main' into feature-tree-table
agoerler Dec 19, 2024
c127115
add disclaimer
agoerler Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ User Interface related Features:
- [Model Localization](https://cap.cloud.sap/docs/guides/i18n) for [English](app/_i18n/i18n.properties) and [German](app/_i18n/i18n_de.properties) language for static texts
- [Custom File Upload extension](app/admin/webapp/extension/Upload.js) which provides a button for uploading `CSV` files
- A simple Swagger UI for the CatalogService API at <http://localhost:8080/swagger/index.html>
- UI5 [Tree Table](app/genres/webapp/manifest.json) with Value Help for [GenreHierarchy](app/admin/fiori-service.cds)
- [Custom event handlers](https://cap.cloud.sap/docs/java/provisioning-api) for Tree Table such as the [Custom business logic for GenreHierarchy](srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java).
Please note, that Tree Tables must be used with HANA. Custom event handler in this case provides a limited support ment for local testing.

CDS Maven Plugin Features:

Expand Down Expand Up @@ -138,6 +141,14 @@ are defined for local development:
- User: `user`, password: `user` to browse books
- User: `admin`, password: `admin` to manage books and orders

### Testing in hybrid mode

You can test the `GenreHierarchyTest` on H2 using the profile `default` as well as on HANA using the profile `hybrid`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather recommend usage of existing profiles in application.yaml, e.g. cloud, which expects HANA.


```
cds bind --exec -- mvn clean install -Dspring.profiles.active=hybrid
```

## Using VS Code

VS Code supports the project out-of-the-box, when using the [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack).
Expand Down
38 changes: 38 additions & 0 deletions app/admin/fiori-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,44 @@ annotate AdminService.Books with @(UI : {
]}
});

// Add Value Help for Tree Table
annotate AdminService.Books with {
genre @(Common: {
Label : 'Genre',
ValueList: {
CollectionPath : 'GenreHierarchy',
Parameters : [
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'name',
},
{
$Type : 'Common.ValueListParameterInOut',
LocalDataProperty: genre_ID,
ValueListProperty: 'ID',
}
],
PresentationVariantQualifier: 'VH',
}
});
}

// Hide ID because of the ValueHelp
annotate AdminService.GenreHierarchy with {
ID @UI.Hidden;
};

annotate AdminService.GenreHierarchy with @UI: {
PresentationVariant #VH: {
$Type : 'UI.PresentationVariantType',
Visualizations : ['@UI.LineItem'],
RecursiveHierarchyQualifier: 'GenreHierarchy'
},
LineItem : [{
$Type: 'UI.DataField',
Value: name,
}]
};

////////////////////////////////////////////////////////////
//
Expand Down
21 changes: 21 additions & 0 deletions app/appconfig/fioriSandboxConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
"title": "Browse Books",
"description": "Find your favorite book"
}
}, {
"id": "browse-genres",
"tileType": "sap.ushell.ui.tile.StaticTile",
"properties": {
"targetURL": "#Genres-display",
"title": "Browse Genres",
"description": "Find your favorite genre"
}
}
]
},
Expand Down Expand Up @@ -112,6 +120,19 @@
"url": "/browse/webapp"
}
},
"browse-genres": {
"semanticObject": "Genres",
"action": "display",
"signature": {
"parameters": {},
"additionalParameters": "allowed"
},
"resolutionResult": {
"applicationType": "SAPUI5",
"additionalInformation": "SAPUI5.Component=genres",
"url": "/genres/webapp"
}
},
"manage-books": {
"semanticObject": "Books",
"action": "manage",
Expand Down
13 changes: 3 additions & 10 deletions app/common.cds
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,8 @@ annotate my.Genres with
UI : {
SelectionFields : [name],
LineItem : [
{Value : name},
{
Value : parent.name,
Label : 'Main Genre'
{Value : name,
Label : '{i18n>Name}',
},
],
}
Expand All @@ -199,12 +197,7 @@ annotate my.Genres with
TypeNamePlural : '{i18n>Genres}',
Title : {Value : name},
Description : {Value : ID}
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>SubGenres}',
Target : 'children/@UI.LineItem'
}, ],
}
});


Expand Down
23 changes: 23 additions & 0 deletions app/genres/fiori-service.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
UI annotations for the Browse GenreHierarchy App
*/

using AdminService from '../../srv/admin-service';


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',
// ExternalKey : null,
LimitedDescendantCount: LimitedDescendantCount,
DistanceFromRoot: DistanceFromRoot,
DrillState: DrillState,
Matched: Matched,
MatchedDescendantCount: MatchedDescendantCount,
LimitedRank: LimitedRank
};
12 changes: 12 additions & 0 deletions app/genres/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "genres",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
3 changes: 3 additions & 0 deletions app/genres/webapp/Component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sap.ui.define(["sap/fe/core/AppComponent"], ac => ac.extend("genres.Component", {
metadata:{ manifest:'json' }
}))
2 changes: 2 additions & 0 deletions app/genres/webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appTitle=Browse Genres
appDescription=Genres as Tree View
2 changes: 2 additions & 0 deletions app/genres/webapp/i18n/i18n_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appTitle=Zeige Genres
appDescription=Genres als Baumansicht
35 changes: 35 additions & 0 deletions app/genres/webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Browse Genres</title>
<style>
html, body, body > div, #container, #container-uiarea {
height: 100%;
}
</style>
<script
id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-resourceroots='{
"genres": "./"
}'
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true"
data-sap-ui-frameOptions="trusted"
></script>
</head>
<body class="sapUiBody sapUiSizeCompact" id="content">
<div
data-sap-ui-component
data-name="genres"
data-id="container"
data-settings='{"id" : "genres"}'
data-handle-validation="true"
></div>
</body>
</html>
129 changes: 129 additions & 0 deletions app/genres/webapp/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"_version": "1.8.0",
"sap.app": {
"id": "genres",
"type": "application",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"AdminService": {
"uri": "/api/admin/",
"type": "OData",
"settings": {
"odataVersion": "4.0"
}
}
},
"-sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"-id": "ui5template.smartTemplate",
"-version": "1.40.12"
},
"crossNavigation": {
"inbounds": {
"Genres-show": {
"signature": {
"parameters": {},
"additionalParameters": "allowed"
},
"semanticObject": "GenreHierarchy",
"action": "show"
}
}
}
},
"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": "GenreHierarchyList",
"target": "GenreHierarchyList"
},
{
"pattern": "GenreHierarchy({key}):?query:",
"name": "GenreHierarchyDetails",
"target": "GenreHierarchyDetails"
}
],
"targets": {
"GenreHierarchyList": {
"type": "Component",
"id": "GenreHierarchyList",
"name": "sap.fe.templates.ListReport",
"options": {
"settings" : {
"entitySet" : "GenreHierarchy",
"navigation" : {
"GenreHierarchy" : {
"detail" : {
"route" : "GenreHierarchyDetails"
}
}
},
"controlConfiguration": {
"@com.sap.vocabularies.UI.v1.LineItem": {
"tableSettings": {
"hierarchyQualifier": "GenreHierarchy",
"type": "TreeTable"
}
}
}
}
}
},
"GenreHierarchyDetails": {
"type": "Component",
"id": "GenreHierarchyDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings" : {
"entitySet": "GenreHierarchy"
}
}
}
}
},
"contentDensities": {
"compact": true,
"cozy": true
}
},
"sap.ui": {
"technology": "UI5",
"fullWidth": false
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
}
}
1 change: 1 addition & 0 deletions app/index.cds
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ using from './orders/fiori-service';
using from './reviews/fiori-service';
using from './notes/fiori-service';
using from './addresses/fiori-service';
using from './genres/fiori-service';
using from './common';
Loading
Loading