@topconsultnpm/sdkui-react 6.22.0-dev3.9 → 6.22.0-dev4.11
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/lib/components/base/TMAlert.js +6 -8
- package/lib/components/base/TMAreaManager.js +53 -55
- package/lib/components/base/TMButton.js +4 -2
- package/lib/components/base/TMCounterContainer.d.ts +3 -1
- package/lib/components/base/TMCounterContainer.js +16 -1
- package/lib/components/base/TMCustomButton.js +40 -48
- package/lib/components/base/TMDataGrid.js +24 -4
- package/lib/components/base/TMPanel.js +173 -170
- package/lib/components/base/TMSpinner.d.ts +2 -1
- package/lib/components/base/TMSpinner.js +9 -7
- package/lib/components/base/TMTabControl.d.ts +5 -0
- package/lib/components/base/TMTabControl.js +18 -7
- package/lib/components/base/TMTreeView.js +20 -0
- package/lib/components/base/TMWaitPanel.js +1 -1
- package/lib/components/base/waitPanel/TMWaitPanelConfirm.d.ts +12 -0
- package/lib/components/base/waitPanel/TMWaitPanelConfirm.js +185 -0
- package/lib/components/base/waitPanel/TMWaitPanelManager.d.ts +179 -0
- package/lib/components/base/waitPanel/TMWaitPanelManager.js +373 -0
- package/lib/components/base/waitPanel/TMWaitPanelView.d.ts +58 -0
- package/lib/components/base/waitPanel/TMWaitPanelView.js +346 -0
- package/lib/components/base/waitPanel/index.d.ts +1 -0
- package/lib/components/base/waitPanel/index.js +1 -0
- package/lib/components/choosers/TMDistinctValues.js +3 -3
- package/lib/components/choosers/TMPathChooser.js +17 -34
- package/lib/components/editors/TMTextBox.d.ts +4 -0
- package/lib/components/editors/TMTextBox.js +99 -11
- package/lib/components/features/archive/TMArchive.js +7 -2
- package/lib/components/features/assistant/TMHelpOnLineChat.d.ts +28 -0
- package/lib/components/features/assistant/TMHelpOnLineChat.js +1231 -0
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +2 -2
- package/lib/components/features/documents/TMBatchUpdateForm.js +3 -4
- package/lib/components/features/documents/TMCopyToFolderForm.js +53 -84
- package/lib/components/features/documents/TMDcmtForm.js +50 -61
- package/lib/components/features/documents/TMDcmtIcon.d.ts +1 -3
- package/lib/components/features/documents/TMDcmtIcon.js +3 -5
- package/lib/components/features/documents/TMDcmtPreview.js +5 -3
- package/lib/components/features/documents/TMDcmtTasks.js +2 -9
- package/lib/components/features/documents/TMFileUploader.js +26 -26
- package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +2 -0
- package/lib/components/features/documents/TMMasterDetailDcmts.js +53 -148
- package/lib/components/features/documents/TMMasterInfoFields.js +3 -2
- package/lib/components/features/documents/TMMergeToPdfForm.js +52 -56
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.js +14 -15
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +1 -1
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.js +3 -3
- package/lib/components/features/documents/TMRelationViewer.d.ts +13 -14
- package/lib/components/features/documents/TMRelationViewer.js +206 -143
- package/lib/components/features/documents/relationTreeState.d.ts +32 -0
- package/lib/components/features/documents/relationTreeState.js +89 -0
- package/lib/components/features/search/TMSearch.js +3 -4
- package/lib/components/features/search/TMSearchQueryPanel.js +0 -4
- package/lib/components/features/search/TMSearchResult.d.ts +5 -0
- package/lib/components/features/search/TMSearchResult.js +51 -24
- package/lib/components/features/search/TMTreeSelector.js +23 -27
- package/lib/components/features/search/TMViewHistoryDcmt.js +15 -26
- package/lib/components/features/tasks/TMTasksView.js +97 -90
- package/lib/components/features/wg/TMWGsCopyMoveForm.js +104 -100
- package/lib/components/forms/TMResultDialog.js +1 -1
- package/lib/components/grids/TMBlogsPost.js +93 -97
- package/lib/components/index.d.ts +5 -1
- package/lib/components/index.js +4 -1
- package/lib/components/layout/panelManager/TMPanelManagerContainer.js +16 -15
- package/lib/components/layout/panelManager/TMPanelManagerContext.d.ts +1 -0
- package/lib/components/layout/panelManager/TMPanelManagerContext.js +5 -1
- package/lib/components/layout/panelManager/TMPanelManagerLoader.d.ts +6 -0
- package/lib/components/layout/panelManager/TMPanelManagerLoader.js +18 -0
- package/lib/components/layout/panelManager/TMPanelManagerToolbar.js +4 -8
- package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.d.ts +1 -1
- package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.js +2 -1
- package/lib/components/pages/TMPage.js +32 -31
- package/lib/components/query/TMQueryEditor.d.ts +3 -0
- package/lib/components/query/TMQueryEditor.js +2 -1
- package/lib/components/sidebar/TMHeader.d.ts +1 -0
- package/lib/components/sidebar/TMHeader.js +2 -2
- package/lib/helper/Enum_Localizator.js +1 -0
- package/lib/helper/SDKUI_Globals.d.ts +7 -2
- package/lib/helper/SDKUI_Globals.js +7 -2
- package/lib/helper/SDKUI_Localizator.d.ts +31 -6
- package/lib/helper/SDKUI_Localizator.js +301 -51
- package/lib/helper/ZipManager.d.ts +1 -1
- package/lib/helper/ZipManager.js +2 -1
- package/lib/helper/checkinCheckoutManager.js +2 -3
- package/lib/helper/dcmtsHelper.d.ts +2 -0
- package/lib/helper/dcmtsHelper.js +3 -1
- package/lib/hooks/useCheckInOutOperations.d.ts +0 -6
- package/lib/hooks/useCheckInOutOperations.js +16 -37
- package/lib/hooks/useDcmtOperations.d.ts +3 -19
- package/lib/hooks/useDcmtOperations.js +175 -229
- package/lib/hooks/useDocumentOperations.d.ts +1 -0
- package/lib/hooks/useDocumentOperations.js +16 -29
- package/lib/hooks/useMultiMasterDetailDcmts.d.ts +0 -15
- package/lib/hooks/useMultiMasterDetailDcmts.js +70 -68
- package/lib/hooks/usePreventFileDrop.js +9 -0
- package/lib/hooks/useWorkflowApprove.js +33 -17
- package/lib/services/caseflow/CaseFlowService.d.ts +69 -9
- package/lib/services/caseflow/CaseFlowService.js +126 -58
- package/package.json +2 -2
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { SDKUI_Localizator } from '../../../helper';
|
|
4
|
+
import TMWaitPanelView from './TMWaitPanelView';
|
|
5
|
+
const Z_INDEX_BASE = 2147483601;
|
|
6
|
+
const RESOLVED = Promise.resolve();
|
|
7
|
+
/** Accumula un messaggio in testa, tenendo solo quelli visibili nel popover. */
|
|
8
|
+
const pushMessage = (list, message, max) => {
|
|
9
|
+
list.unshift(message);
|
|
10
|
+
if (list.length > max)
|
|
11
|
+
list.length = max;
|
|
12
|
+
};
|
|
13
|
+
const pad2 = (n) => (n < 10 ? '0' + n : String(n));
|
|
14
|
+
/** Formatta una durata in millisecondi come "42s", "3m 07s", "1h 12m". */
|
|
15
|
+
const formatDuration = (ms) => {
|
|
16
|
+
const totalSeconds = Math.max(0, Math.round(ms / 1000));
|
|
17
|
+
if (totalSeconds < 60)
|
|
18
|
+
return `${totalSeconds}s`;
|
|
19
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
20
|
+
if (totalMinutes < 60)
|
|
21
|
+
return `${totalMinutes}m ${pad2(totalSeconds % 60)}s`;
|
|
22
|
+
return `${Math.floor(totalMinutes / 60)}h ${pad2(totalMinutes % 60)}m`;
|
|
23
|
+
};
|
|
24
|
+
class TMWaitPanelInstance {
|
|
25
|
+
constructor(options, zIndex) {
|
|
26
|
+
this.abortController = new AbortController();
|
|
27
|
+
this.nodes = null;
|
|
28
|
+
this.closed = false;
|
|
29
|
+
this.elapsedLabel = SDKUI_Localizator.Elapsed;
|
|
30
|
+
this.remainingLabel = SDKUI_Localizator.Remaining;
|
|
31
|
+
// Pausa in attesa della conferma di interruzione.
|
|
32
|
+
this._paused = false;
|
|
33
|
+
this.pauseGate = null;
|
|
34
|
+
this.resolvePauseGate = null;
|
|
35
|
+
this.pausedTotalMs = 0;
|
|
36
|
+
this.pauseStartedAt = 0;
|
|
37
|
+
this.startTime = performance.now();
|
|
38
|
+
this.rafId = 0;
|
|
39
|
+
this._value = 0;
|
|
40
|
+
this._max = 0;
|
|
41
|
+
this._ok = 0;
|
|
42
|
+
this._warning = 0;
|
|
43
|
+
this._error = 0;
|
|
44
|
+
this._secondaryValue = 0;
|
|
45
|
+
this._secondaryMax = 0;
|
|
46
|
+
this._warningMessages = [];
|
|
47
|
+
this._errorMessages = [];
|
|
48
|
+
this.warningMessageTotal = 0;
|
|
49
|
+
this.errorMessageTotal = 0;
|
|
50
|
+
this.messagesDirty = false;
|
|
51
|
+
// Ultimi valori scritti sul DOM: servono a non riscrivere testo identico.
|
|
52
|
+
this.lastPercentText = '';
|
|
53
|
+
this.lastSubtitleText = '';
|
|
54
|
+
this.lastElapsedText = '';
|
|
55
|
+
this.lastRemainingText = '';
|
|
56
|
+
this.lastOk = 0;
|
|
57
|
+
this.lastWarning = 0;
|
|
58
|
+
this.lastError = 0;
|
|
59
|
+
this.lastTitleText = '';
|
|
60
|
+
this.lastSecondaryPercentText = '';
|
|
61
|
+
this.lastSecondaryText = '';
|
|
62
|
+
this.waitWhilePaused = () => this.pauseGate ?? RESOLVED;
|
|
63
|
+
this.step = (delta = 1) => { this._value += delta; this.schedule(); return this.pauseGate ?? RESOLVED; };
|
|
64
|
+
this.setValue = (value) => { this._value = value; this.schedule(); };
|
|
65
|
+
this.setMax = (max) => { this._max = max; this.schedule(); };
|
|
66
|
+
this.setTitle = (title) => { this._title = title; this.schedule(); };
|
|
67
|
+
this.setSubtitle = (subtitle) => { this._subtitleOverride = subtitle; this.schedule(); };
|
|
68
|
+
this.ok = (delta = 1) => { this._ok += delta; this.schedule(); };
|
|
69
|
+
this.warning = (delta = 1, message) => {
|
|
70
|
+
this._warning += delta;
|
|
71
|
+
if (message) {
|
|
72
|
+
pushMessage(this._warningMessages, message, this.maxVisibleMessages);
|
|
73
|
+
this.warningMessageTotal++;
|
|
74
|
+
this.messagesDirty = true;
|
|
75
|
+
}
|
|
76
|
+
this.schedule();
|
|
77
|
+
};
|
|
78
|
+
this.error = (delta = 1, message) => {
|
|
79
|
+
this._error += delta;
|
|
80
|
+
if (message) {
|
|
81
|
+
pushMessage(this._errorMessages, message, this.maxVisibleMessages);
|
|
82
|
+
this.errorMessageTotal++;
|
|
83
|
+
this.messagesDirty = true;
|
|
84
|
+
}
|
|
85
|
+
this.schedule();
|
|
86
|
+
};
|
|
87
|
+
this.setSecondary = (patch) => {
|
|
88
|
+
if (patch.value !== undefined)
|
|
89
|
+
this._secondaryValue = patch.value;
|
|
90
|
+
if (patch.max !== undefined)
|
|
91
|
+
this._secondaryMax = patch.max;
|
|
92
|
+
if (patch.text !== undefined)
|
|
93
|
+
this._secondaryText = patch.text;
|
|
94
|
+
this.schedule();
|
|
95
|
+
};
|
|
96
|
+
this.update = (patch) => {
|
|
97
|
+
if (patch.title !== undefined)
|
|
98
|
+
this._title = patch.title;
|
|
99
|
+
if (patch.subtitle !== undefined)
|
|
100
|
+
this._subtitleOverride = patch.subtitle;
|
|
101
|
+
if (patch.value !== undefined)
|
|
102
|
+
this._value = patch.value;
|
|
103
|
+
if (patch.max !== undefined)
|
|
104
|
+
this._max = patch.max;
|
|
105
|
+
if (patch.ok !== undefined)
|
|
106
|
+
this._ok = patch.ok;
|
|
107
|
+
if (patch.warning !== undefined)
|
|
108
|
+
this._warning = patch.warning;
|
|
109
|
+
if (patch.error !== undefined)
|
|
110
|
+
this._error = patch.error;
|
|
111
|
+
this.schedule();
|
|
112
|
+
};
|
|
113
|
+
this.close = () => {
|
|
114
|
+
if (this.closed)
|
|
115
|
+
return;
|
|
116
|
+
this.closed = true;
|
|
117
|
+
// Sblocca un loop eventualmente fermo in attesa della conferma.
|
|
118
|
+
this.resume();
|
|
119
|
+
if (this.rafId) {
|
|
120
|
+
cancelAnimationFrame(this.rafId);
|
|
121
|
+
this.rafId = 0;
|
|
122
|
+
}
|
|
123
|
+
if (this.tickerId !== undefined) {
|
|
124
|
+
clearInterval(this.tickerId);
|
|
125
|
+
this.tickerId = undefined;
|
|
126
|
+
}
|
|
127
|
+
document.removeEventListener('keydown', this.handleKeyDown, true);
|
|
128
|
+
// Smonto fuori dal render corrente: close() puo' arrivare durante un render.
|
|
129
|
+
this.container.style.display = 'none';
|
|
130
|
+
const root = this.root;
|
|
131
|
+
const container = this.container;
|
|
132
|
+
setTimeout(() => { root.unmount(); container.remove(); }, 0);
|
|
133
|
+
TMWaitPanelManager._unregister(this);
|
|
134
|
+
};
|
|
135
|
+
// #endregion
|
|
136
|
+
this.handleMount = (nodes) => {
|
|
137
|
+
if (this.closed)
|
|
138
|
+
return;
|
|
139
|
+
this.nodes = nodes;
|
|
140
|
+
// Il chiamante puo' aver gia' avanzato prima del montaggio.
|
|
141
|
+
this.flush();
|
|
142
|
+
};
|
|
143
|
+
this.handleKeyDown = (e) => {
|
|
144
|
+
if (this.closed)
|
|
145
|
+
return;
|
|
146
|
+
// Con la conferma aperta la tastiera risponde a lei: Esc = No, Invio = Si.
|
|
147
|
+
if (this._paused) {
|
|
148
|
+
if (e.key === 'Escape') {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
this.resume();
|
|
152
|
+
}
|
|
153
|
+
else if (e.key === 'Enter') {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
this.confirmAbort();
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (e.key !== 'Escape')
|
|
161
|
+
return;
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
this.handleAbort();
|
|
165
|
+
};
|
|
166
|
+
/** Interrompi non annulla subito: mette in pausa il loop e chiede conferma. */
|
|
167
|
+
this.handleAbort = () => {
|
|
168
|
+
if (this.closed || this.aborted || this._paused)
|
|
169
|
+
return;
|
|
170
|
+
this.pause();
|
|
171
|
+
};
|
|
172
|
+
/** Risposta Si: interrompe davvero e lascia ripartire il loop, che uscira' subito. */
|
|
173
|
+
this.confirmAbort = () => {
|
|
174
|
+
if (this.closed || this.aborted)
|
|
175
|
+
return;
|
|
176
|
+
this.abortController.abort();
|
|
177
|
+
const abortButton = this.nodes?.abortButton;
|
|
178
|
+
if (abortButton) {
|
|
179
|
+
abortButton.disabled = true;
|
|
180
|
+
abortButton.textContent = SDKUI_Localizator.Aborting;
|
|
181
|
+
}
|
|
182
|
+
this.options.onAbort?.();
|
|
183
|
+
this.resume();
|
|
184
|
+
};
|
|
185
|
+
/** Risposta No, oppure chiusura del pannello: sblocca il loop e riprende. */
|
|
186
|
+
this.resume = () => {
|
|
187
|
+
if (!this._paused)
|
|
188
|
+
return;
|
|
189
|
+
this._paused = false;
|
|
190
|
+
this.pausedTotalMs += performance.now() - this.pauseStartedAt;
|
|
191
|
+
if (this.nodes)
|
|
192
|
+
this.nodes.confirm.style.display = 'none';
|
|
193
|
+
const resolve = this.resolvePauseGate;
|
|
194
|
+
this.pauseGate = null;
|
|
195
|
+
this.resolvePauseGate = null;
|
|
196
|
+
resolve?.();
|
|
197
|
+
this.schedule();
|
|
198
|
+
};
|
|
199
|
+
/** Programma al massimo un flush per frame. E' l'unico costo pagato da `step()`. */
|
|
200
|
+
this.schedule = () => {
|
|
201
|
+
if (this.closed || this.rafId || !this.nodes)
|
|
202
|
+
return;
|
|
203
|
+
this.rafId = requestAnimationFrame(this.flush);
|
|
204
|
+
};
|
|
205
|
+
/** Riversa sul DOM lo stato corrente (barra, percentuale, testi, contatori), saltando cio' che non e' cambiato. */
|
|
206
|
+
this.flush = () => {
|
|
207
|
+
this.rafId = 0;
|
|
208
|
+
const nodes = this.nodes;
|
|
209
|
+
if (this.closed || !nodes)
|
|
210
|
+
return;
|
|
211
|
+
const ratio = this._max > 0 ? Math.min(1, Math.max(0, this._value / this._max)) : 0;
|
|
212
|
+
// scaleX invece di width: resta sul compositor, niente layout.
|
|
213
|
+
nodes.fill.style.transform = `scaleX(${ratio})`;
|
|
214
|
+
const percentText = `${(ratio * 100).toFixed(2)}%`;
|
|
215
|
+
if (percentText !== this.lastPercentText) {
|
|
216
|
+
this.lastPercentText = percentText;
|
|
217
|
+
nodes.percent.textContent = percentText;
|
|
218
|
+
}
|
|
219
|
+
if (this._title !== this.lastTitleText) {
|
|
220
|
+
this.lastTitleText = this._title;
|
|
221
|
+
nodes.title.textContent = this._title;
|
|
222
|
+
}
|
|
223
|
+
const subtitleText = this.computeSubtitle();
|
|
224
|
+
if (subtitleText !== this.lastSubtitleText) {
|
|
225
|
+
this.lastSubtitleText = subtitleText;
|
|
226
|
+
nodes.subtitle.textContent = subtitleText;
|
|
227
|
+
}
|
|
228
|
+
if (this._ok !== this.lastOk) {
|
|
229
|
+
this.lastOk = this._ok;
|
|
230
|
+
nodes.okValue.textContent = String(this._ok);
|
|
231
|
+
}
|
|
232
|
+
if (this._warning !== this.lastWarning) {
|
|
233
|
+
this.lastWarning = this._warning;
|
|
234
|
+
nodes.warningValue.textContent = String(this._warning);
|
|
235
|
+
}
|
|
236
|
+
if (this._error !== this.lastError) {
|
|
237
|
+
this.lastError = this._error;
|
|
238
|
+
nodes.errorValue.textContent = String(this._error);
|
|
239
|
+
}
|
|
240
|
+
if (this.messagesDirty) {
|
|
241
|
+
this.messagesDirty = false;
|
|
242
|
+
this.flushMessages(nodes.warningPopover, nodes.warningList, this._warningMessages, this.warningMessageTotal);
|
|
243
|
+
this.flushMessages(nodes.errorPopover, nodes.errorList, this._errorMessages, this.errorMessageTotal);
|
|
244
|
+
}
|
|
245
|
+
if (nodes.secondaryFill)
|
|
246
|
+
this.flushSecondary(nodes);
|
|
247
|
+
if (this.options.showEta ?? true)
|
|
248
|
+
this.flushEta(nodes, ratio);
|
|
249
|
+
};
|
|
250
|
+
this.options = options;
|
|
251
|
+
this.maxVisibleMessages = Math.max(1, options.maxVisibleMessages ?? 5);
|
|
252
|
+
this._max = options.max ?? 0;
|
|
253
|
+
this._title = options.title ?? '';
|
|
254
|
+
this._secondaryText = options.secondaryText ?? '';
|
|
255
|
+
this.lastTitleText = this._title;
|
|
256
|
+
this.lastSecondaryText = this._secondaryText;
|
|
257
|
+
this.lastSubtitleText = this.computeSubtitle();
|
|
258
|
+
this.container = document.createElement('div');
|
|
259
|
+
document.body.appendChild(this.container);
|
|
260
|
+
this.root = ReactDOM.createRoot(this.container);
|
|
261
|
+
this.root.render(_jsx(TMWaitPanelView, { title: this._title, subtitle: this.lastSubtitleText, cancelable: options.cancelable ?? false, showEta: options.showEta ?? true, showCounters: options.showCounters ?? true, showSecondary: options.showSecondary ?? false, secondaryText: this._secondaryText, primaryLabel: options.primaryLabel ?? '', secondaryLabel: options.secondaryLabel ?? '', zIndex: zIndex, onAbort: this.handleAbort, onConfirmYes: this.confirmAbort, onConfirmNo: this.resume, onMount: this.handleMount }));
|
|
262
|
+
if (options.cancelable ?? false)
|
|
263
|
+
document.addEventListener('keydown', this.handleKeyDown, true);
|
|
264
|
+
if (options.showEta ?? true)
|
|
265
|
+
this.tickerId = setInterval(this.schedule, 500);
|
|
266
|
+
}
|
|
267
|
+
// #region API pubblica
|
|
268
|
+
get aborted() { return this.abortController.signal.aborted; }
|
|
269
|
+
get signal() { return this.abortController.signal; }
|
|
270
|
+
get value() { return this._value; }
|
|
271
|
+
get max() { return this._max; }
|
|
272
|
+
get counters() { return { ok: this._ok, warning: this._warning, error: this._error }; }
|
|
273
|
+
get isOpen() { return !this.closed; }
|
|
274
|
+
get paused() { return this._paused; }
|
|
275
|
+
pause() {
|
|
276
|
+
if (this._paused)
|
|
277
|
+
return;
|
|
278
|
+
this._paused = true;
|
|
279
|
+
this.pauseStartedAt = performance.now();
|
|
280
|
+
this.pauseGate = new Promise(resolve => { this.resolvePauseGate = resolve; });
|
|
281
|
+
if (this.nodes)
|
|
282
|
+
this.nodes.confirm.style.display = 'flex';
|
|
283
|
+
}
|
|
284
|
+
computeSubtitle() {
|
|
285
|
+
if (this._subtitleOverride !== undefined)
|
|
286
|
+
return this._subtitleOverride;
|
|
287
|
+
const template = this.options.subtitleTemplate;
|
|
288
|
+
if (template)
|
|
289
|
+
return template.replace('{{0}}', String(this._value)).replace('{{1}}', String(this._max));
|
|
290
|
+
return this.options.subtitle ?? '';
|
|
291
|
+
}
|
|
292
|
+
/** Riscrive la lista di un popover con gli ultimi messaggi e la riga "... e altri N". Il popover si apre solo se non e' vuoto. */
|
|
293
|
+
flushMessages(popover, list, messages, total) {
|
|
294
|
+
if (total === 0)
|
|
295
|
+
return;
|
|
296
|
+
const visible = messages.length;
|
|
297
|
+
const items = [];
|
|
298
|
+
for (let i = 0; i < visible; i++) {
|
|
299
|
+
const item = document.createElement('li');
|
|
300
|
+
item.textContent = messages[i];
|
|
301
|
+
items.push(item);
|
|
302
|
+
}
|
|
303
|
+
if (total > visible) {
|
|
304
|
+
const more = document.createElement('li');
|
|
305
|
+
more.className = 'tm-wait-panel-more';
|
|
306
|
+
more.textContent = SDKUI_Localizator.AndOthersCount.replace('{{0}}', String(total - visible));
|
|
307
|
+
items.push(more);
|
|
308
|
+
}
|
|
309
|
+
list.replaceChildren(...items);
|
|
310
|
+
popover.dataset.empty = 'false';
|
|
311
|
+
}
|
|
312
|
+
/** Riversa sul DOM la seconda barra. Invocata solo quando la view l'ha renderizzata. */
|
|
313
|
+
flushSecondary(nodes) {
|
|
314
|
+
const ratio = this._secondaryMax > 0 ? Math.min(1, Math.max(0, this._secondaryValue / this._secondaryMax)) : 0;
|
|
315
|
+
nodes.secondaryFill.style.transform = `scaleX(${ratio})`;
|
|
316
|
+
const percentText = `${(ratio * 100).toFixed(2)}%`;
|
|
317
|
+
if (percentText !== this.lastSecondaryPercentText) {
|
|
318
|
+
this.lastSecondaryPercentText = percentText;
|
|
319
|
+
nodes.secondaryPercent.textContent = percentText;
|
|
320
|
+
}
|
|
321
|
+
if (this._secondaryText !== this.lastSecondaryText) {
|
|
322
|
+
this.lastSecondaryText = this._secondaryText;
|
|
323
|
+
nodes.secondaryText.textContent = this._secondaryText;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/** Aggiorna la riga dei tempi: trascorso al netto delle pause e stima del rimanente. */
|
|
327
|
+
flushEta(nodes, ratio) {
|
|
328
|
+
const pausedMs = this.pausedTotalMs + (this._paused ? performance.now() - this.pauseStartedAt : 0);
|
|
329
|
+
const elapsedMs = performance.now() - this.startTime - pausedMs;
|
|
330
|
+
const elapsedText = `${formatDuration(elapsedMs)} ${this.elapsedLabel}`;
|
|
331
|
+
if (elapsedText !== this.lastElapsedText) {
|
|
332
|
+
this.lastElapsedText = elapsedText;
|
|
333
|
+
nodes.elapsed.textContent = elapsedText;
|
|
334
|
+
}
|
|
335
|
+
// Sotto 1s la stima balla troppo.
|
|
336
|
+
let remainingText = '';
|
|
337
|
+
if (ratio > 0 && ratio < 1 && elapsedMs > 1000) {
|
|
338
|
+
remainingText = `${formatDuration(elapsedMs / ratio - elapsedMs)} ${this.remainingLabel}`;
|
|
339
|
+
}
|
|
340
|
+
if (remainingText !== this.lastRemainingText) {
|
|
341
|
+
this.lastRemainingText = remainingText;
|
|
342
|
+
nodes.remaining.textContent = remainingText;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
export class TMWaitPanelManager {
|
|
347
|
+
/** Apre un wait panel e restituisce l'handle con cui pilotarlo. */
|
|
348
|
+
static show(options = {}) {
|
|
349
|
+
const panel = new TMWaitPanelInstance(options, Z_INDEX_BASE + this._panels.length);
|
|
350
|
+
this._panels.push(panel);
|
|
351
|
+
return panel;
|
|
352
|
+
}
|
|
353
|
+
/** Pannello aperto piu' recente, se presente. */
|
|
354
|
+
static get current() {
|
|
355
|
+
return this._panels[this._panels.length - 1];
|
|
356
|
+
}
|
|
357
|
+
/** True finche' almeno un wait panel e' aperto: flag "operazione massiva in corso" per i refresh periodici. */
|
|
358
|
+
static get isBusy() {
|
|
359
|
+
return this._panels.length > 0;
|
|
360
|
+
}
|
|
361
|
+
/** Chiude tutti i pannelli aperti (rete di sicurezza in caso di unmount della pagina). */
|
|
362
|
+
static closeAll() {
|
|
363
|
+
[...this._panels].forEach(panel => panel.close());
|
|
364
|
+
}
|
|
365
|
+
/** @internal */
|
|
366
|
+
static _unregister(panel) {
|
|
367
|
+
const index = this._panels.indexOf(panel);
|
|
368
|
+
if (index >= 0)
|
|
369
|
+
this._panels.splice(index, 1);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
TMWaitPanelManager._panels = [];
|
|
373
|
+
export default TMWaitPanelManager;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Guscio statico del wait panel: montato una sola volta e mai ri-renderizzato, il manager lo aggiorna via DOM. Le props sono valori iniziali. */
|
|
3
|
+
/** Nodi DOM mutabili di cui il manager ha bisogno per aggiornare il pannello senza React. */
|
|
4
|
+
export interface ITMWaitPanelNodes {
|
|
5
|
+
/** Layer di conferma dell'interruzione: il manager lo accende via style.display. */
|
|
6
|
+
confirm: HTMLElement;
|
|
7
|
+
title: HTMLElement;
|
|
8
|
+
subtitle: HTMLElement;
|
|
9
|
+
percent: HTMLElement;
|
|
10
|
+
fill: HTMLElement;
|
|
11
|
+
elapsed: HTMLElement;
|
|
12
|
+
remaining: HTMLElement;
|
|
13
|
+
okValue: HTMLElement;
|
|
14
|
+
warningValue: HTMLElement;
|
|
15
|
+
errorValue: HTMLElement;
|
|
16
|
+
/** Popover delle pill: il manager riempie la lista e toglie `data-empty` al primo messaggio. */
|
|
17
|
+
warningPopover: HTMLElement;
|
|
18
|
+
warningList: HTMLElement;
|
|
19
|
+
errorPopover: HTMLElement;
|
|
20
|
+
errorList: HTMLElement;
|
|
21
|
+
abortButton: HTMLButtonElement | null;
|
|
22
|
+
/** Presenti solo con `showSecondary`: riga di avanzamento dell'operazione di dettaglio. */
|
|
23
|
+
secondaryText: HTMLElement | null;
|
|
24
|
+
secondaryPercent: HTMLElement | null;
|
|
25
|
+
secondaryFill: HTMLElement | null;
|
|
26
|
+
}
|
|
27
|
+
export interface ITMWaitPanelViewProps {
|
|
28
|
+
/** Valore iniziale del titolo. */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Valore iniziale del sottotitolo. */
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
/** Mostra il bottone di interruzione. */
|
|
33
|
+
cancelable?: boolean;
|
|
34
|
+
/** Mostra la riga "trascorsi / rimanenti". */
|
|
35
|
+
showEta?: boolean;
|
|
36
|
+
/** Mostra le tre pill numeriche ok / warning / error, sempre visibili anche a 0. */
|
|
37
|
+
showCounters?: boolean;
|
|
38
|
+
/** Riserva la seconda barra, quella dell'operazione di dettaglio (es. i byte del file in corso). */
|
|
39
|
+
showSecondary?: boolean;
|
|
40
|
+
/** Valore iniziale del testo della barra secondaria. */
|
|
41
|
+
secondaryText?: string;
|
|
42
|
+
/** Didascalia fissa sopra la barra principale, es. "Documenti". Vuota: non viene resa. */
|
|
43
|
+
primaryLabel?: string;
|
|
44
|
+
/** Didascalia fissa sopra la barra secondaria, es. "File corrente". Vuota: non viene resa. */
|
|
45
|
+
secondaryLabel?: string;
|
|
46
|
+
/** z-index dell'overlay: il manager lo incrementa per i pannelli annidati. */
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
/** L'utente ha premuto Interrompi: il manager chiede conferma. */
|
|
49
|
+
onAbort?: () => void;
|
|
50
|
+
/** Conferma data: interrompere davvero. */
|
|
51
|
+
onConfirmYes?: () => void;
|
|
52
|
+
/** Conferma negata: riprendere. */
|
|
53
|
+
onConfirmNo?: () => void;
|
|
54
|
+
/** Invocato dopo il commit con i nodi DOM da aggiornare imperativamente. */
|
|
55
|
+
onMount?: (nodes: ITMWaitPanelNodes) => void;
|
|
56
|
+
}
|
|
57
|
+
declare const TMWaitPanelView: ({ title, subtitle, cancelable, showEta, showCounters, showSecondary, secondaryText, primaryLabel, secondaryLabel, zIndex, onAbort, onConfirmYes, onConfirmNo, onMount }: ITMWaitPanelViewProps) => React.JSX.Element;
|
|
58
|
+
export default TMWaitPanelView;
|