cat-documents-ng 1.0.6 → 1.0.8
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/README.md +322 -322
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
- package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
- package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
- package/Shared/constant/ERROR.d.ts +52 -0
- package/Shared/constant/SHARED.d.ts +546 -0
- package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +25 -31
- package/Shared/services/app-config.service.d.ts +51 -0
- package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
- package/Shared/services/session.service.d.ts +46 -0
- package/Shared/shared.module.d.ts +14 -0
- package/fesm2022/cat-documents-ng.mjs +11405 -0
- package/fesm2022/cat-documents-ng.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
- package/lib/document/components/document-container/document-container.component.d.ts +162 -0
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
- package/lib/document/components/document-history/document-history.component.d.ts +160 -0
- package/lib/document/components/document-list/document-list.component.d.ts +299 -0
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
- package/lib/document/components/document-search/document-search.component.d.ts +77 -0
- package/lib/document/components/document-status/document-status.component.d.ts +24 -0
- package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
- package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -28
- package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
- package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
- package/lib/document/components/request-document/request-document.component.d.ts +69 -0
- package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
- package/lib/document/components/user-list/user-list.component.d.ts +34 -0
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
- package/lib/document/directives/document.directive.d.ts +20 -0
- package/lib/document/directives/permission.directive.d.ts +38 -0
- package/lib/document/document.module.d.ts +60 -0
- package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +4 -11
- package/lib/document/models/document-category.model.d.ts +24 -0
- package/lib/document/models/document-history.model.d.ts +94 -0
- package/lib/document/models/document-list-response.model.d.ts +33 -0
- package/lib/document/models/document-type.model.d.ts +37 -0
- package/lib/document/models/document.model.d.ts +44 -0
- package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +4 -10
- package/lib/document/models/status-data.model.d.ts +27 -0
- package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
- package/lib/document/models/user-list.model.d.ts +8 -0
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-actions.service.d.ts +48 -0
- package/lib/document/services/document-content-type.service.d.ts +85 -0
- package/lib/document/services/document-history-style.service.d.ts +34 -0
- package/lib/document/services/document-history.service.d.ts +42 -0
- package/lib/document/services/document-http.service.d.ts +179 -0
- package/lib/document/services/document-list.service.d.ts +74 -0
- package/lib/document/services/document-menu.service.d.ts +122 -0
- package/lib/document/services/document-scroll.service.d.ts +55 -0
- package/lib/document/services/document-table-builder.service.d.ts +38 -0
- package/lib/document/services/document-upload-business.service.d.ts +107 -0
- package/lib/document/services/document-upload-data.service.d.ts +40 -0
- package/lib/document/services/document-upload-form.service.d.ts +41 -0
- package/lib/document/services/document-upload.service.d.ts +99 -0
- package/lib/document/services/document-viewer.service.d.ts +97 -0
- package/lib/document/services/document-zoom.service.d.ts +81 -0
- package/lib/document/services/document.service.d.ts +161 -0
- package/lib/document/services/eml-parser.service.d.ts +116 -0
- package/lib/document/services/excel-parser.service.d.ts +169 -0
- package/lib/document/services/file-format.service.d.ts +34 -0
- package/lib/document/services/status-calculator.service.d.ts +20 -0
- package/lib/document/services/user-list.service.d.ts +29 -0
- package/lib/document/state/document.query.d.ts +243 -0
- package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
- package/lib/document/state/document.state.d.ts +61 -0
- package/lib/document/state/document.store.d.ts +56 -0
- package/package.json +11 -5
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -10
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +0 -3
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +0 -13
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -70
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +0 -133
- package/src/Shared/components/table-primary/table-primary.component.html +0 -66
- package/src/Shared/components/table-primary/table-primary.component.scss +0 -227
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +0 -23
- package/src/Shared/components/table-primary/table-primary.component.ts +0 -143
- package/src/Shared/components/table-primary/table-primary.model.ts +0 -21
- package/src/Shared/constant/ERROR.ts +0 -55
- package/src/Shared/constant/PERMISSIONS.ts +0 -17
- package/src/Shared/constant/SHARED.ts +0 -936
- package/src/Shared/services/app-config.service.spec.ts +0 -19
- package/src/Shared/services/app-config.service.ts +0 -73
- package/src/Shared/services/session.service.spec.ts +0 -16
- package/src/Shared/services/session.service.ts +0 -76
- package/src/Shared/shared.module.ts +0 -25
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +0 -1
- package/src/lib/document/components/document-actions/document-actions.component.html +0 -59
- package/src/lib/document/components/document-actions/document-actions.component.scss +0 -362
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +0 -297
- package/src/lib/document/components/document-actions/document-actions.component.ts +0 -163
- package/src/lib/document/components/document-container/document-container.component.html +0 -36
- package/src/lib/document/components/document-container/document-container.component.scss +0 -144
- package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
- package/src/lib/document/components/document-container/document-container.component.ts +0 -363
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +0 -332
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +0 -1877
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +0 -258
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +0 -664
- package/src/lib/document/components/document-history/document-history.component.html +0 -96
- package/src/lib/document/components/document-history/document-history.component.scss +0 -392
- package/src/lib/document/components/document-history/document-history.component.spec.ts +0 -93
- package/src/lib/document/components/document-history/document-history.component.ts +0 -373
- package/src/lib/document/components/document-list/document-list.component.html +0 -46
- package/src/lib/document/components/document-list/document-list.component.scss +0 -513
- package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -486
- package/src/lib/document/components/document-list/document-list.component.ts +0 -682
- package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
- package/src/lib/document/components/document-search/document-search.component.html +0 -64
- package/src/lib/document/components/document-search/document-search.component.scss +0 -206
- package/src/lib/document/components/document-search/document-search.component.spec.ts +0 -82
- package/src/lib/document/components/document-search/document-search.component.ts +0 -163
- package/src/lib/document/components/document-status/document-status.component.html +0 -31
- package/src/lib/document/components/document-status/document-status.component.scss +0 -192
- package/src/lib/document/components/document-status/document-status.component.spec.ts +0 -23
- package/src/lib/document/components/document-status/document-status.component.ts +0 -87
- package/src/lib/document/components/document-upload/document-upload.component.html +0 -160
- package/src/lib/document/components/document-upload/document-upload.component.scss +0 -235
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
- package/src/lib/document/components/document-upload/document-upload.component.ts +0 -668
- package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -50
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -187
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -261
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +0 -48
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +0 -320
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +0 -59
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +0 -150
- package/src/lib/document/components/documents-menu/documents-menu.component.html +0 -44
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +0 -363
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +0 -23
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +0 -316
- package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
- package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
- package/src/lib/document/components/folder-container/folder-container.component.html +0 -56
- package/src/lib/document/components/folder-container/folder-container.component.scss +0 -20
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
- package/src/lib/document/components/folder-container/folder-container.component.ts +0 -328
- package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
- package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
- package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
- package/src/lib/document/components/request-document/request-document.component.html +0 -86
- package/src/lib/document/components/request-document/request-document.component.scss +0 -16
- package/src/lib/document/components/request-document/request-document.component.ts +0 -278
- package/src/lib/document/components/sidebar/sidebar.component.html +0 -75
- package/src/lib/document/components/sidebar/sidebar.component.scss +0 -157
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +0 -114
- package/src/lib/document/components/sidebar/sidebar.component.ts +0 -223
- package/src/lib/document/components/user-list/user-list.component.html +0 -33
- package/src/lib/document/components/user-list/user-list.component.scss +0 -118
- package/src/lib/document/components/user-list/user-list.component.spec.ts +0 -23
- package/src/lib/document/components/user-list/user-list.component.ts +0 -181
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +0 -52
- package/src/lib/document/directives/document.directive.ts +0 -32
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +0 -72
- package/src/lib/document/document.module.ts +0 -351
- package/src/lib/document/models/document-category.model.ts +0 -30
- package/src/lib/document/models/document-history.model.ts +0 -109
- package/src/lib/document/models/document-list-response.model.ts +0 -37
- package/src/lib/document/models/document-type.model.ts +0 -44
- package/src/lib/document/models/document.model.ts +0 -53
- package/src/lib/document/models/status-data.model.ts +0 -31
- package/src/lib/document/models/uploaded-file-response.model.ts +0 -7
- package/src/lib/document/models/user-list.model.ts +0 -10
- package/src/lib/document/services/csv-parser.service.spec.ts +0 -97
- package/src/lib/document/services/csv-parser.service.ts +0 -303
- package/src/lib/document/services/document-actions.service.ts +0 -125
- package/src/lib/document/services/document-content-type.service.ts +0 -193
- package/src/lib/document/services/document-history-style.service.ts +0 -138
- package/src/lib/document/services/document-history.service.ts +0 -129
- package/src/lib/document/services/document-http.service.spec.ts +0 -119
- package/src/lib/document/services/document-http.service.ts +0 -497
- package/src/lib/document/services/document-list.service.ts +0 -195
- package/src/lib/document/services/document-menu.service.ts +0 -277
- package/src/lib/document/services/document-scroll.service.ts +0 -138
- package/src/lib/document/services/document-severity.service.ts +0 -98
- package/src/lib/document/services/document-table-builder.service.ts +0 -82
- package/src/lib/document/services/document-upload-business.service.ts +0 -326
- package/src/lib/document/services/document-upload-data.service.ts +0 -82
- package/src/lib/document/services/document-upload-form.service.ts +0 -149
- package/src/lib/document/services/document-upload.service.spec.ts +0 -99
- package/src/lib/document/services/document-upload.service.ts +0 -209
- package/src/lib/document/services/document-viewer.service.ts +0 -279
- package/src/lib/document/services/document-zoom.service.spec.ts +0 -56
- package/src/lib/document/services/document-zoom.service.ts +0 -164
- package/src/lib/document/services/document.service.ts +0 -356
- package/src/lib/document/services/eml-parser.service.ts +0 -444
- package/src/lib/document/services/excel-parser.service.spec.ts +0 -66
- package/src/lib/document/services/excel-parser.service.ts +0 -483
- package/src/lib/document/services/file-format.service.spec.ts +0 -16
- package/src/lib/document/services/file-format.service.ts +0 -63
- package/src/lib/document/services/status-calculator.service.ts +0 -44
- package/src/lib/document/services/user-list.service.ts +0 -77
- package/src/lib/document/state/document.query.ts +0 -378
- package/src/lib/document/state/document.state.ts +0 -100
- package/src/lib/document/state/document.store.ts +0 -200
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { DocumentContainerComponent } from './document-container.component';
|
|
3
|
-
import { of, throwError } from 'rxjs';
|
|
4
|
-
import { DocumentHttpService } from '../../services/document-http.service';
|
|
5
|
-
import { DocumentStore } from '../../state/document.store';
|
|
6
|
-
import { DocumentQuery } from '../../state/document.query';
|
|
7
|
-
import { DocumentService } from '../../state/document.service';
|
|
8
|
-
import { CommonModule } from '@angular/common';
|
|
9
|
-
import { HttpClientModule } from '@angular/common/http';
|
|
10
|
-
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
11
|
-
import { DocumentListComponent } from '../document-list/document-list.component';
|
|
12
|
-
import { MessageService } from 'primeng/api';
|
|
13
|
-
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
14
|
-
import { DialogModule } from 'primeng/dialog';
|
|
15
|
-
|
|
16
|
-
describe('DocumentContainerComponent', () => {
|
|
17
|
-
let component: DocumentContainerComponent;
|
|
18
|
-
let fixture: ComponentFixture<DocumentContainerComponent>;
|
|
19
|
-
let mockDocumentHttpService: jasmine.SpyObj<DocumentHttpService>;
|
|
20
|
-
let mockDocumentStore: jasmine.SpyObj<DocumentStore>;
|
|
21
|
-
let mockDocumentQuery: jasmine.SpyObj<DocumentQuery>;
|
|
22
|
-
let mockDocumentService: jasmine.SpyObj<DocumentService>;
|
|
23
|
-
|
|
24
|
-
const dummyFolders = [
|
|
25
|
-
{ _id: '1', name: 'Folder A', documentCount: 2 },
|
|
26
|
-
{ _id: '2', name: 'Folder B', documentCount: 0 }
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const dummyDocuments = [
|
|
30
|
-
{ _id: 'doc1', name: 'Document 1' },
|
|
31
|
-
{ _id: 'doc2', name: 'Document 2' }
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
mockDocumentHttpService = jasmine.createSpyObj('DocumentHttpService', [
|
|
36
|
-
'getFoldersData',
|
|
37
|
-
'getDocumentByFolderID',
|
|
38
|
-
'getDocumentTypes' // ✅ Fix added here
|
|
39
|
-
]);
|
|
40
|
-
mockDocumentHttpService.getDocumentTypes.and.returnValue(of([])); // ✅ Return dummy value
|
|
41
|
-
|
|
42
|
-
mockDocumentStore = jasmine.createSpyObj('DocumentStore', ['setDocumentList']);
|
|
43
|
-
mockDocumentQuery = jasmine.createSpyObj('DocumentQuery', ['selectParentDocumentTypeId']);
|
|
44
|
-
mockDocumentService = jasmine.createSpyObj('DocumentService', ['dummy']);
|
|
45
|
-
|
|
46
|
-
await TestBed.configureTestingModule({
|
|
47
|
-
declarations: [DocumentContainerComponent, DocumentListComponent],
|
|
48
|
-
imports: [CommonModule, HttpClientModule, DialogModule],
|
|
49
|
-
providers: [
|
|
50
|
-
{ provide: DocumentHttpService, useValue: mockDocumentHttpService },
|
|
51
|
-
{ provide: DocumentStore, useValue: mockDocumentStore },
|
|
52
|
-
{ provide: DocumentQuery, useValue: mockDocumentQuery },
|
|
53
|
-
{ provide: DocumentService, useValue: mockDocumentService },
|
|
54
|
-
MessageService
|
|
55
|
-
],
|
|
56
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
57
|
-
}).compileComponents();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
fixture = TestBed.createComponent(DocumentContainerComponent);
|
|
62
|
-
component = fixture.componentInstance;
|
|
63
|
-
component.contextId = 'abc123';
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('should create', () => {
|
|
67
|
-
expect(component).toBeTruthy();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should fetch folders and documents on ngOnInit', () => {
|
|
71
|
-
mockDocumentHttpService.getFoldersData.and.returnValue(of(dummyFolders));
|
|
72
|
-
mockDocumentQuery.selectParentDocumentTypeId.and.returnValue(of(null));
|
|
73
|
-
mockDocumentHttpService.getDocumentByFolderID.and.returnValue(of(dummyDocuments));
|
|
74
|
-
|
|
75
|
-
fixture.detectChanges(); // triggers ngOnInit
|
|
76
|
-
|
|
77
|
-
expect(mockDocumentHttpService.getFoldersData).toHaveBeenCalledWith('abc123');
|
|
78
|
-
expect(mockDocumentHttpService.getDocumentByFolderID).toHaveBeenCalledWith('1', 'abc123');
|
|
79
|
-
expect(mockDocumentStore.setDocumentList).toHaveBeenCalledWith(dummyDocuments);
|
|
80
|
-
expect(component.folderList.length).toBe(1); // Only folder with doc count > 0
|
|
81
|
-
expect(component.documentList.length).toBe(2);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should handle folder fetch error', () => {
|
|
85
|
-
const consoleSpy = spyOn(console, 'error');
|
|
86
|
-
mockDocumentHttpService.getFoldersData.and.returnValue(throwError(() => new Error('Error fetching folders')));
|
|
87
|
-
mockDocumentQuery.selectParentDocumentTypeId.and.returnValue(of(null));
|
|
88
|
-
|
|
89
|
-
fixture.detectChanges();
|
|
90
|
-
|
|
91
|
-
expect(consoleSpy).toHaveBeenCalled();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should handle document fetch error', () => {
|
|
95
|
-
const consoleSpy = spyOn(console, 'error');
|
|
96
|
-
mockDocumentHttpService.getFoldersData.and.returnValue(of(dummyFolders));
|
|
97
|
-
mockDocumentQuery.selectParentDocumentTypeId.and.returnValue(of(null));
|
|
98
|
-
mockDocumentHttpService.getDocumentByFolderID.and.returnValue(throwError(() => new Error('Error fetching docs')));
|
|
99
|
-
|
|
100
|
-
fixture.detectChanges();
|
|
101
|
-
|
|
102
|
-
expect(consoleSpy).toHaveBeenCalled();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should unsubscribe on destroy', () => {
|
|
106
|
-
spyOn(component['subscription'], 'unsubscribe');
|
|
107
|
-
component.ngOnDestroy();
|
|
108
|
-
expect(component['subscription'].unsubscribe).toHaveBeenCalled();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit, OnDestroy, OnChanges, SimpleChanges, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core';
|
|
2
|
-
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
3
|
-
import { DocumentService } from '../../state/document.service';
|
|
4
|
-
import { Subscription } from 'rxjs';
|
|
5
|
-
import { ERRORS } from '../../../../Shared/constant/ERROR';
|
|
6
|
-
import { DocumentHttpService } from '../../services/document-http.service';
|
|
7
|
-
import { DocumentQuery } from '../../state/document.query';
|
|
8
|
-
import { DocumentStore } from '../../state/document.store';
|
|
9
|
-
import { DocumentCategory } from '../../models/document-category.model';
|
|
10
|
-
import { UserListModel } from '../../models/user-list.model';
|
|
11
|
-
import { StatusDataModel } from '../../models/status-data.model';
|
|
12
|
-
import { DocumentListResponse } from '../../models/document-list-response.model';
|
|
13
|
-
import { DocumentHelperService } from '../../services/document.service';
|
|
14
|
-
import { DocumentMenuService } from '../../services/document-menu.service';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*This component is responsible for managing and displaying a list of documents.
|
|
18
|
-
* @class DocumentContainerComponent
|
|
19
|
-
* @typedef {DocumentContainerComponent}
|
|
20
|
-
*/
|
|
21
|
-
@Component({
|
|
22
|
-
selector: 'lib-document-container',
|
|
23
|
-
standalone: false,
|
|
24
|
-
templateUrl: './document-container.component.html',
|
|
25
|
-
styleUrl: './document-container.component.scss'
|
|
26
|
-
})
|
|
27
|
-
export class DocumentContainerComponent implements OnInit, OnDestroy, OnChanges {
|
|
28
|
-
/**
|
|
29
|
-
* The document list response data
|
|
30
|
-
* @type {DocumentListResponse[] | null}
|
|
31
|
-
*/
|
|
32
|
-
documentListResponse: DocumentListResponse[] | null = null;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Status data for the current selection
|
|
36
|
-
* @type {StatusDataModel[]}
|
|
37
|
-
*/
|
|
38
|
-
statusData: StatusDataModel[] = []
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The currently selected menu item ID for scrolling
|
|
42
|
-
*/
|
|
43
|
-
selectedMenuItemId: string | null = null;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Additional navigation information for better scrolling
|
|
47
|
-
*/
|
|
48
|
-
navigationInfo: {
|
|
49
|
-
menuItemId: string;
|
|
50
|
-
menuItemLabel: string;
|
|
51
|
-
categoryLabel: string;
|
|
52
|
-
categoryIndex: number;
|
|
53
|
-
} | null = null;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Reference to the content scroll container
|
|
57
|
-
*/
|
|
58
|
-
@ViewChild('contentScrollContainer', { static: false }) contentScrollContainer!: ElementRef;
|
|
59
|
-
|
|
60
|
-
@Output() selectedDocument: EventEmitter<any> = new EventEmitter<any>();
|
|
61
|
-
@Output() selectedDocumentInNewTab: EventEmitter<any> = new EventEmitter<any>();
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Subscription to track selected menu item changes
|
|
65
|
-
*/
|
|
66
|
-
private selectedMenuItemSubscription: Subscription = new Subscription();
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Creates an instance of DocumentContainerComponent.
|
|
70
|
-
* @param {DocumentHttpService} documentHttpService - Service for HTTP operations
|
|
71
|
-
* @param {DocumentHelperService} documentHelperService - Service for document operations
|
|
72
|
-
* @param {DocumentQuery} documentQuery - Query service for document state
|
|
73
|
-
* @param {DocumentStore} documentStore - Store service for document state
|
|
74
|
-
* @param {DocumentMenuService} documentMenuService - Service for menu operations
|
|
75
|
-
*/
|
|
76
|
-
constructor(
|
|
77
|
-
private documentHttpService: DocumentHttpService,
|
|
78
|
-
private documentHelperService: DocumentHelperService,
|
|
79
|
-
private documentQuery: DocumentQuery,
|
|
80
|
-
private documentStore: DocumentStore,
|
|
81
|
-
private documentMenuService: DocumentMenuService
|
|
82
|
-
) {}
|
|
83
|
-
/**
|
|
84
|
-
* Get contextId in input.
|
|
85
|
-
* @type {string}
|
|
86
|
-
*/
|
|
87
|
-
@Input() contextId: string = SHARED.EMPTY;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The list of folders.
|
|
92
|
-
* @type {Array}
|
|
93
|
-
*/
|
|
94
|
-
applicationNumber: string = SHARED.EMPTY
|
|
95
|
-
catagories: DocumentCategory[] = SHARED.EMPTY_ARRAY
|
|
96
|
-
userList: UserListModel[] = SHARED.EMPTY_ARRAY
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Holds the subscription to manage observable cleanup.
|
|
101
|
-
* @type {Subscription}
|
|
102
|
-
*/
|
|
103
|
-
subscription: Subscription = new Subscription();
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Handles changes to input properties
|
|
107
|
-
*/
|
|
108
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
109
|
-
if (changes[SHARED.CONTEXT_ID] && !changes[SHARED.CONTEXT_ID].firstChange) {
|
|
110
|
-
this.handleContextIdChange();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Initializes the component
|
|
116
|
-
*/
|
|
117
|
-
ngOnInit(): void {
|
|
118
|
-
this.clearAllState();
|
|
119
|
-
if (this.contextId && this.contextId !== SHARED.EMPTY) {
|
|
120
|
-
this.initializeData();
|
|
121
|
-
}
|
|
122
|
-
this.setupSelectedMenuItemSubscription();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Sets up subscription to track selected menu item changes
|
|
127
|
-
*/
|
|
128
|
-
setupSelectedMenuItemSubscription(): void {
|
|
129
|
-
this.selectedMenuItemSubscription.add(
|
|
130
|
-
this.documentQuery.selectSelectedMenuItem().subscribe(menuItemId => {
|
|
131
|
-
this.selectedMenuItemId = menuItemId;
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Handles menu item selection events from the documents menu
|
|
138
|
-
* @param event - The menu item selection event
|
|
139
|
-
*/
|
|
140
|
-
onMenuItemSelected(event: {
|
|
141
|
-
item: any;
|
|
142
|
-
category: any;
|
|
143
|
-
navigationInfo?: {
|
|
144
|
-
menuItemId: string;
|
|
145
|
-
menuItemLabel: string;
|
|
146
|
-
categoryLabel: string;
|
|
147
|
-
categoryIndex: number;
|
|
148
|
-
};
|
|
149
|
-
}): void {
|
|
150
|
-
if (event && event.navigationInfo) {
|
|
151
|
-
this.navigationInfo = event.navigationInfo;
|
|
152
|
-
// Don't set selectedMenuItemId here - let the store subscription handle it
|
|
153
|
-
} else {
|
|
154
|
-
this.navigationInfo = null;
|
|
155
|
-
// Don't set selectedMenuItemId here - let the store subscription handle it
|
|
156
|
-
this.resetContentScrollToTop();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Resets the content scroll container to the top
|
|
162
|
-
*/
|
|
163
|
-
private resetContentScrollToTop(): void {
|
|
164
|
-
if (this.contentScrollContainer) {
|
|
165
|
-
this.contentScrollContainer.nativeElement.scrollTo({
|
|
166
|
-
top: 0,
|
|
167
|
-
behavior: 'smooth'
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Initialize all data with proper sequencing to avoid duplicate API calls
|
|
174
|
-
*/
|
|
175
|
-
initializeData(): void {
|
|
176
|
-
this.fetchDocumentCatagories();
|
|
177
|
-
this.fetchUserListWithFilters();
|
|
178
|
-
this.setupStatusDataSubscriptions();
|
|
179
|
-
this.setupFilteredDocumentSubscription();
|
|
180
|
-
this.documentHelperService.initializeSelectionWatcherWithInitialLoad(this.contextId);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Clears all state (store and component) comprehensively
|
|
185
|
-
*/
|
|
186
|
-
clearAllState(): void {
|
|
187
|
-
this.documentStore.clearSelectionState();
|
|
188
|
-
// Don't clear document viewer state - let the viewer handle its own cleanup
|
|
189
|
-
this.documentStore.setDocumentListResponse(null);
|
|
190
|
-
this.documentStore.setDocumentList([]);
|
|
191
|
-
this.documentStore.setDocumentCategories([]);
|
|
192
|
-
this.documentStore.setUserList([]);
|
|
193
|
-
this.documentStore.setStatusData([]);
|
|
194
|
-
this.documentStore.setCurrentDocument(null);
|
|
195
|
-
this.documentStore.setFolders([]);
|
|
196
|
-
this.documentStore.setDocumentAlert(null);
|
|
197
|
-
this.catagories = SHARED.EMPTY_ARRAY;
|
|
198
|
-
this.userList = SHARED.EMPTY_ARRAY;
|
|
199
|
-
this.statusData = [];
|
|
200
|
-
this.documentListResponse = null;
|
|
201
|
-
this.applicationNumber = SHARED.EMPTY;
|
|
202
|
-
this.selectedMenuItemId = null;
|
|
203
|
-
this.navigationInfo = null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Handles contextId change by clearing all state and refetching data
|
|
208
|
-
*/
|
|
209
|
-
handleContextIdChange(): void {
|
|
210
|
-
if (this.contextId && this.contextId !== SHARED.EMPTY) {
|
|
211
|
-
this.subscription.unsubscribe();
|
|
212
|
-
this.subscription = new Subscription();
|
|
213
|
-
this.documentHelperService.cleanupSelectionWatcher();
|
|
214
|
-
this.clearAllState();
|
|
215
|
-
this.initializeData();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Sets up subscriptions to monitor menu item and user selection changes
|
|
221
|
-
* to trigger status data fetching and user list refreshing
|
|
222
|
-
*/
|
|
223
|
-
setupStatusDataSubscriptions(): void {
|
|
224
|
-
|
|
225
|
-
this.subscription.add(
|
|
226
|
-
this.documentQuery.selectSelectedUserId().subscribe(userId => {
|
|
227
|
-
this.fetchStatusData();
|
|
228
|
-
if (this.catagories.length > 0) {
|
|
229
|
-
this.fetchUserListWithFilters();
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
this.subscription.add(
|
|
234
|
-
this.documentQuery.selectSelectedStatus().subscribe(status => {
|
|
235
|
-
this.fetchStatusData();
|
|
236
|
-
if (this.catagories.length > 0) {
|
|
237
|
-
this.fetchUserListWithFilters();
|
|
238
|
-
}
|
|
239
|
-
})
|
|
240
|
-
);
|
|
241
|
-
this.fetchStatusData();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
onDocumentSelectedInNewTab(event: {
|
|
245
|
-
selectedDocument: any;
|
|
246
|
-
contextId: string;
|
|
247
|
-
documentList: any[];
|
|
248
|
-
}): void {
|
|
249
|
-
this.selectedDocumentInNewTab.emit(event);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Fetches status data based on current selections
|
|
253
|
-
*/
|
|
254
|
-
fetchStatusData(): void {
|
|
255
|
-
if (!this.contextId) {
|
|
256
|
-
console.warn(ERRORS.CONTEXT_ID_REQUIRED);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const currentState = this.documentQuery.getSelectionState();
|
|
261
|
-
const contextId = currentState.userId || null;
|
|
262
|
-
this.documentHttpService.getStatusDocumentCount(this.contextId, contextId, null).subscribe({
|
|
263
|
-
next: (statusData) => {
|
|
264
|
-
this.statusData = statusData;
|
|
265
|
-
this.documentStore.setStatusData(statusData);
|
|
266
|
-
},
|
|
267
|
-
error: (error) => {
|
|
268
|
-
console.error(ERRORS.ERROR_FETCHING_STATUS_DATA, error);
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Fetches userlist data with current filters applied
|
|
275
|
-
*/
|
|
276
|
-
fetchUserListWithFilters(): void {
|
|
277
|
-
if (!this.contextId) {
|
|
278
|
-
console.warn(ERRORS.CONTEXT_ID_REQUIRED);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const currentState = this.documentQuery.getSelectionState();
|
|
283
|
-
// If the API supports filtering by menu item or status, we can add those parameters
|
|
284
|
-
this.documentHttpService.getUserListByContextId(this.contextId).subscribe({
|
|
285
|
-
next: (res: UserListModel[]) => {
|
|
286
|
-
this.userList = res;
|
|
287
|
-
this.documentStore.setUserList(res);
|
|
288
|
-
},
|
|
289
|
-
error: (err: any) => {
|
|
290
|
-
console.error(ERRORS.ERROR_FETCHING_USER_LIST, err);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Fetches document catagory data.
|
|
297
|
-
*/
|
|
298
|
-
fetchDocumentCatagories(): void {
|
|
299
|
-
const categoriesSubscription = this.documentHttpService.getDocumentCatagories(this.contextId).subscribe({
|
|
300
|
-
next: (categories: any) => {
|
|
301
|
-
if (categories) {
|
|
302
|
-
this.catagories = categories.categories;
|
|
303
|
-
this.applicationNumber = categories.applicationNumber;
|
|
304
|
-
this.documentStore.setDocumentCategories(categories.categories);
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
error: (err: any) => {
|
|
309
|
-
console.error(ERRORS.ERROR_FETCHING_DOCUMENT_CATEGORIES, err);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
this.subscription.add(categoriesSubscription);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Refetches all data when contextId changes
|
|
317
|
-
*/
|
|
318
|
-
refetchAllDataForNewContext(): void {
|
|
319
|
-
if (this.contextId && this.contextId !== SHARED.EMPTY) {
|
|
320
|
-
this.documentStore.clearSelectionState();
|
|
321
|
-
this.documentStore.clearDocumentViewerState();
|
|
322
|
-
this.fetchDocumentCatagories();
|
|
323
|
-
this.fetchUserListWithFilters();
|
|
324
|
-
this.fetchStatusData();
|
|
325
|
-
this.documentHelperService.initializeSelectionWatcherWithInitialLoad(this.contextId);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Sets up subscription to listen for filtered document responses
|
|
331
|
-
*/
|
|
332
|
-
setupFilteredDocumentSubscription(): void {
|
|
333
|
-
this.subscription.add(
|
|
334
|
-
this.documentQuery.selectDocumentListResponse().subscribe({
|
|
335
|
-
next: (response: any) => {
|
|
336
|
-
this.documentListResponse = response;
|
|
337
|
-
},
|
|
338
|
-
error: (error: any) => {
|
|
339
|
-
console.error(ERRORS.ERROR_RECEIVING_DOCUMENT_LIST, error);
|
|
340
|
-
}
|
|
341
|
-
})
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
onDocumentSelected(document: any): void {
|
|
346
|
-
console.log('Document selected:', document);
|
|
347
|
-
this.selectedDocument.emit(document);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Unsubscribe subscription on destroy of component and clean up state.
|
|
352
|
-
*/
|
|
353
|
-
ngOnDestroy(): void {
|
|
354
|
-
if (this.subscription) {
|
|
355
|
-
this.subscription.unsubscribe();
|
|
356
|
-
}
|
|
357
|
-
if (this.selectedMenuItemSubscription) {
|
|
358
|
-
this.selectedMenuItemSubscription.unsubscribe();
|
|
359
|
-
}
|
|
360
|
-
this.documentHelperService.cleanupSelectionWatcher();
|
|
361
|
-
this.clearAllState();
|
|
362
|
-
}
|
|
363
|
-
}
|