Linh - Add multi-select and bulk actions to Materials table _be#2178
Linh - Add multi-select and bulk actions to Materials table _be#2178linh2020 wants to merge 2 commits into
Conversation
… 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
|
|
handikaharianto
left a comment
There was a problem hiding this comment.
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.

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.

I also agree with this. Could you clarify on this matter? @linh2020 |
pixelpix13
left a comment
There was a problem hiding this comment.
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:
- buildingMaterial schema contains stockHold, isReviewed, and notes.
- bmApplyMaterialBulkAction updates these fields correctly.
- GET /bm/materials returns these fields and they are not excluded by select/projection logic.
Requesting changes pending verification of persistence and retrieval behavior.



Description
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
