@bimdata/design-system 2.0.0-rc.20 → 2.0.0-rc.21

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.
Files changed (25) hide show
  1. package/package.json +1 -2
  2. package/src/BIMDataComponents/index.js +0 -3
  3. package/vue3-plugin.js +0 -11
  4. package/src/BIMDataComponents/BIMDataModelPreview/BIMDataModelPreview.vue +0 -58
  5. package/src/BIMDataComponents/BIMDataModelPreview/Preview2D.vue +0 -116
  6. package/src/BIMDataComponents/BIMDataModelPreview/Preview3D.vue +0 -75
  7. package/src/BIMDataComponents/BIMDataPDFViewer/BIMDataPDFViewer.vue +0 -115
  8. package/src/BIMDataComponents/BIMDataSafeZoneModal/BIMDataSafeZoneModal.vue +0 -37
  9. package/src/BIMDataComponents/BIMDataSafeZoneModal/_BIMDataSafeZoneModal.scss +0 -39
  10. package/src/BIMDataSmartComponents/BIMDataFileManager/BIMDataFileManager.scss +0 -123
  11. package/src/BIMDataSmartComponents/BIMDataFileManager/BIMDataFileManager.vue +0 -636
  12. package/src/BIMDataSmartComponents/BIMDataFileManager/components/FileCard.vue +0 -433
  13. package/src/BIMDataSmartComponents/BIMDataFileManager/components/MultiLineTextBox/MultiLineTextBox.vue +0 -151
  14. package/src/BIMDataSmartComponents/BIMDataFileManager/components/MultiLineTextBox/Tooltip.vue +0 -46
  15. package/src/BIMDataSmartComponents/BIMDataFileManager/components/PdfPageSelector.vue +0 -161
  16. package/src/BIMDataSmartComponents/BIMDataFileManager/components/PieProgressSpinner.vue +0 -73
  17. package/src/BIMDataSmartComponents/BIMDataFileManager/components/UploadFileButton.vue +0 -72
  18. package/src/BIMDataSmartComponents/BIMDataFileManager/components/modals/DeleteModal.vue +0 -184
  19. package/src/BIMDataSmartComponents/BIMDataFileManager/components/modals/RenameModal.vue +0 -186
  20. package/src/BIMDataSmartComponents/BIMDataFileManager/components/newFolder/NewFolderButton.vue +0 -117
  21. package/src/BIMDataSmartComponents/BIMDataFileManager/components/newFolder/NewFolderForm.vue +0 -165
  22. package/src/BIMDataSmartComponents/BIMDataFileManager/i18n.js +0 -141
  23. package/src/BIMDataSmartComponents/BIMDataFileManager/utils/files.js +0 -89
  24. package/src/BIMDataSmartComponents/BIMDataFileManager/utils/flattenTree.js +0 -16
  25. package/src/BIMDataSmartComponents/index.js +0 -10
@@ -1,636 +0,0 @@
1
- <template>
2
- <div class="bimdata-file-manager">
3
- <BIMDataPDFViewer
4
- class="bimdata-file-manager__pdf-viewer"
5
- v-if="pdfToView"
6
- :pdf="pdfToView"
7
- header
8
- >
9
- <template #header-left>
10
- <BIMDataButton
11
- class="m-l-12"
12
- width="32px"
13
- height="32px"
14
- color="primary"
15
- ghost
16
- radius
17
- icon
18
- @click="pdfToView = null"
19
- >
20
- <BIMDataIcon name="arrow" size="xxs" />
21
- </BIMDataButton>
22
- </template>
23
- </BIMDataPDFViewer>
24
- <div
25
- class="bimdata-file-manager__header"
26
- :class="{
27
- 'bimdata-file-manager__header--xs': xsLayout,
28
- 'bimdata-file-manager__header--s': sLayout,
29
- 'bimdata-file-manager__header--m': mLayout,
30
- 'bimdata-file-manager__header--l': lLayout,
31
- }"
32
- v-if="headerButtons || headerSearch"
33
- >
34
- <template v-if="headerButtons">
35
- <NewFolderButton
36
- :disabled="!currentFolder || currentFolder.user_permission < 100"
37
- :projectId="projectId"
38
- :spaceId="spaceId"
39
- :apiClient="apiClient"
40
- :folder="currentFolder"
41
- @success="onNewFolder"
42
- @error="$emit('error', $event)"
43
- />
44
- <UploadFileButton
45
- class="bimdata-file-manager__header__upload"
46
- width="25%"
47
- :disabled="!currentFolder || currentFolder.user_permission < 100"
48
- multiple
49
- @upload="uploadFiles"
50
- />
51
- </template>
52
- <BIMDataSearch
53
- v-if="headerSearch"
54
- :color="searchColor"
55
- class="bimdata-file-manager__search"
56
- width="100%"
57
- placeholder="Search"
58
- v-model="searchText"
59
- ref="search"
60
- clear
61
- radius
62
- />
63
- </div>
64
- <div class="bimdata-file-manager__navigation">
65
- <div
66
- v-if="navigationShown"
67
- class="bimdata-file-manager__navigation__content"
68
- >
69
- <BIMDataButton
70
- color="default"
71
- icon
72
- radius
73
- ghost
74
- width="33px"
75
- height="31px"
76
- @click="back"
77
- >
78
- <BIMDataIcon name="arrow" />
79
- </BIMDataButton>
80
- <BIMDataTextbox
81
- :text="currentFolder.name"
82
- cutPosition="middle"
83
- tooltipPosition="bottom"
84
- tooltipColor="primary"
85
- width="calc(100% - 45px)"
86
- />
87
- </div>
88
- <div v-else class="bimdata-file-manager__navigation__content--empty">
89
- {{ translate("dmsRoot") }}
90
- </div>
91
- </div>
92
- <template v-if="fileStructure">
93
- <div class="bimdata-file-manager__container" v-if="files.length > 0">
94
- <BIMDataResponsiveGrid
95
- :itemWidth="itemWidth"
96
- rowGap="4px"
97
- columnGap="6px"
98
- >
99
- <FileCard
100
- :width="itemWidth"
101
- v-for="file of files"
102
- :key="file.id"
103
- :file="file"
104
- :projectId="projectId"
105
- :spaceId="spaceId"
106
- :apiUrl="apiUrl"
107
- :accessToken="accessToken"
108
- @open-folder="openFolder(file)"
109
- :select="select"
110
- :disabled="isDisabled(file)"
111
- :multi="multi"
112
- :selected="isFileSelected(file)"
113
- :success="isFileSucess(file.id)"
114
- @toggle-select="onToggleFileSelect(file)"
115
- @rename="onRename(file)"
116
- @delete="onDelete(file)"
117
- @view="onView(file)"
118
- @dowload="onDowload(file)"
119
- @loaded="onFileLoaded(file, $event)"
120
- :writeAccess="currentFolder.user_permission >= 100"
121
- :viewPdf="viewPdf"
122
- :pdfModelLoading="pdfModelLoading === file.id"
123
- />
124
- </BIMDataResponsiveGrid>
125
- </div>
126
- <div v-else class="bimdata-file-manager__container--empty">
127
- <div>
128
- <BIMDataIcon name="folderOpen" size="xxxl" fill color="silver" />
129
- <span>{{ translate("emptyFolder") }}</span>
130
- </div>
131
- </div>
132
- </template>
133
- <BIMDataLoading v-else />
134
- <div
135
- v-if="pdfPageSelectorDisplayed"
136
- class="bimdata-file-manager__pdf-page-selector"
137
- >
138
- <PdfPageSelector
139
- :model="pdfModel"
140
- @select="selectPdfPage"
141
- @close="selectPdfPage"
142
- />
143
- </div>
144
- <div class="bimdata-file-manager__modal" v-if="modalDisplayed">
145
- <RenameModal
146
- :projectId="projectId"
147
- :spaceId="spaceId"
148
- :apiClient="apiClient"
149
- :entity="entityRenown"
150
- v-if="entityRenown"
151
- @close="entityRenown = null"
152
- @success="onRenameSuccess"
153
- @error="$emit('error', $event)"
154
- />
155
- <DeleteModal
156
- :projectId="projectId"
157
- :spaceId="spaceId"
158
- :apiClient="apiClient"
159
- :entity="entityDeletable"
160
- v-else-if="entityDeletable"
161
- @close="entityDeletable = null"
162
- @success="onDeleteSuccess"
163
- @error="$emit('error', $event)"
164
- />
165
- </div>
166
- </div>
167
- </template>
168
-
169
- <script>
170
- import { makeBIMDataApiClient } from "@bimdata/typescript-fetch-api-client";
171
-
172
- import BIMDataResponsiveGrid from "../../BIMDataComponents/BIMDataResponsiveGrid/BIMDataResponsiveGrid.vue";
173
- import BIMDataSearch from "../../BIMDataComponents/BIMDataSearch/BIMDataSearch.vue";
174
- import BIMDataLoading from "../../BIMDataComponents/BIMDataLoading/BIMDataLoading.vue";
175
- import BIMDataIcon from "../../BIMDataComponents/BIMDataIcon/BIMDataIcon.vue";
176
- import BIMDataButton from "../../BIMDataComponents/BIMDataButton/BIMDataButton.vue";
177
- import BIMDataTextbox from "../../BIMDataComponents/BIMDataTextbox/BIMDataTextbox.vue";
178
- import BIMDataPDFViewer from "../../BIMDataComponents/BIMDataPDFViewer/BIMDataPDFViewer.vue";
179
-
180
- import FileCard from "./components/FileCard.vue";
181
- import NewFolderButton from "./components/newFolder/NewFolderButton.vue";
182
- import UploadFileButton from "./components/UploadFileButton.vue";
183
- import RenameModal from "./components/modals/RenameModal.vue";
184
- import DeleteModal from "./components/modals/DeleteModal.vue";
185
- import PdfPageSelector from "./components/PdfPageSelector.vue";
186
-
187
- import getFlattenTree from "./utils/flattenTree.js";
188
- import { downloadFiles } from "./utils/files.js";
189
-
190
- import trads from "./i18n.js";
191
-
192
- const XS = 398;
193
- const S = 468;
194
- const M = 800;
195
-
196
- const SUCCESS_TIME = 3000;
197
-
198
- export default {
199
- components: {
200
- BIMDataResponsiveGrid,
201
- BIMDataSearch,
202
- BIMDataLoading,
203
- FileCard,
204
- NewFolderButton,
205
- UploadFileButton,
206
- BIMDataIcon,
207
- BIMDataButton,
208
- BIMDataTextbox,
209
- RenameModal,
210
- DeleteModal,
211
- BIMDataPDFViewer,
212
- PdfPageSelector,
213
- },
214
- provide() {
215
- return {
216
- $translate: this.translate,
217
- };
218
- },
219
- props: {
220
- locale: {
221
- type: String,
222
- default: "en",
223
- },
224
- apiUrl: {
225
- type: String,
226
- default: "https://api.bimdata.io",
227
- },
228
- spaceId: {
229
- type: Number,
230
- required: true,
231
- },
232
- projectId: {
233
- type: Number,
234
- required: true,
235
- },
236
- accessToken: {
237
- type: String,
238
- required: true,
239
- },
240
- select: {
241
- type: Boolean,
242
- default: false,
243
- },
244
- multi: {
245
- type: Boolean,
246
- default: false,
247
- },
248
- searchColor: {
249
- type: String,
250
- default: "primary",
251
- },
252
- headerButtons: {
253
- type: Boolean,
254
- default: true,
255
- },
256
- headerSearch: {
257
- type: Boolean,
258
- default: true,
259
- },
260
- alreadySelectedIds: {
261
- type: Array,
262
- defaut: () => [],
263
- },
264
- selectableFileTypes: {
265
- type: Array,
266
- default: () => [],
267
- },
268
- viewPdf: {
269
- type: Boolean,
270
- default: false,
271
- },
272
- pdfPageSelect: {
273
- type: Boolean,
274
- default: false,
275
- },
276
- },
277
- data() {
278
- return {
279
- currentFolder: null,
280
- loadingFiles: [],
281
- searchText: "",
282
- selectedFiles: [],
283
- apiClient: null,
284
- fileStructure: null,
285
- width: 0,
286
- entityRenown: false,
287
- entityDeletable: false,
288
- successFileIds: [],
289
- pdfToView: null,
290
- pdfModel: null,
291
- pdfModelLoading: null,
292
- pdfPageSelectorDisplayed: false,
293
- };
294
- },
295
- computed: {
296
- modalDisplayed() {
297
- return this.entityRenown || this.entityDeletable;
298
- },
299
- navigationShown() {
300
- return this.currentFolder !== this.fileStructure;
301
- },
302
- itemWidth() {
303
- return this.xsLayout ? "100%" : this.sLayout ? "180px" : "164px";
304
- },
305
- xsLayout() {
306
- return this.width < XS;
307
- },
308
- sLayout() {
309
- return this.width >= XS && this.width < S;
310
- },
311
- mLayout() {
312
- return this.width >= S && this.width < M;
313
- },
314
- lLayout() {
315
- return this.width >= M;
316
- },
317
- multiSelect() {
318
- return this.select && this.multi;
319
- },
320
- files() {
321
- let files = null;
322
- if (this.searchText) {
323
- files = (
324
- (this.currentFolder && this.currentFolder.children) ||
325
- []
326
- ).filter(file => file.name.toLowerCase().includes(this.searchText));
327
- } else {
328
- files = (this.currentFolder && this.currentFolder.children) || [];
329
- }
330
-
331
- files.push(
332
- ...this.loadingFiles.filter(
333
- loadingFile =>
334
- loadingFile.folder.id === this.currentFolder.id &&
335
- !files.find(file => file.id === loadingFile.id) // for multi file loading
336
- )
337
- );
338
-
339
- files.sort((a, b) => (a.name || "").localeCompare(b.name));
340
- files.sort((a, b) => {
341
- const aType = a.nature === "Folder" ? 1 : -1;
342
- const bType = b.nature === "Folder" ? 1 : -1;
343
-
344
- return bType - aType;
345
- });
346
- return files;
347
- },
348
- },
349
- watch: {
350
- accessToken(token) {
351
- this.apiClient.accessToken = token;
352
- },
353
- multi() {
354
- this.selectedFiles = [];
355
- this.$emit("selection-change", this.selectedFiles);
356
- },
357
- select() {
358
- this.selectedFiles = [];
359
- this.$emit("selection-change", this.selectedFiles);
360
- },
361
- },
362
- mounted() {
363
- this.resizeObserver = new ResizeObserver(this.onResize);
364
- this.resizeObserver.observe(this.$el);
365
- },
366
- beforeDestroy() {
367
- if (this.resizeObserver) {
368
- this.resizeObserver.disconnect();
369
- }
370
- clearTimeout(this.timeoutId);
371
-
372
- document.removeEventListener("keydown", this.onKeyDown);
373
- },
374
- async created() {
375
- document.addEventListener("keydown", this.onKeyDown);
376
-
377
- this.loadingFileId = 0;
378
-
379
- try {
380
- this.apiClient = makeBIMDataApiClient({
381
- apiUrl: this.apiUrl,
382
- accessToken: this.accessToken,
383
- });
384
- this.fileStructure =
385
- await this.apiClient.collaborationApi.getProjectDMSTree(
386
- this.spaceId,
387
- this.projectId
388
- );
389
- } catch (error) {
390
- this.$emit("error", error);
391
- }
392
-
393
- this.currentFolder = this.fileStructure;
394
- },
395
- methods: {
396
- isDisabled(file) {
397
- if (file.nature === "Folder") return false;
398
-
399
- const extensionMatch = file.file_name?.match(/\.(\w+$)/);
400
- const fileExtension = extensionMatch && extensionMatch[1];
401
-
402
- return (
403
- this.select &&
404
- this.selectableFileTypes.length > 0 &&
405
- !(fileExtension && this.selectableFileTypes.includes(fileExtension))
406
- );
407
- },
408
- onKeyDown(e) {
409
- if (e.key === "Escape") {
410
- this.entityRenown = null;
411
- this.entityDeletable = null;
412
- if (
413
- this.$refs.search &&
414
- this.$refs.search.$refs.input === document.activeElement
415
- ) {
416
- this.searchText = "";
417
- this.$refs.search.blur();
418
- }
419
- }
420
- },
421
- translate(key) {
422
- return (trads[this.locale] || trads["en"])[key];
423
- },
424
- isFileSucess(id) {
425
- return (
426
- this.successFileIds.includes(id) ||
427
- (this.select &&
428
- this.alreadySelectedIds &&
429
- this.alreadySelectedIds.includes(id))
430
- );
431
- },
432
- onFileLoaded(loadingFile, loadedFile) {
433
- if (!loadingFile.folder.children) {
434
- this.$set(loadingFile.folder, "children", []);
435
- }
436
- loadingFile.folder.children = loadingFile.folder.children.filter(
437
- child => child.id !== loadingFile.id
438
- );
439
- loadingFile.folder.children.push(loadedFile);
440
- this.loadingFiles = this.loadingFiles.filter(
441
- child => child.id !== loadingFile.id
442
- );
443
-
444
- this.$emit("success", {
445
- type: "fileCreated",
446
- message: this.translate("newFileSuccess"),
447
- content: loadedFile,
448
- });
449
-
450
- this.successFileIds.push(loadedFile.id);
451
- this.timeoutId = setTimeout(() => {
452
- if (this.successFileIds) {
453
- this.successFileIds = this.successFileIds.filter(
454
- fileId => fileId !== loadedFile.id
455
- );
456
- }
457
- }, SUCCESS_TIME);
458
- },
459
- onDowload(entity) {
460
- try {
461
- downloadFiles(getFlattenTree(entity), {
462
- projectId: this.projectId,
463
- spaceId: this.spaceId,
464
- accessToken: this.accessToken,
465
- apiUrl: this.apiUrl,
466
- });
467
- } catch (error) {
468
- this.$emit("error", error);
469
- }
470
- },
471
- onDelete(entity) {
472
- this.entityDeletable = entity;
473
- },
474
- onDeleteSuccess() {
475
- const parent = this.getParent(this.fileStructure, this.entityDeletable);
476
- if (parent) {
477
- parent.children = parent.children.filter(
478
- child => child.id !== this.entityDeletable.id
479
- );
480
- }
481
-
482
- const isFolder = this.entityDeletable.nature === "Folder";
483
-
484
- this.$emit("success", {
485
- type: isFolder ? "folderDeleted" : "fileDeleted",
486
- message: isFolder
487
- ? this.translate("deleteFolderSuccess")
488
- : this.translate("deleteFileSuccess"),
489
- content: this.entityDeletable,
490
- });
491
-
492
- this.entityDeletable = null;
493
- },
494
- onRename(entity) {
495
- this.entityRenown = entity;
496
- },
497
- onRenameSuccess() {
498
- const isFolder = this.entityRenown.nature === "Folder";
499
-
500
- this.$emit("success", {
501
- type: isFolder ? "folderRenamed" : "fileRenamed",
502
- message: isFolder
503
- ? this.translate("renameFolderSuccess")
504
- : this.translate("renameFileSuccess"),
505
- content: this.entityRenown,
506
- });
507
- this.entityRenown = null;
508
- },
509
- onView(file) {
510
- this.pdfToView = file;
511
- },
512
- onResize(entries) {
513
- entries.forEach(entry => {
514
- this.width = entry.target.clientWidth;
515
- });
516
- },
517
- /**
518
- * @param { File[] } files
519
- */
520
- uploadFiles(files = []) {
521
- this.loadingFiles.push(...this.formatFiles(files));
522
- },
523
- /**
524
- * @param { File[] } files
525
- */
526
- formatFiles(files) {
527
- return files.map(file => ({
528
- name: file.name,
529
- updated_at: new Date(file.lastModified),
530
- nature: "Document",
531
- id: `loadingfile-${this.loadingFileId++}`,
532
- fileToLoad: file,
533
- folder: this.currentFolder,
534
- }));
535
- },
536
- onNewFolder(newFolder) {
537
- if (!this.currentFolder.children) {
538
- this.$set(this.currentFolder, "children", []);
539
- }
540
- this.currentFolder.children.push(newFolder);
541
- this.$emit("success", {
542
- type: "folderCreated",
543
- message: this.translate("newFolderSuccess"),
544
- content: newFolder,
545
- });
546
- },
547
- async onToggleFileSelect(file) {
548
- if (this.isFileSelected(file)) {
549
- this.selectedFiles = this.selectedFiles.filter(
550
- ({ document }) => document !== file
551
- );
552
- } else {
553
- if (!this.multi) {
554
- this.selectedFiles = [];
555
- }
556
-
557
- let pdfPage = null;
558
- if (this.pdfPageSelect && file.model_type === "PDF") {
559
- // If 'pdfPageSelect' mode is on and the selected file is a PDF model
560
- // fetch the corresponding model to check its children (pages)
561
- this.pdfModelLoading = file.id;
562
- const model = await this.apiClient.modelApi.getModel(
563
- this.spaceId,
564
- file.model_id,
565
- this.projectId
566
- );
567
- this.pdfModelLoading = null;
568
- if (model.children?.length > 0) {
569
- // If this is a multipage PDF open the page selector
570
- this.pdfModel = model;
571
- this.pdfPageSelectorDisplayed = true;
572
- pdfPage = await new Promise(res => (this.selectPdfPage = res));
573
- this.pdfPageSelectorDisplayed = false;
574
- this.pdfModel = null;
575
- if (!pdfPage) return; // If no page has been selected then the file is not selected
576
- }
577
- }
578
-
579
- this.selectedFiles.push({ document: file, pdfPage });
580
- }
581
- this.$emit("selection-change", this.selectedFiles);
582
- },
583
- isFileSelected(file) {
584
- return this.selectedFiles.some(({ document }) => file === document);
585
- },
586
- onBreadcrumClick(step) {
587
- this.currentFolder = step;
588
- },
589
- onBreadcrumBack() {
590
- const to = this.steps[this.steps.length - 2];
591
- if (to) {
592
- this.currentFolder = to;
593
- }
594
- },
595
- openFolder(file) {
596
- this.currentFolder = file;
597
- },
598
- back() {
599
- const parent = this.getParent(this.fileStructure, this.currentFolder);
600
-
601
- if (parent) {
602
- this.currentFolder = parent;
603
- } else {
604
- this.currentFolder = this.fileStructure;
605
- }
606
- },
607
- getParent(parent, fileStructure) {
608
- if (!Array.isArray(parent.children)) return;
609
- if (parent.children.includes(fileStructure)) {
610
- return parent;
611
- } else {
612
- for (let child of parent.children) {
613
- const newParent = this.getParent(child, fileStructure);
614
- if (newParent) {
615
- return newParent;
616
- }
617
- }
618
- }
619
- },
620
- getFolder(id, parent = this.fileStructure) {
621
- if (parent.id === id) {
622
- return parent;
623
- } else {
624
- for (let child of parent.children || []) {
625
- const folder = this.getFolder(id, child);
626
- if (folder) {
627
- return folder;
628
- }
629
- }
630
- }
631
- },
632
- },
633
- };
634
- </script>
635
-
636
- <style scoped lang="scss" src="./BIMDataFileManager.scss"></style>