cat-documents-ng 0.2.42 → 0.2.44

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.
@@ -14,16 +14,23 @@ export declare class DocumentActionsComponent implements OnChanges {
14
14
  showAcceptDialog: boolean;
15
15
  showRejectDialog: boolean;
16
16
  acceptNote: string;
17
- rejectNote: string;
17
+ private _rejectNote;
18
18
  cardClass: string;
19
19
  rejectButtonClass: string;
20
20
  acceptButtonClass: string;
21
+ isRejectNoteEmpty: boolean;
21
22
  constructor(documentActionsService: DocumentActionsService);
23
+ get rejectNote(): string;
24
+ set rejectNote(value: string);
22
25
  ngOnChanges(changes: SimpleChanges): void;
23
26
  /**
24
27
  * Updates computed properties based on currentStatus and statusId
25
28
  */
26
29
  private updateComputedProperties;
30
+ /**
31
+ * Updates the isRejectNoteEmpty property based on current rejectNote value
32
+ */
33
+ private updateRejectNoteEmpty;
27
34
  onAcceptClick(): void;
28
35
  onRejectClick(): void;
29
36
  onDeleteClick(): void;
@@ -63,7 +63,7 @@ export declare class DocumentContainerComponent implements OnInit, OnDestroy {
63
63
  ngOnInit(): void;
64
64
  /**
65
65
  * Sets up subscriptions to monitor menu item and user selection changes
66
- * to trigger status data fetching
66
+ * to trigger status data fetching and user list refreshing
67
67
  */
68
68
  private setupStatusDataSubscriptions;
69
69
  /**
@@ -71,13 +71,13 @@ export declare class DocumentContainerComponent implements OnInit, OnDestroy {
71
71
  */
72
72
  private fetchStatusData;
73
73
  /**
74
- * Fetches document catagory data.
74
+ * Fetches userlist data with current filters applied
75
75
  */
76
- fetchDocumentCatagories(): void;
76
+ fetchUserListWithFilters(): void;
77
77
  /**
78
- * Fetches userlist data
78
+ * Fetches document catagory data.
79
79
  */
80
- fetchUserList(): void;
80
+ fetchDocumentCatagories(): void;
81
81
  /**
82
82
  * Sets up subscription to listen for filtered document responses
83
83
  */
@@ -3,9 +3,9 @@ import { DynamicDialogRef } from 'primeng/dynamicdialog';
3
3
  import { DocumentHttpService } from '../../services/document-http.service';
4
4
  import { DocumentHelperService } from '../../services/document.service';
5
5
  import { DocumentListItem } from '../../models/document-list-response.model';
6
- import { DocumentHistorySection } from '../../models/document-history.model';
7
6
  import { DocumentAction } from '../../services/document-actions.service';
8
7
  import { MessageService } from 'primeng/api';
8
+ import { DocumentViewerService, DocumentViewerState } from '../../services/document-viewer.service';
9
9
  import * as i0 from "@angular/core";
10
10
  /**
11
11
  * Component for viewing and managing document details.
@@ -16,6 +16,7 @@ export declare class DocumentViewerComponent implements OnChanges, OnDestroy {
16
16
  documentHttpService: DocumentHttpService;
17
17
  private documentService;
18
18
  private messageService;
19
+ private documentViewerService;
19
20
  /**
20
21
  * Get the selected document by user.
21
22
  * @type {*}
@@ -26,6 +27,11 @@ export declare class DocumentViewerComponent implements OnChanges, OnDestroy {
26
27
  * @type {*}
27
28
  */
28
29
  documentList?: DocumentListItem[];
30
+ /**
31
+ * The context ID for API calls
32
+ * @type {string}
33
+ */
34
+ contextId?: string;
29
35
  /**
30
36
  * Event emitted when document status is updated to refresh the document list
31
37
  * @type {EventEmitter<void>}
@@ -46,41 +52,16 @@ export declare class DocumentViewerComponent implements OnChanges, OnDestroy {
46
52
  * @type {boolean}
47
53
  */
48
54
  isVerified: boolean;
49
- /**
50
- * Data used for displaying alert messages.
51
- * @type {any}
52
- */
53
- alertData: any;
54
- /**
55
- * Document history data
56
- * @type {DocumentHistorySection[]}
57
- */
58
- documentHistory: DocumentHistorySection[];
59
- /**
60
- * Whether to show document history
61
- * @type {boolean}
62
- */
63
- showDocumentHistory: boolean;
64
55
  /**
65
56
  * Messages for user feedback
66
57
  * @type {any[]}
67
58
  */
68
59
  messages: any[];
69
60
  /**
70
- * Loading state for document actions
71
- * @type {boolean}
72
- */
73
- isActionLoading: boolean;
74
- /**
75
- * Computed document status for the actions component
76
- * @type {'pending' | 'accepted' | 'rejected'}
77
- */
78
- documentStatus: 'pending' | 'accepted' | 'rejected';
79
- /**
80
- * Computed flag indicating if document is uploaded
81
- * @type {boolean}
61
+ * Current state from the service
62
+ * @type {DocumentViewerState}
82
63
  */
83
- documentIsUploaded: boolean;
64
+ currentState: DocumentViewerState;
84
65
  /**
85
66
  * Holds the subscription to manage observable cleanup.
86
67
  * @private
@@ -91,51 +72,31 @@ export declare class DocumentViewerComponent implements OnChanges, OnDestroy {
91
72
  * Initializes a new instance of the DocumentViewerComponent.
92
73
  * @param {DocumentHttpService} documentHttpService - Handle the http service.
93
74
  * @param {DocumentService} documentService - Handle the states.
75
+ * @param {DocumentViewerService} documentViewerService - Handle the viewer business logic.
94
76
  */
95
- constructor(documentHttpService: DocumentHttpService, documentService: DocumentHelperService, messageService: MessageService);
77
+ constructor(documentHttpService: DocumentHttpService, documentService: DocumentHelperService, messageService: MessageService, documentViewerService: DocumentViewerService);
96
78
  /**
97
79
  * Fetches the alerts for the selected document.
98
80
  * @returns {void}
99
81
  */
100
82
  ngOnChanges(changes: SimpleChanges): void;
101
- handleSelectedDocument(document: DocumentListItem): void;
102
83
  /**
103
- * Loads document history data
104
- * @returns {void}
84
+ * Handles document selection from template
85
+ * @param document The selected document
105
86
  */
106
- loadDocumentHistory(documentId: string): void;
87
+ handleSelectedDocument(document: DocumentListItem): void;
107
88
  /**
108
89
  * Determines if the given content type is an image.
109
90
  * @param {string | undefined} contentType - The MIME type of the content.
110
91
  * @returns {boolean} `true` if the content type is an image; otherwise, `false`.
111
92
  */
112
93
  isImage(contentType?: string): boolean;
113
- ngOnDestroy(): void;
114
- /**
115
- * Updates computed properties based on selectedDocument
116
- */
117
- private updateComputedProperties;
118
- /**
119
- * Calculates the current status of the document for the actions component
120
- * @returns {'pending' | 'accepted' | 'rejected'} The current document status
121
- */
122
- private calculateDocumentStatus;
123
- /**
124
- * Calculates if the document is uploaded and ready for actions
125
- * @returns {boolean} True if document is uploaded
126
- */
127
- private calculateIsDocumentUploaded;
128
94
  /**
129
95
  * Handles document actions from the actions component
130
96
  * @param {DocumentAction} action - The action performed
131
97
  */
132
98
  handleDocumentAction(action: DocumentAction): void;
133
- /**
134
- * Updates the document status via API call
135
- * @param {string} status - The new status (Approved, Rejected)
136
- * @param {string} description - The status update description
137
- */
138
- private updateDocumentStatus;
99
+ ngOnDestroy(): void;
139
100
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentViewerComponent, never>;
140
- static ɵcmp: i0.ɵɵComponentDeclaration<DocumentViewerComponent, "document-viewer", never, { "selectedDocument": { "alias": "selectedDocument"; "required": false; }; "documentList": { "alias": "documentList"; "required": false; }; }, { "documentStatusUpdated": "documentStatusUpdated"; }, never, ["*"], false, never>;
101
+ static ɵcmp: i0.ɵɵComponentDeclaration<DocumentViewerComponent, "document-viewer", never, { "selectedDocument": { "alias": "selectedDocument"; "required": false; }; "documentList": { "alias": "documentList"; "required": false; }; "contextId": { "alias": "contextId"; "required": false; }; }, { "documentStatusUpdated": "documentStatusUpdated"; }, never, ["*"], false, never>;
141
102
  }
@@ -116,9 +116,9 @@ export declare class DocumentHttpService {
116
116
  */
117
117
  private normalizeStatus;
118
118
  /**
119
- * Deletes a document by its ID and refreshes the document list
119
+ * Deletes a document by its ID and refreshes all data (categories, userlist, status, and document list)
120
120
  * @param {string} documentId - The ID of the document to delete
121
- * @param {string} contextId - The context ID to refresh the document list
121
+ * @param {string} contextId - The context ID to refresh all data
122
122
  * @returns {Observable<any>} Observable that emits the delete response
123
123
  */
124
124
  deleteDocument(documentId: string, contextId: string): Observable<any>;
@@ -1,8 +1,10 @@
1
1
  import { DocumentListResponse, DocumentListItem } from '../models/document-list-response.model';
2
2
  import { TableData } from '../../../Shared/components/table-primary/table-primary.model';
3
+ import { SessionService } from '../../../Shared/services/session.service';
3
4
  import * as i0 from "@angular/core";
4
5
  export declare class DocumentTableBuilderService {
5
- constructor();
6
+ private sessionService;
7
+ constructor(sessionService: SessionService);
6
8
  /**
7
9
  * Builds a single table from document list items
8
10
  * @param documents Array of document list items
@@ -0,0 +1,95 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DocumentHttpService } from './document-http.service';
3
+ import { DocumentHelperService } from './document.service';
4
+ import { DocumentListItem } from '../models/document-list-response.model';
5
+ import { DocumentHistorySection } from '../models/document-history.model';
6
+ import { DocumentAction } from './document-actions.service';
7
+ import { MessageService } from 'primeng/api';
8
+ import { DocumentStore } from '../state/document.store';
9
+ import { DocumentQuery } from '../state/document.query';
10
+ import * as i0 from "@angular/core";
11
+ export interface DocumentViewerState {
12
+ selectedDocument?: DocumentListItem;
13
+ documentHistory: DocumentHistorySection[];
14
+ showDocumentHistory: boolean;
15
+ isActionLoading: boolean;
16
+ documentStatus: 'pending' | 'accepted' | 'rejected';
17
+ documentIsUploaded: boolean;
18
+ alertData: any;
19
+ }
20
+ export declare class DocumentViewerService {
21
+ private documentHttpService;
22
+ private documentService;
23
+ private messageService;
24
+ private documentStore;
25
+ private documentQuery;
26
+ constructor(documentHttpService: DocumentHttpService, documentService: DocumentHelperService, messageService: MessageService, documentStore: DocumentStore, documentQuery: DocumentQuery);
27
+ /**
28
+ * Gets the current document viewer state as an observable
29
+ */
30
+ get state$(): Observable<DocumentViewerState>;
31
+ /**
32
+ * Gets the current document viewer state synchronously
33
+ */
34
+ getCurrentState(): DocumentViewerState;
35
+ /**
36
+ * Updates the selected document and recalculates all computed properties
37
+ * @param document The selected document
38
+ */
39
+ updateSelectedDocument(document: DocumentListItem): void;
40
+ /**
41
+ * Loads document history data
42
+ * @param documentId The document ID
43
+ */
44
+ loadDocumentHistory(documentId: string): void;
45
+ /**
46
+ * Determines if the given content type is an image
47
+ * @param contentType The MIME type of the content
48
+ * @returns True if the content type is an image
49
+ */
50
+ isImage(contentType?: string): boolean;
51
+ /**
52
+ * Handles document actions and updates status
53
+ * @param action The action performed
54
+ * @param contextId The context ID for API calls
55
+ */
56
+ handleDocumentAction(action: DocumentAction, contextId?: string): void;
57
+ /**
58
+ * Updates the document status via API call and refreshes all related data
59
+ * @param status The new status (Approved, Rejected)
60
+ * @param description The status update description
61
+ * @param contextId The context ID for API calls
62
+ */
63
+ private updateDocumentStatus;
64
+ /**
65
+ * Deletes a document and refreshes all data while preserving current filters
66
+ * @param documentId The ID of the document to delete
67
+ * @param contextId The context ID for API calls
68
+ */
69
+ private deleteDocument;
70
+ /**
71
+ * Refreshes all related data after document status update
72
+ * @param contextId The context ID for API calls
73
+ */
74
+ private refreshAllData;
75
+ /**
76
+ * Gets alert data for the document
77
+ * @param document The document
78
+ * @returns Alert data
79
+ */
80
+ private getAlertData;
81
+ /**
82
+ * Calculates the current status of the document for the actions component
83
+ * @param document The document
84
+ * @returns The current document status
85
+ */
86
+ private calculateDocumentStatus;
87
+ /**
88
+ * Calculates if the document is uploaded and ready for actions
89
+ * @param document The document
90
+ * @returns True if document is uploaded
91
+ */
92
+ private calculateIsDocumentUploaded;
93
+ static ɵfac: i0.ɵɵFactoryDeclaration<DocumentViewerService, never>;
94
+ static ɵprov: i0.ɵɵInjectableDeclaration<DocumentViewerService>;
95
+ }
@@ -83,6 +83,25 @@ export declare class DocumentHelperService {
83
83
  userId: string | null;
84
84
  status: string | null;
85
85
  }>;
86
+ /**
87
+ * Get the current selection state value synchronously
88
+ * @returns the current selection state value
89
+ */
90
+ getSelectionStateValue(): {
91
+ menuItem: string | null;
92
+ userId: string | null;
93
+ status: string | null;
94
+ };
95
+ /**
96
+ * Set status data in the store
97
+ * @param statusData the status data to set
98
+ */
99
+ setStatusData(statusData: any[]): void;
100
+ /**
101
+ * Set user list in the store
102
+ * @param userList the user list to set
103
+ */
104
+ setUserList(userList: any[]): void;
86
105
  /**
87
106
  * Get observable for filtered documents
88
107
  * @returns Observable that emits filtered document responses
@@ -98,6 +117,25 @@ export declare class DocumentHelperService {
98
117
  * @param contextId - The context ID to use for the API call
99
118
  */
100
119
  refreshDocumentsWithoutFilters(contextId: string): void;
120
+ /**
121
+ * Refresh all data with current filters after accept/reject/delete operations
122
+ * This includes document categories, status data, user list, and document list
123
+ *
124
+ * This method ensures that after a document action (accept/reject/delete):
125
+ * 1. Document categories are refreshed
126
+ * 2. Status counts are refreshed with current menu item and user filters
127
+ * 3. User list is refreshed with current filters (if applicable)
128
+ * 4. Document list is refreshed with all current filters (menu item, user, status, search)
129
+ *
130
+ * Filter application:
131
+ * - Document categories: Uses base contextId
132
+ * - Status data: Uses userId as contextId and menuItem as categoryId
133
+ * - User list: Uses base contextId (can be enhanced with additional filters if API supports)
134
+ * - Document list: Uses all current filters (menuItem, userId, status, searchKey)
135
+ *
136
+ * @param contextId - The context ID to use for the API calls
137
+ */
138
+ refreshAllDataWithCurrentFilters(contextId: string): void;
101
139
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentHelperService, never>;
102
140
  static ɵprov: i0.ɵɵInjectableDeclaration<DocumentHelperService>;
103
141
  }
@@ -8,6 +8,8 @@ import { DocumentCategory } from '../models/document-category.model';
8
8
  import { UserListModel } from '../models/user-list.model';
9
9
  import { StatusDataModel } from '../models/status-data.model';
10
10
  import { DocumentListResponse } from '../models/document-list-response.model';
11
+ import { DocumentListItem } from '../models/document-list-response.model';
12
+ import { DocumentHistorySection } from '../models/document-history.model';
11
13
  import * as i0 from "@angular/core";
12
14
  /**
13
15
  * Query service for managing document state.
@@ -136,6 +138,102 @@ export declare class DocumentQuery extends QueryEntity<DocumentState> {
136
138
  * @returns {DocumentListResponse[] | null} The current document list response.
137
139
  */
138
140
  getDocumentListResponse(): DocumentListResponse[] | null;
141
+ /**
142
+ * Selects the selected document for viewing.
143
+ * @returns {Observable<DocumentListItem | undefined>} Observable that emits the selected document.
144
+ */
145
+ selectSelectedDocument(): Observable<DocumentListItem | undefined>;
146
+ /**
147
+ * Gets the current selected document value (synchronous).
148
+ * @returns {DocumentListItem | undefined} The current selected document.
149
+ */
150
+ getSelectedDocument(): DocumentListItem | undefined;
151
+ /**
152
+ * Selects the document history.
153
+ * @returns {Observable<DocumentHistorySection[]>} Observable that emits the document history.
154
+ */
155
+ selectDocumentHistory(): Observable<DocumentHistorySection[]>;
156
+ /**
157
+ * Gets the current document history value (synchronous).
158
+ * @returns {DocumentHistorySection[]} The current document history.
159
+ */
160
+ getDocumentHistory(): DocumentHistorySection[];
161
+ /**
162
+ * Selects the document history visibility state.
163
+ * @returns {Observable<boolean>} Observable that emits the current document history visibility.
164
+ */
165
+ selectShowDocumentHistory(): Observable<boolean>;
166
+ /**
167
+ * Gets the current document history visibility value (synchronous).
168
+ * @returns {boolean} The current document history visibility.
169
+ */
170
+ getShowDocumentHistory(): boolean;
171
+ /**
172
+ * Selects the action loading state.
173
+ * @returns {Observable<boolean>} Observable that emits the current action loading state.
174
+ */
175
+ selectIsActionLoading(): Observable<boolean>;
176
+ /**
177
+ * Gets the current action loading value (synchronous).
178
+ * @returns {boolean} The current action loading state.
179
+ */
180
+ getIsActionLoading(): boolean;
181
+ /**
182
+ * Selects the document status.
183
+ * @returns {Observable<'pending' | 'accepted' | 'rejected'>} Observable that emits the current document status.
184
+ */
185
+ selectDocumentStatus(): Observable<'pending' | 'accepted' | 'rejected'>;
186
+ /**
187
+ * Gets the current document status value (synchronous).
188
+ * @returns {'pending' | 'accepted' | 'rejected'} The current document status.
189
+ */
190
+ getDocumentStatus(): 'pending' | 'accepted' | 'rejected';
191
+ /**
192
+ * Selects the document uploaded state.
193
+ * @returns {Observable<boolean>} Observable that emits the current document uploaded state.
194
+ */
195
+ selectDocumentIsUploaded(): Observable<boolean>;
196
+ /**
197
+ * Gets the current document uploaded value (synchronous).
198
+ * @returns {boolean} The current document uploaded state.
199
+ */
200
+ getDocumentIsUploaded(): boolean;
201
+ /**
202
+ * Selects the alert data.
203
+ * @returns {Observable<any>} Observable that emits the current alert data.
204
+ */
205
+ selectAlertData(): Observable<any>;
206
+ /**
207
+ * Gets the current alert data value (synchronous).
208
+ * @returns {any} The current alert data.
209
+ */
210
+ getAlertData(): any;
211
+ /**
212
+ * Selects all document viewer state properties.
213
+ * @returns {Observable<{selectedDocument?: DocumentListItem, documentHistory: DocumentHistorySection[], showDocumentHistory: boolean, isActionLoading: boolean, documentStatus: 'pending' | 'accepted' | 'rejected', documentIsUploaded: boolean, alertData: any}>} Observable that emits the current document viewer state.
214
+ */
215
+ selectDocumentViewerState(): Observable<{
216
+ selectedDocument?: DocumentListItem;
217
+ documentHistory: DocumentHistorySection[];
218
+ showDocumentHistory: boolean;
219
+ isActionLoading: boolean;
220
+ documentStatus: 'pending' | 'accepted' | 'rejected';
221
+ documentIsUploaded: boolean;
222
+ alertData: any;
223
+ }>;
224
+ /**
225
+ * Gets the current document viewer state values (synchronous).
226
+ * @returns {Object} The current document viewer state values.
227
+ */
228
+ getDocumentViewerState(): {
229
+ selectedDocument?: DocumentListItem;
230
+ documentHistory: DocumentHistorySection[];
231
+ showDocumentHistory: boolean;
232
+ isActionLoading: boolean;
233
+ documentStatus: 'pending' | 'accepted' | 'rejected';
234
+ documentIsUploaded: boolean;
235
+ alertData: any;
236
+ };
139
237
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentQuery, never>;
140
238
  static ɵprov: i0.ɵɵInjectableDeclaration<DocumentQuery>;
141
239
  }
@@ -8,6 +8,8 @@ import { Message } from 'primeng/api';
8
8
  import { UserListModel } from '../models/user-list.model';
9
9
  import { StatusDataModel } from '../models/status-data.model';
10
10
  import { DocumentListResponse } from '../models/document-list-response.model';
11
+ import { DocumentListItem } from '../models/document-list-response.model';
12
+ import { DocumentHistorySection } from '../models/document-history.model';
11
13
  /**
12
14
  * Represents the state of the documents in the application.
13
15
  * This interface extends Akita's `EntityState` to include additional properties
@@ -40,6 +42,13 @@ export interface DocumentState extends EntityState<DocumentModel, string> {
40
42
  userList: UserListModel[];
41
43
  statusData: StatusDataModel[];
42
44
  documentListResponse: DocumentListResponse[] | null;
45
+ selectedDocument?: DocumentListItem;
46
+ documentHistory: DocumentHistorySection[];
47
+ showDocumentHistory: boolean;
48
+ isActionLoading: boolean;
49
+ documentStatus: 'pending' | 'accepted' | 'rejected';
50
+ documentIsUploaded: boolean;
51
+ alertData: any;
43
52
  }
44
53
  /**
45
54
  * Creates the initial state for the `DocumentState` store.
@@ -6,6 +6,8 @@ import { DocumentModel } from '../models/document.model';
6
6
  import { UserListModel } from '../models/user-list.model';
7
7
  import { StatusDataModel } from '../models/status-data.model';
8
8
  import { DocumentListResponse } from '../models/document-list-response.model';
9
+ import { DocumentListItem } from '../models/document-list-response.model';
10
+ import { DocumentHistorySection } from '../models/document-history.model';
9
11
  import * as i0 from "@angular/core";
10
12
  /**
11
13
  * Store that manages the state of documents in the application.
@@ -38,6 +40,15 @@ export declare class DocumentStore extends EntityStore<DocumentState> {
38
40
  setUserList(userList: UserListModel[]): void;
39
41
  setStatusData(statusData: StatusDataModel[]): void;
40
42
  setDocumentListResponse(response: DocumentListResponse[] | null): void;
43
+ setSelectedDocument(document: DocumentListItem | undefined): void;
44
+ setDocumentHistory(history: DocumentHistorySection[]): void;
45
+ setShowDocumentHistory(show: boolean): void;
46
+ setIsActionLoading(loading: boolean): void;
47
+ setDocumentStatus(status: 'pending' | 'accepted' | 'rejected'): void;
48
+ setDocumentIsUploaded(uploaded: boolean): void;
49
+ setAlertData(alertData: any): void;
50
+ updateDocumentViewerState(document?: DocumentListItem, history?: DocumentHistorySection[], showHistory?: boolean, loading?: boolean, status?: 'pending' | 'accepted' | 'rejected', uploaded?: boolean, alertData?: any): void;
51
+ clearDocumentViewerState(): void;
41
52
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentStore, never>;
42
53
  static ɵprov: i0.ɵɵInjectableDeclaration<DocumentStore>;
43
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cat-documents-ng",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.0.0",
6
6
  "@angular/core": "^19.0.0"