@xh/hoist 74.0.0-SNAPSHOT.1747924226267 → 74.0.0-SNAPSHOT.1748001673599
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/build/types/cmp/viewmanager/View.d.ts +5 -0
- package/build/types/cmp/viewmanager/ViewManagerModel.d.ts +6 -0
- package/build/types/data/RecordAction.d.ts +1 -1
- package/cmp/viewmanager/View.ts +7 -0
- package/cmp/viewmanager/ViewManagerModel.ts +21 -5
- package/data/RecordAction.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -17,6 +17,11 @@ export declare class View<T extends PlainObject = PlainObject> {
|
|
|
17
17
|
* state of the components is captured.
|
|
18
18
|
*/
|
|
19
19
|
readonly value: Partial<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Defaulted to value, but may be updated during ViewManagerModel's settleTime to be
|
|
22
|
+
* the "settled" state after loading. Used for comparison to determine dirtiness.
|
|
23
|
+
*/
|
|
24
|
+
settledValue: Partial<T>;
|
|
20
25
|
private readonly model;
|
|
21
26
|
get name(): string;
|
|
22
27
|
get group(): string;
|
|
@@ -43,6 +43,11 @@ export interface ViewManagerConfig {
|
|
|
43
43
|
* True (default) to allow users to share their views with other users.
|
|
44
44
|
*/
|
|
45
45
|
enableSharing?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* True (default) to save pending state to SessionStorage so that it can be restored across
|
|
48
|
+
* browser refreshes. Unlike auto-save, this does not write to the database.
|
|
49
|
+
*/
|
|
50
|
+
preserveUnsavedChanges?: boolean;
|
|
46
51
|
/**
|
|
47
52
|
* Function to determine the initial view for a user, when no view has already been persisted.
|
|
48
53
|
* Will be passed a list of views available to the current user. Implementations where
|
|
@@ -132,6 +137,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
132
137
|
readonly enableDefault: boolean;
|
|
133
138
|
readonly enableGlobal: boolean;
|
|
134
139
|
readonly enableSharing: boolean;
|
|
140
|
+
readonly preserveUnsavedChanges: boolean;
|
|
135
141
|
readonly manageGlobal: boolean;
|
|
136
142
|
readonly settleTime: number;
|
|
137
143
|
readonly initialViewSpec: (views: ViewInfo[]) => ViewInfo;
|
|
@@ -55,7 +55,7 @@ export interface ActionFnData {
|
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* A RecordAction encapsulates a shared set of configuration for items within components such as
|
|
58
|
-
* a Grid Context Menu
|
|
58
|
+
* a Grid Context Menu and RecordActionBar (aka grid context menus and action columns).
|
|
59
59
|
*
|
|
60
60
|
* Components passed these actions will render them with an appropriate UI (e.g. menu item, button)
|
|
61
61
|
* and call their `actionFn` when clicked, passing it a data object (if available) sourced from the
|
package/cmp/viewmanager/View.ts
CHANGED
|
@@ -27,6 +27,12 @@ export class View<T extends PlainObject = PlainObject> {
|
|
|
27
27
|
*/
|
|
28
28
|
readonly value: Partial<T> = null;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Defaulted to value, but may be updated during ViewManagerModel's settleTime to be
|
|
32
|
+
* the "settled" state after loading. Used for comparison to determine dirtiness.
|
|
33
|
+
*/
|
|
34
|
+
settledValue: Partial<T> = null;
|
|
35
|
+
|
|
30
36
|
private readonly model: ViewManagerModel;
|
|
31
37
|
|
|
32
38
|
get name(): string {
|
|
@@ -92,6 +98,7 @@ export class View<T extends PlainObject = PlainObject> {
|
|
|
92
98
|
constructor(info: ViewInfo, value: Partial<T>, model: ViewManagerModel) {
|
|
93
99
|
this.info = info;
|
|
94
100
|
this.value = value;
|
|
101
|
+
this.settledValue = value;
|
|
95
102
|
this.model = model;
|
|
96
103
|
}
|
|
97
104
|
}
|
|
@@ -74,6 +74,12 @@ export interface ViewManagerConfig {
|
|
|
74
74
|
*/
|
|
75
75
|
enableSharing?: boolean;
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* True (default) to save pending state to SessionStorage so that it can be restored across
|
|
79
|
+
* browser refreshes. Unlike auto-save, this does not write to the database.
|
|
80
|
+
*/
|
|
81
|
+
preserveUnsavedChanges?: boolean;
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
84
|
* Function to determine the initial view for a user, when no view has already been persisted.
|
|
79
85
|
* Will be passed a list of views available to the current user. Implementations where
|
|
@@ -176,6 +182,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
176
182
|
readonly enableDefault: boolean;
|
|
177
183
|
readonly enableGlobal: boolean;
|
|
178
184
|
readonly enableSharing: boolean;
|
|
185
|
+
readonly preserveUnsavedChanges: boolean;
|
|
179
186
|
readonly manageGlobal: boolean;
|
|
180
187
|
readonly settleTime: number;
|
|
181
188
|
readonly initialViewSpec: (views: ViewInfo[]) => ViewInfo;
|
|
@@ -296,6 +303,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
296
303
|
enableDefault = true,
|
|
297
304
|
enableGlobal = true,
|
|
298
305
|
enableSharing = true,
|
|
306
|
+
preserveUnsavedChanges = true,
|
|
299
307
|
settleTime = 1000,
|
|
300
308
|
initialViewSpec = null
|
|
301
309
|
}: ViewManagerConfig) {
|
|
@@ -317,6 +325,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
317
325
|
this.enableGlobal = enableGlobal;
|
|
318
326
|
this.enableSharing = enableSharing;
|
|
319
327
|
this.enableAutoSave = enableAutoSave;
|
|
328
|
+
this.preserveUnsavedChanges = preserveUnsavedChanges;
|
|
320
329
|
this.settleTime = settleTime;
|
|
321
330
|
this.initialViewSpec = initialViewSpec;
|
|
322
331
|
|
|
@@ -421,13 +430,15 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
421
430
|
|
|
422
431
|
@action
|
|
423
432
|
setValue(value: Partial<T>) {
|
|
433
|
+
value = this.cleanState(value);
|
|
434
|
+
|
|
424
435
|
const {view, pendingValue, lastPushed, settleTime} = this;
|
|
425
436
|
if (!pendingValue && settleTime && !olderThan(lastPushed, settleTime)) {
|
|
426
|
-
|
|
437
|
+
this.view.settledValue = value;
|
|
427
438
|
}
|
|
428
439
|
|
|
429
|
-
|
|
430
|
-
if (!isEqual(value, view.
|
|
440
|
+
// Todo: Consider how this interacts with the localStorage pending state
|
|
441
|
+
if (!isEqual(value, view.settledValue)) {
|
|
431
442
|
this.pendingValue = {
|
|
432
443
|
token: pendingValue ? pendingValue.token : view.token,
|
|
433
444
|
baseUpdated: pendingValue ? pendingValue.baseUpdated : view.lastUpdated,
|
|
@@ -515,7 +526,9 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
515
526
|
this.views = views;
|
|
516
527
|
this.userPinned = state.userPinned;
|
|
517
528
|
this.autoSave = state.autoSave;
|
|
518
|
-
this.
|
|
529
|
+
if (this.preserveUnsavedChanges) {
|
|
530
|
+
this.pendingValue = XH.sessionStorageService.get(pendingValueStorageKey);
|
|
531
|
+
}
|
|
519
532
|
});
|
|
520
533
|
|
|
521
534
|
// 2) Initialize/choose initial view. Null is ok, and will yield default.
|
|
@@ -546,7 +559,10 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
546
559
|
private pendingValueReaction(): ReactionSpec {
|
|
547
560
|
return {
|
|
548
561
|
track: () => this.pendingValue,
|
|
549
|
-
run: v =>
|
|
562
|
+
run: v => {
|
|
563
|
+
if (!this.preserveUnsavedChanges) return;
|
|
564
|
+
XH.sessionStorageService.set(this.pendingValueStorageKey, v);
|
|
565
|
+
}
|
|
550
566
|
};
|
|
551
567
|
}
|
|
552
568
|
|
package/data/RecordAction.ts
CHANGED
|
@@ -83,7 +83,7 @@ export interface ActionFnData {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* A RecordAction encapsulates a shared set of configuration for items within components such as
|
|
86
|
-
* a Grid Context Menu
|
|
86
|
+
* a Grid Context Menu and RecordActionBar (aka grid context menus and action columns).
|
|
87
87
|
*
|
|
88
88
|
* Components passed these actions will render them with an appropriate UI (e.g. menu item, button)
|
|
89
89
|
* and call their `actionFn` when clicked, passing it a data object (if available) sourced from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "74.0.0-SNAPSHOT.
|
|
3
|
+
"version": "74.0.0-SNAPSHOT.1748001673599",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|