Skip to content

Commit aa2c04b

Browse files
committed
Allow addition of multiple application components
1 parent 053c452 commit aa2c04b

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

webui/src/js/viewModels/choose-component-dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function(accUtils, ko, i18n, props, validationHelper, ArrayDataProvider) {
1414

1515
this.i18n = i18n;
1616
this.availableComponentNames = args.availableComponentNames;
17-
this.selectedComponentName = ko.observable();
17+
this.selectedComponentNames = ko.observableArray();
1818

1919
this.availableComponentNamesDP = new ArrayDataProvider(this.availableComponentNames, { keyAttributes: 'value' });
2020

@@ -42,7 +42,7 @@ function(accUtils, ko, i18n, props, validationHelper, ArrayDataProvider) {
4242

4343
$(DIALOG_SELECTOR)[0].close();
4444

45-
const result = {componentName: this.selectedComponentName()};
45+
const result = {componentNames: this.selectedComponentNames()};
4646
args.setValue(result);
4747
};
4848

webui/src/js/viewModels/vz-application-design-view.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,20 @@ function (project, accUtils, utils, ko, i18n, BufferingDataProvider, ArrayDataPr
107107

108108
dialogHelper.promptDialog('choose-component-dialog', { availableComponentNames }).then(result => {
109109
// no result indicates operation was cancelled
110-
if (result && result.componentName) {
111-
this.project.vzApplication.components.addNewItem({
112-
name: result.componentName,
113-
ingressTraitEnable: false,
114-
manualScalerTraitEnabled: false,
115-
metricsTraitEnabled: false,
116-
loggingTraitEnabled: false,
117-
});
110+
if (result && result.componentNames) {
111+
for(const componentName of result.componentNames) {
112+
this.project.vzApplication.components.addNewItem({
113+
name: componentName,
114+
ingressTraitEnable: false,
115+
manualScalerTraitEnabled: false,
116+
metricsTraitEnabled: false,
117+
loggingTraitEnabled: false,
118+
});
119+
}
120+
121+
// this shouldn't be needed, but duplicate entries will show in the components accordion
122+
// if multiple components are added at once.
123+
this.components.observable.sort();
118124

119125
// this shouldn't be needed, but when a new component is added,
120126
// the accordion control doesn't enforce "single collapsible open" behavior.

webui/src/js/views/choose-component-dialog.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
<oj-validation-group id="chooseComponentTracker">
1313
<div class="oj-panel">
1414
<oj-form-layout max-columns="2" direction="row">
15-
<oj-select-single label-hint="[[labelMapper('name-label')]]"
16-
value="{{selectedComponentName}}"
17-
data="{{availableComponentNamesDP}}"
18-
help.instruction="[[labelMapper('name-help')]]">
19-
</oj-select-single>
15+
<oj-select-many label-hint="[[labelMapper('name-label')]]"
16+
value="{{selectedComponentNames}}"
17+
help.instruction="[[labelMapper('name-help')]]">
18+
<oj-bind-for-each data="[[availableComponentNamesDP]]">
19+
<template>
20+
<oj-option value="[[$current.data.value]]">
21+
<oj-bind-text value="[[$current.data.label]]"></oj-bind-text>
22+
</oj-option>
23+
</template>
24+
</oj-bind-for-each>
25+
</oj-select-many>
2026
</oj-form-layout>
2127
</div>
2228
</oj-validation-group>

0 commit comments

Comments
 (0)