@apia/uploader-component 5.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/dist/index.d.ts +203 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1591 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1591 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Box, getVariant, Textarea, Input, Select } from '@apia/theme';
|
|
3
|
+
import { getLabel, parseAsSize, arrayOrArray, toBoolean } from '@apia/util';
|
|
4
|
+
import React, { createContext, useContext, forwardRef, useCallback, useMemo, useEffect, createElement } from 'react';
|
|
5
|
+
import { Permissions as Permissions$1, CollapsiblePanel, FileCard, Dropzone, SimpleButton, ApiaUtil, DateInput, AutocompleteController, Autocomplete, IconButton, RequiredMark, NumberInput, SwitchCard } from '@apia/components';
|
|
6
|
+
import { observer } from 'mobx-react-lite';
|
|
7
|
+
import { ApiaMonDocModal2 } from '@apia/api';
|
|
8
|
+
import { Tree } from '@apia/tree2-component';
|
|
9
|
+
import { FilePicker } from '@apia/uploader-controller';
|
|
10
|
+
import { makeObservable, action, observable } from 'mobx';
|
|
11
|
+
import { FileIcon, Icon } from '@apia/icons';
|
|
12
|
+
|
|
13
|
+
function makeDocTypeTooltip(api, docTypes) {
|
|
14
|
+
const docTypesInfo = docTypes || getTooltipsToShow(api);
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
Box,
|
|
17
|
+
{
|
|
18
|
+
className: "docTypes__tooltipWrapper",
|
|
19
|
+
...getVariant("layout.common.components.uploader.tooltip"),
|
|
20
|
+
children: docTypesInfo.map((currentDocType) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(Box, { className: "head", as: "strong", children: currentDocType.label }),
|
|
22
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
23
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
24
|
+
window.LBL_ALLOWED_EXTENSIONS,
|
|
25
|
+
" "
|
|
26
|
+
] }),
|
|
27
|
+
/* @__PURE__ */ jsxs(Box, { as: "span", children: [
|
|
28
|
+
currentDocType.extensions.length > 0 ? currentDocType.extensions.join(", ") : getLabel("lblAllDcTypeAcc").text,
|
|
29
|
+
"."
|
|
30
|
+
] })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
33
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
34
|
+
window.LBL_MAX_SIZE,
|
|
35
|
+
" "
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsx(Box, { as: "span", children: parseAsSize(currentDocType.maxSize) })
|
|
38
|
+
] })
|
|
39
|
+
] }, currentDocType.id))
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function buildExtensionsArray(ext) {
|
|
44
|
+
return (ext ?? "").split(";").filter((current) => current !== "").map((current) => `.${current}`);
|
|
45
|
+
}
|
|
46
|
+
function addDocTypeInfoToArray(arr, docType) {
|
|
47
|
+
arr.push({
|
|
48
|
+
extensions: buildExtensionsArray(docType.docExts),
|
|
49
|
+
id: docType.id,
|
|
50
|
+
label: docType.title,
|
|
51
|
+
maxSize: docType.maxSize
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getTooltipsToShow(api) {
|
|
55
|
+
try {
|
|
56
|
+
const hasOneClickUpload = api.props.modalConfig.oneClickUpload;
|
|
57
|
+
const docTypes = api.state.allowedTypes;
|
|
58
|
+
const docTypesInfo = [];
|
|
59
|
+
const generic = docTypes.find((c) => String(c.id) === "1");
|
|
60
|
+
if (generic) {
|
|
61
|
+
addDocTypeInfoToArray(docTypesInfo, generic);
|
|
62
|
+
} else if (hasOneClickUpload) {
|
|
63
|
+
const docType = docTypes[0];
|
|
64
|
+
addDocTypeInfoToArray(docTypesInfo, docType);
|
|
65
|
+
} else {
|
|
66
|
+
docTypes.forEach((docType) => {
|
|
67
|
+
addDocTypeInfoToArray(docTypesInfo, docType);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return docTypesInfo;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const FileUploadContext = createContext(
|
|
77
|
+
void 0
|
|
78
|
+
);
|
|
79
|
+
const FileUploadProvider = ({
|
|
80
|
+
store,
|
|
81
|
+
children
|
|
82
|
+
}) => {
|
|
83
|
+
return /* @__PURE__ */ jsx(FileUploadContext.Provider, { value: store, children });
|
|
84
|
+
};
|
|
85
|
+
const useFileUploadContext = () => {
|
|
86
|
+
const context = useContext(FileUploadContext);
|
|
87
|
+
if (context === void 0) {
|
|
88
|
+
throw new Error("There is no FileUploadContext");
|
|
89
|
+
}
|
|
90
|
+
return context;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const Permissions = observer(() => {
|
|
94
|
+
const controller = useFileUploadContext();
|
|
95
|
+
const modalConfig = controller.modalConfig;
|
|
96
|
+
const state = controller.state;
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
Permissions$1,
|
|
99
|
+
{
|
|
100
|
+
everyonePermissionsValue: state.permissions.allowAllType,
|
|
101
|
+
onChangeEveryonePermissions: (ev) => {
|
|
102
|
+
state.permissions.allowAllType = ev;
|
|
103
|
+
},
|
|
104
|
+
onChangePools: (pools) => {
|
|
105
|
+
controller.state.permissions.pools = pools;
|
|
106
|
+
},
|
|
107
|
+
onChangeUsers: (users) => {
|
|
108
|
+
controller.state.permissions.users = users;
|
|
109
|
+
},
|
|
110
|
+
permissions: controller.state.permissions,
|
|
111
|
+
collapsePermissions: modalConfig.collapsePermissions,
|
|
112
|
+
disabled: state.isReadonly
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const FilesList = observer(
|
|
118
|
+
forwardRef(({ iconsSize, ...props }, ref) => {
|
|
119
|
+
const controller = useFileUploadContext();
|
|
120
|
+
const files = controller.inProgressFiles;
|
|
121
|
+
const fromDirectoryFile = controller.state.fromDirectoryFile;
|
|
122
|
+
const handleClose = useCallback(
|
|
123
|
+
(name) => {
|
|
124
|
+
controller.clearFile(name);
|
|
125
|
+
},
|
|
126
|
+
[controller]
|
|
127
|
+
);
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
CollapsiblePanel,
|
|
130
|
+
{
|
|
131
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("lblPrevDocsToAdd").text }),
|
|
132
|
+
id: "selectedFiles",
|
|
133
|
+
collapseIconToRight: true,
|
|
134
|
+
closedIcon: "ArrowUpThin",
|
|
135
|
+
openIcon: "ArrowDownThin",
|
|
136
|
+
rememberCollapsedState: false,
|
|
137
|
+
children: /* @__PURE__ */ jsxs(
|
|
138
|
+
Box,
|
|
139
|
+
{
|
|
140
|
+
...props,
|
|
141
|
+
as: "ul",
|
|
142
|
+
className: "filesList",
|
|
143
|
+
...getVariant("layout.common.filesList"),
|
|
144
|
+
ref,
|
|
145
|
+
children: [
|
|
146
|
+
!fromDirectoryFile ? files.map((c) => {
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
FileCard,
|
|
149
|
+
{
|
|
150
|
+
name: c.name,
|
|
151
|
+
iconsSize,
|
|
152
|
+
handleClose,
|
|
153
|
+
className: "fileList__modal"
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}) : /* @__PURE__ */ jsx(
|
|
157
|
+
FileCard,
|
|
158
|
+
{
|
|
159
|
+
name: fromDirectoryFile.docName,
|
|
160
|
+
className: "fileList__modal",
|
|
161
|
+
handleClose: () => {
|
|
162
|
+
controller.clearPartialState();
|
|
163
|
+
controller.clearDirectoryFile();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
files.length === 0 && !fromDirectoryFile && getLabel("lblNoUpType").text
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
})
|
|
174
|
+
);
|
|
175
|
+
var FilesList$1 = React.memo(FilesList);
|
|
176
|
+
|
|
177
|
+
const AddFileSection = observer(() => {
|
|
178
|
+
const controller = useFileUploadContext();
|
|
179
|
+
const modalConfig = controller.modalConfig;
|
|
180
|
+
const handleOnChange = (e) => {
|
|
181
|
+
const newFiles = Array.from(e);
|
|
182
|
+
controller.addFiles(newFiles);
|
|
183
|
+
};
|
|
184
|
+
const filePicker = new FilePicker(controller.api);
|
|
185
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Box, { className: "uploader__dropzone_description_section", children: /* @__PURE__ */ jsxs(Box, { className: "uploader__dropzone", children: [
|
|
187
|
+
controller.conf?.versionFile && /* @__PURE__ */ jsx("strong", { children: getLabel("lblNameMustBe", {
|
|
188
|
+
text: { TOK1: controller.conf?.versionFile.docName ?? "" }
|
|
189
|
+
}).text }),
|
|
190
|
+
/* @__PURE__ */ jsx(
|
|
191
|
+
Dropzone,
|
|
192
|
+
{
|
|
193
|
+
progress: controller.progress,
|
|
194
|
+
className: "dropzoneModal",
|
|
195
|
+
messageError: controller.state.fileReqError ? getLabel("msgReqField").text : void 0,
|
|
196
|
+
onChange: handleOnChange
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
(modalConfig.allowDocumentsMonitor || modalConfig.allowPickFromDirectories) && !controller.conf?.versionFile && /* @__PURE__ */ jsxs(Box, { className: "uploader__dropzone_actions", children: [
|
|
200
|
+
modalConfig.allowPickFromDirectories && /* @__PURE__ */ jsx(
|
|
201
|
+
SimpleButton,
|
|
202
|
+
{
|
|
203
|
+
variant: "outline",
|
|
204
|
+
onClick: () => {
|
|
205
|
+
let modal = null;
|
|
206
|
+
const handleSelection = () => {
|
|
207
|
+
const firstElement = filePicker.selectedItems.values().next().value;
|
|
208
|
+
if (firstElement?.id)
|
|
209
|
+
controller.api.pickFileById(
|
|
210
|
+
firstElement.state.nodeProps.id
|
|
211
|
+
);
|
|
212
|
+
modal?.close();
|
|
213
|
+
};
|
|
214
|
+
modal = ApiaUtil.instance.modals.open({
|
|
215
|
+
title: getLabel("btnSelDcFrmTree").text,
|
|
216
|
+
children: /* @__PURE__ */ jsx(
|
|
217
|
+
Tree,
|
|
218
|
+
{
|
|
219
|
+
id: controller.api.id,
|
|
220
|
+
isMultiple: false,
|
|
221
|
+
onNodeDoubleClick: handleSelection,
|
|
222
|
+
store: filePicker
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
onConfirm: handleSelection,
|
|
226
|
+
onCancel: () => modal?.close()
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
children: getLabel("btnSelDcFrmTree").text
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
modalConfig.allowDocumentsMonitor && modalConfig.monitorId && /* @__PURE__ */ jsx(
|
|
233
|
+
SimpleButton,
|
|
234
|
+
{
|
|
235
|
+
variant: "outline",
|
|
236
|
+
onClick: () => new ApiaMonDocModal2().openModal({
|
|
237
|
+
monitorProperties: {
|
|
238
|
+
docTypeId: controller.docTypes.map((d) => d.id),
|
|
239
|
+
docTypeSel: controller.selectedDocTypeId ?? "1",
|
|
240
|
+
monDocId: controller.api.props.modalConfig.monitorId ?? 1
|
|
241
|
+
}
|
|
242
|
+
}).then((res) => {
|
|
243
|
+
if (res[0]?.row?.id)
|
|
244
|
+
controller.api.pickFileById(res[0].row.id);
|
|
245
|
+
}),
|
|
246
|
+
children: getLabel("btnMonDoc").text
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] })
|
|
250
|
+
] }) }),
|
|
251
|
+
/* @__PURE__ */ jsx(FilesList$1, {}),
|
|
252
|
+
/* @__PURE__ */ jsxs(Box, { className: "uploader__dropzone_description_section", children: [
|
|
253
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
254
|
+
/* @__PURE__ */ jsx("span", { children: getLabel("lblDes").text }),
|
|
255
|
+
/* @__PURE__ */ jsx(
|
|
256
|
+
Textarea,
|
|
257
|
+
{
|
|
258
|
+
disabled: controller.state.isReadonly,
|
|
259
|
+
value: controller.description,
|
|
260
|
+
onChange: (e) => {
|
|
261
|
+
controller.setDescription(e.target.value);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
267
|
+
/* @__PURE__ */ jsx("span", { children: getLabel("lblExpDate").text }),
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
DateInput,
|
|
270
|
+
{
|
|
271
|
+
disabled: controller.state.isReadonly,
|
|
272
|
+
value: controller.state.docExpDate,
|
|
273
|
+
onChange: (d) => {
|
|
274
|
+
controller.state.docExpDate = d ?? void 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] })
|
|
279
|
+
] })
|
|
280
|
+
] });
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const UploaderFileHeader = observer(() => {
|
|
284
|
+
const controller = useFileUploadContext();
|
|
285
|
+
const docTypes = controller.docTypes.map((c) => ({
|
|
286
|
+
label: c.title,
|
|
287
|
+
value: String(c.id)
|
|
288
|
+
}));
|
|
289
|
+
const selectedDocTypeId = controller.selectedDocTypeId;
|
|
290
|
+
const properties = {
|
|
291
|
+
disabled: controller.state.fromDirectoryFile || controller.conf?.versionFile ? true : false,
|
|
292
|
+
caseInsensitive: true,
|
|
293
|
+
options: docTypes,
|
|
294
|
+
value: docTypes.find((c) => c.value === selectedDocTypeId)?.value || docTypes[0]?.value,
|
|
295
|
+
onChange(id) {
|
|
296
|
+
controller.changeDocType(id);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const handler = useMemo(() => {
|
|
300
|
+
return new AutocompleteController(properties);
|
|
301
|
+
}, []);
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
handler.setValue(selectedDocTypeId);
|
|
304
|
+
}, [selectedDocTypeId]);
|
|
305
|
+
return /* @__PURE__ */ jsxs("label", { children: [
|
|
306
|
+
/* @__PURE__ */ jsx("span", { children: getLabel("lblDocType").text }),
|
|
307
|
+
/* @__PURE__ */ jsxs(Box, { className: "uploader__file_selection", children: [
|
|
308
|
+
/* @__PURE__ */ jsx(Autocomplete, { handler, properties }),
|
|
309
|
+
/* @__PURE__ */ jsx(
|
|
310
|
+
IconButton,
|
|
311
|
+
{
|
|
312
|
+
variant: "outline",
|
|
313
|
+
className: "uploader__file_infoBtn",
|
|
314
|
+
icon: "Info",
|
|
315
|
+
size: "Xl",
|
|
316
|
+
iconSize: 20,
|
|
317
|
+
onMouseEnter: (e) => {
|
|
318
|
+
ApiaUtil.instance.tooltips.open({
|
|
319
|
+
attachToElement: () => e.target,
|
|
320
|
+
children: makeDocTypeTooltip(
|
|
321
|
+
controller.api,
|
|
322
|
+
arrayOrArray(controller.selectedDocType).map((c) => ({
|
|
323
|
+
extensions: c.docExts.split(";"),
|
|
324
|
+
id: c.id,
|
|
325
|
+
label: c.title,
|
|
326
|
+
maxSize: c.maxSize
|
|
327
|
+
}))
|
|
328
|
+
)
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] })
|
|
334
|
+
] });
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const MetadataLabel = observer(
|
|
338
|
+
forwardRef(
|
|
339
|
+
({ metadata, i }, ref) => {
|
|
340
|
+
const controller = useFileUploadContext();
|
|
341
|
+
return /* @__PURE__ */ jsxs(
|
|
342
|
+
Box,
|
|
343
|
+
{
|
|
344
|
+
tabIndex: i === 0 ? 0 : -1,
|
|
345
|
+
className: "metadata__render_container",
|
|
346
|
+
ref: metadata.free !== "Y" ? ref : null,
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ jsx(RequiredMark, { isRequired: metadata.required === "Y" }),
|
|
349
|
+
metadata.free === "Y" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
350
|
+
/* @__PURE__ */ jsx(
|
|
351
|
+
Input,
|
|
352
|
+
{
|
|
353
|
+
value: metadata.title,
|
|
354
|
+
disabled: controller.state.isReadonly,
|
|
355
|
+
tabIndex: i === 0 ? 0 : -1,
|
|
356
|
+
ref,
|
|
357
|
+
className: "metadata__field",
|
|
358
|
+
onChange: (e) => {
|
|
359
|
+
metadata.title = e.target.value;
|
|
360
|
+
metadata.labelErrorMessage = "";
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
metadata.labelErrorMessage && /* @__PURE__ */ jsx(Box, { as: "span", className: "errorRequired", children: metadata.labelErrorMessage })
|
|
365
|
+
] }) : /* @__PURE__ */ jsx("span", { children: metadata.title })
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
const MetadataField = observer(
|
|
374
|
+
forwardRef(({ metadata }, ref) => {
|
|
375
|
+
let component = null;
|
|
376
|
+
const controller = useFileUploadContext();
|
|
377
|
+
if (metadata.type === "D") {
|
|
378
|
+
component = /* @__PURE__ */ jsx(
|
|
379
|
+
DateInput,
|
|
380
|
+
{
|
|
381
|
+
disabled: controller.state.isReadonly,
|
|
382
|
+
className: "metadata__field",
|
|
383
|
+
value: metadata.value,
|
|
384
|
+
tabIndex: -1,
|
|
385
|
+
ref,
|
|
386
|
+
onChange: (e) => {
|
|
387
|
+
metadata.value = e;
|
|
388
|
+
metadata.errorMessage = "";
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
} else if (metadata.type === "N") {
|
|
393
|
+
component = /* @__PURE__ */ jsx(
|
|
394
|
+
NumberInput,
|
|
395
|
+
{
|
|
396
|
+
value: metadata.value,
|
|
397
|
+
disabled: controller.state.isReadonly,
|
|
398
|
+
className: "metadata__field",
|
|
399
|
+
tabIndex: -1,
|
|
400
|
+
ref,
|
|
401
|
+
onChange: (e) => {
|
|
402
|
+
if (e.error) {
|
|
403
|
+
metadata.errorMessage = getLabel("msgMustBeNum").text;
|
|
404
|
+
} else {
|
|
405
|
+
metadata.errorMessage = "";
|
|
406
|
+
}
|
|
407
|
+
metadata.value = e.value;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
} else {
|
|
412
|
+
component = /* @__PURE__ */ jsx(
|
|
413
|
+
Input,
|
|
414
|
+
{
|
|
415
|
+
value: metadata.value,
|
|
416
|
+
disabled: controller.state.isReadonly,
|
|
417
|
+
tabIndex: -1,
|
|
418
|
+
ref,
|
|
419
|
+
className: "metadata__field",
|
|
420
|
+
onChange: (e) => {
|
|
421
|
+
metadata.value = e.target.value;
|
|
422
|
+
metadata.errorMessage = "";
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
return /* @__PURE__ */ jsxs(Box, { className: "metadata__render_container", children: [
|
|
428
|
+
/* @__PURE__ */ jsx(
|
|
429
|
+
RequiredMark,
|
|
430
|
+
{
|
|
431
|
+
isRequired: metadata.required === "Y" || metadata.free === "Y"
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
component,
|
|
435
|
+
metadata.errorMessage && /* @__PURE__ */ jsx(Box, { as: "span", className: "errorRequired", children: metadata.errorMessage })
|
|
436
|
+
] });
|
|
437
|
+
})
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
var __defProp = Object.defineProperty;
|
|
441
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
442
|
+
var __publicField = (obj, key, value) => {
|
|
443
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
444
|
+
return value;
|
|
445
|
+
};
|
|
446
|
+
let MetadataTable$1 = class MetadataTable {
|
|
447
|
+
constructor() {
|
|
448
|
+
__publicField(this, "activeCell", null);
|
|
449
|
+
__publicField(this, "lastSelectedIndex", null);
|
|
450
|
+
__publicField(this, "selectedIndices", []);
|
|
451
|
+
__publicField(this, "cellRefs", {});
|
|
452
|
+
__publicField(this, "onDelete");
|
|
453
|
+
__publicField(this, "component", observer(() => {
|
|
454
|
+
const controller = useFileUploadContext();
|
|
455
|
+
const modalConfig = controller.modalConfig;
|
|
456
|
+
const columns = [
|
|
457
|
+
{ name: "metadataName", label: getLabel("lblTit").text },
|
|
458
|
+
{ name: "metadataValue", label: getLabel("lblValue").text }
|
|
459
|
+
];
|
|
460
|
+
const metadata = controller.allMetadata;
|
|
461
|
+
const isRowSelectable = (rowIndex) => metadata[rowIndex].free === "Y";
|
|
462
|
+
this.onDelete = () => {
|
|
463
|
+
controller.deleteMetadata(this.selectedIndices);
|
|
464
|
+
const offset = controller.state.metadata.metadataArray.length;
|
|
465
|
+
const newLength = metadata.length - 1;
|
|
466
|
+
if (newLength - offset > 0) {
|
|
467
|
+
this.selectedIndices = [newLength - 1];
|
|
468
|
+
this.setActiveCell({ row: newLength - 1, col: 0 });
|
|
469
|
+
this.setLastSelectedIndex(newLength - 1);
|
|
470
|
+
this.focusCell(newLength - 1, 0);
|
|
471
|
+
} else {
|
|
472
|
+
this.selectedIndices = [];
|
|
473
|
+
this.setLastSelectedIndex(newLength - 1);
|
|
474
|
+
this.focusCell(newLength - 1, 0);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
return /* @__PURE__ */ jsxs(
|
|
478
|
+
CollapsiblePanel,
|
|
479
|
+
{
|
|
480
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("titMetadata").text }),
|
|
481
|
+
id: "metadata",
|
|
482
|
+
collapseIconToRight: true,
|
|
483
|
+
closedIcon: "ArrowUpThin",
|
|
484
|
+
openIcon: "ArrowDownThin",
|
|
485
|
+
"aria-label": getLabel("titMetadata").text,
|
|
486
|
+
collapsed: modalConfig.collapseMetadata,
|
|
487
|
+
children: [
|
|
488
|
+
(metadata.length > 0 || controller.state.metadata.isFreeMetadata) && /* @__PURE__ */ jsxs(
|
|
489
|
+
Box,
|
|
490
|
+
{
|
|
491
|
+
className: "metadata__container",
|
|
492
|
+
tabIndex: 0,
|
|
493
|
+
onKeyDown: (e) => this.handleKeyDown(e, columns, metadata.length, isRowSelectable),
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ jsx(Box, { className: "metadata__table_container", children: /* @__PURE__ */ jsxs(
|
|
496
|
+
Box,
|
|
497
|
+
{
|
|
498
|
+
as: "table",
|
|
499
|
+
role: "table",
|
|
500
|
+
"aria-label": "Metadata Table",
|
|
501
|
+
"aria-describedby": "metadata-table-description",
|
|
502
|
+
children: [
|
|
503
|
+
/* @__PURE__ */ jsx("thead", { role: "rowgroup", children: /* @__PURE__ */ jsx("tr", { role: "row", children: columns.map((col) => /* @__PURE__ */ jsx("th", { role: "columnheader", scope: "col", children: col.label }, col.name)) }) }),
|
|
504
|
+
/* @__PURE__ */ jsx("tbody", { role: "rowgroup", children: metadata.map((c, rowIndex) => {
|
|
505
|
+
const isRowSelected = this.selectedIndices?.includes(rowIndex);
|
|
506
|
+
return /* @__PURE__ */ jsx(
|
|
507
|
+
"tr",
|
|
508
|
+
{
|
|
509
|
+
role: "row",
|
|
510
|
+
onClick: (e) => {
|
|
511
|
+
e.stopPropagation();
|
|
512
|
+
this.handleRowClick(
|
|
513
|
+
rowIndex,
|
|
514
|
+
e,
|
|
515
|
+
isRowSelectable(rowIndex)
|
|
516
|
+
);
|
|
517
|
+
},
|
|
518
|
+
className: `${isRowSelected ? "selected" : ""}`,
|
|
519
|
+
children: columns.map((col, colIndex) => /* @__PURE__ */ jsx(
|
|
520
|
+
"td",
|
|
521
|
+
{
|
|
522
|
+
role: "cell",
|
|
523
|
+
style: {
|
|
524
|
+
cursor: !isRowSelectable(rowIndex) ? "not-allowed" : "default"
|
|
525
|
+
},
|
|
526
|
+
onClick: (e) => {
|
|
527
|
+
e.stopPropagation();
|
|
528
|
+
this.handleRowClick(
|
|
529
|
+
rowIndex,
|
|
530
|
+
e,
|
|
531
|
+
isRowSelectable(rowIndex),
|
|
532
|
+
colIndex
|
|
533
|
+
);
|
|
534
|
+
},
|
|
535
|
+
children: colIndex === 0 ? /* @__PURE__ */ jsx(
|
|
536
|
+
MetadataLabel,
|
|
537
|
+
{
|
|
538
|
+
i: rowIndex,
|
|
539
|
+
metadata: metadata[rowIndex],
|
|
540
|
+
ref: (el) => this.updateCellRef(
|
|
541
|
+
`cell-${rowIndex}-${colIndex}`,
|
|
542
|
+
el
|
|
543
|
+
)
|
|
544
|
+
}
|
|
545
|
+
) : /* @__PURE__ */ jsx(
|
|
546
|
+
MetadataField,
|
|
547
|
+
{
|
|
548
|
+
metadata: metadata[rowIndex],
|
|
549
|
+
ref: (el) => this.updateCellRef(
|
|
550
|
+
`cell-${rowIndex}-${colIndex}`,
|
|
551
|
+
el
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
)
|
|
555
|
+
},
|
|
556
|
+
col.name
|
|
557
|
+
))
|
|
558
|
+
},
|
|
559
|
+
c.id
|
|
560
|
+
);
|
|
561
|
+
}) })
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
) }),
|
|
565
|
+
metadata.length < 1 && /* @__PURE__ */ jsx(Box, { children: getLabel("lblNoMetadataForThisDocType").text }),
|
|
566
|
+
controller.state.metadata.isFreeMetadata && /* @__PURE__ */ jsxs(Box, { className: "metadata__actions", children: [
|
|
567
|
+
/* @__PURE__ */ jsx(
|
|
568
|
+
IconButton,
|
|
569
|
+
{
|
|
570
|
+
disabled: controller.state.isReadonly,
|
|
571
|
+
icon: "Plus",
|
|
572
|
+
...getVariant("outline"),
|
|
573
|
+
className: "addMetadata",
|
|
574
|
+
onClick: () => {
|
|
575
|
+
controller.addMetadata();
|
|
576
|
+
setTimeout(() => {
|
|
577
|
+
const newRowI = metadata.length;
|
|
578
|
+
const newField = document.querySelector(
|
|
579
|
+
"tr:last-child .metadata__field"
|
|
580
|
+
);
|
|
581
|
+
if (newField) {
|
|
582
|
+
newField.scrollIntoView({
|
|
583
|
+
behavior: "smooth",
|
|
584
|
+
block: "nearest",
|
|
585
|
+
inline: "nearest"
|
|
586
|
+
});
|
|
587
|
+
newField.focus();
|
|
588
|
+
}
|
|
589
|
+
this.selectedIndices = [newRowI];
|
|
590
|
+
this.setActiveCell({ row: newRowI, col: 0 });
|
|
591
|
+
this.setLastSelectedIndex(newRowI);
|
|
592
|
+
const container = document.querySelector(
|
|
593
|
+
".uploader__content"
|
|
594
|
+
);
|
|
595
|
+
if (container) {
|
|
596
|
+
container.scrollTo({
|
|
597
|
+
top: container.scrollHeight,
|
|
598
|
+
behavior: "smooth"
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}, 0);
|
|
602
|
+
},
|
|
603
|
+
type: "button",
|
|
604
|
+
"aria-label": "Add Metadata",
|
|
605
|
+
"aria-description": "Adds a new metadata row to the table"
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
/* @__PURE__ */ jsx(
|
|
609
|
+
IconButton,
|
|
610
|
+
{
|
|
611
|
+
disabled: controller.state.isReadonly || this.selectedIndices.length === 0,
|
|
612
|
+
icon: "Trash",
|
|
613
|
+
...getVariant("outline-danger"),
|
|
614
|
+
onClick: () => this.onDelete && this.onDelete(),
|
|
615
|
+
type: "button",
|
|
616
|
+
className: "deleteMetadata",
|
|
617
|
+
"aria-label": "Delete Metadata",
|
|
618
|
+
"aria-description": "Deletes the selected metadata row"
|
|
619
|
+
}
|
|
620
|
+
)
|
|
621
|
+
] })
|
|
622
|
+
]
|
|
623
|
+
}
|
|
624
|
+
),
|
|
625
|
+
metadata.length < 1 && !controller.state.metadata.isFreeMetadata && /* @__PURE__ */ jsx(Fragment, { children: getLabel("lblNoMetadataForThisDocType").text })
|
|
626
|
+
]
|
|
627
|
+
}
|
|
628
|
+
);
|
|
629
|
+
}));
|
|
630
|
+
makeObservable(this, {
|
|
631
|
+
activeCell: observable,
|
|
632
|
+
lastSelectedIndex: observable,
|
|
633
|
+
selectedIndices: observable,
|
|
634
|
+
cellRefs: observable,
|
|
635
|
+
setActiveCell: action,
|
|
636
|
+
setLastSelectedIndex: action,
|
|
637
|
+
setSelectedIndices: action,
|
|
638
|
+
updateCellRef: action,
|
|
639
|
+
handleRowClick: action,
|
|
640
|
+
handleKeyDown: action
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
setActiveCell(cell) {
|
|
644
|
+
this.activeCell = cell;
|
|
645
|
+
}
|
|
646
|
+
setLastSelectedIndex(index) {
|
|
647
|
+
this.lastSelectedIndex = index;
|
|
648
|
+
}
|
|
649
|
+
setSelectedIndices(indices) {
|
|
650
|
+
this.selectedIndices = indices;
|
|
651
|
+
}
|
|
652
|
+
updateCellRef(key, el) {
|
|
653
|
+
this.cellRefs[key] = el;
|
|
654
|
+
}
|
|
655
|
+
// Helper: returns an inclusive range between two indices.
|
|
656
|
+
getRange(start, end) {
|
|
657
|
+
const range = [];
|
|
658
|
+
const min = Math.min(start, end);
|
|
659
|
+
const max = Math.max(start, end);
|
|
660
|
+
for (let i = min; i <= max; i++) {
|
|
661
|
+
range.push(i);
|
|
662
|
+
}
|
|
663
|
+
return range;
|
|
664
|
+
}
|
|
665
|
+
focusCell(rowI, colI) {
|
|
666
|
+
const cellKey = `cell-${rowI}-${colI}`;
|
|
667
|
+
const cellEl = this.cellRefs[cellKey];
|
|
668
|
+
cellEl?.focus();
|
|
669
|
+
cellEl?.scrollIntoView({
|
|
670
|
+
behavior: "smooth",
|
|
671
|
+
block: "nearest",
|
|
672
|
+
inline: "nearest"
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
// Modified handleRowClick: now accepts an optional colIndex.
|
|
676
|
+
handleRowClick(index, e, isSelectable = true, colIndex) {
|
|
677
|
+
const newCol = colIndex !== void 0 ? colIndex : 0;
|
|
678
|
+
if (isSelectable) {
|
|
679
|
+
if (e && e.ctrlKey) {
|
|
680
|
+
if (this.selectedIndices.includes(index)) {
|
|
681
|
+
this.selectedIndices = this.selectedIndices.filter(
|
|
682
|
+
(i) => i !== index
|
|
683
|
+
);
|
|
684
|
+
} else {
|
|
685
|
+
this.selectedIndices.push(index);
|
|
686
|
+
}
|
|
687
|
+
this.lastSelectedIndex = index;
|
|
688
|
+
this.activeCell = { row: index, col: newCol };
|
|
689
|
+
} else if (e && e.shiftKey && this.lastSelectedIndex !== null) {
|
|
690
|
+
const range = this.getRange(this.lastSelectedIndex, index);
|
|
691
|
+
this.selectedIndices = Array.from(
|
|
692
|
+
/* @__PURE__ */ new Set([...this.selectedIndices, ...range])
|
|
693
|
+
);
|
|
694
|
+
this.lastSelectedIndex = index;
|
|
695
|
+
this.activeCell = { row: index, col: newCol };
|
|
696
|
+
} else {
|
|
697
|
+
this.selectedIndices = [index];
|
|
698
|
+
this.lastSelectedIndex = index;
|
|
699
|
+
this.activeCell = { row: index, col: newCol };
|
|
700
|
+
}
|
|
701
|
+
} else {
|
|
702
|
+
this.activeCell = { row: index, col: newCol };
|
|
703
|
+
}
|
|
704
|
+
this.focusCell(index, newCol);
|
|
705
|
+
}
|
|
706
|
+
// Handle key navigation.
|
|
707
|
+
// isRowSelectable is a predicate function that returns true if a given row is selectable.
|
|
708
|
+
handleKeyDown(e, columns, listLength, isRowSelectable) {
|
|
709
|
+
if (listLength === 0)
|
|
710
|
+
return;
|
|
711
|
+
if (this.selectedIndices.length > 0 && e.key === "Delete" || e.key === "Del" || e.key === "Supr") {
|
|
712
|
+
e.preventDefault();
|
|
713
|
+
if (this.onDelete) {
|
|
714
|
+
this.onDelete();
|
|
715
|
+
}
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
const maxColIndex = columns.length - 1;
|
|
719
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
720
|
+
e.preventDefault();
|
|
721
|
+
const currentRow = this.lastSelectedIndex !== null ? this.lastSelectedIndex : 0;
|
|
722
|
+
let newRow = currentRow;
|
|
723
|
+
if (e.key === "ArrowDown") {
|
|
724
|
+
newRow = (currentRow + 1) % listLength;
|
|
725
|
+
} else if (e.key === "ArrowUp") {
|
|
726
|
+
newRow = (currentRow - 1 + listLength) % listLength;
|
|
727
|
+
}
|
|
728
|
+
if (isRowSelectable(newRow)) {
|
|
729
|
+
if (e.shiftKey) {
|
|
730
|
+
this.selectedIndices = Array.from(
|
|
731
|
+
/* @__PURE__ */ new Set([...this.selectedIndices, newRow])
|
|
732
|
+
);
|
|
733
|
+
} else {
|
|
734
|
+
this.selectedIndices = [newRow];
|
|
735
|
+
}
|
|
736
|
+
this.lastSelectedIndex = newRow;
|
|
737
|
+
} else {
|
|
738
|
+
this.lastSelectedIndex = newRow;
|
|
739
|
+
}
|
|
740
|
+
const newCol = this.activeCell ? this.activeCell.col : 0;
|
|
741
|
+
this.activeCell = { row: newRow, col: newCol };
|
|
742
|
+
const cellKey = `cell-${newRow}-${newCol}`;
|
|
743
|
+
const cellEl = this.cellRefs[cellKey];
|
|
744
|
+
cellEl?.focus();
|
|
745
|
+
cellEl?.scrollIntoView({
|
|
746
|
+
behavior: "smooth",
|
|
747
|
+
block: "nearest",
|
|
748
|
+
inline: "nearest"
|
|
749
|
+
});
|
|
750
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
751
|
+
e.preventDefault();
|
|
752
|
+
let currentCell = this.activeCell;
|
|
753
|
+
if (!currentCell) {
|
|
754
|
+
const row = this.lastSelectedIndex !== null ? this.lastSelectedIndex : 0;
|
|
755
|
+
currentCell = { row, col: 0 };
|
|
756
|
+
}
|
|
757
|
+
if (e.key === "ArrowLeft") {
|
|
758
|
+
const newCol = currentCell.col - 1;
|
|
759
|
+
if (newCol >= 0 && this.cellRefs[`cell-${currentCell.row}-${newCol}`]) {
|
|
760
|
+
this.activeCell = { row: currentCell.row, col: newCol };
|
|
761
|
+
} else {
|
|
762
|
+
let found = false;
|
|
763
|
+
let target = null;
|
|
764
|
+
for (let r = currentCell.row + 1; r < listLength; r++) {
|
|
765
|
+
for (let c = currentCell.col - 1; c >= 0; c--) {
|
|
766
|
+
if (this.cellRefs[`cell-${r}-${c}`]) {
|
|
767
|
+
target = { row: r, col: c };
|
|
768
|
+
found = true;
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
if (found)
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
if (found && target) {
|
|
776
|
+
this.activeCell = target;
|
|
777
|
+
} else {
|
|
778
|
+
this.activeCell = { row: currentCell.row, col: 0 };
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
} else if (e.key === "ArrowRight") {
|
|
782
|
+
let newCol = currentCell.col + 1;
|
|
783
|
+
if (newCol > maxColIndex || !this.cellRefs[`cell-${currentCell.row}-${newCol}`]) {
|
|
784
|
+
newCol = maxColIndex;
|
|
785
|
+
}
|
|
786
|
+
this.activeCell = { row: currentCell.row, col: newCol };
|
|
787
|
+
}
|
|
788
|
+
if (this.activeCell) {
|
|
789
|
+
const cellKey = `cell-${this.activeCell.row}-${this.activeCell.col}`;
|
|
790
|
+
const cellEl = this.cellRefs[cellKey];
|
|
791
|
+
cellEl?.focus();
|
|
792
|
+
cellEl?.scrollIntoView({
|
|
793
|
+
behavior: "smooth",
|
|
794
|
+
block: "nearest",
|
|
795
|
+
inline: "nearest"
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
reset() {
|
|
801
|
+
this.activeCell = null;
|
|
802
|
+
this.lastSelectedIndex = null;
|
|
803
|
+
this.selectedIndices = [];
|
|
804
|
+
this.cellRefs = {};
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
const Directory = observer(() => {
|
|
809
|
+
const controller = useFileUploadContext();
|
|
810
|
+
const modalConfig = controller.modalConfig;
|
|
811
|
+
if (controller.state.isReadonly)
|
|
812
|
+
return null;
|
|
813
|
+
return /* @__PURE__ */ jsxs(
|
|
814
|
+
CollapsiblePanel,
|
|
815
|
+
{
|
|
816
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("lblDocFolders").text }),
|
|
817
|
+
id: "direcotry",
|
|
818
|
+
collapseIconToRight: true,
|
|
819
|
+
closedIcon: "ArrowUpThin",
|
|
820
|
+
openIcon: "ArrowDownThin",
|
|
821
|
+
className: "uploader__directory",
|
|
822
|
+
collapsed: modalConfig.collapseDirectories,
|
|
823
|
+
children: [
|
|
824
|
+
/* @__PURE__ */ jsx(
|
|
825
|
+
IconButton,
|
|
826
|
+
{
|
|
827
|
+
className: "uploader__directory__clear-directory",
|
|
828
|
+
icon: "Close",
|
|
829
|
+
title: "",
|
|
830
|
+
onClick: () => {
|
|
831
|
+
controller.directories.selectedItems.clear();
|
|
832
|
+
controller.state.docFolder = void 0;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
),
|
|
836
|
+
/* @__PURE__ */ jsx(
|
|
837
|
+
Tree,
|
|
838
|
+
{
|
|
839
|
+
id: controller.api.id,
|
|
840
|
+
isMultiple: false,
|
|
841
|
+
onSelect: (nodes) => {
|
|
842
|
+
const node = nodes.values().next().value;
|
|
843
|
+
if (node && node.state.nodeProps.canWrite)
|
|
844
|
+
controller.state.docFolder = Number(node.id);
|
|
845
|
+
},
|
|
846
|
+
store: controller.directories
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
]
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
const Metadata = new MetadataTable$1();
|
|
855
|
+
const UploaderContent = observer(() => {
|
|
856
|
+
const controller = useFileUploadContext();
|
|
857
|
+
const modalConfig = controller.modalConfig;
|
|
858
|
+
return /* @__PURE__ */ jsxs(
|
|
859
|
+
Box,
|
|
860
|
+
{
|
|
861
|
+
className: "uploader__container",
|
|
862
|
+
...getVariant("layout.common.components.uploader.defaultView"),
|
|
863
|
+
children: [
|
|
864
|
+
/* @__PURE__ */ jsx(UploaderFileHeader, {}),
|
|
865
|
+
/* @__PURE__ */ jsxs(Box, { className: "uploader__content", children: [
|
|
866
|
+
/* @__PURE__ */ jsx(AddFileSection, {}),
|
|
867
|
+
modalConfig.showPermissions && /* @__PURE__ */ jsx(Permissions, {}),
|
|
868
|
+
modalConfig.showDirectoriesStructure && /* @__PURE__ */ jsx(Directory, {}),
|
|
869
|
+
modalConfig.showMetadata && /* @__PURE__ */ jsx(Metadata.component, {})
|
|
870
|
+
] })
|
|
871
|
+
]
|
|
872
|
+
}
|
|
873
|
+
);
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
function openUploaderModal(c) {
|
|
877
|
+
ApiaUtil.instance.modals.open({
|
|
878
|
+
children: /* @__PURE__ */ jsx(FileUploadProvider, { store: c, children: /* @__PURE__ */ jsx(UploaderContent, {}) }),
|
|
879
|
+
size: "fileModal",
|
|
880
|
+
noHeader: true,
|
|
881
|
+
initialFocusGetter(ref) {
|
|
882
|
+
return ref.querySelector(".dropzone");
|
|
883
|
+
},
|
|
884
|
+
onConfirm: async () => {
|
|
885
|
+
const isValid = await c.confirm();
|
|
886
|
+
if (isValid) {
|
|
887
|
+
c.onCloseModal();
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
const dropzone = document.querySelector(".dropzoneModal");
|
|
891
|
+
if (dropzone && c.state.fileReqError) {
|
|
892
|
+
dropzone.focus();
|
|
893
|
+
} else {
|
|
894
|
+
document.querySelector(
|
|
895
|
+
".metadata__table_container .metadata__field:has(+ .errorRequired)"
|
|
896
|
+
)?.focus();
|
|
897
|
+
}
|
|
898
|
+
return false;
|
|
899
|
+
},
|
|
900
|
+
onCancel() {
|
|
901
|
+
c.onCloseModal();
|
|
902
|
+
},
|
|
903
|
+
onExited() {
|
|
904
|
+
c.onCloseModal();
|
|
905
|
+
},
|
|
906
|
+
onClose() {
|
|
907
|
+
c.onCloseModal();
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
const FileIconRenderer = observer(({ node }) => {
|
|
913
|
+
return /* @__PURE__ */ jsx(FileIcon, { iconSize: "sm", docName: node.state.label });
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
const FolderIconRenderer = observer(({ node }) => {
|
|
917
|
+
return node.state.isExpanded ? /* @__PURE__ */ jsx(Icon, { title: "", name: "FolderOpen" }) : /* @__PURE__ */ jsx(Icon, { title: "", name: "FolderClosed" });
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
const LoadMoreRenderer = observer(({ node }) => {
|
|
921
|
+
return /* @__PURE__ */ jsx(
|
|
922
|
+
SimpleButton,
|
|
923
|
+
{
|
|
924
|
+
isLoading: node.state.nodeProps.isLoadingMore,
|
|
925
|
+
tabIndex: -1,
|
|
926
|
+
variant: "inherit-sm",
|
|
927
|
+
children: node.state.label
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
});
|
|
931
|
+
|
|
932
|
+
const LockedFolderIconRenderer = observer(() => {
|
|
933
|
+
return /* @__PURE__ */ jsx(Box, { sx: { "& *": { color: "palette.error.main" } }, children: /* @__PURE__ */ jsx(Icon, { title: "", name: "Locked" }) });
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
const DeleteDocument = (api, f, props) => {
|
|
937
|
+
return {
|
|
938
|
+
children: /* @__PURE__ */ jsx(Box, { children: getLabel("btnDel").text }),
|
|
939
|
+
key: "7",
|
|
940
|
+
onClick: async () => {
|
|
941
|
+
const file = api.getDocument(f.docId);
|
|
942
|
+
if (await ApiaUtil.instance.dialogs.confirm({
|
|
943
|
+
children: (
|
|
944
|
+
// !window.langId &&
|
|
945
|
+
Object.values(api.state.translatedFiles.get(file.docId) ?? {}).length > 0 ? getLabel("msgDelFileTrans").text : window.MSG_CONFIG_DELETE_DOCUMENT_FILE_INPUT_NAME.replace(
|
|
946
|
+
"<TOK>",
|
|
947
|
+
file.docName ?? file.name ?? "NONAME"
|
|
948
|
+
)
|
|
949
|
+
),
|
|
950
|
+
title: window.BTN_FILE_ERASE_LBL
|
|
951
|
+
})) {
|
|
952
|
+
await api.ajaxDeleteDocument(file.docId, props?.langId);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
const DownloadDocument = (api, file) => {
|
|
959
|
+
return {
|
|
960
|
+
children: /* @__PURE__ */ jsx(Box, { children: getLabel("lblDownFile").text }),
|
|
961
|
+
key: "3",
|
|
962
|
+
onClick: () => {
|
|
963
|
+
api.checkWebDavLock(file.docId);
|
|
964
|
+
api.downloadDocument(file.docId);
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
const EditDocument = (api, file) => {
|
|
970
|
+
return {
|
|
971
|
+
children: /* @__PURE__ */ jsx(Box, { children: getLabel("lblEdit").text }),
|
|
972
|
+
key: "2",
|
|
973
|
+
onClick: () => {
|
|
974
|
+
api.editDocument(file.docId);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
const LockDocument = (api, file) => {
|
|
980
|
+
return {
|
|
981
|
+
icon: (file.isLocked || toBoolean(file.lock) || file.locked) && "Check",
|
|
982
|
+
children: /* @__PURE__ */ jsx(
|
|
983
|
+
Box,
|
|
984
|
+
{
|
|
985
|
+
sx: {
|
|
986
|
+
display: "flex",
|
|
987
|
+
alignItems: "center",
|
|
988
|
+
gap: 3
|
|
989
|
+
},
|
|
990
|
+
children: file.isLocked || toBoolean(file.lock) || file.locked ? getLabel("lblDocLockedBy", {
|
|
991
|
+
text: { TOK1: file.lockingUser || file?.lockedBy || "" }
|
|
992
|
+
}).text : getLabel("btnLock").text
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
key: "5",
|
|
996
|
+
onClick: () => {
|
|
997
|
+
api.lockDocument(file.docId);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
function getUploaderShownMenuOptions({
|
|
1003
|
+
showDownload,
|
|
1004
|
+
showEdition,
|
|
1005
|
+
showLock,
|
|
1006
|
+
showVersion,
|
|
1007
|
+
showDelete,
|
|
1008
|
+
showTranslate
|
|
1009
|
+
}, file) {
|
|
1010
|
+
const showEditOption = showEdition !== false && file.canEdit !== false && Number(file?.docId) >= 0 && !window.IN_MONITOR;
|
|
1011
|
+
const showLockOption = showLock !== false && file.canWrite !== false && Number(file?.docId) >= 0 && !window.IN_MONITOR;
|
|
1012
|
+
const showDownloadOption = showDownload !== false;
|
|
1013
|
+
const showVersionOption = showVersion !== false && file.canWrite !== false && Number(file?.docId) >= 0 && !window.IN_MONITOR;
|
|
1014
|
+
const showDeleteOption = showDelete !== false && file.canWrite !== false && !window.IN_MONITOR;
|
|
1015
|
+
const showTranslateOption = showTranslate !== false && file.canWrite !== false && !window.IN_MONITOR;
|
|
1016
|
+
return {
|
|
1017
|
+
showEditOption,
|
|
1018
|
+
showLockOption,
|
|
1019
|
+
showDownloadOption,
|
|
1020
|
+
showVersionOption,
|
|
1021
|
+
showDeleteOption,
|
|
1022
|
+
showTranslateOption
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
const VersionTable = ({
|
|
1027
|
+
data,
|
|
1028
|
+
api,
|
|
1029
|
+
file
|
|
1030
|
+
}) => {
|
|
1031
|
+
return /* @__PURE__ */ jsx(
|
|
1032
|
+
CollapsiblePanel,
|
|
1033
|
+
{
|
|
1034
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("sbtDocVer").text }),
|
|
1035
|
+
id: "versions_infoModal",
|
|
1036
|
+
collapseIconToRight: true,
|
|
1037
|
+
closedIcon: "ArrowUpThin",
|
|
1038
|
+
openIcon: "ArrowDownThin",
|
|
1039
|
+
defaultCollapsed: true,
|
|
1040
|
+
children: /* @__PURE__ */ jsx(Box, { className: "doc_info_table_container", children: /* @__PURE__ */ jsxs("table", { className: "doc_info_table versions_table", children: [
|
|
1041
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1042
|
+
/* @__PURE__ */ jsx("th", { children: getLabel("lblVer").text }),
|
|
1043
|
+
/* @__PURE__ */ jsx("th", { children: getLabel("lblUsu").text }),
|
|
1044
|
+
/* @__PURE__ */ jsx("th", { children: getLabel("lblDate").text })
|
|
1045
|
+
] }) }),
|
|
1046
|
+
/* @__PURE__ */ jsx("tbody", { children: data.map((version, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
1047
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(
|
|
1048
|
+
SimpleButton,
|
|
1049
|
+
{
|
|
1050
|
+
variant: "link",
|
|
1051
|
+
onClick: () => {
|
|
1052
|
+
api.downloadVersion(file.docId, version.verNumber);
|
|
1053
|
+
},
|
|
1054
|
+
children: version.verNumber
|
|
1055
|
+
}
|
|
1056
|
+
) }),
|
|
1057
|
+
/* @__PURE__ */ jsx("td", { children: version.verUser }),
|
|
1058
|
+
/* @__PURE__ */ jsx("td", { children: version.verDate })
|
|
1059
|
+
] }, index)) })
|
|
1060
|
+
] }) })
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
const PermissionsInfo = ({ data }) => {
|
|
1066
|
+
return /* @__PURE__ */ jsxs(
|
|
1067
|
+
CollapsiblePanel,
|
|
1068
|
+
{
|
|
1069
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("lblPer").text }),
|
|
1070
|
+
id: "permissions_infoModal",
|
|
1071
|
+
collapseIconToRight: true,
|
|
1072
|
+
closedIcon: "ArrowUpThin",
|
|
1073
|
+
openIcon: "ArrowDownThin",
|
|
1074
|
+
className: "uploader__permissions",
|
|
1075
|
+
defaultCollapsed: true,
|
|
1076
|
+
children: [
|
|
1077
|
+
/* @__PURE__ */ jsxs(Box, { className: "allPermissions", children: [
|
|
1078
|
+
/* @__PURE__ */ jsx("span", { children: getLabel("lblTod").text }),
|
|
1079
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: data.allPoolPermission, children: [
|
|
1080
|
+
/* @__PURE__ */ jsx("option", { value: "M", children: getLabel("lblPerMod").text }),
|
|
1081
|
+
/* @__PURE__ */ jsx("option", { value: "R", children: getLabel("lblPerVer").text }),
|
|
1082
|
+
/* @__PURE__ */ jsx("option", { value: "", children: getLabel("lblAccessDenied").text })
|
|
1083
|
+
] })
|
|
1084
|
+
] }),
|
|
1085
|
+
/* @__PURE__ */ jsx(Box, { className: "permissions__list", children: /* @__PURE__ */ jsxs(Box, { as: "ul", children: [
|
|
1086
|
+
arrayOrArray(data.permissions?.user).map((c) => {
|
|
1087
|
+
return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
|
|
1088
|
+
SwitchCard,
|
|
1089
|
+
{
|
|
1090
|
+
label: c.name,
|
|
1091
|
+
align: "right",
|
|
1092
|
+
icon: "User2",
|
|
1093
|
+
value: c.permType === "M" ? true : false,
|
|
1094
|
+
switchProps: { disabled: true }
|
|
1095
|
+
}
|
|
1096
|
+
) }, c.id);
|
|
1097
|
+
}),
|
|
1098
|
+
arrayOrArray(data.permissions?.pool).map((c) => {
|
|
1099
|
+
return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
|
|
1100
|
+
SwitchCard,
|
|
1101
|
+
{
|
|
1102
|
+
label: c.name,
|
|
1103
|
+
align: "right",
|
|
1104
|
+
icon: "Groups",
|
|
1105
|
+
value: c.permType === "M" ? true : false,
|
|
1106
|
+
switchProps: { disabled: true }
|
|
1107
|
+
}
|
|
1108
|
+
) }, c.id);
|
|
1109
|
+
})
|
|
1110
|
+
] }) })
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
);
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
const InfoTable = ({
|
|
1117
|
+
data,
|
|
1118
|
+
docId
|
|
1119
|
+
}) => {
|
|
1120
|
+
return /* @__PURE__ */ jsx(Box, { as: "table", variant: "layout.common.tables.information", children: /* @__PURE__ */ jsxs("tbody", { children: [
|
|
1121
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
1122
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1123
|
+
getLabel("lblDocType").text,
|
|
1124
|
+
":"
|
|
1125
|
+
] }) }),
|
|
1126
|
+
/* @__PURE__ */ jsx("td", { children: data.type })
|
|
1127
|
+
] }),
|
|
1128
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
1129
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1130
|
+
getLabel("lblDocName").text,
|
|
1131
|
+
":"
|
|
1132
|
+
] }) }),
|
|
1133
|
+
/* @__PURE__ */ jsx("td", { children: data.name })
|
|
1134
|
+
] }),
|
|
1135
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
1136
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1137
|
+
getLabel("lblDes").text,
|
|
1138
|
+
":"
|
|
1139
|
+
] }) }),
|
|
1140
|
+
/* @__PURE__ */ jsx("td", { children: data.description })
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
1143
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1144
|
+
getLabel("lblExpDate").text,
|
|
1145
|
+
":"
|
|
1146
|
+
] }) }),
|
|
1147
|
+
/* @__PURE__ */ jsx("td", { children: data.expirationDate })
|
|
1148
|
+
] }),
|
|
1149
|
+
data.folderPath && /* @__PURE__ */ jsxs("tr", { children: [
|
|
1150
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1151
|
+
getLabel("lblDir").text,
|
|
1152
|
+
":"
|
|
1153
|
+
] }) }),
|
|
1154
|
+
/* @__PURE__ */ jsx("td", { children: data.folderPath })
|
|
1155
|
+
] }),
|
|
1156
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
1157
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1158
|
+
getLabel("lblDwnLink").text,
|
|
1159
|
+
":"
|
|
1160
|
+
] }) }),
|
|
1161
|
+
Number(docId) > 0 && /* @__PURE__ */ jsxs(Box, { as: "td", className: "table__buttons", children: [
|
|
1162
|
+
/* @__PURE__ */ jsx(
|
|
1163
|
+
IconButton,
|
|
1164
|
+
{
|
|
1165
|
+
icon: "Download",
|
|
1166
|
+
size: "Lg",
|
|
1167
|
+
onClick: () => {
|
|
1168
|
+
window.open(data.downloadLink, "_blank");
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
/* @__PURE__ */ jsx(
|
|
1173
|
+
IconButton,
|
|
1174
|
+
{
|
|
1175
|
+
icon: "Copy",
|
|
1176
|
+
size: "Lg",
|
|
1177
|
+
title: getLabel("lblCpyLink").text,
|
|
1178
|
+
onClick: () => {
|
|
1179
|
+
navigator.clipboard.writeText(data.downloadLink).then(() => {
|
|
1180
|
+
ApiaUtil.instance.notifications.notify({
|
|
1181
|
+
message: getLabel("lblCopiedLink").text,
|
|
1182
|
+
type: "success"
|
|
1183
|
+
});
|
|
1184
|
+
console.log("Download link copied to clipboard");
|
|
1185
|
+
}).catch((err) => {
|
|
1186
|
+
console.error("Failed to copy download link:", err);
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
)
|
|
1191
|
+
] })
|
|
1192
|
+
] })
|
|
1193
|
+
] }) });
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
const MetadataTable = ({
|
|
1197
|
+
data
|
|
1198
|
+
}) => {
|
|
1199
|
+
return /* @__PURE__ */ jsx(
|
|
1200
|
+
CollapsiblePanel,
|
|
1201
|
+
{
|
|
1202
|
+
label: /* @__PURE__ */ jsx("span", { children: getLabel("titMetadata").text }),
|
|
1203
|
+
id: "metadata_infoModal",
|
|
1204
|
+
collapseIconToRight: true,
|
|
1205
|
+
closedIcon: "ArrowUpThin",
|
|
1206
|
+
openIcon: "ArrowDownThin",
|
|
1207
|
+
defaultCollapsed: true,
|
|
1208
|
+
children: /* @__PURE__ */ jsx(Box, { className: "doc_info_table_container", children: /* @__PURE__ */ jsxs("table", { className: "doc_info_table", children: [
|
|
1209
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1210
|
+
/* @__PURE__ */ jsx("th", { children: getLabel("lblTit").text }),
|
|
1211
|
+
/* @__PURE__ */ jsx("th", { children: getLabel("lblVal").text })
|
|
1212
|
+
] }) }),
|
|
1213
|
+
/* @__PURE__ */ jsx("tbody", { children: data.map((item, index) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
1214
|
+
/* @__PURE__ */ jsx("td", { children: item.title }),
|
|
1215
|
+
/* @__PURE__ */ jsx("td", { children: item.value })
|
|
1216
|
+
] }, index)) })
|
|
1217
|
+
] }) })
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
const DocInfoModal = (api, file) => {
|
|
1223
|
+
return {
|
|
1224
|
+
children: /* @__PURE__ */ jsx(Box, { children: getLabel("btnInfo").text }),
|
|
1225
|
+
key: "1",
|
|
1226
|
+
onClick: async () => {
|
|
1227
|
+
const data = {
|
|
1228
|
+
...parseDocumentInfo(await api.getDocumentInfo({ docId: file.docId }))
|
|
1229
|
+
};
|
|
1230
|
+
ApiaUtil.instance.modals.open({
|
|
1231
|
+
children: /* @__PURE__ */ jsx(DocModalComponent, { data, file, api }),
|
|
1232
|
+
size: "flex",
|
|
1233
|
+
title: getLabel("btnInfo").text
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
};
|
|
1238
|
+
const DocModalComponent = ({
|
|
1239
|
+
data,
|
|
1240
|
+
file,
|
|
1241
|
+
api
|
|
1242
|
+
}) => {
|
|
1243
|
+
return /* @__PURE__ */ jsxs(Box, { ...getVariant("layout.common.components.uploader.infoModal"), children: [
|
|
1244
|
+
/* @__PURE__ */ jsx(InfoTable, { data, docId: file.docId }),
|
|
1245
|
+
/* @__PURE__ */ jsx(PermissionsInfo, { data }),
|
|
1246
|
+
data.versions.length > 0 && /* @__PURE__ */ jsx(VersionTable, { data: data.versions, api, file }),
|
|
1247
|
+
data.metadata.length > 0 && /* @__PURE__ */ jsx(MetadataTable, { data: data.metadata })
|
|
1248
|
+
] });
|
|
1249
|
+
};
|
|
1250
|
+
function parseDocumentInfo(data) {
|
|
1251
|
+
if (!data)
|
|
1252
|
+
throw new Error("There is no data in DocumentInfoModal");
|
|
1253
|
+
const { general } = data.function.data;
|
|
1254
|
+
return {
|
|
1255
|
+
docId: general.docId,
|
|
1256
|
+
allPoolPermission: general.docAllPoolPerm,
|
|
1257
|
+
description: general.docDesc,
|
|
1258
|
+
downloadLink: general.docDwnExternal,
|
|
1259
|
+
expirationDate: general.docExpDate ?? "",
|
|
1260
|
+
metadata: arrayOrArray(data.function.metadatas?.metadata),
|
|
1261
|
+
name: general.docName,
|
|
1262
|
+
permissions: data.function.data?.permissions,
|
|
1263
|
+
type: general.docTypeLabel,
|
|
1264
|
+
versions: arrayOrArray(data.function.data?.versions?.version),
|
|
1265
|
+
folderPath: data.function.data.general.docFolderPath
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
const VersionDocument = (api, file) => {
|
|
1270
|
+
return {
|
|
1271
|
+
children: /* @__PURE__ */ jsx(Box, { children: getLabel("lblUploadNewVersion").text }),
|
|
1272
|
+
key: "6",
|
|
1273
|
+
onClick: async () => {
|
|
1274
|
+
if (!api.modalConfig.oneClickUpload) {
|
|
1275
|
+
api.onVersionUpload(file);
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
const input = document.createElement("input");
|
|
1279
|
+
input.type = "file";
|
|
1280
|
+
input.multiple = true;
|
|
1281
|
+
input.style.display = "none";
|
|
1282
|
+
const cleanup = () => {
|
|
1283
|
+
input.removeEventListener("change", onChange);
|
|
1284
|
+
if (input.parentNode)
|
|
1285
|
+
input.parentNode.removeChild(input);
|
|
1286
|
+
};
|
|
1287
|
+
const onChange = (e) => {
|
|
1288
|
+
try {
|
|
1289
|
+
const target = e.target;
|
|
1290
|
+
if (target && target.files && target.files.length > 0) {
|
|
1291
|
+
const newFiles = Array.from(target.files);
|
|
1292
|
+
api.onVersionUpload(file, { newFiles });
|
|
1293
|
+
}
|
|
1294
|
+
} finally {
|
|
1295
|
+
cleanup();
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
input.addEventListener("change", onChange);
|
|
1299
|
+
document.body.appendChild(input);
|
|
1300
|
+
if (api.modalConfig.oneClickUpload) {
|
|
1301
|
+
const checkLock = await api.checkLockDocument(file.docId, true);
|
|
1302
|
+
const isLocked = await api.checkWebDavLock(file.docId);
|
|
1303
|
+
if (checkLock === true && isLocked) {
|
|
1304
|
+
input.click();
|
|
1305
|
+
}
|
|
1306
|
+
} else {
|
|
1307
|
+
input.click();
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
function openUploaderMenu(anchor, uploaderApi, props, file, langId) {
|
|
1314
|
+
const {
|
|
1315
|
+
showDeleteOption,
|
|
1316
|
+
showDownloadOption,
|
|
1317
|
+
showEditOption,
|
|
1318
|
+
showLockOption,
|
|
1319
|
+
showTranslateOption,
|
|
1320
|
+
showVersionOption
|
|
1321
|
+
} = getUploaderShownMenuOptions(props, file);
|
|
1322
|
+
ApiaUtil.instance.menu.open({
|
|
1323
|
+
items: [
|
|
1324
|
+
DocInfoModal(uploaderApi, file),
|
|
1325
|
+
showEditOption && EditDocument(uploaderApi, file),
|
|
1326
|
+
showDownloadOption && DownloadDocument(uploaderApi, file),
|
|
1327
|
+
/**
|
|
1328
|
+
* Lock version and delete section
|
|
1329
|
+
*/
|
|
1330
|
+
showLockOption || showVersionOption || showDeleteOption ? "separator" : null,
|
|
1331
|
+
showLockOption && LockDocument(uploaderApi, file),
|
|
1332
|
+
showVersionOption && VersionDocument(uploaderApi, file),
|
|
1333
|
+
showDeleteOption && DeleteDocument(uploaderApi, file, {
|
|
1334
|
+
langId: langId ? Number(langId) : void 0
|
|
1335
|
+
}),
|
|
1336
|
+
/**
|
|
1337
|
+
* Sign and translation section
|
|
1338
|
+
*/
|
|
1339
|
+
showTranslateOption ? "separator" : null,
|
|
1340
|
+
showTranslateOption && TranslateDocument(uploaderApi, file)
|
|
1341
|
+
].filter(Boolean),
|
|
1342
|
+
menuProps: {
|
|
1343
|
+
anchorRef: {
|
|
1344
|
+
current: anchor.closest("button")
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
const TranslateDocument = (api, file) => {
|
|
1351
|
+
const translationsCount = [
|
|
1352
|
+
...api.state.translatedFiles.get(file.docId)?.values() ?? []
|
|
1353
|
+
].length;
|
|
1354
|
+
return {
|
|
1355
|
+
children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
1356
|
+
getLabel("btnTrans").text,
|
|
1357
|
+
" (",
|
|
1358
|
+
translationsCount,
|
|
1359
|
+
")"
|
|
1360
|
+
] }),
|
|
1361
|
+
key: "9",
|
|
1362
|
+
onClick: () => {
|
|
1363
|
+
ApiaUtil.instance.modals.open({
|
|
1364
|
+
title: getLabel("titTra").text,
|
|
1365
|
+
children: /* @__PURE__ */ jsx(TranslateDocumentModal, { api, file }),
|
|
1366
|
+
initialFocusGetter(ref) {
|
|
1367
|
+
return ref.querySelector(".dropzone");
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
};
|
|
1373
|
+
const TranslateDocumentModal = observer(
|
|
1374
|
+
({ api, file }) => {
|
|
1375
|
+
const langs = Object.entries(api.langs ?? {}).map(([key, value]) => ({
|
|
1376
|
+
id: key,
|
|
1377
|
+
title: String(value)
|
|
1378
|
+
}));
|
|
1379
|
+
const translateFileMap = api.state.translatedFiles.get(file.docId);
|
|
1380
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
|
|
1381
|
+
/* @__PURE__ */ jsx(Box, { sx: { fontWeight: "bold" }, children: getLabel("lblTranslatesForFile", {
|
|
1382
|
+
text: { TOK1: file.docName ?? "" }
|
|
1383
|
+
}).text }),
|
|
1384
|
+
langs.map((c) => {
|
|
1385
|
+
const translatedFile = translateFileMap?.get(Number(c.id));
|
|
1386
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
1387
|
+
/* @__PURE__ */ jsx("span", { children: c.title }),
|
|
1388
|
+
translateFileMap && translatedFile ? /* @__PURE__ */ jsx(
|
|
1389
|
+
FileCard,
|
|
1390
|
+
{
|
|
1391
|
+
name: translatedFile.docName ?? "",
|
|
1392
|
+
width: "100%",
|
|
1393
|
+
additionalButtons: [
|
|
1394
|
+
{
|
|
1395
|
+
icon: "Download",
|
|
1396
|
+
size: "Lg",
|
|
1397
|
+
iconSize: 20,
|
|
1398
|
+
onClick: (e) => {
|
|
1399
|
+
e.stopPropagation();
|
|
1400
|
+
api.checkWebDavLock(translatedFile.docId);
|
|
1401
|
+
api.downloadDocument(translatedFile.docId);
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
icon: "Ellipsis",
|
|
1406
|
+
size: "Lg",
|
|
1407
|
+
iconSize: 20,
|
|
1408
|
+
onClick: (e) => {
|
|
1409
|
+
e.stopPropagation();
|
|
1410
|
+
openUploaderMenu(
|
|
1411
|
+
e.target,
|
|
1412
|
+
api,
|
|
1413
|
+
{
|
|
1414
|
+
showTranslate: false,
|
|
1415
|
+
showEdition: false,
|
|
1416
|
+
showLock: true,
|
|
1417
|
+
showDelete: true,
|
|
1418
|
+
showDownload: true,
|
|
1419
|
+
showVersion: false
|
|
1420
|
+
},
|
|
1421
|
+
translatedFile,
|
|
1422
|
+
c.id
|
|
1423
|
+
);
|
|
1424
|
+
},
|
|
1425
|
+
onDoubleClick: (e) => {
|
|
1426
|
+
e.stopPropagation();
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
]
|
|
1430
|
+
}
|
|
1431
|
+
) : /* @__PURE__ */ jsx(
|
|
1432
|
+
Dropzone,
|
|
1433
|
+
{
|
|
1434
|
+
onClick: (ev) => {
|
|
1435
|
+
if (!api.modalConfig.oneClickUpload) {
|
|
1436
|
+
ev.preventDefault();
|
|
1437
|
+
api.onTranslateUpload({
|
|
1438
|
+
langId: Number(c.id),
|
|
1439
|
+
translatingFile: file
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
onChange: (e) => {
|
|
1444
|
+
api.onTranslateUpload(
|
|
1445
|
+
{
|
|
1446
|
+
langId: Number(c.id),
|
|
1447
|
+
translatingFile: file
|
|
1448
|
+
},
|
|
1449
|
+
e
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
)
|
|
1454
|
+
] });
|
|
1455
|
+
})
|
|
1456
|
+
] });
|
|
1457
|
+
}
|
|
1458
|
+
);
|
|
1459
|
+
|
|
1460
|
+
const UploadedFiles = observer(
|
|
1461
|
+
({
|
|
1462
|
+
uploaderApi,
|
|
1463
|
+
hideDropzone,
|
|
1464
|
+
openContextMenu
|
|
1465
|
+
}) => {
|
|
1466
|
+
const existingFiles = uploaderApi.filesArray;
|
|
1467
|
+
const handleFileClick = (e, file) => {
|
|
1468
|
+
if (e.ctrlKey) {
|
|
1469
|
+
uploaderApi.state.selectedFiles = uploaderApi.state.selectedFiles.filter((id) => id !== file.docId);
|
|
1470
|
+
} else {
|
|
1471
|
+
if (!uploaderApi.state.selectedFiles.includes(file.docId)) {
|
|
1472
|
+
uploaderApi.state.selectedFiles.push(file.docId);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
const handleInfoButton = useCallback(
|
|
1477
|
+
(ev) => ApiaUtil.instance.tooltips.open({
|
|
1478
|
+
attachToElement: () => ev.target,
|
|
1479
|
+
children: makeDocTypeTooltip(uploaderApi)
|
|
1480
|
+
}),
|
|
1481
|
+
[uploaderApi]
|
|
1482
|
+
);
|
|
1483
|
+
return /* @__PURE__ */ jsxs(
|
|
1484
|
+
Box,
|
|
1485
|
+
{
|
|
1486
|
+
sx: {
|
|
1487
|
+
p: 4,
|
|
1488
|
+
display: "flex",
|
|
1489
|
+
flexDirection: "column",
|
|
1490
|
+
gap: 4
|
|
1491
|
+
},
|
|
1492
|
+
children: [
|
|
1493
|
+
!hideDropzone && /* @__PURE__ */ jsx(
|
|
1494
|
+
Dropzone,
|
|
1495
|
+
{
|
|
1496
|
+
progress: uploaderApi.state.progress,
|
|
1497
|
+
className: "dropzone__uploadedfiles",
|
|
1498
|
+
onClick: (ev) => {
|
|
1499
|
+
if (!uploaderApi.modalConfig.oneClickUpload) {
|
|
1500
|
+
ev.preventDefault();
|
|
1501
|
+
uploaderApi.onStartUpload();
|
|
1502
|
+
}
|
|
1503
|
+
},
|
|
1504
|
+
onChange: (e) => {
|
|
1505
|
+
uploaderApi.onStartUpload(e);
|
|
1506
|
+
},
|
|
1507
|
+
handleInfoButton: (e) => handleInfoButton(e)
|
|
1508
|
+
}
|
|
1509
|
+
),
|
|
1510
|
+
/* @__PURE__ */ jsxs(Box, { className: "uploadedFiles__container", children: [
|
|
1511
|
+
existingFiles.length > 0 && /* @__PURE__ */ jsx(
|
|
1512
|
+
Box,
|
|
1513
|
+
{
|
|
1514
|
+
...getVariant("layout.common.components.uploader.filesList"),
|
|
1515
|
+
className: "uploadedFiles",
|
|
1516
|
+
children: uploaderApi.filesArray.map((c) => {
|
|
1517
|
+
return /* @__PURE__ */ createElement(
|
|
1518
|
+
FileCard,
|
|
1519
|
+
{
|
|
1520
|
+
...Number(c.docId) >= 0 ? {
|
|
1521
|
+
onDropFiles: (files) => {
|
|
1522
|
+
uploaderApi.onVersionUpload(
|
|
1523
|
+
uploaderApi.state.files[c.docId],
|
|
1524
|
+
{ newFiles: files }
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
} : {},
|
|
1528
|
+
className: `${uploaderApi.state.selectedFiles.find((current) => current === c.docId) ? "selected" : ""}`,
|
|
1529
|
+
key: c.docId,
|
|
1530
|
+
name: c.docName ?? "",
|
|
1531
|
+
width: "100%",
|
|
1532
|
+
onClick: (e) => handleFileClick(e, c),
|
|
1533
|
+
onDoubleClick: () => {
|
|
1534
|
+
uploaderApi.downloadDocument(c.docId);
|
|
1535
|
+
},
|
|
1536
|
+
additionalButtons: [
|
|
1537
|
+
{
|
|
1538
|
+
icon: "Download",
|
|
1539
|
+
size: "Lg",
|
|
1540
|
+
iconSize: 20,
|
|
1541
|
+
onClick: (e) => {
|
|
1542
|
+
e.stopPropagation();
|
|
1543
|
+
uploaderApi.downloadDocument(c.docId);
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
{
|
|
1547
|
+
icon: "Ellipsis",
|
|
1548
|
+
size: "Lg",
|
|
1549
|
+
iconSize: 20,
|
|
1550
|
+
onClick: (e) => {
|
|
1551
|
+
e.stopPropagation();
|
|
1552
|
+
(openContextMenu ? openContextMenu : openUploaderMenu)(
|
|
1553
|
+
e.target,
|
|
1554
|
+
uploaderApi,
|
|
1555
|
+
{
|
|
1556
|
+
showEdition: toBoolean(window.IS_EDITION_ALLOWED),
|
|
1557
|
+
showTranslate: uploaderApi.context.allowTranslation
|
|
1558
|
+
},
|
|
1559
|
+
c
|
|
1560
|
+
);
|
|
1561
|
+
},
|
|
1562
|
+
onDoubleClick: (e) => {
|
|
1563
|
+
e.stopPropagation();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
]
|
|
1567
|
+
}
|
|
1568
|
+
);
|
|
1569
|
+
})
|
|
1570
|
+
}
|
|
1571
|
+
),
|
|
1572
|
+
/* @__PURE__ */ jsx(
|
|
1573
|
+
SimpleButton,
|
|
1574
|
+
{
|
|
1575
|
+
variant: "outline-sm",
|
|
1576
|
+
className: "download_Button",
|
|
1577
|
+
onClick: () => {
|
|
1578
|
+
uploaderApi.downloadMultipleDocuments();
|
|
1579
|
+
},
|
|
1580
|
+
children: getLabel("btnDow").text
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
] })
|
|
1584
|
+
]
|
|
1585
|
+
}
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
);
|
|
1589
|
+
|
|
1590
|
+
export { AddFileSection, DeleteDocument, Directory, DocInfoModal, DownloadDocument, EditDocument, FileIconRenderer, FileUploadProvider, FolderIconRenderer, InfoTable, LoadMoreRenderer, LockDocument, LockedFolderIconRenderer, MetadataTable$1 as MetadataTable, Permissions, PermissionsInfo, TranslateDocument, TranslateDocumentModal, UploadedFiles, UploaderContent, UploaderFileHeader, VersionDocument, VersionTable, getUploaderShownMenuOptions, makeDocTypeTooltip, openUploaderMenu, openUploaderModal, parseDocumentInfo, useFileUploadContext };
|
|
1591
|
+
//# sourceMappingURL=index.js.map
|