Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ angular.module('forms', ['blimpKit', 'platformView', 'platformLocale', 'platform
};
#end

#foreach($feed in $feeds)
${dollar}http.get('$feed.url').then(response => {
$scope.$feed.name = response.data;
}).catch(e => {
console.error(e);
});

#end
$scope.model = {};
#macro(formWidgets $elements)
#foreach($element in $elements)
Expand Down Expand Up @@ -118,5 +110,33 @@ angular.module('forms', ['blimpKit', 'platformView', 'platformLocale', 'platform

$code

#end
#foreach($feed in $feeds)
${dollar}http.get(`$feed.url`).then(response => {
#if($feed.func)
#if($feed.name == 'model')
Object.assign($scope.model, ${feed.func}(response.data));
#else
$scope.$feed.name = ${feed.func}(response.data);
#end
#else
#if($feed.name == 'model')
Object.assign($scope.model, response.data);
#else
$scope.$feed.name = response.data;
#end
#end
}, error => {
console.error('$feed.name', error);
const errorData = JSON.stringify(error);
LocaleService.onInit(() => {
Dialogs.showAlert({
title: LocaleService.t('$projectName:${tprefix}.dialogs.feedErrorTitle', 'Feed request failed'),
message: errorData && errorData !== '{}' ? errorData : LocaleService.t('$projectName:${tprefix}.dialogs.feedError', { feed: '$feed.name' }, "Could not retrive data from the feed '$feed.name'. See console for more information."),
type: AlertTypes.Error,
preformatted: false,
});
});
});
#end
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"dialogs": {
"successTitle": "Submited",
"errorTitle": "Submit failed",
"feedErrorTitle": "Feed request failed",
"feedError": "Could not retrive data from feed '{{feed}}'. See console for more information.",
"successMsg": "Form submited successfully!"
},
"t": {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2026 Eclipse Dirigible contributors
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors
* SPDX-License-Identifier: EPL-2.0
*/
const viewData = {
id: 'formBuilderHelp',
label: 'Feeds Help',
path: '/services/web/editor-form-builder/dialogs/help.html',
maxWidth: '540px',
closeButton: true
};
if (typeof exports !== 'undefined') {
exports.getView = () => viewData;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!--

Copyright (c) 2010-2026 Eclipse Dirigible contributors

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v20.html

SPDX-FileCopyrightText: Eclipse Dirigible contributors
SPDX-License-Identifier: EPL-2.0

-->
<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" ng-app="help" ng-controller="HelpController">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" sizes="any" href="data:;base64,iVBORw0KGgo=">
<title config-title></title>
<script type="text/javascript" src="/services/web/editor-form-builder/configs/help-window.js"></script>
<meta name="platform-links" category="ng-view">
</head>

<body class="bk-padding" bk-scrollbar>
<h2 bk-title wrap="true" header-size="4">Name</h2>
<p class="bk-font--normal">The feed name determines the scope variable to which the response value is assigned.
<p class="bk-font--normal">For example, if the feed name is <code class="fd-code fd-code--inline">extraData</code>, the corresponding variable will be available as <code class="fd-code fd-code--inline">$scope.extraData</code>.
Within the Designer tab, this variable can be referenced without the <code class="fd-code fd-code--inline">$scope.</code> prefix.</p>
<p class="bk-font--normal">To assign the response data directly to the model, set the feed name to <code class="fd-code fd-code--inline">model</code>.</p>

<h2 bk-title wrap="true" header-size="4">URL</h2>
<p class="bk-font--normal">This field specifies the URL of your back-end service. If the URL is dynamic, you can use a template literal (<code class="fd-code fd-code--inline">${}</code>) to interpolate variable values or invoke
functions.</p>
<p class="bk-font--normal">For example, if the URL is defined as:</p>
<code class="fd-code">/path/to/service/${someId}/</code>
<p class="bk-font--normal">and a variable is declared in the Code tab as:</p>
<code class="fd-code">const someId = '1';</code>
<p class="bk-font--normal">then the resulting request URL will be:</p>
<code class="fd-code">/path/to/service/1/</code>

<h2 class="bk-padding-top--sm" bk-title wrap="true" header-size="4">Function</h2>
<p class="bk-font--normal">Specifying a function name is optional.</p>
<p class="bk-font--normal">If you need to modify the response data before it is assigned to the target variable, you can provide a function name here. Then, define a corresponding function in the Code tab. This function must accept
the response data as its first parameter, apply any necessary transformations, and return the updated result for assignment.</p>
<p class="bk-font--normal">For example, if the function name is set to:</p>
<code class="fd-code">printResponse</code>
<p class="bk-font--normal">the function should be defined as:</p>
<pre><code class="fd-code">function printResponse(data) {
console.log(data);
return data;
}</code></pre>

<script>
angular.module('help', ['blimpKit', 'platformView']).controller('HelpController', () => {});
</script>
<theme></theme>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ <h4 bk-panel-title>
<bk-toolbar has-title="false">
<bk-toolbar-spacer></bk-toolbar-spacer>
<bk-button glyph="sap-icon--add" title="Add feed to list" state="transparent" label="Add" aria-label="Add feed to list" ng-click="addFeed()"></bk-button>
<bk-button glyph="sap-icon--question-mark" title="Feed help" state="transparent" aria-label="Feed help" ng-click="feedHelp()"></bk-button>
</bk-toolbar>
<bk-scrollbar class="bk-fill-parent">
<table bk-table display-mode="compact" outer-borders="bottom">
<thead bk-table-header sticky="true" interactive="false">
<tr bk-table-row>
<th bk-table-header-cell>Name</th>
<th bk-table-header-cell>URL</th>
<th bk-table-header-cell>Function</th>
<th bk-table-header-cell></th>
</tr>
</thead>
Expand All @@ -191,6 +193,7 @@ <h4 bk-panel-title>
<tr bk-table-row hoverable="false" ng-repeat="feed in formData.feeds track by $index">
<td bk-table-cell>{{feed.name}}</td>
<td bk-table-cell>{{feed.url}}</td>
<td bk-table-cell>{{feed.func}}</td>
<td bk-table-cell fit-content="true">
<bk-button glyph="sap-icon--edit" title="Edit feed" state="transparent" aria-label="Edit feed" ng-click="editFeed(feed)"></bk-button>
<bk-button glyph="sap-icon--delete" title="Delete feed" state="transparent" aria-label="Delete feed" ng-click="deleteFeed($index)"></bk-button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"module": "editor-form-builder/configs/help-window.js",
"extensionPoint": "platform-windows",
"description": "Feeds help window"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,14 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
minlength: 1,
required: true
},
'afFunc': {
label: 'Function Name',
controlType: 'input',
placeholder: '',
type: 'text',
minlength: 1,
required: false
},
},
submitLabel: 'Add',
cancelLabel: 'Cancel'
Expand All @@ -1879,7 +1887,8 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
$scope.$evalAsync(() => {
$scope.formData.feeds.push({
name: form['afName'],
url: form['afUrl']
url: form['afUrl'],
func: form['afFunc']
});
$scope.fileChanged();
});
Expand Down Expand Up @@ -1918,6 +1927,15 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
value: feed.url,
required: true
},
'afFunc': {
label: 'Function Name',
controlType: 'input',
placeholder: '',
type: 'text',
minlength: 1,
value: feed.func,
required: false
},
},
submitLabel: 'Save',
cancelLabel: 'Cancel'
Expand All @@ -1926,6 +1944,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
$scope.$evalAsync(() => {
feed.name = form['afName'];
feed.url = form['afUrl'];
feed.func = form['afFunc'];
$scope.fileChanged();
});
}
Expand Down Expand Up @@ -2059,6 +2078,12 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
$scope.selectedTab = tabId;
};

$scope.feedHelp = () => {
dialogHub.showWindow({
id: 'formBuilderHelp'
});
};

const createDomFromJson = (model, containerId) => {
for (let i = 0; i < model.length; i++) {
let control;
Expand Down
Loading