Skip to content

Commit d0835c7

Browse files
authored
Fixed #5834 (#5835)
Signed-off-by: StanZGenchev <stan.genchev@codbex.com>
1 parent 75c2b7d commit d0835c7

File tree

3 files changed

+57
-18
lines changed
  • components
    • template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui
    • ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder

3 files changed

+57
-18
lines changed

components/template/template-form-builder-angularjs/src/main/resources/META-INF/dirigible/template-form-builder-angularjs/ui/index.html.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ $result##
3737
<script type="text/javascript" src="controller.js"></script>
3838
#foreach($script in $scripts)
3939
<script type="text/javascript" src="$script.url"></script>
40+
#end
41+
#foreach($style in $styles)
42+
<link href="$style.url" rel="stylesheet" />
4043
#end
4144
</head>
4245

components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/editor.html

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<bk-icon-tab-bar-tab label="Feeds" tab-id="feeds" ng-click="switchTab('feeds')"></bk-icon-tab-bar-tab>
4343
<bk-icon-tab-bar-tab label="Code" tab-id="code" ng-click="switchTab('code')"></bk-icon-tab-bar-tab>
4444
<bk-icon-tab-bar-tab label="Scripts" tab-id="scripts" ng-click="switchTab('scripts')"></bk-icon-tab-bar-tab>
45+
<bk-icon-tab-bar-tab label="Styles" tab-id="styles" ng-click="switchTab('styles')"></bk-icon-tab-bar-tab>
4546
<bk-icon-tab-bar-buttons align-right="true">
4647
<bk-button state="transparent" glyph="sap-icon--save" label="Save" aria-label="save" ng-click="shortcuts()" ng-disabled="!(isFormValid() && changed)"></bk-button>
4748
<bk-button state="transparent" glyph="sap-icon-TNT--operations" aria-label="Regenerate" title="Regenerate" label="Regenerate" ng-click="regenerate()" ng-disabled="changed || !canRegenerate"></bk-button>
@@ -222,7 +223,7 @@ <h4 bk-panel-title>
222223
<bk-icon-tab-bar-panel class="bk-vbox bk-fill-parent fb-panel" tab-id="scripts" ng-show="selectedTab === 'scripts'">
223224
<bk-toolbar has-title="false">
224225
<bk-toolbar-spacer></bk-toolbar-spacer>
225-
<bk-button glyph="sap-icon--add" title="Add script URL to list" state="transparent" label="Add" aria-label="Add script URL to list" ng-click="addScript()"></bk-button>
226+
<bk-button glyph="sap-icon--add" title="Add script URL to list" state="transparent" label="Add" aria-label="Add script URL to list" ng-click="addUrl(true)"></bk-button>
226227
</bk-toolbar>
227228
<bk-scrollbar class="bk-fill-parent">
228229
<table bk-table display-mode="compact" outer-borders="bottom">
@@ -241,8 +242,38 @@ <h4 bk-panel-title>
241242
<td bk-table-cell>{{script.name}}</td>
242243
<td bk-table-cell>{{script.url}}</td>
243244
<td bk-table-cell fit-content="true">
244-
<bk-button glyph="sap-icon--edit" title="Edit script" state="transparent" aria-label="Edit script" ng-click="editScript(script)"></bk-button>
245-
<bk-button glyph="sap-icon--delete" title="Delete script" state="transparent" aria-label="Delete script" ng-click="deleteScript($index)"></bk-button>
245+
<bk-button glyph="sap-icon--edit" title="Edit script" state="transparent" aria-label="Edit script" ng-click="editUrl(script, true)"></bk-button>
246+
<bk-button glyph="sap-icon--delete" title="Delete script" state="transparent" aria-label="Delete script" ng-click="deleteUrl($index, true)"></bk-button>
247+
</td>
248+
</tr>
249+
</tbody>
250+
</table>
251+
</bk-scrollbar>
252+
</bk-icon-tab-bar-panel>
253+
<bk-icon-tab-bar-panel class="bk-vbox bk-fill-parent fb-panel" tab-id="styles" ng-show="selectedTab === 'styles'">
254+
<bk-toolbar has-title="false">
255+
<bk-toolbar-spacer></bk-toolbar-spacer>
256+
<bk-button glyph="sap-icon--add" title="Add style URL to list" state="transparent" label="Add" aria-label="Add style URL to list" ng-click="addUrl(false)"></bk-button>
257+
</bk-toolbar>
258+
<bk-scrollbar class="bk-fill-parent">
259+
<table bk-table display-mode="compact" outer-borders="bottom">
260+
<thead bk-table-header sticky="true" interactive="false">
261+
<tr bk-table-row>
262+
<th bk-table-header-cell>Name</th>
263+
<th bk-table-header-cell>URL</th>
264+
<th bk-table-header-cell></th>
265+
</tr>
266+
</thead>
267+
<tbody bk-table-body>
268+
<tr ng-if="formData.styles.length === 0" bk-table-row>
269+
<td bk-table-cell no-data="true">No styles.</td>
270+
</tr>
271+
<tr bk-table-row hoverable="false" ng-repeat="style in formData.styles track by $index">
272+
<td bk-table-cell>{{style.name}}</td>
273+
<td bk-table-cell>{{style.url}}</td>
274+
<td bk-table-cell fit-content="true">
275+
<bk-button glyph="sap-icon--edit" title="Edit style" state="transparent" aria-label="Edit style" ng-click="editUrl(style, false)"></bk-button>
276+
<bk-button glyph="sap-icon--delete" title="Delete style" state="transparent" aria-label="Delete style" ng-click="deleteUrl($index, false)"></bk-button>
246277
</td>
247278
</tr>
248279
</tbody>

components/ui/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/js/editor.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
4444
$scope.formData = {
4545
feeds: [],
4646
scripts: [],
47+
styles: [],
4748
code: ''
4849
};
4950

@@ -2209,9 +2210,9 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
22092210
$scope.fileChanged();
22102211
};
22112212

2212-
$scope.addScript = () => {
2213+
$scope.addUrl = (script = true) => {
22132214
dialogHub.showFormDialog({
2214-
title: 'Add script',
2215+
title: `Add ${script ? 'script' : 'style'}`,
22152216
form: {
22162217
'asName': {
22172218
label: 'Name',
@@ -2236,7 +2237,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
22362237
}).then((form) => {
22372238
if (form) {
22382239
$scope.$evalAsync(() => {
2239-
$scope.formData.scripts.push({
2240+
$scope.formData[script ? 'scripts' : 'styles'].push({
22402241
name: form['asName'],
22412242
url: form['asUrl']
22422243
});
@@ -2246,25 +2247,25 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
22462247
}, (error) => {
22472248
console.error(error);
22482249
dialogHub.showAlert({
2249-
title: 'New script error',
2250-
message: 'There was an error while adding the new script.',
2250+
title: `New ${script ? 'script' : 'style'} error`,
2251+
message: `There was an error while adding the new ${script ? 'script' : 'style'}.`,
22512252
type: AlertTypes.Error,
22522253
preformatted: false,
22532254
});
22542255
});
22552256
};
22562257

2257-
$scope.editScript = (script) => {
2258+
$scope.editUrl = (item, script = true) => {
22582259
dialogHub.showFormDialog({
2259-
title: 'Edit script',
2260+
title: `Edit ${script ? 'script' : 'style'}`,
22602261
form: {
22612262
'asName': {
22622263
label: 'Name',
22632264
controlType: 'input',
22642265
placeholder: '',
22652266
type: 'text',
22662267
minlength: 1,
2267-
value: script.name,
2268+
value: item.name,
22682269
focus: true,
22692270
required: true
22702271
},
@@ -2274,7 +2275,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
22742275
placeholder: '',
22752276
type: 'text',
22762277
minlength: 1,
2277-
value: script.url,
2278+
value: item.url,
22782279
required: true
22792280
},
22802281
},
@@ -2283,24 +2284,24 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
22832284
}).then((form) => {
22842285
if (form) {
22852286
$scope.$evalAsync(() => {
2286-
script.name = form['asName'];
2287-
script.url = form['asUrl'];
2287+
item.name = form['asName'];
2288+
item.url = form['asUrl'];
22882289
$scope.fileChanged();
22892290
});
22902291
}
22912292
}, (error) => {
22922293
console.error(error);
22932294
dialogHub.showAlert({
2294-
title: 'New script error',
2295-
message: 'There was an error while adding the new script.',
2295+
title: `New ${script ? 'script' : 'style'} error`,
2296+
message: `There was an error while adding the new ${script ? 'script' : 'style'}.`,
22962297
type: AlertTypes.Error,
22972298
preformatted: false,
22982299
});
22992300
});
23002301
};
23012302

2302-
$scope.deleteScript = (index) => {
2303-
$scope.formData.scripts.splice(index, 1);
2303+
$scope.deleteUrl = (index, script = true) => {
2304+
$scope.formData[script ? 'scripts' : 'styles'].splice(index, 1);
23042305
$scope.fileChanged();
23052306
};
23062307

@@ -2480,6 +2481,9 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
24802481
if (response.data.hasOwnProperty('scripts')) {
24812482
$scope.formData.scripts = response.data.scripts;
24822483
}
2484+
if (response.data.hasOwnProperty('styles')) {
2485+
$scope.formData.styles = response.data.styles;
2486+
}
24832487
if (response.data.hasOwnProperty('form')) {
24842488
createDomFromJson(migrateForm(response.data.form));
24852489
}
@@ -2542,6 +2546,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou
25422546
metadata: getMetadataFromForm(),
25432547
feeds: $scope.formData.feeds,
25442548
scripts: $scope.formData.scripts,
2549+
styles: $scope.formData.styles,
25452550
code: $scope.formData.code,
25462551
form: createFormJson($scope.formModel)
25472552
};

0 commit comments

Comments
 (0)