@masterteam/delegations 0.0.39 → 0.0.40
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.
|
@@ -2167,17 +2167,24 @@ class ScopePicker {
|
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
2169
|
});
|
|
2170
|
-
//
|
|
2171
|
-
// so large catalogs open compact;
|
|
2170
|
+
// Expansion on options (re)load: Template nodes expand by default (levels
|
|
2171
|
+
// collapse so large catalogs open compact); additionally expand the path to
|
|
2172
|
+
// any already-selected grant so an edit's saved selection is visible.
|
|
2172
2173
|
effect(() => {
|
|
2173
2174
|
const model = this.treeModel();
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2175
|
+
untracked(() => this.expandedKeys.set(this.collectExpansion(model, this.selectedKeys(), new Set())));
|
|
2176
|
+
});
|
|
2177
|
+
// One-time: when an initial (edit) scope arrives AFTER options, expand the
|
|
2178
|
+
// path to its selected grants so the user sees what's re-selected.
|
|
2179
|
+
let prefillExpanded = false;
|
|
2180
|
+
effect(() => {
|
|
2181
|
+
const grants = this.scope().grants;
|
|
2182
|
+
const model = this.treeModel();
|
|
2183
|
+
if (prefillExpanded || !grants.length || !model.length) {
|
|
2184
|
+
return;
|
|
2179
2185
|
}
|
|
2180
|
-
|
|
2186
|
+
prefillExpanded = true;
|
|
2187
|
+
untracked(() => this.expandedKeys.update((prev) => this.collectExpansion(model, this.selectedKeys(), prev)));
|
|
2181
2188
|
});
|
|
2182
2189
|
// Debounced scope preview.
|
|
2183
2190
|
let timer = null;
|
|
@@ -2321,6 +2328,32 @@ class ScopePicker {
|
|
|
2321
2328
|
trackVisible(_index, item) {
|
|
2322
2329
|
return item.node.key;
|
|
2323
2330
|
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Template keys (open by default) plus the ancestor keys of every selected
|
|
2333
|
+
* operation, so an edit's saved selection is expanded into view. Only valid
|
|
2334
|
+
* grants (those matching an option node) contribute — invalid saved grants
|
|
2335
|
+
* have no node and are simply ignored.
|
|
2336
|
+
*/
|
|
2337
|
+
collectExpansion(model, selected, base) {
|
|
2338
|
+
const keys = new Set(base);
|
|
2339
|
+
const walk = (nodes, ancestors) => {
|
|
2340
|
+
for (const node of nodes) {
|
|
2341
|
+
if (node.kind === 'template') {
|
|
2342
|
+
keys.add(node.key);
|
|
2343
|
+
}
|
|
2344
|
+
if (node.kind === 'operation' && selected.has(node.key)) {
|
|
2345
|
+
for (const ancestor of ancestors) {
|
|
2346
|
+
keys.add(ancestor);
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
if (node.children?.length) {
|
|
2350
|
+
walk(node.children, [...ancestors, node.key]);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
model.forEach((node) => walk([node], []));
|
|
2355
|
+
return keys;
|
|
2356
|
+
}
|
|
2324
2357
|
// --- App accessibility ----------------------------------------------------
|
|
2325
2358
|
toggleAccessibility(key) {
|
|
2326
2359
|
if (this.readonly()) {
|