flexdesk 0.4.1 → 0.4.3
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 +24 -0
- package/dist/charts.js +2 -2
- package/dist/{chunk-XKDTIT4Q.js → chunk-4RGQSRMC.js} +2 -2
- package/dist/{chunk-QIU5S2RU.js → chunk-P4AALM3A.js} +2 -2
- package/dist/{chunk-QIU5S2RU.js.map → chunk-P4AALM3A.js.map} +2 -2
- package/dist/tiles.js +2 -2
- package/dist/widgets.js +1 -1
- package/dist/wm.js +232 -107
- package/dist/wm.js.map +3 -3
- package/package.json +1 -1
- package/src/tiling/shell.js +8 -1
- package/src/tiling/tile_breadcrumb.js +9 -8
- package/src/tiling/tile_renderer.js +1 -1
- package/src/tiling/wm.js +258 -118
- package/src/ui/components/data_table.js +5 -1
- /package/dist/{chunk-XKDTIT4Q.js.map → chunk-4RGQSRMC.js.map} +0 -0
package/package.json
CHANGED
package/src/tiling/shell.js
CHANGED
|
@@ -91,6 +91,10 @@ import { openForm } from '../ui/components/modal.js';
|
|
|
91
91
|
* its section that is already open, rather
|
|
92
92
|
* than rewriting it into a second copy of
|
|
93
93
|
* that list. Default off.
|
|
94
|
+
* @param {boolean} [cfg.floatActiveTab] C34. Whether floating a tile takes
|
|
95
|
+
* only the tab on screen, leaving its
|
|
96
|
+
* siblings in the tile. Default off: the
|
|
97
|
+
* whole pane floats, strip and all (R8).
|
|
94
98
|
* @param {'top'|'bottom'} [cfg.tabLayout] C22. Where a multi-tab leaf draws its
|
|
95
99
|
* tabs. `'bottom'` is the framework's own
|
|
96
100
|
* spreadsheet strip under the tile body
|
|
@@ -128,6 +132,7 @@ export async function createShell({
|
|
|
128
132
|
snapPromotion = false,
|
|
129
133
|
promoteInPlace = false,
|
|
130
134
|
backToOpenList = false,
|
|
135
|
+
floatActiveTab = false,
|
|
131
136
|
tabLayout = null,
|
|
132
137
|
chrome = {},
|
|
133
138
|
// An embedder that moved its sections out of the top bar — into an icon
|
|
@@ -170,6 +175,7 @@ export async function createShell({
|
|
|
170
175
|
snapPromotion,
|
|
171
176
|
promoteInPlace,
|
|
172
177
|
backToOpenList,
|
|
178
|
+
floatActiveTab,
|
|
173
179
|
tabLayout,
|
|
174
180
|
// `ctx` is the delivery vehicle for leaf-mounted chrome: tile_renderer
|
|
175
181
|
// spreads it into every content factory, which is how the breadcrumb
|
|
@@ -528,7 +534,8 @@ function _tileContextMenu(wm, leafId, x, y) {
|
|
|
528
534
|
// most of them — a menu disagreeing with its verb in the generous
|
|
529
535
|
// direction is a dead control; in the mean direction it is a missing
|
|
530
536
|
// feature, and this file has shipped one of each.
|
|
531
|
-
{ label: 'Float this
|
|
537
|
+
{ label: wm.floatActiveTab ? 'Float this tab as a window' : 'Float this pane as a window',
|
|
538
|
+
icon: 'web_asset',
|
|
532
539
|
action: 'promote',
|
|
533
540
|
disabled: isPanel || !leaf.content
|
|
534
541
|
|| wm.renderer?.leafChrome?.(leafId)?.promote === false },
|
|
@@ -44,20 +44,21 @@ export function mountTileBreadcrumb(kind, props, ctx) {
|
|
|
44
44
|
// before the renderer threaded wm through — still navigates.
|
|
45
45
|
const getWm = () => ctx?.wm || window.__twm?.wm || null;
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
// jumping back to the primary tile.
|
|
47
|
+
// Every crumb CLIMBS: `wm.navigateUp` (C35), not `wm.navigate`. A crumb
|
|
48
|
+
// means "up to this level of where I am", and from a record whose list is
|
|
49
|
+
// already open that is what Backspace means too, so the WM answers both
|
|
50
|
+
// with one rule and the breadcrumb never works out which crumb is the
|
|
51
|
+
// parent. Passing `ctx` keeps the click inside its own tile or floating
|
|
52
|
+
// window.
|
|
54
53
|
const navigate = (k, p = {}) => {
|
|
55
54
|
const wm = getWm();
|
|
56
55
|
if (!wm) {
|
|
57
56
|
console.error('[breadcrumb] no WM available — click ignored', k);
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
if (typeof wm.
|
|
59
|
+
if (typeof wm.navigateUp === 'function') {
|
|
60
|
+
wm.navigateUp(k, p, { ctx });
|
|
61
|
+
} else if (typeof wm.navigate === 'function') {
|
|
61
62
|
wm.navigate(k, p, { ctx, dest: 'origin' });
|
|
62
63
|
} else if (typeof wm.openInPrimary === 'function') {
|
|
63
64
|
// Fallback for older WM revisions.
|
|
@@ -561,7 +561,7 @@ export class TileRenderer {
|
|
|
561
561
|
<button class="twm-leaf__btn" data-action="split-v" title="Split vertically (Alt+V)">
|
|
562
562
|
<span class="material-symbols-outlined">splitscreen_add</span>
|
|
563
563
|
</button>
|
|
564
|
-
<button class="twm-leaf__btn" data-action="promote" title="Float this pane as a window (Alt+F)">
|
|
564
|
+
<button class="twm-leaf__btn" data-action="promote" title="Float this ${this.ctx.wm?.floatActiveTab ? 'tab' : 'pane'} as a window (Alt+F)">
|
|
565
565
|
<span class="material-symbols-outlined">web_asset</span>
|
|
566
566
|
</button>`}
|
|
567
567
|
<button class="twm-leaf__btn" data-action="close" title="Close (Alt+W)">
|
package/src/tiling/wm.js
CHANGED
|
@@ -34,7 +34,8 @@ const PANEL_TITLES = {
|
|
|
34
34
|
export class WindowManager {
|
|
35
35
|
constructor({ rootEl, api, ctx, onChange, eventBus, host, taxonomy, events, content,
|
|
36
36
|
panelDefaults = null, snapPromotion = false,
|
|
37
|
-
promoteInPlace = false, tabLayout = null, backToOpenList = false
|
|
37
|
+
promoteInPlace = false, tabLayout = null, backToOpenList = false,
|
|
38
|
+
floatActiveTab = false }) {
|
|
38
39
|
if (!taxonomy) throw new Error('WindowManager: a taxonomy is required');
|
|
39
40
|
if (!content || typeof content.mount !== 'function') {
|
|
40
41
|
throw new Error('WindowManager: a content registry is required '
|
|
@@ -57,6 +58,8 @@ export class WindowManager {
|
|
|
57
58
|
this.ctx = ctx || {};
|
|
58
59
|
this.eventBus = eventBus || null;
|
|
59
60
|
this.onChange = onChange || (() => {});
|
|
61
|
+
// C34. Whether the tile's float gesture takes only the tab on screen.
|
|
62
|
+
this.floatActiveTab = !!floatActiveTab;
|
|
60
63
|
|
|
61
64
|
// The leaf a fresh or emptied desktop starts with. Comes from the
|
|
62
65
|
// taxonomy's root kind — NOT a hardcoded 'home'. An embedder with a
|
|
@@ -85,10 +88,24 @@ export class WindowManager {
|
|
|
85
88
|
this.promoteInPlace = !!promoteInPlace;
|
|
86
89
|
/** C32. Whether Backspace on an ENTITY tab closes it and returns to a list
|
|
87
90
|
* that is already open, instead of turning the tab into a second copy of
|
|
88
|
-
* that list. See `
|
|
91
|
+
* that list. See `_returnToOpenList`. Default off: it changes what the key
|
|
89
92
|
* does, and an existing embedder upgrading must not find tabs closing
|
|
90
93
|
* where they used to navigate. */
|
|
91
94
|
this.backToOpenList = !!backToOpenList;
|
|
95
|
+
|
|
96
|
+
// C34. BACK BELONGS TO WHAT YOU ARE LOOKING AT. A floating window is not a
|
|
97
|
+
// tile, so the tree's focus never moves to it, and Backspace pressed while
|
|
98
|
+
// reading a window used to walk the tile BEHIND it. The last pointerdown
|
|
99
|
+
// says which one the user is in: inside a window it names that window,
|
|
100
|
+
// anywhere else it clears. Capture phase, so content that stops the event
|
|
101
|
+
// cannot hide it.
|
|
102
|
+
this._backWindowId = null;
|
|
103
|
+
const doc = rootEl?.ownerDocument || globalThis.document;
|
|
104
|
+
doc?.addEventListener?.('pointerdown', (e) => {
|
|
105
|
+
const el = e.target?.closest?.('[data-window-id]');
|
|
106
|
+
this._backWindowId = el && this._windowToLeaf.has(el.getAttribute('data-window-id'))
|
|
107
|
+
? el.getAttribute('data-window-id') : null;
|
|
108
|
+
}, true);
|
|
92
109
|
this._snapCtl = null;
|
|
93
110
|
this.desktops = new DesktopManager({
|
|
94
111
|
seed: this._rootLeaf, panelDefaults: this.panelDefaults });
|
|
@@ -244,67 +261,50 @@ export class WindowManager {
|
|
|
244
261
|
* methods (openFromContext / openInLeaf / navigateActiveTab) —
|
|
245
262
|
* they all record history by default. */
|
|
246
263
|
navigateBack() {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
// instead (Backspace from the nav panel should still navigate
|
|
254
|
-
// the user's content area).
|
|
255
|
-
const focusedId = tree.focusedLeafId;
|
|
256
|
-
const primaryId = tree.primaryLeafId();
|
|
257
|
-
const focusedLeaf = focusedId ? tree.get(focusedId) : null;
|
|
258
|
-
const focusedKind = focusedLeaf?.content?.kind || '';
|
|
259
|
-
const id = (focusedId && focusedKind
|
|
260
|
-
&& !focusedKind.startsWith('panel:')
|
|
261
|
-
&& focusedKind !== 'window-placeholder')
|
|
262
|
-
? focusedId : primaryId;
|
|
263
|
-
if (!id) return;
|
|
264
|
-
// (1) Per-tab history pop, if anything was recorded.
|
|
265
|
-
const prior = tree.popActiveTabHistory?.(id);
|
|
266
|
-
if (prior && prior.kind) {
|
|
267
|
-
// Cross-page back entries carry a `topNav` marker — pop
|
|
268
|
-
// routes via swapToPage so we land on the correct page.
|
|
269
|
-
const leafNow = tree.get(id);
|
|
270
|
-
const curKind = leafNow?.content?.kind;
|
|
271
|
-
const curTopNav = curKind ? this.taxonomy.topNavFor(curKind) : null;
|
|
272
|
-
if (prior.topNav && curTopNav && prior.topNav !== curTopNav) {
|
|
273
|
-
tree.swapToPage?.(
|
|
274
|
-
id,
|
|
275
|
-
{ kind: prior.kind, props: prior.props || {},
|
|
276
|
-
title: prior.title || _tabTitle(prior.kind, prior.props) },
|
|
277
|
-
curTopNav, prior.topNav,
|
|
278
|
-
{ recordHistory: false },
|
|
279
|
-
);
|
|
280
|
-
} else {
|
|
281
|
-
tree.replaceActiveTabContent(
|
|
282
|
-
id,
|
|
283
|
-
{ kind: prior.kind, props: prior.props || {} },
|
|
284
|
-
prior.title || _tabTitle(prior.kind, prior.props),
|
|
285
|
-
{ recordHistory: false },
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
tree.focus(id);
|
|
289
|
-
this.renderer.render();
|
|
290
|
-
this._persist();
|
|
291
|
-
this._notifyChange('navigate-back');
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
// (2) C32. An entity tab with nowhere left to go back to, beside a list
|
|
295
|
-
// of its own section that is already open: close it and land there.
|
|
296
|
-
if (this.backToOpenList && this._backToOpenList(id)) return;
|
|
264
|
+
const scope = this._backScope();
|
|
265
|
+
if (!scope) return;
|
|
266
|
+
// (1) Per-tab history, browser-style. Tiles only: a window keeps none.
|
|
267
|
+
if (scope.leafId && this._popTabHistory(scope.leafId)) return;
|
|
268
|
+
// (2) C32. A record beside an open list of its section closes onto it.
|
|
269
|
+
if (this._returnToOpenList(scope)) return;
|
|
297
270
|
// (3) Taxonomy fallback — the user's path is gone, so walk the
|
|
298
|
-
// canonical parent instead. An ENTITY-level parent wins (the
|
|
299
|
-
// instance one level up,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
271
|
+
// canonical parent instead, in place. An ENTITY-level parent wins (the
|
|
272
|
+
// instance one level up); failing that, the KIND-level parent.
|
|
273
|
+
const active = this._scopeActiveTab(scope);
|
|
274
|
+
if (!active) return;
|
|
275
|
+
const up = this.taxonomy.parentOf(active.kind, active.props || {});
|
|
276
|
+
const parentKind = up ? up.kind : this.taxonomy.parentKindFor(active.kind);
|
|
277
|
+
if (parentKind) this._navigateInScope(scope, parentKind, up ? (up.props || {}) : {});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* C35. CLIMB TO A LEVEL: what a breadcrumb crumb means.
|
|
282
|
+
*
|
|
283
|
+
* `navigate` goes to exactly the target. A crumb says something different:
|
|
284
|
+
* "take me up to this level of where I am". From a record, the level it
|
|
285
|
+
* names is usually a list of the record's own section, and when such a list
|
|
286
|
+
* is already open that is the SAME request Backspace makes, so it goes
|
|
287
|
+
* through the same rule, `_returnToOpenList`, and closes the record onto the
|
|
288
|
+
* open list instead of turning the record into a second copy of it.
|
|
289
|
+
*
|
|
290
|
+
* Every crumb calls this, so no crumb needs to know whether it is the
|
|
291
|
+
* immediate parent. A crumb that names an entity (an epic above a story), a
|
|
292
|
+
* record with no list of its section open, or content that is not a record
|
|
293
|
+
* navigates in place, exactly as `navigate(…, { dest: 'origin' })` would.
|
|
294
|
+
*
|
|
295
|
+
* @param {string} kind
|
|
296
|
+
* @param {object} [props]
|
|
297
|
+
* @param {{ctx?: object}} [opts] the crumb's tile or window context
|
|
298
|
+
*/
|
|
299
|
+
navigateUp(kind, props = {}, { ctx = null } = {}) {
|
|
300
|
+
const scope = this._scopeFromCtx(ctx);
|
|
301
|
+
if (!scope) return this.navigate(kind, props, { ctx, dest: 'origin' });
|
|
302
|
+
const active = this._scopeActiveTab(scope);
|
|
303
|
+
const aimsAtOwnList = !_isEntityTab({ props })
|
|
304
|
+
&& _isEntityTab(active)
|
|
305
|
+
&& this.taxonomy.topNavFor(kind) === this.taxonomy.topNavFor(active.kind);
|
|
306
|
+
if (aimsAtOwnList && this._returnToOpenList(scope)) return;
|
|
307
|
+
this._navigateInScope(scope, kind, props);
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/** True when `navigateBack` would do something user-visible — i.e.
|
|
@@ -353,71 +353,181 @@ export class WindowManager {
|
|
|
353
353
|
this._persist();
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
// ── Back and up: one scope model, one rule ─────────────────────
|
|
357
|
+
//
|
|
358
|
+
// A SCOPE is where a navigation happens: `{ leafId }` for a tile or
|
|
359
|
+
// `{ windowId }` for a floating window. Backspace and `navigateUp` both
|
|
360
|
+
// resolve one, and everything below works on a scope, so tiles and windows
|
|
361
|
+
// cannot drift into two versions of the same behaviour.
|
|
362
|
+
|
|
363
|
+
/** The scope Backspace acts on. C34: a floating window the user last
|
|
364
|
+
* clicked in, because the tree's focus never moves to a window; else the
|
|
365
|
+
* focused content tile; else the primary tile. Panels are never a scope:
|
|
366
|
+
* Backspace from the nav panel walks the content area. */
|
|
367
|
+
_backScope() {
|
|
368
|
+
if (this._backWindowId && this._windowToLeaf.has(this._backWindowId)) {
|
|
369
|
+
return { windowId: this._backWindowId };
|
|
370
|
+
}
|
|
371
|
+
this._backWindowId = null;
|
|
372
|
+
const tree = this._tree();
|
|
373
|
+
const focusedId = tree.focusedLeafId;
|
|
374
|
+
const focusedKind = focusedId ? tree.get(focusedId)?.content?.kind || '' : '';
|
|
375
|
+
const id = (focusedId && focusedKind
|
|
376
|
+
&& !focusedKind.startsWith('panel:')
|
|
377
|
+
&& focusedKind !== 'window-placeholder')
|
|
378
|
+
? focusedId : tree.primaryLeafId();
|
|
379
|
+
return id ? { leafId: id } : null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** The scope a content context names: its window, or its tile. Null for a
|
|
383
|
+
* panel or a context the WM does not know. */
|
|
384
|
+
_scopeFromCtx(ctx) {
|
|
385
|
+
if (ctx?.windowId && this._windowToLeaf.has(ctx.windowId)) return { windowId: ctx.windowId };
|
|
386
|
+
const leaf = ctx?.leafId ? this._tree().get(ctx.leafId) : null;
|
|
387
|
+
const k = leaf?.content?.kind || '';
|
|
388
|
+
if (leaf && leaf.kind === 'leaf' && k && !k.startsWith('panel:')) return { leafId: leaf.id };
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** A scope's tab list and active index. A window promoted with no strip, or
|
|
393
|
+
* a tile with no tab array, reads as a single tab. */
|
|
394
|
+
_scopeTabs(scope) {
|
|
395
|
+
if (scope?.windowId) {
|
|
396
|
+
const rec = this._windowToLeaf.get(scope.windowId);
|
|
397
|
+
if (!rec) return null;
|
|
398
|
+
const tabs = Array.isArray(rec.tabs) && rec.tabs.length ? rec.tabs : [rec.original].filter(Boolean);
|
|
399
|
+
return { tabs, activeIdx: Math.max(0, Math.min(tabs.length - 1, rec.activeTabIdx || 0)) };
|
|
400
|
+
}
|
|
401
|
+
const leaf = scope?.leafId ? this._tree().get(scope.leafId) : null;
|
|
402
|
+
if (!leaf || leaf.kind !== 'leaf') return null;
|
|
403
|
+
const tabs = Array.isArray(leaf.tabs) && leaf.tabs.length ? leaf.tabs : [leaf.content].filter(Boolean);
|
|
404
|
+
return { tabs, activeIdx: Math.max(0, Math.min(tabs.length - 1, leaf.activeTabIdx || 0)) };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
_scopeActiveTab(scope) {
|
|
408
|
+
const src = this._scopeTabs(scope);
|
|
409
|
+
return src ? src.tabs[src.activeIdx] || null : null;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** Replace what a scope shows, in place: the tile's active tab (recording
|
|
413
|
+
* history) or the window's content. */
|
|
414
|
+
_navigateInScope(scope, kind, props = {}) {
|
|
415
|
+
if (scope.windowId) return this.openInWindow(scope.windowId, kind, props);
|
|
416
|
+
return this.navigateActiveTab(scope.leafId, kind, props);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Pop the active tab's history, if it has any. */
|
|
420
|
+
_popTabHistory(id) {
|
|
421
|
+
const tree = this._tree();
|
|
422
|
+
const prior = tree.popActiveTabHistory?.(id);
|
|
423
|
+
if (!prior || !prior.kind) return false;
|
|
424
|
+
// Cross-page back entries carry a `topNav` marker — pop
|
|
425
|
+
// routes via swapToPage so we land on the correct page.
|
|
426
|
+
const curKind = tree.get(id)?.content?.kind;
|
|
427
|
+
const curTopNav = curKind ? this.taxonomy.topNavFor(curKind) : null;
|
|
428
|
+
const title = prior.title || _tabTitle(prior.kind, prior.props);
|
|
429
|
+
if (prior.topNav && curTopNav && prior.topNav !== curTopNav) {
|
|
430
|
+
tree.swapToPage?.(id, { kind: prior.kind, props: prior.props || {}, title },
|
|
431
|
+
curTopNav, prior.topNav, { recordHistory: false });
|
|
432
|
+
} else {
|
|
433
|
+
tree.replaceActiveTabContent(id, { kind: prior.kind, props: prior.props || {} },
|
|
434
|
+
title, { recordHistory: false });
|
|
435
|
+
}
|
|
436
|
+
tree.focus(id);
|
|
437
|
+
this.renderer.render();
|
|
438
|
+
this._persist();
|
|
439
|
+
this._notifyChange('navigate-back');
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
|
|
359
443
|
/**
|
|
360
|
-
* C32. BACK FROM
|
|
361
|
-
*
|
|
362
|
-
* The gesture this is for: a list
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* the
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* record
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* list
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* Matching is by SECTION (`topNavFor`) and not by kind, because the list a
|
|
387
|
-
* record was opened from is often not the record's taxonomy parent: a root
|
|
388
|
-
* landing page that renders the section, or a list that a flattened taxonomy
|
|
389
|
-
* files beside the record rather than above it.
|
|
390
|
-
*
|
|
391
|
-
* @returns {boolean} whether it closed a tab
|
|
444
|
+
* C32 / C34 / C35. BACK FROM A RECORD RETURNS TO THE LIST; IT DOES NOT MAKE ONE.
|
|
445
|
+
*
|
|
446
|
+
* The gesture this is for: a list, a record opened from it into a new tab,
|
|
447
|
+
* then Backspace or the list's crumb in that record. Rewriting the record
|
|
448
|
+
* into its parent would leave the list open twice. The user's model is a
|
|
449
|
+
* browser's: the list is still open, so going back closes the record and
|
|
450
|
+
* shows the list again. This function is the ONLY place that rule lives.
|
|
451
|
+
*
|
|
452
|
+
* Applies when `backToOpenList` is on and the scope's active tab is a RECORD
|
|
453
|
+
* (its props carry an `id`). The list is an open tab that is not a record
|
|
454
|
+
* and belongs to the same SECTION (`topNavFor`), matched by section and not
|
|
455
|
+
* by kind because a record's list is often not its taxonomy parent: a root
|
|
456
|
+
* landing that renders the section, or a list filed beside the record.
|
|
457
|
+
*
|
|
458
|
+
* Where it looks, in order:
|
|
459
|
+
* - the scope's own tabs, nearest to the LEFT first (new tabs are appended,
|
|
460
|
+
* so the tab a record came from sits to its left), then to the right;
|
|
461
|
+
* - for a WINDOW only, then any tile of the window's desktop, primary tile
|
|
462
|
+
* first, activating a list tab there. Closing a window's last tab closes
|
|
463
|
+
* the window, which discards it; a plain close never docks back.
|
|
464
|
+
*
|
|
465
|
+
* Declines, leaving the caller to navigate in place, when there is no such
|
|
466
|
+
* list, so Back never closes a record into a tile with nothing to show.
|
|
467
|
+
*
|
|
468
|
+
* @returns {boolean} whether it closed the record
|
|
392
469
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
if (!
|
|
397
|
-
const
|
|
398
|
-
if (tabs.length < 2) return false;
|
|
399
|
-
const activeIdx = Math.max(0, Math.min(tabs.length - 1, leaf.activeTabIdx || 0));
|
|
470
|
+
_returnToOpenList(scope) {
|
|
471
|
+
if (!this.backToOpenList) return false;
|
|
472
|
+
const src = this._scopeTabs(scope);
|
|
473
|
+
if (!src) return false;
|
|
474
|
+
const { tabs, activeIdx } = src;
|
|
400
475
|
const active = tabs[activeIdx];
|
|
401
476
|
if (!_isEntityTab(active)) return false;
|
|
402
477
|
const section = this.taxonomy.topNavFor(active.kind);
|
|
403
478
|
if (!section) return false;
|
|
479
|
+
const isList = (t) => !!t && !_isEntityTab(t) && this.taxonomy.topNavFor(t.kind) === section;
|
|
480
|
+
|
|
481
|
+
const own = _nearestIndex(tabs, activeIdx, isList);
|
|
482
|
+
if (own >= 0 && tabs.length > 1) {
|
|
483
|
+
const landing = own > activeIdx ? own - 1 : own;
|
|
484
|
+
if (scope.windowId) {
|
|
485
|
+
this._windowTabAction(scope.windowId, 'close', { idx: activeIdx });
|
|
486
|
+
this.showWindowTab(scope.windowId, landing);
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
const tree = this._tree();
|
|
490
|
+
tree.removeLeafTab(scope.leafId, activeIdx);
|
|
491
|
+
tree.setActiveLeafTab(scope.leafId, landing);
|
|
492
|
+
tree.focus(scope.leafId);
|
|
493
|
+
this.renderer.render();
|
|
494
|
+
this._persist();
|
|
495
|
+
this._notifyChange('navigate-back-close');
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
if (!scope.windowId) return false;
|
|
404
499
|
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
500
|
+
const rec = this._windowToLeaf.get(scope.windowId);
|
|
501
|
+
const tree = (this.desktops.desktops[rec.desktopIdx] || this.desktops.active()).tree;
|
|
502
|
+
const primaryId = tree.primaryLeafId();
|
|
503
|
+
const leaves = tree.leaves?.() || [];
|
|
504
|
+
const ordered = [...leaves.filter((l) => l.id === primaryId), ...leaves.filter((l) => l.id !== primaryId)];
|
|
505
|
+
for (const leaf of ordered) {
|
|
506
|
+
const ltabs = Array.isArray(leaf.tabs) ? leaf.tabs : [];
|
|
507
|
+
const cur = Math.max(0, Math.min(ltabs.length - 1, leaf.activeTabIdx || 0));
|
|
508
|
+
const hit = isList(ltabs[cur]) ? cur : ltabs.findIndex(isList);
|
|
509
|
+
if (hit < 0) continue;
|
|
510
|
+
if (this._backWindowId === scope.windowId) this._backWindowId = null;
|
|
511
|
+
if (Array.isArray(rec.tabs) && rec.tabs.length > 1) {
|
|
512
|
+
this._windowTabAction(scope.windowId, 'close', { idx: activeIdx });
|
|
513
|
+
} else {
|
|
514
|
+
try { rec.window.close({ force: true }); } catch { /* already gone */ }
|
|
515
|
+
}
|
|
516
|
+
if (this.desktops.active().tree === tree) {
|
|
517
|
+
tree.setActiveLeafTab(leaf.id, hit);
|
|
518
|
+
tree.focus(leaf.id);
|
|
519
|
+
this.renderer.render();
|
|
520
|
+
}
|
|
521
|
+
this._persist();
|
|
522
|
+
this._notifyChange('navigate-back-close');
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
return false;
|
|
419
526
|
}
|
|
420
527
|
|
|
528
|
+
/** Navigate inside the current tab — preserves every other tab in
|
|
529
|
+
* the leaf. Used by Backspace + breadcrumb segments + anything
|
|
530
|
+
* else that should walk WITHIN the tile rather than reset it. */
|
|
421
531
|
navigateActiveTab(leafId, kind, props = {}) {
|
|
422
532
|
const tree = this._tree();
|
|
423
533
|
const leaf = tree.get(leafId);
|
|
@@ -555,6 +665,20 @@ export class WindowManager {
|
|
|
555
665
|
tree.swapToPage(leafId,
|
|
556
666
|
{ kind, props, title },
|
|
557
667
|
currentTopNav, targetTopNav);
|
|
668
|
+
// C35. THE SAME PAGE WITH DIFFERENT PROPS IS A DIFFERENT VIEW. swapToPage
|
|
669
|
+
// finds an existing tab by kind + props.id, and a list has no id, so a
|
|
670
|
+
// filter clicked while that list is showing matched the open list tab
|
|
671
|
+
// and re-activated it unchanged: the click did nothing. The active tab
|
|
672
|
+
// must carry the requested props. A BARE open (no props, a top-nav
|
|
673
|
+
// click) is left alone, because putting back the tab you left, filter
|
|
674
|
+
// and all, is the point of archiving page tabs. BugDesk's own tiling
|
|
675
|
+
// fork carried this correction; it is upstream now.
|
|
676
|
+
const _leaf = tree.get(leafId);
|
|
677
|
+
const _active = _leaf?.tabs?.[_leaf.activeTabIdx];
|
|
678
|
+
if (_active && _active.kind === kind && Object.keys(props || {}).length > 0
|
|
679
|
+
&& JSON.stringify(_active.props || {}) !== JSON.stringify(props || {})) {
|
|
680
|
+
tree.replaceActiveTabContent(leafId, { kind, props }, title, { recordHistory: false });
|
|
681
|
+
}
|
|
558
682
|
tree.focus(leafId);
|
|
559
683
|
if (spawned) this._canonicalize(tree, this.desktops.active());
|
|
560
684
|
this.renderer.render();
|
|
@@ -828,6 +952,14 @@ export class WindowManager {
|
|
|
828
952
|
const tree = this._tree();
|
|
829
953
|
const focused = tree.focused();
|
|
830
954
|
if (!focused) return null;
|
|
955
|
+
// C34. An embedder whose tabs are separate records, not one pane's
|
|
956
|
+
// views, floats the record on screen and leaves its siblings in place.
|
|
957
|
+
// A window then holds one tab, so it draws no strip at all.
|
|
958
|
+
const tabs = Array.isArray(focused.tabs) ? focused.tabs : [];
|
|
959
|
+
if (this.floatActiveTab && tabs.length > 1) {
|
|
960
|
+
const idx = Math.max(0, Math.min(tabs.length - 1, focused.activeTabIdx || 0));
|
|
961
|
+
return this.floatTabAsWindow(focused.id, idx);
|
|
962
|
+
}
|
|
831
963
|
return this.floatPane(focused.id);
|
|
832
964
|
}
|
|
833
965
|
|
|
@@ -3714,6 +3846,14 @@ function _swapSiblings(tree, aId, bId) {
|
|
|
3714
3846
|
|
|
3715
3847
|
/** A tab showing ONE record rather than a list: its props name an `id`. The same
|
|
3716
3848
|
* test `swapToPage` applies to "the caller asked for a specific entity". */
|
|
3849
|
+
/** The index nearest to `from` whose tab passes `test`: leftward first, then
|
|
3850
|
+
* rightward. -1 when none does. */
|
|
3851
|
+
function _nearestIndex(tabs, from, test) {
|
|
3852
|
+
for (let i = from - 1; i >= 0; i--) if (test(tabs[i])) return i;
|
|
3853
|
+
for (let i = from + 1; i < tabs.length; i++) if (test(tabs[i])) return i;
|
|
3854
|
+
return -1;
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3717
3857
|
function _isEntityTab(tab) {
|
|
3718
3858
|
return !!tab && tab.props != null && tab.props.id != null && tab.props.id !== '';
|
|
3719
3859
|
}
|
|
@@ -1467,7 +1467,11 @@ export class DataTable {
|
|
|
1467
1467
|
const isServerSide = typeof onPageChange === 'function';
|
|
1468
1468
|
const processedRows = isServerSide ? rows : this._getProcessedRows();
|
|
1469
1469
|
const offset = isServerSide ? (configOffset || 0) : this._state.offset;
|
|
1470
|
-
|
|
1470
|
+
// NO PAGINATION MEANS NO PAGES. This used to slice to `pageSize` either
|
|
1471
|
+
// way, so a table built with `pagination: false` silently showed its
|
|
1472
|
+
// first hundred rows and offered no control to reach the rest.
|
|
1473
|
+
const pageRows = isServerSide || !this.config.pagination
|
|
1474
|
+
? processedRows : processedRows.slice(offset, offset + pageSize);
|
|
1471
1475
|
|
|
1472
1476
|
const table = document.createElement('table');
|
|
1473
1477
|
table.className = readonly ? 'twm-preview-table twm-preview-table--readonly' : 'twm-preview-table';
|
|
File without changes
|