-
Notifications
You must be signed in to change notification settings - Fork 1
WorkCardComponent JavaScript
The WorkCardComponent is a Lightning Web Component (LWC) that displays detailed action items related to a selected work record. The component dynamically updates based on messages received through the Lightning message service, providing a responsive and interactive user experience. Pagination is included but only becomes active when there are more than four action items.
-
@track workItemActions: Tracks the list of work item actions related to the selected work record. -
workRecordId: Stores the ID of the currently selected work record. -
isModalOpen: Controls the visibility of the edit modal. -
message: Stores messages to display when no work item actions are available or when there is an error. -
wiredResult: Holds the result from the getWorkItemActions Apex method for refreshing data. -
@track page: Manages the current page for pagination. -
@track pageSize: Defines the number of action items displayed per page. -
@track totalRecords: The total number of work item actions retrieved. -
@track totalPage: The total number of pages calculated based on totalRecords and pageSize.
-
connectedCallback(): Subscribes to message channels and initializes the component when it is first inserted into the DOM. -
wiredWorkItemActions(result): Processes the data returned from the getWorkItemActions Apex method, managing pagination and setting the component's state. -
handleWorkMessage(message): Handles messages received from the WorkMessageChannel, updating the work record ID and fetching related work item actions. -
handleWorkItemMessage(message): Handles messages received from the WorkItemMessageChannel, triggering a data refresh for the current work record. -
refreshData(): Refreshes the work item actions based on the current work record ID, resetting pagination if necessary. -
handleEditClick(event): Opens the modal for editing a specific work item action. -
handleModalClose(): Closes the modal after editing is complete. -
updateTotalPages(): Updates the total pages based on the number of work item actions retrieved. -
isPreviousDisabled(): Disables the "Previous" button if on the first page. -
isNextDisabled(): Disables the "Next" button if on the last page or if pagination is not required.
The component enables pagination when there are more than four work item actions. The pagination controls allow users to navigate through the action items efficiently. When switching between work records, the pagination resets to the first page to ensure that all items are visible.
The work item actions are sorted by their Status__c field, prioritizing items with a status of 'Not Started' at the top. This ensures that users can focus on the most urgent tasks first.