OLMIS-8249: Mark invalid adjustment quantity fields#89
Conversation
Reasons whose quantity is not greater than 0 block the physical inventory update, but the offending fields were not marked, so users could not tell which line was blocking them. Expose hasValidQuantity on the AdjustmentsModalController and add a quantity-invalid class to an adjustment row when its quantity is not greater than 0. The invalid state is rendered on the whole quantity field (the .input-control wrapper), matching how the Reason field is marked. The selector targets the wrapper <div> only: a bare .input-control also matches the inner <input> (which @extends .input-control) and would paint a second, nested border. Covered by new AdjustmentsModalController hasValidQuantity specs.
|
Generally the solution looks good but I'd propose reusing the existing styles. This proposition introduces another invalid style that is only used for adjustments modal but the FE already has such styles / directives that can be reused. Try to work with openlmis-invalid attribute or with is-invalid class (or both). I suppose the openlmis-quantity-unit-input might be problematic so please review briefly if the invalid styles are wired to this directive or can be easily wired (packs&doses are currently in improvement stage so maybe it would be great to propose some enhancements). |
Per review, replace the bespoke invalid style with the platform's existing openlmis-invalid mechanism, the same pattern used by stock-add-products-modal. - Drop the module-scoped SCSS rule and the custom quantity-invalid class. - validateAdjustment stores a quantityInvalid message on an adjustment whose quantity is not greater than 0; it runs on quantity change and for every row on save. - Mark the quantity cell with openlmis-invalid, and broadcast openlmis-form-submit on save so the messages are revealed. No custom CSS. Works in both the Packs and the Doses view. Specs updated to cover validateAdjustment and save marking.
|



Problem
Reasons whose quantity is not greater than 0 (zero or empty) block the physical
inventory update, but the offending fields in the "Reasons for …" modal were not
marked — so the user got the "Quantity must be greater than 0" alert without any
indication of which line was blocking them.
Changes
hasValidQuantityonAdjustmentsModalController.quantity-invalidclass to an adjustment row (editable mode only) when itsquantity is not greater than 0.
.input-controlwrapper),matching how the required Reason field is marked. The selector targets the wrapper
<div>only — a bare.input-controlalso matches the inner<input>(which@extends.input-control) and would paint a second, nested border.Files changed (4):
adjustments-modal.controller.js,adjustments-modal.html,_adjustments-modal.scss,adjustments-modal.controller.spec.js.Testing
grunt test— all unit tests pass (964/964), including newhasValidQuantityspecs.grunt eslint— clean (no new issues).ui-components+reference-uilocally and verified the highlight in thephysical inventory adjustments modal (Packs and Doses).
Screenshot