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

Default Filters #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions app/featureShowcase/layouts_RootEntities.cds
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ annotate service.RootEntities with @(
annotate service.RootEntities with @(
//Shown filters for the given fields after opening the application
UI.SelectionFields : [
country_code,
stringProperty,
fieldWithPrice,
criticality_code,
Expand Down Expand Up @@ -698,6 +699,32 @@ annotate service.RootEntities with @(
Visualizations : ['@UI.LineItem#simplified'],
},
},
UI.SelectionPresentationVariant #DefaultFilter : {
SelectionVariant : {
SelectOptions : [
{
PropertyName : country_code,
Ranges : [
{
Sign : #I,
Option : #EQ,
Low : 'DE',
},
{
Sign : #I,
Option : #EQ,
Low : 'FR',
},
],
},
],
},
PresentationVariant : {
SortOrder : [
],
Visualizations : ['@UI.LineItem'],
},
},
);

/**
Expand Down
5 changes: 4 additions & 1 deletion app/featureShowcase/webapp/Component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sap.ui.define(['sap/fe/core/AppComponent'], function(AppComponent) {
sap.ui.define([
'sap/fe/core/AppComponent',
'sap/fe/featureShowcase/mainApp/control/FeatureShowcaseChildEntity2', // To ensure the custom control is loaded during templating
], function(AppComponent) {
'use strict';

return AppComponent.extend("sap.fe.featureShowcase.mainApp.Component", {
Expand Down
44 changes: 44 additions & 0 deletions app/featureShowcase/webapp/control/FeatureShowcaseChildEntity2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
sap.ui.define([
'sap/m/Link',
'sap/fe/macros/field/FieldTemplating',
'sap/m/MessageBox',
], function (
Link,
FieldTemplating,
MessageBox,
) {
'use strict';

return Link.extend("sap.fe.featureShowcase.mainApp.control.FeatureShowcaseChildEntity2", {
metadata: {
manifest: "json"
},
renderer: {},

// Implement the interface dictated by the templating process
getTemplate: function (xml, internalField) {
const text = FieldTemplating.getTextBinding(internalField.dataModelPath, internalField.formatOptions, true);

return xml`<myApp:FeatureShowcaseChildEntity2
xmlns="sap.m"
xmlns:myApp="sap.fe.featureShowcase.mainApp.control"
xmlns:core="sap.ui.core"
id="${internalField.noWrapperId}"
text="${text}"
visible="${internalField.displayVisible}"
wrapping="${internalField.wrap === undefined ? true : internalField.wrap}"
ariaLabelledBy="${internalField.ariaLabelledBy}"
emptyIndicatorMode="${internalField.emptyIndicatorMode}"
customData:loadValue="${internalField.valueAsStringBindingExpression}"
>
</myApp:FeatureShowcaseChildEntity2>`;
},

//
init: function () {
this.attachPress(oEvent => {
MessageBox.show('I am a custom control, injected in a FE template');
});
},
});
});
3 changes: 2 additions & 1 deletion app/featureShowcase/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"entitySet": "RootEntities",
"variantManagement": "Page",
"enhanceI18n": "i18n/customI18N.properties",
"defaultTemplateAnnotationPath": "com.sap.vocabularies.UI.v1.SelectionPresentationVariant#DefaultFilter",
"navigation": {
"RootEntities": {
"detail": {
Expand All @@ -119,7 +120,7 @@
}
},
"initialLoad": true,
"views": {
"XviewsX": {
Copy link
Author

Choose a reason for hiding this comment

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

This should not be here, but having both active at the same time crashes the app.

"paths": [
{
"key": "tab1",
Expand Down
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
};

</script>
<script src="https://ui5.sap.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
<script src="http://localhost:4004/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
<script
src="https://ui5.sap.com/resources/sap-ui-core.js"
src="http://localhost:4004/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.ushell, sap.fe.templates"
data-sap-ui-compatVersion="edge"
data-sap-ui-theme="sap_horizon"
Expand Down
45 changes: 44 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"dependencies": {
"@sap/cds": "^7.2",
"content-disposition": "^0.5.3",
"express": "^4"
"express": "^4",
"http-proxy": "^1.18.1"
},
"devDependencies": {
"@sap/ux-specification": "^1.90.12",
"@cap-js/sqlite": "^1.1.0"
"@cap-js/sqlite": "^1.1.0",
"@sap/ux-specification": "^1.90.12"
},
"scripts": {
"start": "cds run"
Expand Down
24 changes: 24 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const cds = require('@sap/cds');
const express = require('express');

module.exports = (o) => {
cds.on('bootstrap', app => {
const ui5 = 'https://ui5.sap.com';
['resources', 'test-resources'].forEach(x => {
console.log('overlaying', x)
const proxy = require('http-proxy').createProxyServer({
host: ui5,
changeOrigin: true,
});
app.use(`/${x}`, express.static(`ui5overlay/${x}`));
app.use(`/${x}`, function (req, res, next) {
proxy.web(req, res, {
target: `${ui5}/${x}`
}, next);
});
});
});

// delegate to default server
return cds.server(o);
}
Loading