Skip to content

Commit da5afcc

Browse files
rakillenrobertpatrick
authored andcommitted
Implement reordering of list attributes
1 parent dc02526 commit da5afcc

File tree

8 files changed

+94
-21
lines changed

8 files changed

+94
-21
lines changed

electron/app/locales/en/modeledit.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,12 +1044,12 @@
10441044
"a-CallbackQueueMdbRunAsPrincipalName-label": "Callback Queue MDB Run As Principal Name",
10451045
"a-CallbackQueueMdbRunAsPrincipalName-help": "For use only with the JAX-RPC stack. For JAX-WS, use WebServiceBufferingMBean instead.",
10461046

1047-
"a-CandidateMachine-label": "Candidate Machine",
1047+
"a-CandidateMachine-label": "Candidate Machines",
10481048
"a-CandidateMachine-help": "Limits the list of candidate machines that the cluster specifies. (Requires you to enable this server for automatic migration and to configure the cluster with a set of candidate machines.) If this server fails and if it is enabled for automatic migration, Node Manager automatically restarts it. By default, Node Manager restarts the server on any of the candidate machines that the cluster specifies (in order of preference that you configured in the cluster). To change the default, you use this server's list of candidate machines to create a subset of the cluster-wide candidates. You can also change the order of preference.",
10491049

10501050
"a-CandidateMachinesForMigratableServer-label": "Candidate Machines for Migratable Server",
10511051
"a-CandidateMachinesForMigratableServer-itemLabel": "Candidate Machine",
1052-
"a-CandidateMachinesForMigratableServer-itemHelp": "Specify a candidate machine opn which a node manager can restart failed servers.",
1052+
"a-CandidateMachinesForMigratableServer-itemHelp": "Specify a candidate machine on which a node manager can restart failed servers.",
10531053
"f-Cluster-a-CandidateMachinesForMigratableServer-help": "Specifies the set of machines (and order of preference) on which Node Manager will restart failed servers. (Requires you to enable each server for automatic migration.) Each server can specify a subset of these cluster-wide candidates, which limits the machines on which the server can be restarted. Servers can also specify their own order of preference.",
10541054

10551055
"a-Capacity-label": "Capacity",

webui/src/js/utils/modelEdit/metadata/JDBCSystemResource.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@
256256
{ "value": "Load-Balancing", "labelKey": "options-load-balancing-label" }
257257
]
258258
},
259+
"DataSourceList": {
260+
"reorderable": true
261+
},
259262
"GlobalTransactionsProtocol": {
260263
"options": [
261264
{ "value": "OnePhaseCommit", "labelKey": "options-one-phase-commit-label" },

webui/src/js/utils/modelEdit/metadata/JMSSystemResource.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
{ "value": "Discard", "labelKey": "options-discard-label" },
3939
{ "value": "Log", "labelKey": "options-log-label" },
4040
{ "value": "Redirect", "labelKey": "options-redirect-label" }
41-
]
41+
],
42+
"reorderable": true
4243
},
4344
"LoadBalancingPolicy": {
4445
"options": [

webui/src/js/utils/modelEdit/metadata/SecurityConfiguration.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@
590590
},
591591
"SecurityConfiguration/Realm": {
592592
"attributeDetails": {
593+
"AuthMethods": {
594+
"reorderable": true
595+
},
593596
"CertPathBuilder": {
594597
"editorType": "combo",
595598
"optionsMethod": "getCertPathBuilderInRealmOptions"
@@ -605,6 +608,9 @@
605608
"IdentityAssertionDoNotCacheContextElement": {
606609
"disabled": "secConfigRealmIdentityAssertionCacheFields"
607610
},
611+
"IdentityAssertionHeaderNamePrecedence": {
612+
"reorderable": true
613+
},
608614
"MaxWebLogicPrincipalsInCache": {
609615
"disabled": "secConfigRealmWlsPrincipalValidatorCacheFields"
610616
},

webui/src/js/utils/modelEdit/metadata/Server.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"CandidateMachine": {
2828
"editorType": "combo",
29-
"optionsMethod": "getMachineOptions"
29+
"optionsMethod": "getMachineOptions",
30+
"reorderable": true
3031
},
3132
"Cluster": {
3233
"editorType": "combo",

webui/src/js/utils/modelEdit/metadata/ServerTemplate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"CandidateMachine": {
2626
"editorType": "combo",
27-
"optionsMethod": "getMachineOptions"
27+
"optionsMethod": "getMachineOptions",
28+
"reorderable": true
2829
},
2930
"Cluster": {
3031
"editorType": "combo",

webui/src/js/viewModels/modelEdit/list-attribute-editor.js

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ function(accUtils, ko, DialogHelper, ArrayDataProvider,
2424
this.observable = ATTRIBUTE.observable;
2525
this.disabled = MetaHandlers.getDisabledHandler(ATTRIBUTE, ATTRIBUTE_MAP);
2626
this.extraClass = ko.computed(() => this.disabled() ? 'wkt-model-edit-table-disabled' : null);
27+
this.reorderable = ATTRIBUTE.reorderable;
2728

2829
this.ariaLabel = MessageHelper.getAttributeLabel(ATTRIBUTE, ALIAS_PATH);
2930
this.addLabel = MessageHelper.getAddItemLabel(ATTRIBUTE, ALIAS_PATH, false);
3031
this.deleteLabel = MessageHelper.getDeleteItemLabel(ATTRIBUTE, ALIAS_PATH);
3132
this.noDataLabel = MessageHelper.getNoItemsMessage(ATTRIBUTE, ALIAS_PATH);
3233
this.helpText = MessageHelper.getAttributeHelp(ATTRIBUTE, ALIAS_PATH);
34+
this.moveUpLabel = MessageHelper.t('move-up-label');
35+
this.moveDownLabel = MessageHelper.t('move-down-label');
3336

3437
const subscriptions = [];
3538

@@ -47,31 +50,42 @@ function(accUtils, ko, DialogHelper, ArrayDataProvider,
4750
};
4851

4952
// this is dynamic to allow i18n values to load correctly
50-
this.columnData = [
51-
{
52-
headerText: MessageHelper.getAttributeLabel(ATTRIBUTE, ALIAS_PATH),
53-
headerClassName: 'wkt-model-edit-attribute-label',
54-
sortable: 'disable'
55-
},
56-
{
53+
this.columnData = [];
54+
this.columnData.push({
55+
headerText: MessageHelper.getAttributeLabel(ATTRIBUTE, ALIAS_PATH),
56+
headerClassName: 'wkt-model-edit-attribute-label',
57+
sortable: 'disable'
58+
});
59+
60+
if (this.reorderable) {
61+
this.columnData.push({
5762
className: 'wkt-table-delete-cell',
5863
headerClassName: 'wkt-table-add-header',
59-
headerTemplate: 'headerTemplate',
6064
template: 'actionTemplate',
61-
sortable: 'disable',
62-
width: ViewHelper.BUTTON_COLUMN_WIDTH
63-
}];
65+
sortable: 'disabled',
66+
width: '30px'
67+
});
68+
}
69+
70+
this.columnData.push({
71+
className: 'wkt-table-delete-cell',
72+
headerClassName: 'wkt-table-add-header',
73+
headerTemplate: 'headerTemplate',
74+
template: 'actionTemplate',
75+
sortable: 'disable',
76+
width: ViewHelper.BUTTON_COLUMN_WIDTH
77+
});
6478

6579
this.observableItems = ko.observableArray([]);
6680

6781
// update the internal list observable from the attribute observable.
6882
// the attribute observable value may be a list or comma-separated string.
6983
// if the value is a string, it might be a variable token.
7084
this.updateList = () => {
71-
this.observableItems.removeAll();
85+
const newItems = [];
7286
const value = ModelEditHelper.getDerivedValue(this.observable());
73-
let elements = null;
7487
if(value != null) {
88+
let elements;
7589
if (Array.isArray(value)) {
7690
elements = value;
7791
} else {
@@ -80,12 +94,13 @@ function(accUtils, ko, DialogHelper, ArrayDataProvider,
8094
}
8195

8296
elements.forEach(element => {
83-
this.observableItems.push({
97+
newItems.push({
8498
uid: utils.getShortUuid(),
8599
name: element
86100
});
87101
});
88102
}
103+
this.observableItems(newItems);
89104
};
90105

91106
// update attribute observable from the internal list observable.
@@ -99,7 +114,7 @@ function(accUtils, ko, DialogHelper, ArrayDataProvider,
99114
};
100115

101116
// use unique ID (uid) as key in the UI only, in case name changes
102-
this.propertiesDataProvider = new BufferingDataProvider(new ArrayDataProvider(
117+
this.listDataProvider = new BufferingDataProvider(new ArrayDataProvider(
103118
this.observableItems, {keyAttributes: 'uid'}));
104119

105120
// add a new row with an unused unique ID and new name
@@ -123,6 +138,30 @@ function(accUtils, ko, DialogHelper, ArrayDataProvider,
123138
this.observableItems.remove(context.item.data);
124139
this.updateObservable();
125140
};
141+
142+
this.canMoveUp = rowData => {
143+
return this.observableItems.indexOf(rowData) > 0;
144+
};
145+
146+
this.canMoveDown = rowData => {
147+
return this.observableItems.indexOf(rowData) < this.observableItems().length - 1;
148+
};
149+
150+
this.moveUp = (event, context) => {
151+
const rowData = context.item.data;
152+
const index = this.observableItems.indexOf(rowData);
153+
this.observableItems.splice(index, 1); // remove from old location
154+
this.observableItems.splice(index - 1, 0, rowData);
155+
this.updateObservable();
156+
};
157+
158+
this.moveDown = (event, context) => {
159+
const rowData = context.item.data;
160+
const index = this.observableItems.indexOf(rowData);
161+
this.observableItems.splice(index, 1); // remove from old location
162+
this.observableItems.splice(index + 1, 0, rowData);
163+
this.updateObservable();
164+
};
126165
}
127166

128167
return ListAttributeEditor;

webui/src/js/views/modelEdit/list-attribute-editor.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class="wkt-model-edit-table wkt-model-edit-list-table"
88
:aria-label="[[ariaLabel]]"
99
:class="[[extraClass]]"
10-
data="[[propertiesDataProvider]]"
10+
data="[[listDataProvider]]"
1111
display="grid"
1212
horizontal-grid-visible="enabled"
1313
vertical-grid-visible="enabled"
@@ -17,6 +17,28 @@
1717
<template slot="rowTemplate" data-oj-as="row">
1818
<tr data-bind="attr: {'data-uid': row.data.uid}">
1919
<td><oj-bind-text value="[[row.data.name]]"></oj-bind-text></td>
20+
<oj-bind-if test="[[reorderable]]">
21+
<td>
22+
<div class="wkt-model-edit-reorder-cell">
23+
<oj-c-button display="icons"
24+
chroming="borderless"
25+
size="sm"
26+
label="[[moveUpLabel]]"
27+
disabled="[[!canMoveUp(row.data)]]"
28+
on-oj-action="[[moveUp]]">
29+
<span slot="endIcon" class="oj-ux-ico-chevron-up"></span>
30+
</oj-c-button>
31+
<oj-c-button display="icons"
32+
chroming="borderless"
33+
size="sm"
34+
label="[[moveDownLabel]]"
35+
disabled="[[!canMoveDown(row.data)]]"
36+
on-oj-action="[[moveDown]]">
37+
<span slot="endIcon" class="oj-ux-ico-chevron-down"></span>
38+
</oj-c-button>
39+
</div>
40+
</td>
41+
</oj-bind-if>
2042
<td>
2143
<oj-c-button
2244
display="icons"

0 commit comments

Comments
 (0)