cat-documents-ng 0.1.30 → 0.1.32

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 (92) hide show
  1. package/{src/Shared/constant/ERROR.ts → Shared/constant/ERROR.d.ts} +43 -38
  2. package/Shared/constant/PERMISSIONS.d.ts +20 -0
  3. package/Shared/constant/SHARED.d.ts +215 -0
  4. package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +60 -65
  5. package/Shared/services/app-config.service.d.ts +51 -0
  6. package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +27 -29
  7. package/Shared/services/session.service.d.ts +46 -0
  8. package/fesm2022/cat-documents-ng.mjs +2623 -0
  9. package/fesm2022/cat-documents-ng.mjs.map +1 -0
  10. package/index.d.ts +5 -0
  11. package/lib/document/components/document-container/document-container.component.d.ts +101 -0
  12. package/lib/document/components/document-list/document-list.component.d.ts +193 -0
  13. package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
  14. package/lib/document/components/document-upload/document-upload.component.d.ts +120 -0
  15. package/lib/document/components/document-viewer/document-viewer.component.d.ts +77 -0
  16. package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +37 -53
  17. package/lib/document/components/folder-container/folder-container.component.d.ts +29 -0
  18. package/lib/document/components/linked-document/linked-document.component.d.ts +38 -0
  19. package/lib/document/directives/document.directive.d.ts +20 -0
  20. package/lib/document/directives/permission.directive.d.ts +38 -0
  21. package/lib/document/document.module.d.ts +40 -0
  22. package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +38 -45
  23. package/lib/document/models/document-type.model.d.ts +37 -0
  24. package/lib/document/models/document.model.d.ts +44 -0
  25. package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +29 -35
  26. package/lib/document/services/document-http.service.d.ts +69 -0
  27. package/lib/document/services/document-upload.service.d.ts +67 -0
  28. package/lib/document/services/document.service.d.ts +20 -0
  29. package/lib/document/services/file-format.service.d.ts +23 -0
  30. package/lib/document/state/document.query.d.ts +50 -0
  31. package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +64 -95
  32. package/{src/lib/document/state/document.state.ts → lib/document/state/document.state.d.ts} +36 -52
  33. package/lib/document/state/document.store.d.ts +29 -0
  34. package/package.json +25 -20
  35. package/{src/public-api.ts → public-api.d.ts} +6 -10
  36. package/ng-package.json +0 -11
  37. package/src/Shared/constant/PERMISSIONS.ts +0 -16
  38. package/src/Shared/constant/SHARED.ts +0 -312
  39. package/src/Shared/services/app-config.service.spec.ts +0 -19
  40. package/src/Shared/services/app-config.service.ts +0 -73
  41. package/src/Shared/services/session.service.spec.ts +0 -16
  42. package/src/Shared/services/session.service.ts +0 -76
  43. package/src/assets/config/api.config.json +0 -20
  44. package/src/lib/document/components/document-container/document-container.component.html +0 -14
  45. package/src/lib/document/components/document-container/document-container.component.scss +0 -8
  46. package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
  47. package/src/lib/document/components/document-container/document-container.component.ts +0 -173
  48. package/src/lib/document/components/document-list/document-list.component.html +0 -81
  49. package/src/lib/document/components/document-list/document-list.component.scss +0 -82
  50. package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -96
  51. package/src/lib/document/components/document-list/document-list.component.ts +0 -244
  52. package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
  53. package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
  54. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
  55. package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
  56. package/src/lib/document/components/document-upload/document-upload.component.html +0 -56
  57. package/src/lib/document/components/document-upload/document-upload.component.scss +0 -32
  58. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
  59. package/src/lib/document/components/document-upload/document-upload.component.ts +0 -162
  60. package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -98
  61. package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -54
  62. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
  63. package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -106
  64. package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
  65. package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
  66. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
  67. package/src/lib/document/components/folder-container/folder-container.component.html +0 -2
  68. package/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
  69. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
  70. package/src/lib/document/components/folder-container/folder-container.component.ts +0 -37
  71. package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
  72. package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
  73. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
  74. package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
  75. package/src/lib/document/directives/document.directive.ts +0 -32
  76. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  77. package/src/lib/document/directives/permission.directive.ts +0 -66
  78. package/src/lib/document/document.module.ts +0 -241
  79. package/src/lib/document/models/document-type.model.ts +0 -44
  80. package/src/lib/document/models/document.model.ts +0 -53
  81. package/src/lib/document/services/document-http.service.spec.ts +0 -119
  82. package/src/lib/document/services/document-http.service.ts +0 -125
  83. package/src/lib/document/services/document-upload.service.spec.ts +0 -99
  84. package/src/lib/document/services/document-upload.service.ts +0 -127
  85. package/src/lib/document/services/document.service.ts +0 -29
  86. package/src/lib/document/services/file-format.service.spec.ts +0 -16
  87. package/src/lib/document/services/file-format.service.ts +0 -41
  88. package/src/lib/document/state/document.query.ts +0 -52
  89. package/src/lib/document/state/document.store.ts +0 -51
  90. package/tsconfig.lib.json +0 -15
  91. package/tsconfig.lib.prod.json +0 -11
  92. package/tsconfig.spec.json +0 -15
@@ -1,54 +0,0 @@
1
- .alert-card {
2
- background-color: #fb392d1a;
3
- }
4
-
5
- .success-alert {
6
- border-radius: 10px;
7
- border: 1px solid rgba(251, 57, 45, 0.1);
8
- background: linear-gradient(0deg, #dedede 0%, #dedede 100%), #fff;
9
- }
10
-
11
- .p-timeline-event-opposite {
12
- display: none;
13
- }
14
- .decription {
15
- color: #676b89;
16
- }
17
- .textAreaControl textarea {
18
- width: 100%;
19
- resize: vertical;
20
- max-width: 100%;
21
- }
22
-
23
- .document-btn-wrapper {
24
- .p-button-outlined {
25
- color: #f57c00;
26
- }
27
- }
28
-
29
- .document-viewer{
30
- .p-dialog{
31
- width: 100%;
32
- height: 100%;
33
- max-height: 100% !important;
34
- box-shadow: none !important;
35
- }
36
- .p-dialog-header-close-icon{
37
- height: 20px;
38
- width: 20px;
39
- }
40
- .p-dialog-header{
41
- background-color:#FFF;
42
- border-radius: 0;
43
- }
44
- .p-dialog-content{
45
- background-color:#FFF;
46
- border-radius: 0;
47
- }
48
- }
49
-
50
- .uploadedImages{
51
- width: 95%;
52
- height: 100%;
53
- object-fit: contain;
54
- }
@@ -1,79 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DocumentViewerComponent } from './document-viewer.component';
3
- import { TimelineModule } from 'primeng/timeline';
4
- import { FormsModule } from '@angular/forms';
5
- import { CheckboxModule } from 'primeng/checkbox';
6
- import { HttpClientModule } from '@angular/common/http';
7
- import { DocumentService } from '../../services/document.service';
8
- import { DocumentHttpService } from '../../services/document-http.service';
9
- import { of } from 'rxjs';
10
- import { DocumentModel } from '../../models/document.model';
11
- import { LinkedDocumentComponent } from '../linked-document/linked-document.component';
12
-
13
- describe('DocumentViewerComponent', () => {
14
- let component: DocumentViewerComponent;
15
- let fixture: ComponentFixture<DocumentViewerComponent>;
16
- let documentService: jasmine.SpyObj<DocumentService>;
17
-
18
- beforeEach(async () => {
19
- const documentServiceSpy = jasmine.createSpyObj('DocumentService', ['set']);
20
-
21
- await TestBed.configureTestingModule({
22
- declarations: [DocumentViewerComponent, LinkedDocumentComponent],
23
- imports: [TimelineModule, FormsModule, CheckboxModule, HttpClientModule],
24
- providers: [
25
- { provide: DocumentService, useValue: documentServiceSpy },
26
- DocumentHttpService,
27
- ],
28
- }).compileComponents();
29
-
30
- fixture = TestBed.createComponent(DocumentViewerComponent);
31
- component = fixture.componentInstance;
32
- documentService = TestBed.inject(DocumentService) as jasmine.SpyObj<DocumentService>;
33
- fixture.detectChanges();
34
- });
35
-
36
- it('should create', () => {
37
- expect(component).toBeTruthy();
38
- });
39
-
40
- it('should call set method of documentService on ngOnChanges when selectedDocument is set', () => {
41
- const document: DocumentModel = { _id: '22', contentType: 'image/png', documentUrl: 'http://example.com/image.png', status: 'approved' };
42
- component.selectedDocument = document;
43
- component.ngOnChanges();
44
- expect(documentService.set).toHaveBeenCalledWith(document);
45
- });
46
-
47
- it('should determine if content type is an image', () => {
48
- const validImageType = 'image/png';
49
- const invalidImageType = 'application/pdf';
50
- expect(component.isImage(validImageType)).toBeTrue();
51
- expect(component.isImage(invalidImageType)).toBeFalse();
52
- });
53
-
54
- it('should set selectedDocument correctly when handleSelectedDocument is called', () => {
55
- const document: DocumentModel = { _id: '22', contentType: 'image/png', documentUrl: 'http://example.com/image.png' };
56
- component.handleSelectedDocument(document);
57
- expect(component.selectedDocument).toEqual(document);
58
- expect(documentService.set).toHaveBeenCalledWith(document);
59
- });
60
-
61
- it('should display the document image if selectedDocument is an image', () => {
62
- const imageDocument: DocumentModel = {
63
- _id : "122",
64
- contentType: 'image/png',
65
- documentUrl: 'http://example.com/image.png',
66
- };
67
- component.selectedDocument = imageDocument;
68
- fixture.detectChanges();
69
- const imgElement = fixture.debugElement.nativeElement.querySelector('.img-container img');
70
- expect(imgElement).toBeTruthy();
71
- expect(imgElement.src).toContain('http://example.com/image.png');
72
- });
73
-
74
- it('should update isVerified flag', () => {
75
- component.isVerified = true;
76
- fixture.detectChanges();
77
- expect(component.isVerified).toBeTrue();
78
- });
79
- });
@@ -1,106 +0,0 @@
1
- import {
2
- Component,
3
- Input,
4
- OnChanges,
5
- OnDestroy,
6
- SimpleChanges,
7
- ViewEncapsulation,
8
- } from '@angular/core';
9
- import { DynamicDialogRef } from 'primeng/dynamicdialog';
10
- import { DocumentAlertList, DUMMYSUMMARY, SHARED, SUPPORTED_IMAGE_TYPES } from '../../../../Shared/constant/SHARED';
11
- import { DocumentHttpService } from '../../services/document-http.service';
12
- import { Subscription } from 'rxjs';
13
- import { DocumentModel } from '../../models/document.model';
14
- import { DocumentService } from '../../services/document.service';
15
-
16
- /**
17
- * Component for viewing and managing document details.
18
- * @class DocumentViewerComponent
19
- * @typedef {DocumentViewerComponent}
20
- */
21
- @Component({
22
- selector: 'document-viewer',
23
- templateUrl: './document-viewer.component.html',
24
- standalone : false,
25
- styleUrl: './document-viewer.component.scss',
26
- encapsulation: ViewEncapsulation.None,
27
- })
28
- export class DocumentViewerComponent implements OnChanges, OnDestroy {
29
- /**
30
- * Get the selected document by user.
31
- * @type {*}
32
- */
33
- @Input() selectedDocument?: DocumentModel; // <-- Made optional to prevent undefined issues
34
- /**
35
- * Get the selected document by user.
36
- * @type {*}
37
- */
38
- @Input() documentList?: DocumentModel[]; // <-- Made optional to prevent undefined issues
39
-
40
- /**
41
- * Indicates whether a checkbox is selected.
42
- * @type {boolean}
43
- */
44
- checked: boolean = false;
45
-
46
- /**
47
- * Reference to the dynamic dialog used for displaying additional details.
48
- * @type {(DynamicDialogRef | undefined)}
49
- */
50
- ref: DynamicDialogRef | undefined;
51
-
52
- /**
53
- * Indicates whether the document has been verified.
54
- * @type {boolean}
55
- */
56
- isVerified: boolean = false;
57
-
58
- /**
59
- * Data used for displaying alert messages.
60
- * @type {any}
61
- */
62
- alertData!: any;
63
-
64
- /**
65
- * Holds the subscription to manage observable cleanup.
66
- * @private
67
- * @type {Subscription}
68
- */
69
- private subscription: Subscription = new Subscription();
70
- /**
71
- * Initializes a new instance of the DocumentViewerComponent.
72
- * @param {DocumentHttpService} documentHttpService - Handle the http service.
73
- * @param {DocumentService} documentService - Handle the states.
74
- */
75
- constructor(public documentHttpService : DocumentHttpService, private documentService: DocumentService) {}
76
-
77
- /**
78
- * Fetches the alerts for the selected document.
79
- * @returns {void}
80
- */
81
- ngOnChanges() {
82
- if (this.selectedDocument) {
83
- this.documentService.set(this.selectedDocument);
84
- this.alertData = DocumentAlertList.find((res: any) => res.status === this.selectedDocument?.status);
85
- }
86
- }
87
-
88
- handleSelectedDocument(document:DocumentModel){
89
- this.selectedDocument = document
90
- this.documentService.set(this.selectedDocument);
91
- }
92
-
93
- /**
94
- * Determines if the given content type is an image.
95
- * @param {string | undefined} contentType - The MIME type of the content.
96
- * @returns {boolean} `true` if the content type is an image; otherwise, `false`.
97
- */
98
- isImage(contentType?: string): boolean {
99
- return contentType ? SUPPORTED_IMAGE_TYPES.includes(contentType) : false;
100
- }
101
-
102
- ngOnDestroy(): void {
103
- this.subscription.unsubscribe();
104
- }
105
-
106
- }
@@ -1,46 +0,0 @@
1
- <div class="card p-0 folder-info">
2
- <div class="text-900 text-xl font-semibold ml-2 mb-1">Folders</div>
3
- <div class="grid m-0">
4
- <div *ngFor="let folder of folderList" class="col-12 md:col-6 xl:col-4 container-wrapper">
5
- <div
6
- class="p-3 border-1 h-full surface-border flex flex-column justify-content-between hover:surface-100 cursor-pointer border-round"
7
- (click)="handleClickForFilter(folder._id)"
8
- >
9
- <div class="icon">
10
- <img src="../../../../assets/images/FolderImg.png" alt="" />
11
- </div>
12
- <div class="flex flex-column">
13
- <span class="text-600 mt-2"> {{ folder.documentCount }} Files </span>
14
- <span class="text-900 text-lg mt-2 mb-2 font-semibold font-medium">
15
- {{ folder.folderName }}
16
- </span>
17
- </div>
18
- <hr />
19
- <div class="flex justify-content-between">
20
- <div class="flex flex-column">
21
- <span>Missing</span>
22
- <span
23
- [ngClass]="{
24
- 'text-pink-500': missingFileCount > 0,
25
- 'text-green-500': missingFileCount === 0
26
- }"
27
- >
28
- {{ missingFileCount }}
29
- </span>
30
- </div>
31
- <div class="flex flex-column">
32
- <span>Pending</span>
33
- <span
34
- [ngClass]="{
35
- 'text-yellow-500': pendingFileCount > 0,
36
- 'text-green-500': pendingFileCount === 0
37
- }"
38
- >
39
- {{ pendingFileCount }}
40
- </span>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- </div>
46
- </div>
@@ -1,9 +0,0 @@
1
- .container-wrapper{
2
- &:nth-child(3n + 1) {
3
- padding-left: 0;
4
- }
5
-
6
- &:nth-child(3n) {
7
- padding-right: 0;
8
- }
9
- }
@@ -1,70 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { FolderBlockComponent } from './folder-block.component';
3
- import { SHARED } from '../../../../Shared/constant/SHARED';
4
- import { DocumentStore } from '../../state/document.store';
5
- import { FolderBlockModel } from '../../models/folder.model';
6
-
7
- describe('FolderBlockComponent', () => {
8
- let component: FolderBlockComponent;
9
- let fixture: ComponentFixture<FolderBlockComponent>;
10
- let mockDocumentStore: jasmine.SpyObj<DocumentStore>;
11
-
12
- beforeEach(async () => {
13
- mockDocumentStore = jasmine.createSpyObj('DocumentStore', ['setParentDocumentTypeId']); // Include the method here
14
-
15
- await TestBed.configureTestingModule({
16
- declarations: [FolderBlockComponent],
17
- providers: [
18
- { provide: DocumentStore, useValue: mockDocumentStore }
19
- ],
20
- }).compileComponents();
21
-
22
- fixture = TestBed.createComponent(FolderBlockComponent);
23
- component = fixture.componentInstance;
24
-
25
- // Mock folder blocks input
26
- component.folderList = [
27
- { _id: '1', folderName: 'Folder 1', documentCount: 5 },
28
- { _id: '2', folderName: 'Folder 2', documentCount: 3 },
29
- ] as FolderBlockModel[];
30
-
31
- fixture.detectChanges();
32
- });
33
-
34
-
35
- it('should create', () => {
36
- expect(component).toBeTruthy();
37
- });
38
-
39
- it('should render the folder blocks correctly', () => {
40
- const folderElements = fixture.debugElement.nativeElement.querySelectorAll('.grid .col-12');
41
- expect(folderElements.length).toBe(2); // Should match the length of folderBlocks input
42
- });
43
-
44
- it('should display the correct file count for each folder', () => {
45
- const folderTextElements = fixture.debugElement.nativeElement.querySelectorAll('.text-600');
46
- expect(folderTextElements[0].textContent).toContain('5 Files');
47
- expect(folderTextElements[1].textContent).toContain('3 Files');
48
- });
49
-
50
- it('should return correct folderBlockId from handleClickForFilter', () => {
51
- const validFolderBlockId = '1';
52
- const invalidFolderBlockId = '';
53
-
54
- expect(component.handleClickForFilter(validFolderBlockId)).toBe(validFolderBlockId);
55
- expect(component.handleClickForFilter(invalidFolderBlockId)).toBe(SHARED.EMPTY);
56
- });
57
-
58
- it('should display the missing and pending file counts correctly', () => {
59
- const missingFileCountElements = fixture.debugElement.nativeElement.querySelectorAll('.text-pink-500');
60
- const pendingFileCountElements = fixture.debugElement.nativeElement.querySelectorAll('.text-yellow-500');
61
-
62
- expect(missingFileCountElements.length).toBeGreaterThan(0); // Check if any element with `text-pink-500` class is present
63
- expect(pendingFileCountElements.length).toBeGreaterThan(0); // Check if any element with `text-yellow-500` class is present
64
- });
65
-
66
- it('should set the missingFileCount and pendingFileCount to SHARED constants', () => {
67
- expect(component.missingFileCount).toBe(SHARED.MISSINGCOUNT);
68
- expect(component.pendingFileCount).toBe(SHARED.PENDINGCOUNT);
69
- });
70
- });
@@ -1,2 +0,0 @@
1
-
2
- <lib-folder-block [folderList]="folderList"></lib-folder-block>
@@ -1,27 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { Listbox, ListboxModule } from 'primeng/listbox';
3
- import { TimelineModule } from 'primeng/timeline';
4
- import { FormsModule } from '@angular/forms';
5
- import { CheckboxModule } from 'primeng/checkbox';
6
- import { FolderContainerComponent } from './folder-container.component';
7
- import { FolderBlockComponent } from '../folder-block/folder-block.component';
8
-
9
- describe('FolderContainerComponent', () => {
10
- let component: FolderContainerComponent;
11
- let fixture: ComponentFixture<FolderContainerComponent>;
12
-
13
- beforeEach(async () => {
14
- await TestBed.configureTestingModule({
15
- declarations: [FolderContainerComponent , FolderBlockComponent],
16
- imports : [ListboxModule, TimelineModule, FormsModule, CheckboxModule]
17
- }).compileComponents();
18
-
19
- fixture = TestBed.createComponent(FolderContainerComponent);
20
- component = fixture.componentInstance;
21
- fixture.detectChanges();
22
- });
23
-
24
- it('should create', () => {
25
- expect(component).toBeTruthy();
26
- });
27
- });
@@ -1,37 +0,0 @@
1
- import { Component, Input } from '@angular/core';
2
- import { FOLDERPANEL, SHARED } from '../../../../Shared/constant/SHARED';
3
- import { DocumentModel } from '../../models/document.model';
4
- import { FolderBlockModel } from '../../models/folder.model';
5
-
6
- /**
7
- * The `FolderContainerComponent` is responsible for rendering a container
8
- * that displays a list of documents and associated folder panel data.
9
- *
10
- * This component utilizes the `FOLDERPANEL` constant for folder panel data
11
- * and accepts a document list input of type `DocumentModel`.
12
- */
13
- @Component({
14
- selector: 'lib-folder-container',
15
- standalone: false,
16
- templateUrl: './folder-container.component.html',
17
- styleUrl: './folder-container.component.scss'
18
- })
19
- export class FolderContainerComponent {
20
- /**
21
- * A list of documents passed as input to the component.
22
- * Represents the document data to be displayed in the folder container.
23
- */
24
- @Input() documentList?: DocumentModel[];
25
- /**
26
- * A list of documents passed as input to the component.
27
- * Represents the document data to be displayed in the folder container.
28
- */
29
- @Input() folderList: FolderBlockModel[] = SHARED.EMPTY_ARRAY;
30
-
31
- /**
32
- * The context ID for the folder container.
33
- * @type {string}
34
- */
35
- @Input() contextId: string = SHARED.EMPTY;
36
-
37
- }
@@ -1,23 +0,0 @@
1
- <div class="summary-card mb-4 pb-1">
2
- <div class="card p-0 mb-0"
3
- style="border-bottom: 1px solid;border-color: rgba(68, 72, 109, 0.2); border-bottom-right-radius: 0px;border-bottom-left-radius: 0px; background-color: #F9fafb;">
4
- <div class="p-0">
5
- <h4 class="m-0 pt-3 pl-3 mb-3" style="font-size: 21px; font-weight: bold; ">Linked Documents</h4>
6
- </div>
7
- </div>
8
- <div class="card mb-0" style="border-top-right-radius: 0px;border-top-left-radius: 0px;">
9
- @for(document of documentList; track document){
10
- <div class="linkedDocument documentName m-2">
11
- <div class="documentName" [class.selected]="document._id === selectedDocument?._id"
12
- (click)="handleDocumentClick(document)">
13
- <span class="pi pi-link"></span>
14
- {{document.fileName}}
15
- </div>
16
- </div>
17
- }
18
-
19
- </div>
20
-
21
-
22
- </div>
23
-
@@ -1,10 +0,0 @@
1
- .documentName{
2
- font-family: inherit;
3
- text-decoration: underline;
4
- cursor: pointer;
5
- width: max-content;
6
- }
7
- .selected{
8
- color: var(--primary-color);
9
-
10
- }
@@ -1,61 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { LinkedDocumentComponent } from './linked-document.component';
3
- import { DocumentModel } from '../../models/document.model';
4
- import { Component, Input } from '@angular/core';
5
-
6
- /**
7
- * A mock child component used for testing the LinkedDocumentComponent.
8
- * It mimics a real child component that receives document-related inputs.
9
- */
10
- @Component({
11
- selector: 'app-mock-child',
12
- template: ''
13
- })
14
- class MockChildComponent {
15
- /**
16
- * Represents the currently selected document.
17
- */
18
- @Input() selectedDocument?: DocumentModel;
19
-
20
- /**
21
- * A list of available documents.
22
- */
23
- @Input() documentList?: DocumentModel[];
24
- }
25
-
26
- describe('LinkedDocumentComponent', () => {
27
- let component: LinkedDocumentComponent;
28
- let fixture: ComponentFixture<LinkedDocumentComponent>;
29
-
30
- beforeEach(async () => {
31
- await TestBed.configureTestingModule({
32
- declarations: [LinkedDocumentComponent],
33
- }).compileComponents();
34
- });
35
-
36
- beforeEach(() => {
37
- fixture = TestBed.createComponent(LinkedDocumentComponent);
38
- component = fixture.componentInstance;
39
- fixture.detectChanges();
40
- });
41
-
42
- /**
43
- * Ensures that the component is created successfully.
44
- */
45
- it('should create', () => {
46
- expect(component).toBeTruthy();
47
- });
48
-
49
- /**
50
- * Tests whether the `handleDocumentClick` method correctly emits
51
- * the `selectedDocumentChange` event with the expected document data.
52
- */
53
- it('should emit selectedDocumentChange event when handleDocumentClick is called', () => {
54
- spyOn(component.selectedDocumentChange, 'emit');
55
- const document: DocumentModel = { _id: '1', fileName: 'Doc1' };
56
-
57
- component.handleDocumentClick(document);
58
-
59
- expect(component.selectedDocumentChange.emit).toHaveBeenCalledWith(document);
60
- });
61
- });
@@ -1,49 +0,0 @@
1
- import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
2
- import { DocumentQuery } from '../../state/document.query';
3
- import { DocumentModel } from '../../models/document.model';
4
-
5
- /**
6
- * Description placeholder
7
- * @class LinkedDocumentComponent
8
- * @typedef {LinkedDocumentComponent}
9
- * @implements {OnChanges}
10
- */
11
- @Component({
12
- selector: 'app-linked-document',
13
- templateUrl: './linked-document.component.html',
14
- styleUrl: './linked-document.component.scss',
15
- standalone : false
16
- })
17
- export class LinkedDocumentComponent {
18
- /**
19
- * Selected document for view.
20
- * @type {?DocumentModel}
21
- */
22
- @Input() selectedDocument?: DocumentModel;
23
- /**
24
- * Whole document list.
25
- * @type {?DocumentModel[]}
26
- */
27
- @Input() documentList?: DocumentModel[];
28
- /**
29
- * Changed selected document.
30
- * @type {*}
31
- */
32
- @Output() selectedDocumentChange = new EventEmitter<DocumentModel>();
33
-
34
- /**
35
- * Filtered documents.
36
- * @type {DocumentModel[]}
37
- */
38
- filteredDocuments: DocumentModel[] = [];
39
-
40
- /**
41
- * Handle the click on the document.
42
- * @param {DocumentModel} document - Clicked document.
43
- */
44
- handleDocumentClick(document: DocumentModel): void {
45
- this.selectedDocument = document;
46
- this.selectedDocumentChange.emit(this.selectedDocument);
47
- }
48
-
49
- }
@@ -1,32 +0,0 @@
1
- import { Directive, TemplateRef, ViewContainerRef } from "@angular/core";
2
- import { DocumentService } from "../services/document.service";
3
- import { DocumentModel } from "../models/document.model";
4
-
5
- /**
6
- * Directive to display the document data
7
- */
8
- @Directive({
9
- selector: '[doc]',
10
- standalone: false
11
- })
12
- export class DocumentDirective {
13
-
14
- /**
15
- * Creates an instance of DocumentDirective.
16
- * @param documentService Service to get the document data.
17
- * @param templateRef Reference to the template.
18
- * @param vcr View container reference to manage the view.
19
- */
20
- constructor(
21
- private documentService: DocumentService,
22
- private templateRef: TemplateRef<any>,
23
- private vcr: ViewContainerRef
24
- ) {
25
- this.documentService.get().subscribe((document: DocumentModel | null) => {
26
- this.vcr.clear();
27
- if (document) {
28
- this.vcr.createEmbeddedView(this.templateRef, { $implicit: document });
29
- }
30
- });
31
- }
32
- }