diff --git a/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/controller.js.template b/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/controller.js.template index 4195b33dd33..afd2bc9798a 100644 --- a/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/controller.js.template +++ b/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/controller.js.template @@ -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) @@ -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 }); \ No newline at end of file diff --git a/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/translations.json.template b/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/translations.json.template index 76db25022e6..86fdba51a30 100644 --- a/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/translations.json.template +++ b/components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/translations.json.template @@ -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": {} diff --git a/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/configs/help-window.js b/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/configs/help-window.js new file mode 100644 index 00000000000..c774b048885 --- /dev/null +++ b/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/configs/help-window.js @@ -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; +} \ No newline at end of file diff --git a/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/dialogs/help.html b/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/dialogs/help.html new file mode 100644 index 00000000000..11930b6e3ed --- /dev/null +++ b/components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/dialogs/help.html @@ -0,0 +1,61 @@ + + + + +
+ + + +The feed name determines the scope variable to which the response value is assigned. +
For example, if the feed name is extraData, the corresponding variable will be available as $scope.extraData.
+ Within the Designer tab, this variable can be referenced without the $scope. prefix.
To assign the response data directly to the model, set the feed name to model.
This field specifies the URL of your back-end service. If the URL is dynamic, you can use a template literal (${}) to interpolate variable values or invoke
+ functions.
For example, if the URL is defined as:
+/path/to/service/${someId}/
+ and a variable is declared in the Code tab as:
+const someId = '1';
+ then the resulting request URL will be:
+/path/to/service/1/
+
+ Specifying a function name is optional.
+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.
+For example, if the function name is set to:
+printResponse
+ the function should be defined as:
+function printResponse(data) {
+ console.log(data);
+ return data;
+}
+
+
+ | Name | URL | +Function | |
|---|---|---|---|
| {{feed.name}} | {{feed.url}} | +{{feed.func}} |
|