Skip to content

Linh - Add multi-select and bulk actions to Materials table _be#2178

Open
linh2020 wants to merge 2 commits into
developmentfrom
linh_bulk_actions_materials_backend
Open

Linh - Add multi-select and bulk actions to Materials table _be#2178
linh2020 wants to merge 2 commits into
developmentfrom
linh_bulk_actions_materials_backend

Conversation

@linh2020

@linh2020 linh2020 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Description

image

Please include the exact bug/functionality description and a summary of the changes/ related issues. Please also include any other relevant motivation and context:
Adds backend persistence for new bulk material actions so frontend actions are not local-only and survive refresh/reload.

Fixes # (bug list priority high/medium/low x.y.z)
Fixes #MEDIUM-bmdashboard-materials-bulk-actions

Or Implements # (WBS)
Implements #WBS-BM-Materials-Bulk-Actions

Related PRS (if any):

This backend PR is related to the #YYY frontend PR.
To test this backend PR you need to checkout the #YYY frontend PR.

Main changes explained:

Update buildingMaterial.js to add persistent fields:

stockHold (Boolean)
isReviewed (Boolean)
notes (String)
Update bmMaterialsController.js to add bmApplyMaterialBulkAction:

validates materialIds and action
supports actions: hold, review, notes
updates selected materials via updateMany
returns applied-record count summary
Update bmMaterialsRouter.js to expose:

POST /bm/materials/bulk-actions

How to test:

check into current branch (frontend + backend PR branches)
backend:
cd backend/HGNRest
npm install
npm run dev (or project-standard start command)
frontend:
cd frontend/HighestGoodNetworkApp
npm install
npm run dev
Clear site data/cache
log as admin user
go to /bmdashboard/materials
verify:
row checkboxes appear and select-all works
rows are highlighted when selected
Bulk Actions is disabled with 0 selected rows
select multiple rows and run Mark as Hold, then confirm Hold column/status reflects persisted value after refresh
select multiple rows and run Mark as Reviewed, then confirm persisted value after refresh
run Add/Update Notes and confirm status chip appears and persists after refresh
run Export Selected (CSV/PDF) and confirm file contents are for selected items only
verify this new feature works in dark mode
verify responsive behavior at mobile/tablet widths (bulk bar wraps correctly and remains usable)

Screenshots
Screenshot 2026-06-12 at 11 06 14 PM

Screenshot 2026-06-12 at 11 04 56 PM

… hold/review/notes

- extend buildingMaterial schema with persistent bulk-action fields:
  - stockHold (Boolean, default false)
  - isReviewed (Boolean, default false)
  - notes (String, default empty)
- add controller handler bmApplyMaterialBulkAction to process bulk material updates
- support bulk actions:
  - hold
  - review
  - notes
- validate request payload (materialIds, action, notes requirements)
- apply updates via updateMany and return affected count in response
- expose new route:
  - POST /bm/materials/bulk-actions

Files updated:
- backend/HGNRest/src/models/bmdashboard/buildingMaterial.js
- backend/HGNRest/src/controllers/bmdashboard/bmMaterialsController.js
- backend/HGNRest/src/routes/bmdashboard/bmMaterialsRouter.js
@sonarqubecloud

Copy link
Copy Markdown

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Apr 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@handikaharianto handikaharianto left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, i just reviewed this PR and here are my findings:

Worked well

No bulk action results in bad request✅

When action property is not passed, the API endpoint returns a 400 Bad Request, which is a proper response to this scenario.
Image

Requires some updates

Not so helpful message❌

The following image shows that it returns a result properties that says "Applied 'hold' to undefined material records". Showing undefined to the users will confuse them.
Image

@handikaharianto

Copy link
Copy Markdown

hi @linh2020 Tested POST /bm/materials/bulk-actions together with the related frontend implementation.

Bulk actions execute successfully, however the expected persisted fields could not be verified after execution.

Observed:

  • Response reports "Applied 'hold' to undefined material records."

  • GET /bm/materials does not appear to return:

    • stockHold
    • isReviewed
    • notes
  • Database records do not appear to contain these fields.

Please verify:

  1. buildingMaterial schema contains stockHold, isReviewed, and notes.
  2. bmApplyMaterialBulkAction updates these fields correctly.
  3. GET /bm/materials returns these fields and they are not excluded by select/projection logic.

Requesting changes pending verification of persistence and retrieval behavior.

I also agree with this. Could you clarify on this matter? @linh2020

@pixelpix13 pixelpix13 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @linh2020
Tested POST /bm/materials/bulk-actions together with the related frontend implementation.

Bulk actions execute successfully, however the expected persisted fields could not be verified after execution.

Observed:

  • Response reports "Applied 'hold' to undefined material records."
  • GET /bm/materials does not appear to return:
    • stockHold
    • isReviewed
    • notes
  • Database records do not appear to contain these fields.

Please verify:

  1. buildingMaterial schema contains stockHold, isReviewed, and notes.
  2. bmApplyMaterialBulkAction updates these fields correctly.
  3. GET /bm/materials returns these fields and they are not excluded by select/projection logic.

Requesting changes pending verification of persistence and retrieval behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants