@acorex/connectivity 19.2.17-next.0 → 19.2.19

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.
@@ -3,10 +3,10 @@ import { RootConfig, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMFolderServ
3
3
  import { RootConfig as RootConfig$3, AXMNotificationEntityService } from '@acorex/modules/notification-management';
4
4
  import * as i1$1 from '@acorex/platform/auth';
5
5
  import { AXPSessionService, AXPPermissionProviderService, AXPAuthModule } from '@acorex/platform/auth';
6
- import { AXPDataGenerator, AXPRegionalService, AXPFileStorageStatus, AXPFileStorageService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
6
+ import { AXPDataGenerator, AXPFileTypeProviderService, AXPRegionalService, AXPFileStorageStatus, AXPFileStorageService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
7
7
  import { AXPDexieEntityStorageService, AXPEntityDefinitionRegistryService, AXP_DATA_SEEDER_TOKEN, AXPEntityStorageService } from '@acorex/platform/layout/entity';
8
8
  import * as i0 from '@angular/core';
9
- import { inject, Injectable, NgModule } from '@angular/core';
9
+ import { inject, Injectable, NgModule, Injector } from '@angular/core';
10
10
  import * as i1 from '@acorex/modules/conversation';
11
11
  import { AXMConverstionModuleConst, AXMChatServiceImpl, AXMCommentServiceImpl, AXMChatModule, AXMChatService } from '@acorex/modules/conversation';
12
12
  import { AXPDataGenerator as AXPDataGenerator$1 } from '@acorex/platform/core';
@@ -550,84 +550,200 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
550
550
  }]
551
551
  }] });
552
552
 
553
- const DocumentTypeMocks = [
553
+ const checkbox$1 = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"checkbox-editor","name":"checkbox-editor1","options":{"label":"i accept","readonly":false,"disabled":false},"defaultValue":false,"path":"accept-check-box"}],"name":"page-layout1"}],"name":"document"}';
554
+ const color$1 = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"block-layout","name":"block-layout1","options":{"flexDirection":{"id":"ax-flex-row"},"flexJustifyContent":{"id":"ax-justify-normal"},"flexAlignItems":{"id":"ax-items-start"},"gap":2,"flexWrap":{"id":"ax-flex-nowrap"},"spacing":{"margin":"0px 0px 0px 0px","padding":"0px 0px 0px 0px"},"border":{"width":"0px","radius":"0px","color":"#000000","style":"none"},"flexOptions":{"gap":"0px","flexDirection":"row","flexWrap":"nowrap","justifyContent":"flex-start","alignItems":"flex-start"}}},"children":[{"type":"color-editor","name":"color-editor1","options":{"readonly":false,"disabled":false,"validations":{"required":{"rule":"required","message":"This field is required."}},"placeholder":"pick color"},"path":"color-box"}]}],"name":"page-layout1"}],"name":"document"}';
555
+ const titleInterface$1 = `{
556
+ "type": "document-layout",
557
+ "children": [
554
558
  {
555
- id: AXPDataGenerator$1.uuid(),
556
- name: 'OHS',
557
- title: 'Occupational Health and Safety Policy',
558
- maxSize: 5000,
559
- isEncrypted: false,
560
- meta: [
561
- {
562
- name: 'checkbox',
563
- title: 'Check Box',
564
- interface: '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"checkbox-editor","name":"checkbox-editor1","options":{"label":"i accept","readonly":false,"disabled":false},"defaultValue":false,"path":"accept-check-box"}],"name":"page-layout1"}],"name":"document"}',
565
- },
566
- ],
567
- type: {
568
- selectedItems: [
569
- {
570
- name: 'image.jpg',
571
- title: 'Image/JPEG',
572
- icon: 'fa-light fa-image ax-text-purple-500',
573
- },
574
- {
575
- name: 'image.png',
576
- title: 'Image/PNG',
577
- icon: 'fa-light fa-image ax-text-purple-500',
578
- },
559
+ "type": "page-layout",
560
+ "children": [
561
+ {
562
+ "type": "title-editor",
563
+ "name": "title-editor1",
564
+ "meta": {
565
+ "header": true
566
+ },
567
+ "options": {
568
+ "multiple": false,
569
+ "disabled": false,
570
+ "hasClearButton": false,
571
+ "validations": {
572
+ "regex": null,
573
+ "required": {
574
+ "rule": "required",
575
+ "message": "This field is required."
576
+ }
577
+ }
578
+ },
579
+ "defaultValue": "",
580
+ "path": "title"
581
+ }
582
+ ],
583
+ "name": "page-layout1"
584
+ }
585
+ ],
586
+ "name": "document"
587
+ }`;
588
+ const descriptionInterface$1 = `{
589
+ "type": "document-layout",
590
+ "children": [
591
+ {
592
+ "type": "page-layout",
593
+ "children": [
594
+ {
595
+ "type": "description-editor",
596
+ "name": "description-editor1",
597
+ "meta": {
598
+ "header": true
599
+ },
600
+ "options": {
601
+ "multiple": false,
602
+ "disabled": false,
603
+ "hasClearButton": false,
604
+ },
605
+ "defaultValue": "",
606
+ "path": "description"
607
+ }
608
+ ],
609
+ "name": "page-layout1"
610
+ }
611
+ ],
612
+ "name": "document"
613
+ }`;
614
+ const contractNumberInterface$1 = `{
615
+ "type": "document-layout",
616
+ "children": [
617
+ {
618
+ "type": "page-layout",
619
+ "children": [
620
+ {
621
+ "type": "number-editor",
622
+ "name": "number-editor1",
623
+ "meta": {
624
+ "header": true
625
+ },
626
+ "options": {
627
+ "multiple": false,
628
+ "disabled": false,
629
+ "hasClearButton": false,
630
+ },
631
+ "defaultValue": "",
632
+ "path": "contract-number"
633
+ }
634
+ ],
635
+ "name": "page-layout1"
636
+ }
637
+ ],
638
+ "name": "document"
639
+ }`;
640
+ const evaluatorInterface$1 = `{
641
+ "type": "document-layout",
642
+ "children": [
643
+ {
644
+ "type": "page-layout",
645
+ "children": [
646
+ {
647
+ "type": "text-editor",
648
+ "name": "text-editor1",
649
+ "meta": {
650
+ "header": true
651
+ },
652
+ "options": {
653
+ "multiple": false,
654
+ "disabled": false,
655
+ "hasClearButton": false,
656
+ },
657
+ "defaultValue": "",
658
+ "path": "evaluator"
659
+ }
660
+ ],
661
+ "name": "page-layout1"
662
+ }
663
+ ],
664
+ "name": "document"
665
+ }`;
666
+ async function DocumentTypeMockGenerator(injector) {
667
+ const fileTypeProvider = injector.get(AXPFileTypeProviderService);
668
+ const Items = await fileTypeProvider.items();
669
+ // Define the correct type for the items and use flatMap to create a flat array
670
+ const selectedItems = Items.flatMap((parent) => parent.extensions.map((extension) => ({
671
+ name: `${parent.name}.${extension.name}`,
672
+ title: `${parent.title}/${extension.title}`,
673
+ icon: extension.icon ? extension.icon : "",
674
+ })));
675
+ return [
676
+ {
677
+ id: AXPDataGenerator$1.uuid(),
678
+ name: 'risk-assessment-report',
679
+ title: 'Risk Assessment Report',
680
+ maxSize: 5000,
681
+ isEncrypted: false,
682
+ isMultiple: true,
683
+ meta: [
579
684
  {
580
- name: 'image.gif',
581
- title: 'Image/GIF',
582
- icon: 'fa-light fa-image ax-text-purple-500',
685
+ name: 'accept-check-box',
686
+ title: 'Agreement Box',
687
+ interface: checkbox$1,
583
688
  },
584
689
  ],
585
- context: {
586
- image: {
587
- width: '22',
588
- height: '33',
589
- },
590
- gift: {
591
- duration: '11',
690
+ type: {
691
+ selectedItems: [
692
+ {
693
+ name: 'image.jpg',
694
+ title: 'Image/JPEG',
695
+ icon: 'fa-light fa-image ax-text-purple-500',
696
+ },
697
+ {
698
+ name: 'image.png',
699
+ title: 'Image/PNG',
700
+ icon: 'fa-light fa-image ax-text-purple-500',
701
+ },
702
+ {
703
+ name: 'image.gif',
704
+ title: 'Image/GIF',
705
+ icon: 'fa-light fa-image ax-text-purple-500',
706
+ },
707
+ ],
708
+ context: {
709
+ image: {
710
+ width: '22',
711
+ height: '33',
712
+ },
713
+ gift: {
714
+ duration: '11',
715
+ },
592
716
  },
593
717
  },
594
718
  },
595
- },
596
- {
597
- id: AXPDataGenerator$1.uuid(),
598
- name: 'WHS',
599
- title: 'Workplace Health and Safety Guidelines',
600
- maxSize: 10000,
601
- isEncrypted: true,
602
- meta: [{ name: 'external', title: 'External', interface: '' }],
603
- type: {
604
- selectedItems: [
605
- {
606
- name: 'audio.mp3',
607
- title: 'MP3',
608
- icon: 'fa-light fa-file-audio ax-text-green-500',
609
- },
610
- {
611
- name: 'audio.wav',
612
- title: 'WAV',
613
- icon: 'fa-light fa-file-audio ax-text-green-500',
614
- },
615
- ],
616
- context: {
617
- audio: {
618
- bitrate: '320',
619
- duration: '180',
719
+ {
720
+ id: AXPDataGenerator$1.uuid(),
721
+ name: 'any',
722
+ title: 'Any Document',
723
+ maxSize: 50000,
724
+ isEncrypted: false,
725
+ isMultiple: false,
726
+ meta: [],
727
+ type: {
728
+ selectedItems: [],
729
+ context: {
730
+ audio: {
731
+ bitrate: '320',
732
+ duration: '180',
733
+ },
620
734
  },
621
735
  },
622
736
  },
623
- },
624
- ];
737
+ ];
738
+ }
625
739
 
626
740
  class AXCDocumentTypeDataSeeder {
627
741
  constructor() {
742
+ this.injector = inject(Injector);
628
743
  this.storageService = inject(AXPDexieEntityStorageService);
629
744
  }
630
745
  async seed() {
746
+ const DocumentTypeMocks = await DocumentTypeMockGenerator(this.injector);
631
747
  await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.documentType.name}`, DocumentTypeMocks);
632
748
  }
633
749
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCDocumentTypeDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -637,8 +753,242 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
637
753
  type: Injectable
638
754
  }] });
639
755
 
756
+ class AXMFolderMockService extends AXMFolderServiceImpl {
757
+ async updateParentFolders(folder) {
758
+ if (folder.parentId) {
759
+ const parent = await this.getOne(folder.parentId);
760
+ if (parent && parent.id) {
761
+ if (!parent.folders) {
762
+ parent.folders = [];
763
+ }
764
+ const existingIndex = parent.folders.findIndex((f) => f.id === folder.id);
765
+ if (existingIndex === -1) {
766
+ parent.folders.push(folder);
767
+ }
768
+ else {
769
+ parent.folders[existingIndex] = folder;
770
+ }
771
+ await super.updateOne(parent.id, { folders: parent.folders });
772
+ await this.updateParentFolders(parent);
773
+ }
774
+ }
775
+ }
776
+ async removeFromParent(folder) {
777
+ if (folder.parentId) {
778
+ const parent = await this.getOne(folder.parentId);
779
+ if (parent && parent.id && parent.folders) {
780
+ parent.folders = parent.folders.filter((f) => f.id !== folder.id);
781
+ await super.updateOne(parent.id, { folders: parent.folders });
782
+ await this.updateParentFolders(parent);
783
+ }
784
+ }
785
+ }
786
+ async insertOne(request) {
787
+ const newId = await super.insertOne(request);
788
+ const folderData = {
789
+ ...request,
790
+ id: newId,
791
+ };
792
+ await this.updateParentFolders(folderData);
793
+ return newId;
794
+ }
795
+ async updateOne(id, values) {
796
+ const currentFolder = await this.getOne(id);
797
+ const updatedFolder = await super.updateOne(id, values);
798
+ if (currentFolder && values.parentId !== undefined && currentFolder.parentId !== values.parentId) {
799
+ await this.removeFromParent(currentFolder);
800
+ }
801
+ await this.updateParentFolders(updatedFolder);
802
+ return updatedFolder;
803
+ }
804
+ async deleteOne(id) {
805
+ const folderToDelete = await this.getOne(id);
806
+ if (folderToDelete) {
807
+ await this.removeFromParent(folderToDelete);
808
+ await super.deleteOne(id);
809
+ }
810
+ }
811
+ async getPath(folderId) {
812
+ const path = [];
813
+ let currentId = folderId;
814
+ while (currentId) {
815
+ const folder = await this.getOne(currentId);
816
+ if (!folder) {
817
+ // Folder not found in persisted storage
818
+ break;
819
+ }
820
+ path.push(folder);
821
+ currentId = folder.parentId ?? null;
822
+ }
823
+ return path.reverse();
824
+ }
825
+ async getOne(id) {
826
+ const folder = await super.getOne(id);
827
+ if (folder) {
828
+ folder.nodeCount = (folder.folders?.length ?? 0) + (folder.documents?.length ?? 0);
829
+ folder.folders?.forEach((f) => {
830
+ f.nodeCount = (f.folders?.length ?? 0) + (f.documents?.length ?? 0);
831
+ });
832
+ }
833
+ return folder;
834
+ }
835
+ /**
836
+ * Search folders with specified name using recursive method
837
+ * @param searchTerm search term
838
+ * @param rootFolderId ID of the root folder to start the search
839
+ */
840
+ async searchFolders(searchTerm, rootFolderId) {
841
+ const result = [];
842
+ await this.searchFoldersRecursive(searchTerm, rootFolderId, result);
843
+ return result;
844
+ }
845
+ /**
846
+ * Recursive folder search
847
+ * @param searchTerm search term
848
+ * @param folderId current folder ID
849
+ * @param result results array
850
+ */
851
+ async searchFoldersRecursive(searchTerm, folderId, result) {
852
+ try {
853
+ // Get current folder
854
+ const currentFolder = await this.getOne(folderId);
855
+ if (!currentFolder) {
856
+ return;
857
+ }
858
+ // Check subfolders
859
+ const subFolders = currentFolder.folders || [];
860
+ // Add folders that match the search term
861
+ for (const folder of subFolders) {
862
+ if (folder.name.toLowerCase().includes(searchTerm.toLowerCase())) {
863
+ result.push(folder);
864
+ }
865
+ // Recursive search in subfolders
866
+ if (folder.id) {
867
+ await this.searchFoldersRecursive(searchTerm, folder.id, result);
868
+ }
869
+ }
870
+ }
871
+ catch (error) {
872
+ console.error('Error searching folders:', error);
873
+ }
874
+ }
875
+ }
876
+
877
+ class AXMFileMockService extends AXMDocumentServiceImpl {
878
+ constructor() {
879
+ super();
880
+ this.folderService = new AXMFolderMockService();
881
+ }
882
+ async updateParentFolder(file) {
883
+ if (!file.parentId) {
884
+ throw new Error('File must have a parent folder');
885
+ }
886
+ const parent = await this.folderService.getOne(file.parentId);
887
+ if (parent && parent.id) {
888
+ if (!parent.documents) {
889
+ parent.documents = [];
890
+ }
891
+ const existingIndex = parent.documents.findIndex((f) => f.id === file.id);
892
+ if (existingIndex === -1) {
893
+ parent.documents.push(file);
894
+ }
895
+ else {
896
+ parent.documents[existingIndex] = file;
897
+ }
898
+ await this.folderService.updateOne(parent.id, { documents: parent.documents });
899
+ }
900
+ }
901
+ async removeFromParent(file) {
902
+ if (!file.parentId) {
903
+ throw new Error('File must have a parent folder');
904
+ }
905
+ const parent = await this.folderService.getOne(file.parentId);
906
+ if (parent && parent.id && parent.documents) {
907
+ parent.documents = parent.documents.filter((f) => f.id !== file.id);
908
+ await this.folderService.updateOne(parent.id, { documents: parent.documents });
909
+ }
910
+ }
911
+ async insertOne(request) {
912
+ if (!request.parentId) {
913
+ throw new Error('File must have a parent folder');
914
+ }
915
+ const newId = await super.insertOne(request);
916
+ const fileData = {
917
+ ...request,
918
+ id: newId,
919
+ };
920
+ await this.updateParentFolder(fileData);
921
+ return newId;
922
+ }
923
+ async updateOne(id, values) {
924
+ const currentFile = await this.getOne(id);
925
+ const updatedFile = await super.updateOne(id, values);
926
+ if (currentFile && values.parentId !== undefined && currentFile.parentId !== values.parentId) {
927
+ await this.removeFromParent(currentFile);
928
+ }
929
+ await this.updateParentFolder(updatedFile);
930
+ return updatedFile;
931
+ }
932
+ async deleteOne(id) {
933
+ const fileToDelete = await this.getOne(id);
934
+ if (fileToDelete) {
935
+ await this.removeFromParent(fileToDelete);
936
+ await super.deleteOne(id);
937
+ }
938
+ }
939
+ async getPath(documentId) {
940
+ const file = await this.getOne(documentId);
941
+ if (!file) {
942
+ throw new Error('File not found');
943
+ }
944
+ return await this.folderService.getPath(file.parentId);
945
+ }
946
+ /**
947
+ * جستجوی فایل‌ها با نام مشخص شده با استفاده از روش بازگشتی
948
+ * @param searchTerm عبارت جستجو
949
+ * @param rootFolderId شناسه فولدر ریشه برای شروع جستجو
950
+ */
951
+ async searchFiles(searchTerm, rootFolderId) {
952
+ const result = [];
953
+ await this.searchFilesRecursive(searchTerm, rootFolderId, result);
954
+ return result;
955
+ }
956
+ /**
957
+ * جستجوی بازگشتی فایل‌ها
958
+ * @param searchTerm عبارت جستجو
959
+ * @param folderId شناسه فولدر فعلی
960
+ * @param result آرایه نتایج
961
+ */
962
+ async searchFilesRecursive(searchTerm, folderId, result) {
963
+ try {
964
+ const currentFolder = await this.folderService.getOne(folderId);
965
+ if (!currentFolder) {
966
+ return;
967
+ }
968
+ const files = currentFolder.documents || [];
969
+ for (const file of files) {
970
+ if (file.name.toLowerCase().includes(searchTerm.toLowerCase())) {
971
+ result.push(file);
972
+ }
973
+ }
974
+ const subFolders = currentFolder.folders || [];
975
+ for (const folder of subFolders) {
976
+ if (folder.id) {
977
+ await this.searchFilesRecursive(searchTerm, folder.id, result);
978
+ }
979
+ }
980
+ }
981
+ catch (error) {
982
+ console.error('Error searching files:', error);
983
+ }
984
+ }
985
+ }
986
+
640
987
  const allFolders = [];
641
988
  const allFiles = [];
989
+ function getRandomSize() {
990
+ return AXPDataGenerator$1.number(500 * 1024, 10 * 1024 * 1024);
991
+ }
642
992
  const rootFolder = {
643
993
  id: AXPDataGenerator$1.uuid(),
644
994
  name: 'WHS Documentation',
@@ -652,6 +1002,7 @@ const rootFolder = {
652
1002
  updatedAt: new Date(),
653
1003
  createdBy: 'system',
654
1004
  updatedBy: 'system',
1005
+ size: getRandomSize(),
655
1006
  folders: [],
656
1007
  documents: [],
657
1008
  };
@@ -741,6 +1092,7 @@ sites.forEach((site) => {
741
1092
  id: siteFolderId,
742
1093
  name: site,
743
1094
  color: '#FFFFFF',
1095
+ size: getRandomSize(),
744
1096
  description: `WHS Documentation for ${site}`,
745
1097
  parentId: rootFolder.id,
746
1098
  isSystem: false,
@@ -762,6 +1114,7 @@ sites.forEach((site) => {
762
1114
  id: roleFolderId,
763
1115
  name: role,
764
1116
  color: '#FFFFFF',
1117
+ size: getRandomSize(),
765
1118
  description: `${role} Documentation`,
766
1119
  parentId: siteFolder.id,
767
1120
  isSystem: false,
@@ -784,6 +1137,15 @@ sites.forEach((site) => {
784
1137
  name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
785
1138
  title: title,
786
1139
  parentId: roleFolderId,
1140
+ size: getRandomSize(),
1141
+ createdAt: new Date(),
1142
+ updatedAt: new Date(),
1143
+ createdBy: 'system',
1144
+ updatedBy: 'system',
1145
+ fileId: `${window.location.origin}/assets/temp/${fileType.ext}/${Math.floor(Math.random() * 3) + 1}.${fileType.ext}`,
1146
+ meta: {
1147
+ type: fileType.ext == 'png' || fileType.ext == 'jpg' ? 'image' : fileType.ext,
1148
+ },
787
1149
  };
788
1150
  allFiles.push(file);
789
1151
  roleFolder.documents?.push(file);
@@ -799,6 +1161,7 @@ sites.forEach((site) => {
799
1161
  id: deptFolderId,
800
1162
  name: dept.name,
801
1163
  color: '#' + Math.floor(Math.random() * 16777215).toString(16),
1164
+ size: getRandomSize(),
802
1165
  description: `${dept.name} documentation`,
803
1166
  parentId: siteFolder.id,
804
1167
  isSystem: false,
@@ -813,11 +1176,21 @@ sites.forEach((site) => {
813
1176
  documents: [],
814
1177
  };
815
1178
  dept.commonFiles.forEach((fileName) => {
1179
+ const [name, extension] = fileName.split('.');
816
1180
  const file = {
817
1181
  id: AXPDataGenerator$1.uuid(),
818
1182
  name: fileName,
819
- title: fileName.split('.')[0],
1183
+ title: name,
820
1184
  parentId: deptFolderId,
1185
+ size: getRandomSize(),
1186
+ createdAt: new Date(),
1187
+ updatedAt: new Date(),
1188
+ createdBy: 'system',
1189
+ updatedBy: 'system',
1190
+ fileId: `${window.location.origin}/assets/temp/${extension}/${Math.floor(Math.random() * 3) + 1}.${extension}`,
1191
+ meta: {
1192
+ type: extension == 'png' || extension == 'jpg' ? 'image' : extension,
1193
+ },
821
1194
  };
822
1195
  allFiles.push(file);
823
1196
  deptFolder.documents?.push(file);
@@ -828,6 +1201,7 @@ sites.forEach((site) => {
828
1201
  id: subFolderId,
829
1202
  name: subFolderName,
830
1203
  color: '#' + Math.floor(Math.random() * 16777215).toString(16),
1204
+ size: getRandomSize(),
831
1205
  description: `${subFolderName} documentation`,
832
1206
  parentId: deptFolderId,
833
1207
  isSystem: false,
@@ -849,6 +1223,15 @@ sites.forEach((site) => {
849
1223
  name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
850
1224
  title: title,
851
1225
  parentId: subFolderId,
1226
+ fileId: `${window.location.origin}/assets/temp/${fileType.ext}/${Math.floor(Math.random() * 3) + 1}.${fileType.ext}`,
1227
+ size: getRandomSize(),
1228
+ createdAt: new Date(),
1229
+ updatedAt: new Date(),
1230
+ createdBy: 'system',
1231
+ updatedBy: 'system',
1232
+ meta: {
1233
+ type: fileType.ext == 'png' || fileType.ext == 'jpg' ? 'image' : fileType.ext,
1234
+ },
852
1235
  };
853
1236
  allFiles.push(file);
854
1237
  subFolder.documents?.push(file);
@@ -868,247 +1251,13 @@ allFolders.push(rootFolder);
868
1251
  const FOLDER_MOCK_DATA = allFolders;
869
1252
  const FILE_MOCK_DATA = allFiles;
870
1253
 
871
- class AXCFileDataSeeder {
872
- constructor() {
873
- this.storageService = inject(AXPDexieEntityStorageService);
874
- }
875
- async seed() {
876
- await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.document.name}`, FILE_MOCK_DATA);
877
- }
878
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
879
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder }); }
880
- }
881
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder, decorators: [{
882
- type: Injectable
883
- }] });
884
-
885
- class AXMFolderMockService extends AXMFolderServiceImpl {
886
- async updateParentFolders(folder) {
887
- if (folder.parentId) {
888
- const parent = await this.getOne(folder.parentId);
889
- if (parent && parent.id) {
890
- if (!parent.folders) {
891
- parent.folders = [];
892
- }
893
- const existingIndex = parent.folders.findIndex((f) => f.id === folder.id);
894
- if (existingIndex === -1) {
895
- parent.folders.push(folder);
896
- }
897
- else {
898
- parent.folders[existingIndex] = folder;
899
- }
900
- await super.updateOne(parent.id, { folders: parent.folders });
901
- await this.updateParentFolders(parent);
902
- }
903
- }
904
- }
905
- async removeFromParent(folder) {
906
- if (folder.parentId) {
907
- const parent = await this.getOne(folder.parentId);
908
- if (parent && parent.id && parent.folders) {
909
- parent.folders = parent.folders.filter((f) => f.id !== folder.id);
910
- await super.updateOne(parent.id, { folders: parent.folders });
911
- await this.updateParentFolders(parent);
912
- }
913
- }
914
- }
915
- async insertOne(request) {
916
- const newId = await super.insertOne(request);
917
- const folderData = {
918
- ...request,
919
- id: newId,
920
- };
921
- await this.updateParentFolders(folderData);
922
- return newId;
923
- }
924
- async updateOne(id, values) {
925
- const currentFolder = await this.getOne(id);
926
- const updatedFolder = await super.updateOne(id, values);
927
- if (currentFolder && values.parentId !== undefined && currentFolder.parentId !== values.parentId) {
928
- await this.removeFromParent(currentFolder);
929
- }
930
- await this.updateParentFolders(updatedFolder);
931
- return updatedFolder;
932
- }
933
- async deleteOne(id) {
934
- const folderToDelete = await this.getOne(id);
935
- if (folderToDelete) {
936
- await this.removeFromParent(folderToDelete);
937
- await super.deleteOne(id);
938
- }
939
- }
940
- async getPath(folderId) {
941
- const path = [];
942
- let currentId = folderId;
943
- while (currentId) {
944
- const folder = await this.getOne(currentId);
945
- if (!folder) {
946
- // Folder not found in persisted storage
947
- break;
948
- }
949
- path.push(folder);
950
- currentId = folder.parentId ?? null;
951
- }
952
- return path.reverse();
953
- }
954
- /**
955
- * جستجوی فولدرها با نام مشخص شده با استفاده از روش بازگشتی
956
- * @param searchTerm عبارت جستجو
957
- * @param rootFolderId شناسه فولدر ریشه برای شروع جستجو
958
- */
959
- async searchFolders(searchTerm, rootFolderId) {
960
- const result = [];
961
- await this.searchFoldersRecursive(searchTerm, rootFolderId, result);
962
- return result;
963
- }
964
- /**
965
- * جستجوی بازگشتی فولدرها
966
- * @param searchTerm عبارت جستجو
967
- * @param folderId شناسه فولدر فعلی
968
- * @param result آرایه نتایج
969
- */
970
- async searchFoldersRecursive(searchTerm, folderId, result) {
971
- try {
972
- // دریافت فولدر فعلی
973
- const currentFolder = await this.getOne(folderId);
974
- if (!currentFolder) {
975
- return;
976
- }
977
- // بررسی زیرفولدرها
978
- const subFolders = currentFolder.folders || [];
979
- // افزودن فولدرهایی که با عبارت جستجو مطابقت دارند
980
- for (const folder of subFolders) {
981
- if (folder.name.toLowerCase().includes(searchTerm.toLowerCase())) {
982
- result.push(folder);
983
- }
984
- // جستجوی بازگشتی در زیرفولدرها
985
- if (folder.id) {
986
- await this.searchFoldersRecursive(searchTerm, folder.id, result);
987
- }
988
- }
989
- }
990
- catch (error) {
991
- console.error('Error searching folders:', error);
992
- }
993
- }
994
- }
995
-
996
- class AXMFileMockService extends AXMDocumentServiceImpl {
997
- constructor() {
998
- super();
999
- this.folderService = new AXMFolderMockService();
1000
- }
1001
- async updateParentFolder(file) {
1002
- if (!file.parentId) {
1003
- throw new Error('File must have a parent folder');
1004
- }
1005
- const parent = await this.folderService.getOne(file.parentId);
1006
- if (parent && parent.id) {
1007
- if (!parent.documents) {
1008
- parent.documents = [];
1009
- }
1010
- const existingIndex = parent.documents.findIndex((f) => f.id === file.id);
1011
- if (existingIndex === -1) {
1012
- parent.documents.push(file);
1013
- }
1014
- else {
1015
- parent.documents[existingIndex] = file;
1016
- }
1017
- await this.folderService.updateOne(parent.id, { documents: parent.documents });
1018
- }
1019
- }
1020
- async removeFromParent(file) {
1021
- if (!file.parentId) {
1022
- throw new Error('File must have a parent folder');
1023
- }
1024
- const parent = await this.folderService.getOne(file.parentId);
1025
- if (parent && parent.id && parent.documents) {
1026
- parent.documents = parent.documents.filter((f) => f.id !== file.id);
1027
- await this.folderService.updateOne(parent.id, { documents: parent.documents });
1028
- }
1029
- }
1030
- async insertOne(request) {
1031
- if (!request.parentId) {
1032
- throw new Error('File must have a parent folder');
1033
- }
1034
- const newId = await super.insertOne(request);
1035
- const fileData = {
1036
- ...request,
1037
- id: newId,
1038
- };
1039
- await this.updateParentFolder(fileData);
1040
- return newId;
1041
- }
1042
- async updateOne(id, values) {
1043
- const currentFile = await this.getOne(id);
1044
- const updatedFile = await super.updateOne(id, values);
1045
- if (currentFile && values.parentId !== undefined && currentFile.parentId !== values.parentId) {
1046
- await this.removeFromParent(currentFile);
1047
- }
1048
- await this.updateParentFolder(updatedFile);
1049
- return updatedFile;
1050
- }
1051
- async deleteOne(id) {
1052
- const fileToDelete = await this.getOne(id);
1053
- if (fileToDelete) {
1054
- await this.removeFromParent(fileToDelete);
1055
- await super.deleteOne(id);
1056
- }
1057
- }
1058
- async getPath(documentId) {
1059
- const file = await this.getOne(documentId);
1060
- if (!file) {
1061
- throw new Error('File not found');
1062
- }
1063
- return await this.folderService.getPath(file.parentId);
1064
- }
1065
- /**
1066
- * جستجوی فایل‌ها با نام مشخص شده با استفاده از روش بازگشتی
1067
- * @param searchTerm عبارت جستجو
1068
- * @param rootFolderId شناسه فولدر ریشه برای شروع جستجو
1069
- */
1070
- async searchFiles(searchTerm, rootFolderId) {
1071
- const result = [];
1072
- await this.searchFilesRecursive(searchTerm, rootFolderId, result);
1073
- return result;
1074
- }
1075
- /**
1076
- * جستجوی بازگشتی فایل‌ها
1077
- * @param searchTerm عبارت جستجو
1078
- * @param folderId شناسه فولدر فعلی
1079
- * @param result آرایه نتایج
1080
- */
1081
- async searchFilesRecursive(searchTerm, folderId, result) {
1082
- try {
1083
- const currentFolder = await this.folderService.getOne(folderId);
1084
- if (!currentFolder) {
1085
- return;
1086
- }
1087
- const files = currentFolder.documents || [];
1088
- for (const file of files) {
1089
- if (file.name.toLowerCase().includes(searchTerm.toLowerCase())) {
1090
- result.push(file);
1091
- }
1092
- }
1093
- const subFolders = currentFolder.folders || [];
1094
- for (const folder of subFolders) {
1095
- if (folder.id) {
1096
- await this.searchFilesRecursive(searchTerm, folder.id, result);
1097
- }
1098
- }
1099
- }
1100
- catch (error) {
1101
- console.error('Error searching files:', error);
1102
- }
1103
- }
1104
- }
1105
-
1106
1254
  class AXCFolderDataSeeder {
1107
1255
  constructor() {
1108
1256
  this.storageService = inject(AXPDexieEntityStorageService);
1109
1257
  }
1110
1258
  async seed() {
1111
1259
  await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.folder.name}`, FOLDER_MOCK_DATA);
1260
+ await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.document.name}`, FILE_MOCK_DATA);
1112
1261
  }
1113
1262
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1114
1263
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder }); }
@@ -2528,9 +2677,9 @@ class AXCFileStorageService {
2528
2677
  size: request.file.size,
2529
2678
  mimeType: request.file.type,
2530
2679
  uploadedAt: new Date(),
2531
- isPublic: request.metadata?.["isPublic"] || true,
2680
+ isPublic: request.metadata?.['isPublic'] || true,
2532
2681
  isPrimary: request.isPrimary || false,
2533
- status: AXPFileStorageStatus.Temporary, // Use enum
2682
+ status: request.status ?? AXPFileStorageStatus.Temporary, // Use enum
2534
2683
  };
2535
2684
  // Save the binary content along with metadata in Dexie
2536
2685
  await db.files.add({ ...fileInfo, binary: request.file });
@@ -2575,8 +2724,7 @@ class AXCFileStorageService {
2575
2724
  (!request.isPublic || file.isPublic === request.isPublic) &&
2576
2725
  (!request.mimeType || file.mimeType === request.mimeType) &&
2577
2726
  (!request.uploadedAtRange ||
2578
- (file.uploadedAt >= request.uploadedAtRange.from &&
2579
- file.uploadedAt <= request.uploadedAtRange.to)) &&
2727
+ (file.uploadedAt >= request.uploadedAtRange.from && file.uploadedAt <= request.uploadedAtRange.to)) &&
2580
2728
  file.status === AXPFileStorageStatus.Committed // Use enum
2581
2729
  );
2582
2730
  });
@@ -2626,22 +2774,73 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
2626
2774
  type: Injectable
2627
2775
  }], ctorParameters: () => [] });
2628
2776
 
2777
+ const OHS_ID = AXPDataGenerator$1.uuid();
2778
+ const METADATA_CATEGORY_MOCK = [
2779
+ {
2780
+ id: AXPDataGenerator$1.uuid(),
2781
+ title: 'General',
2782
+ },
2783
+ {
2784
+ id: OHS_ID,
2785
+ title: 'OHS',
2786
+ },
2787
+ {
2788
+ id: AXPDataGenerator$1.uuid(),
2789
+ title: 'General',
2790
+ parentId: OHS_ID,
2791
+ },
2792
+ {
2793
+ id: AXPDataGenerator$1.uuid(),
2794
+ title: 'License',
2795
+ parentId: OHS_ID,
2796
+ },
2797
+ ];
2629
2798
  const checkbox = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"checkbox-editor","name":"checkbox-editor1","options":{"label":"i accept","readonly":false,"disabled":false},"defaultValue":false,"path":"accept-check-box"}],"name":"page-layout1"}],"name":"document"}';
2630
2799
  const color = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"block-layout","name":"block-layout1","options":{"flexDirection":{"id":"ax-flex-row"},"flexJustifyContent":{"id":"ax-justify-normal"},"flexAlignItems":{"id":"ax-items-start"},"gap":2,"flexWrap":{"id":"ax-flex-nowrap"},"spacing":{"margin":"0px 0px 0px 0px","padding":"0px 0px 0px 0px"},"border":{"width":"0px","radius":"0px","color":"#000000","style":"none"},"flexOptions":{"gap":"0px","flexDirection":"row","flexWrap":"nowrap","justifyContent":"flex-start","alignItems":"flex-start"}}},"children":[{"type":"color-editor","name":"color-editor1","options":{"readonly":false,"disabled":false,"validations":{"required":{"rule":"required","message":"This field is required."}},"placeholder":"pick color"},"path":"color-box"}]}],"name":"page-layout1"}],"name":"document"}';
2800
+ const titleInterface = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"title-editor","name":"title-editor1","meta":{"header":true},"options":{"multiple":false,"disabled":false,"hasClearButton":false,"validations":{"regex":null,"required":{"rule":"required","message":"This field is required."}}},"defaultValue":"","path":"title"}],"name":"page-layout1"}],"name":"document"}';
2801
+ const descriptionInterface = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"description-editor","name":"description-editor1","meta":{"header":true},"options":{"multiple":false,"disabled":false,"hasClearButton":false},"defaultValue":"","path":"description"}],"name":"page-layout1"}],"name":"document"}';
2802
+ const contractNumberInterface = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"number-editor","name":"number-editor1","meta":{"header":true},"options":{"multiple":false,"disabled":false,"hasClearButton":false},"defaultValue":"","path":"contract-number"}],"name":"page-layout1"}],"name":"document"}';
2803
+ const evaluatorInterface = '{"type":"document-layout","children":[{"type":"page-layout","children":[{"type":"text-editor","name":"text-editor1","meta":{"header":true},"options":{"multiple":false,"disabled":false,"hasClearButton":false},"defaultValue":"","path":"evaluator"}],"name":"page-layout1"}],"name":"document"}';
2631
2804
  const METADATA_MOCK = [
2632
2805
  {
2633
2806
  id: AXPDataGenerator$1.uuid(),
2634
- name: 'checkbox',
2635
- title: 'Checkbox',
2807
+ name: 'title',
2808
+ title: 'Title',
2809
+ defaultValue: '',
2810
+ interface: titleInterface,
2811
+ categoryId: METADATA_CATEGORY_MOCK[0].id,
2812
+ },
2813
+ {
2814
+ id: AXPDataGenerator$1.uuid(),
2815
+ name: 'description',
2816
+ title: 'Description',
2817
+ defaultValue: '',
2818
+ interface: descriptionInterface,
2819
+ categoryId: METADATA_CATEGORY_MOCK[0].id,
2820
+ },
2821
+ {
2822
+ id: AXPDataGenerator$1.uuid(),
2823
+ name: 'agreement-check-box',
2824
+ title: 'Agreement Box',
2636
2825
  defaultValue: false,
2637
2826
  interface: checkbox,
2827
+ categoryId: METADATA_CATEGORY_MOCK[2].id,
2828
+ },
2829
+ {
2830
+ id: AXPDataGenerator$1.uuid(),
2831
+ name: 'contract-number',
2832
+ title: 'Contract Number',
2833
+ defaultValue: '',
2834
+ interface: contractNumberInterface,
2835
+ categoryId: METADATA_CATEGORY_MOCK[2].id,
2638
2836
  },
2639
2837
  {
2640
2838
  id: AXPDataGenerator$1.uuid(),
2641
- name: 'color',
2642
- title: 'Color',
2643
- defaultValue: '#000000',
2644
- interface: color,
2839
+ name: 'evaluator',
2840
+ title: 'Evaluator',
2841
+ defaultValue: '',
2842
+ interface: evaluatorInterface,
2843
+ categoryId: METADATA_CATEGORY_MOCK[3].id,
2645
2844
  },
2646
2845
  ];
2647
2846
 
@@ -2650,6 +2849,7 @@ class AXCMetaDataDefinitionDataSeeder {
2650
2849
  this.storageService = inject(AXPDexieEntityStorageService);
2651
2850
  }
2652
2851
  async seed() {
2852
+ await this.storageService.initial(`${RootConfig$5.module.name}.${RootConfig$5.entities.metaDataDefinitionCategory.name}`, METADATA_CATEGORY_MOCK);
2653
2853
  await this.storageService.initial(`${RootConfig$5.module.name}.${RootConfig$5.entities.metaDataDefinition.name}`, METADATA_MOCK);
2654
2854
  }
2655
2855
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCMetaDataDefinitionDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -3264,11 +3464,6 @@ class AXCMockModule {
3264
3464
  useClass: AXCDocumentTypeDataSeeder,
3265
3465
  multi: true,
3266
3466
  },
3267
- {
3268
- provide: AXP_DATA_SEEDER_TOKEN,
3269
- useClass: AXCFileDataSeeder,
3270
- multi: true,
3271
- },
3272
3467
  {
3273
3468
  provide: AXPModuleDesignerService,
3274
3469
  useClass: AXCModuleDesignerService,
@@ -3386,11 +3581,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3386
3581
  useClass: AXCDocumentTypeDataSeeder,
3387
3582
  multi: true,
3388
3583
  },
3389
- {
3390
- provide: AXP_DATA_SEEDER_TOKEN,
3391
- useClass: AXCFileDataSeeder,
3392
- multi: true,
3393
- },
3394
3584
  {
3395
3585
  provide: AXPModuleDesignerService,
3396
3586
  useClass: AXCModuleDesignerService,