@neovici/cosmoz-treenode-navigator 6.0.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -12
- package/dist/cosmoz-treenode-button-view.d.ts +2 -0
- package/dist/cosmoz-treenode-button-view.d.ts.map +1 -0
- package/dist/cosmoz-treenode-button-view.js +203 -0
- package/dist/cosmoz-treenode-button-view.js.map +1 -0
- package/dist/cosmoz-treenode-button-view.styles.d.ts +3 -0
- package/dist/cosmoz-treenode-button-view.styles.d.ts.map +1 -0
- package/dist/cosmoz-treenode-button-view.styles.js +218 -0
- package/dist/cosmoz-treenode-button-view.styles.js.map +1 -0
- package/dist/cosmoz-treenode-navigator.d.ts +2 -0
- package/dist/cosmoz-treenode-navigator.d.ts.map +1 -0
- package/dist/cosmoz-treenode-navigator.js +233 -0
- package/dist/cosmoz-treenode-navigator.js.map +1 -0
- package/dist/cosmoz-treenode-navigator.styles.d.ts +3 -0
- package/dist/cosmoz-treenode-navigator.styles.d.ts.map +1 -0
- package/{cosmoz-treenode-navigator.styles.js → dist/cosmoz-treenode-navigator.styles.js} +12 -4
- package/dist/cosmoz-treenode-navigator.styles.js.map +1 -0
- package/dist/hooks/useKeyDown.d.ts +2 -0
- package/dist/hooks/useKeyDown.d.ts.map +1 -0
- package/dist/hooks/useKeyDown.js +16 -0
- package/dist/hooks/useKeyDown.js.map +1 -0
- package/dist/util/helpers.d.ts +51 -0
- package/dist/util/helpers.d.ts.map +1 -0
- package/dist/util/helpers.js +123 -0
- package/dist/util/helpers.js.map +1 -0
- package/package.json +61 -16
- package/test/data/basicTree.js +34 -34
- package/test/data/rtlTest.js +6 -7
- package/cosmoz-treenode-button-view.js +0 -445
- package/cosmoz-treenode-navigator.js +0 -297
- package/helpers.js +0 -124
- package/test/cosmoz-treenode-button-view.test.js +0 -52
- package/test/cosmoz-treenode-navigator.test.js +0 -102
package/test/data/basicTree.js
CHANGED
|
@@ -10,14 +10,14 @@ export default {
|
|
|
10
10
|
3: {
|
|
11
11
|
name: 'System',
|
|
12
12
|
pathLocator: '1.2.3',
|
|
13
|
-
children: {}
|
|
13
|
+
children: {},
|
|
14
14
|
},
|
|
15
15
|
4: {
|
|
16
16
|
name: 'Microsoft.NET',
|
|
17
17
|
pathLocator: '1.2.4',
|
|
18
|
-
children: {}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
18
|
+
children: {},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
21
|
},
|
|
22
22
|
5: {
|
|
23
23
|
name: 'Program Files',
|
|
@@ -25,13 +25,13 @@ export default {
|
|
|
25
25
|
children: {
|
|
26
26
|
6: {
|
|
27
27
|
name: 'Microsoft VS Code',
|
|
28
|
-
pathLocator: '1.5.6'
|
|
28
|
+
pathLocator: '1.5.6',
|
|
29
29
|
},
|
|
30
30
|
7: {
|
|
31
31
|
name: 'Git',
|
|
32
|
-
pathLocator: '1.5.7'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
32
|
+
pathLocator: '1.5.7',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
35
|
},
|
|
36
36
|
100: {
|
|
37
37
|
name: 'Users',
|
|
@@ -43,17 +43,17 @@ export default {
|
|
|
43
43
|
children: {
|
|
44
44
|
201: {
|
|
45
45
|
name: 'Documents',
|
|
46
|
-
pathLocator: '1.100.200.201'
|
|
46
|
+
pathLocator: '1.100.200.201',
|
|
47
47
|
},
|
|
48
48
|
202: {
|
|
49
49
|
name: 'Music',
|
|
50
|
-
pathLocator: '1.100.200.202'
|
|
50
|
+
pathLocator: '1.100.200.202',
|
|
51
51
|
},
|
|
52
52
|
203: {
|
|
53
53
|
name: 'Pictures',
|
|
54
|
-
pathLocator: '1.100.200.203'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
54
|
+
pathLocator: '1.100.200.203',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
57
|
},
|
|
58
58
|
300: {
|
|
59
59
|
name: 'John',
|
|
@@ -61,17 +61,17 @@ export default {
|
|
|
61
61
|
children: {
|
|
62
62
|
301: {
|
|
63
63
|
name: 'Documents',
|
|
64
|
-
pathLocator: '1.100.300.301'
|
|
64
|
+
pathLocator: '1.100.300.301',
|
|
65
65
|
},
|
|
66
66
|
302: {
|
|
67
67
|
name: 'Music',
|
|
68
|
-
pathLocator: '1.100.300.302'
|
|
68
|
+
pathLocator: '1.100.300.302',
|
|
69
69
|
},
|
|
70
70
|
303: {
|
|
71
71
|
name: 'Pictures',
|
|
72
|
-
pathLocator: '1.100.300.303'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
72
|
+
pathLocator: '1.100.300.303',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
75
|
},
|
|
76
76
|
400: {
|
|
77
77
|
name: 'Public',
|
|
@@ -79,21 +79,21 @@ export default {
|
|
|
79
79
|
children: {
|
|
80
80
|
401: {
|
|
81
81
|
name: 'Public Documents',
|
|
82
|
-
pathLocator: '1.100.400.401'
|
|
82
|
+
pathLocator: '1.100.400.401',
|
|
83
83
|
},
|
|
84
84
|
402: {
|
|
85
85
|
name: 'Public Music',
|
|
86
|
-
pathLocator: '1.100.400.402'
|
|
86
|
+
pathLocator: '1.100.400.402',
|
|
87
87
|
},
|
|
88
88
|
403: {
|
|
89
89
|
name: 'Public Pictures',
|
|
90
|
-
pathLocator: '1.100.400.403'
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
90
|
+
pathLocator: '1.100.400.403',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
97
|
},
|
|
98
98
|
1000: {
|
|
99
99
|
name: 'D:',
|
|
@@ -105,14 +105,14 @@ export default {
|
|
|
105
105
|
children: {
|
|
106
106
|
1002: {
|
|
107
107
|
name: 'John',
|
|
108
|
-
pathLocator: '1000.1001.1002'
|
|
109
|
-
}
|
|
110
|
-
}
|
|
108
|
+
pathLocator: '1000.1001.1002',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
111
|
},
|
|
112
112
|
1002: {
|
|
113
113
|
name: 'Backup',
|
|
114
|
-
pathLocator: '1000.1002'
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
114
|
+
pathLocator: '1000.1002',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
118
|
};
|
package/test/data/rtlTest.js
CHANGED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import '@polymer/paper-icon-button/paper-icon-button';
|
|
2
|
-
import '@polymer/paper-button/paper-button';
|
|
3
|
-
import '@polymer/iron-icons/iron-icons';
|
|
4
|
-
|
|
5
|
-
import { Debouncer } from '@polymer/polymer/lib/utils/debounce';
|
|
6
|
-
import { timeOut } from '@polymer/polymer/lib/utils/async';
|
|
7
|
-
|
|
8
|
-
import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
9
|
-
import { html } from '@polymer/polymer/lib/utils/html-tag';
|
|
10
|
-
|
|
11
|
-
import '@neovici/cosmoz-dialog';
|
|
12
|
-
import { Tree } from '@neovici/cosmoz-tree';
|
|
13
|
-
import { translatable } from '@neovici/cosmoz-i18next';
|
|
14
|
-
|
|
15
|
-
import './cosmoz-treenode-navigator';
|
|
16
|
-
import { getNode, getTreePathParts } from './helpers';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
`cosmoz-treenode-navigator`
|
|
20
|
-
Navigator through object with treelike datastructure.
|
|
21
|
-
|
|
22
|
-
@appliesMixin translatable
|
|
23
|
-
*/
|
|
24
|
-
class CosmozTreenodeButtonView extends translatable(PolymerElement) {
|
|
25
|
-
/* eslint-disable-next-line max-lines-per-function */
|
|
26
|
-
static get template() {
|
|
27
|
-
return html`
|
|
28
|
-
<style>
|
|
29
|
-
.actions {
|
|
30
|
-
display: flex;
|
|
31
|
-
}
|
|
32
|
-
.open {
|
|
33
|
-
flex: auto;
|
|
34
|
-
}
|
|
35
|
-
.pathToNode {
|
|
36
|
-
max-width: 320px;
|
|
37
|
-
overflow: hidden;
|
|
38
|
-
text-overflow: ellipsis;
|
|
39
|
-
white-space: nowrap;
|
|
40
|
-
direction: rtl;
|
|
41
|
-
text-align: left;
|
|
42
|
-
}
|
|
43
|
-
/* Safari only css fix */
|
|
44
|
-
_:matches(x),
|
|
45
|
-
_:lang(x) + _:-webkit-full-screen-document,
|
|
46
|
-
.pathToNode span {
|
|
47
|
-
display: inline-block;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
#chips {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-wrap: wrap;
|
|
53
|
-
max-width: 90%;
|
|
54
|
-
padding: 20px;
|
|
55
|
-
overflow-y: auto;
|
|
56
|
-
max-height: 30vh;
|
|
57
|
-
}
|
|
58
|
-
.chip {
|
|
59
|
-
border-radius: 500px;
|
|
60
|
-
background-color: #e0e0e0;
|
|
61
|
-
margin: 1px 4px 1px 0;
|
|
62
|
-
white-space: nowrap;
|
|
63
|
-
overflow: hidden;
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
}
|
|
67
|
-
.chip > span {
|
|
68
|
-
color: #424242;
|
|
69
|
-
margin-left: 10px;
|
|
70
|
-
font-size: 13px;
|
|
71
|
-
overflow: hidden;
|
|
72
|
-
text-overflow: ellipsis;
|
|
73
|
-
}
|
|
74
|
-
.chip iron-icon {
|
|
75
|
-
margin: 2px 4px;
|
|
76
|
-
color: #cdcdcd;
|
|
77
|
-
background-color: #a6a6a6;
|
|
78
|
-
border-radius: 500px;
|
|
79
|
-
cursor: pointer;
|
|
80
|
-
min-width: 16px;
|
|
81
|
-
width: 16px;
|
|
82
|
-
min-height: 16px;
|
|
83
|
-
height: 16px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
#dialogTree {
|
|
87
|
-
min-width: 250px !important;
|
|
88
|
-
width: 450px;
|
|
89
|
-
}
|
|
90
|
-
</style>
|
|
91
|
-
<div class="actions">
|
|
92
|
-
<paper-button
|
|
93
|
-
part="button"
|
|
94
|
-
class="open"
|
|
95
|
-
raised
|
|
96
|
-
on-click="openDialogTree"
|
|
97
|
-
title="[[ buttonText ]]"
|
|
98
|
-
>
|
|
99
|
-
<div class="pathToNode">‎<span>[[ buttonText ]]</span></div>
|
|
100
|
-
</paper-button>
|
|
101
|
-
<paper-icon-button
|
|
102
|
-
part="clear"
|
|
103
|
-
icon="clear"
|
|
104
|
-
on-click="reset"
|
|
105
|
-
hidden$="[[ !_enableReset(nodePath, noReset) ]]"
|
|
106
|
-
></paper-icon-button>
|
|
107
|
-
</div>
|
|
108
|
-
<template
|
|
109
|
-
is="dom-if"
|
|
110
|
-
if="[[ _showSelectedNodes(multiSelection, selectedNodes.length) ]]"
|
|
111
|
-
>
|
|
112
|
-
<div id="chips" class="row">
|
|
113
|
-
<template is="dom-repeat" items="[[ selectedNodes ]]">
|
|
114
|
-
<div class="chip">
|
|
115
|
-
<span>[[ _getChipText(item, tree) ]]</span
|
|
116
|
-
><iron-icon
|
|
117
|
-
icon="clear"
|
|
118
|
-
on-click="_clearItemSelection"
|
|
119
|
-
></iron-icon>
|
|
120
|
-
</div>
|
|
121
|
-
</template>
|
|
122
|
-
</div>
|
|
123
|
-
</template>
|
|
124
|
-
|
|
125
|
-
<cosmoz-dialog
|
|
126
|
-
id="dialogTree"
|
|
127
|
-
class="treeDialog"
|
|
128
|
-
on-iron-overlay-opened="onOpened"
|
|
129
|
-
on-iron-overlay-closed="onClosed"
|
|
130
|
-
modal
|
|
131
|
-
prerender
|
|
132
|
-
>
|
|
133
|
-
<template>
|
|
134
|
-
<h2>[[ dialogText ]]</h2>
|
|
135
|
-
<cosmoz-treenode-navigator
|
|
136
|
-
id="treeNavigator"
|
|
137
|
-
class="no-padding"
|
|
138
|
-
tree="[[ tree ]]"
|
|
139
|
-
selected-node="{{ selectedNode }}"
|
|
140
|
-
on-data-plane-changed="refit"
|
|
141
|
-
highlighted-node-path="{{ highlightedNodePath }}"
|
|
142
|
-
search-placeholder="[[ searchPlaceholder ]]"
|
|
143
|
-
search-global-placeholder="[[ searchGlobalPlaceholder ]]"
|
|
144
|
-
search-min-length="[[ searchMinLength ]]"
|
|
145
|
-
node-path="{{ nodePath }}"
|
|
146
|
-
nodes-on-node-path="{{ nodesOnNodePath }}"
|
|
147
|
-
on-node-dblclicked="_selectNodeAndCloseDialog"
|
|
148
|
-
on-select-node="selectNode"
|
|
149
|
-
opened="[[ opened ]]"
|
|
150
|
-
>
|
|
151
|
-
<slot></slot>
|
|
152
|
-
</cosmoz-treenode-navigator>
|
|
153
|
-
<div class="buttons">
|
|
154
|
-
<paper-button
|
|
155
|
-
disabled="[[!highlightedNodePath]]"
|
|
156
|
-
autofocus
|
|
157
|
-
on-click="selectNode"
|
|
158
|
-
>[[ _('Select', t) ]]</paper-button
|
|
159
|
-
>
|
|
160
|
-
<paper-button dialog-dismiss>[[ _('Cancel', t) ]]</paper-button>
|
|
161
|
-
</div>
|
|
162
|
-
</template>
|
|
163
|
-
</cosmoz-dialog>
|
|
164
|
-
`;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
static get is() {
|
|
168
|
-
return 'cosmoz-treenode-button-view';
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/* eslint-disable-next-line max-lines-per-function */
|
|
172
|
-
static get properties() {
|
|
173
|
-
return {
|
|
174
|
-
multiSelection: {
|
|
175
|
-
type: Boolean,
|
|
176
|
-
value: false,
|
|
177
|
-
},
|
|
178
|
-
/*
|
|
179
|
-
* The main node structure
|
|
180
|
-
*/
|
|
181
|
-
tree: {
|
|
182
|
-
type: Tree,
|
|
183
|
-
},
|
|
184
|
-
/*
|
|
185
|
-
* Currently selected node object
|
|
186
|
-
*/
|
|
187
|
-
selectedNode: {
|
|
188
|
-
type: Object,
|
|
189
|
-
value() {
|
|
190
|
-
return {};
|
|
191
|
-
},
|
|
192
|
-
notify: true,
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* Selected nodes
|
|
196
|
-
*/
|
|
197
|
-
selectedNodes: {
|
|
198
|
-
type: Array,
|
|
199
|
-
notify: true,
|
|
200
|
-
value: () => [],
|
|
201
|
-
},
|
|
202
|
-
/**
|
|
203
|
-
* If true, reset button gets hidden
|
|
204
|
-
*/
|
|
205
|
-
noReset: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
value: false,
|
|
208
|
-
},
|
|
209
|
-
/**
|
|
210
|
-
* If true opened
|
|
211
|
-
*/
|
|
212
|
-
opened: {
|
|
213
|
-
type: Boolean,
|
|
214
|
-
value: false,
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
/*
|
|
218
|
-
* Placeholder for the search field
|
|
219
|
-
*/
|
|
220
|
-
searchPlaceholder: {
|
|
221
|
-
type: String,
|
|
222
|
-
},
|
|
223
|
-
/*
|
|
224
|
-
* Placeholder for button text
|
|
225
|
-
*/
|
|
226
|
-
buttonTextPlaceholder: {
|
|
227
|
-
type: String,
|
|
228
|
-
computed: 'getButtonTextPlaceholder(multiSelection)',
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
buttonText: {
|
|
232
|
-
type: String,
|
|
233
|
-
computed: '_getButtonLabel(nodesOnNodePath, buttonTextPlaceholder)',
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
/*
|
|
237
|
-
* The path of the selected node
|
|
238
|
-
*/
|
|
239
|
-
nodePath: {
|
|
240
|
-
type: String,
|
|
241
|
-
notify: true,
|
|
242
|
-
},
|
|
243
|
-
/*
|
|
244
|
-
* The nodes on the path of the selected node
|
|
245
|
-
*/
|
|
246
|
-
nodesOnNodePath: {
|
|
247
|
-
type: Array,
|
|
248
|
-
},
|
|
249
|
-
/*
|
|
250
|
-
* Text displayed when local search has finished
|
|
251
|
-
* to suggest a search on the entire tree
|
|
252
|
-
*/
|
|
253
|
-
searchGlobalPlaceholder: {
|
|
254
|
-
type: String,
|
|
255
|
-
value: 'Click to search again but globally.',
|
|
256
|
-
},
|
|
257
|
-
/*
|
|
258
|
-
* Settable text for dialog title.
|
|
259
|
-
*/
|
|
260
|
-
dialogText: {
|
|
261
|
-
type: String,
|
|
262
|
-
value: 'Search or navigate to chosen destination',
|
|
263
|
-
},
|
|
264
|
-
/*
|
|
265
|
-
* Minimum length before an search
|
|
266
|
-
* starts.
|
|
267
|
-
*/
|
|
268
|
-
searchMinLength: {
|
|
269
|
-
type: Number,
|
|
270
|
-
value: 1,
|
|
271
|
-
},
|
|
272
|
-
/*
|
|
273
|
-
* Path string of highlighted (focused) node
|
|
274
|
-
*/
|
|
275
|
-
highlightedNodePath: {
|
|
276
|
-
type: String,
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Event handler for node chip removal button, removes a node chip.
|
|
282
|
-
* @param {object} event Polymer event object.
|
|
283
|
-
* @returns {void}
|
|
284
|
-
*/
|
|
285
|
-
_clearItemSelection(event) {
|
|
286
|
-
const item = event.model.item,
|
|
287
|
-
selectedIndex = this.selectedNodes.indexOf(item);
|
|
288
|
-
|
|
289
|
-
// This will remove from the DOM the source element of the processed event ...
|
|
290
|
-
this.splice('selectedNodes', selectedIndex, 1);
|
|
291
|
-
// ... so we must prevent further propagation of this event, because its source is now invalid.
|
|
292
|
-
// (This has caused troubles in app-drawer-layout click event handler).
|
|
293
|
-
|
|
294
|
-
if (!this.selectedNodes.length) {
|
|
295
|
-
this.reset();
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
event.preventDefault();
|
|
299
|
-
event.stopPropagation();
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Get a text label for the node selection button.
|
|
303
|
-
* @param {boolean} multiSelection Multi selection setting.
|
|
304
|
-
* @returns {string} Text label.
|
|
305
|
-
*/
|
|
306
|
-
getButtonTextPlaceholder(multiSelection) {
|
|
307
|
-
return multiSelection
|
|
308
|
-
? this._('Select a node')
|
|
309
|
-
: this._('No selection made');
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Whether the reset button should be enabled or not.
|
|
313
|
-
* @param {string} nodePath Node path to check.
|
|
314
|
-
* @param {boolean} noReset Bypass to force disabled.
|
|
315
|
-
* @returns {boolean} Whether the button should be enabled or not.
|
|
316
|
-
*/
|
|
317
|
-
_enableReset(nodePath, noReset) {
|
|
318
|
-
if (noReset) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
return !!nodePath;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Get a button label based on path parts or a placeholder.
|
|
325
|
-
* @param {array} pathParts Nodes on the node path.
|
|
326
|
-
* @param {string} placeholder Replacement placeholder if no nodes are available.
|
|
327
|
-
* @returns {string} Button label.
|
|
328
|
-
*/
|
|
329
|
-
_getButtonLabel(pathParts, placeholder) {
|
|
330
|
-
if (!Array.isArray(pathParts) || pathParts.length === 0) {
|
|
331
|
-
return placeholder;
|
|
332
|
-
}
|
|
333
|
-
return pathParts
|
|
334
|
-
.filter((n) => n)
|
|
335
|
-
.map((part) => part[this.tree.searchProperty])
|
|
336
|
-
.join(' / ');
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Get text from a node to set on a node chip.
|
|
340
|
-
* @param {object} node Node to get text from.
|
|
341
|
-
* @returns {string} Chip text.
|
|
342
|
-
*/
|
|
343
|
-
_getChipText(node) {
|
|
344
|
-
return node.name;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Open the treenode navigator dialog.
|
|
348
|
-
* @returns {void}
|
|
349
|
-
*/
|
|
350
|
-
openDialogTree() {
|
|
351
|
-
this.$.dialogTree.open();
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Focus on the treenode navigator in the treenode navigator dialog.
|
|
355
|
-
* @returns {void}
|
|
356
|
-
*/
|
|
357
|
-
focusSearch() {
|
|
358
|
-
this.$.dialogTree.paperDialog
|
|
359
|
-
.querySelector('#treeNavigator')
|
|
360
|
-
.shadowRoot.querySelector('cosmoz-input')
|
|
361
|
-
.focus();
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Reset the component to make it ready for reuse
|
|
365
|
-
* @returns {void}
|
|
366
|
-
*/
|
|
367
|
-
reset() {
|
|
368
|
-
this.nodePath = '';
|
|
369
|
-
this.selectedNode = {};
|
|
370
|
-
this.nodesOnNodePath = [];
|
|
371
|
-
this.selectedNodes = [];
|
|
372
|
-
this.highlightedNodePath = '';
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Select the node in the treenode navigator.
|
|
376
|
-
* @returns {void}
|
|
377
|
-
*/
|
|
378
|
-
selectNode() {
|
|
379
|
-
// nodePath selects the node, without it no selectedNode
|
|
380
|
-
|
|
381
|
-
this.selectedNode = getNode(
|
|
382
|
-
this.highlightedNodePath || this.nodePath,
|
|
383
|
-
this.tree
|
|
384
|
-
);
|
|
385
|
-
if (this.highlightedNodePath) {
|
|
386
|
-
this.nodePath = this.highlightedNodePath;
|
|
387
|
-
}
|
|
388
|
-
this.nodesOnNodePath = getTreePathParts(
|
|
389
|
-
this.highlightedNodePath || this.nodePath,
|
|
390
|
-
this.tree
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
if (this.multiSelection) {
|
|
394
|
-
if (
|
|
395
|
-
!this.selectedNodes.some(
|
|
396
|
-
(node) => node.pathLocator === this.highlightedNodePath
|
|
397
|
-
)
|
|
398
|
-
) {
|
|
399
|
-
this.push('selectedNodes', this.selectedNode);
|
|
400
|
-
}
|
|
401
|
-
this.nodePath = '';
|
|
402
|
-
this.selectedNode = {};
|
|
403
|
-
}
|
|
404
|
-
this.$.dialogTree.close();
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Selects node and closes the dialog
|
|
408
|
-
* @returns {void}
|
|
409
|
-
*/
|
|
410
|
-
_selectNodeAndCloseDialog() {
|
|
411
|
-
this.selectNode();
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Determine if selected nodes container should be visible or not.
|
|
415
|
-
* @param {boolean} multiSelection Multi selection setting.
|
|
416
|
-
* @param {number} selectedNodesLength Selected nodes quantity.
|
|
417
|
-
* @returns {boolean} Whether the selected nodes container should be visible or not.
|
|
418
|
-
*/
|
|
419
|
-
_showSelectedNodes(multiSelection, selectedNodesLength) {
|
|
420
|
-
return multiSelection && selectedNodesLength > 0;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Callback event handler to refit the treenode navigator dialog when
|
|
424
|
-
* data plane has changed.
|
|
425
|
-
* @returns {void}
|
|
426
|
-
*/
|
|
427
|
-
refit() {
|
|
428
|
-
this._debouncer = Debouncer.debounce(
|
|
429
|
-
this._debouncer,
|
|
430
|
-
timeOut.after(50), // 5 was enough during test
|
|
431
|
-
() => {
|
|
432
|
-
this.$.dialogTree.fit();
|
|
433
|
-
}
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
onOpened() {
|
|
438
|
-
this.opened = true;
|
|
439
|
-
this.focusSearch();
|
|
440
|
-
}
|
|
441
|
-
onClosed() {
|
|
442
|
-
this.opened = false;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
customElements.define(CosmozTreenodeButtonView.is, CosmozTreenodeButtonView);
|