@openmrs/esm-stock-management-app 1.0.1-pre.327
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +39 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +14 -0
- package/.turbo.json +18 -0
- package/.yarn/plugins/@yarnpkg/plugin-outdated.cjs +35 -0
- package/LICENSE +401 -0
- package/README.md +3 -0
- package/__mocks__/react-i18next.js +55 -0
- package/dist/26.js +2 -0
- package/dist/26.js.LICENSE.txt +32 -0
- package/dist/26.js.map +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/294.js.map +1 -0
- package/dist/375.js +2 -0
- package/dist/375.js.LICENSE.txt +40 -0
- package/dist/375.js.map +1 -0
- package/dist/46.js +1 -0
- package/dist/46.js.map +1 -0
- package/dist/484.js +1 -0
- package/dist/484.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/707.js +1 -0
- package/dist/707.js.map +1 -0
- package/dist/800.js +2 -0
- package/dist/800.js.LICENSE.txt +3 -0
- package/dist/800.js.map +1 -0
- package/dist/935.js +2 -0
- package/dist/935.js.LICENSE.txt +19 -0
- package/dist/935.js.map +1 -0
- package/dist/979.js +1 -0
- package/dist/979.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +60 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-stock-management-app.js +1 -0
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +356 -0
- package/dist/openmrs-esm-stock-management-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/i18next-parser.config.js +89 -0
- package/jest.config.js +25 -0
- package/package.json +116 -0
- package/src/config-schema.ts +18 -0
- package/src/constants.ts +214 -0
- package/src/core/api/api.ts +34 -0
- package/src/core/api/types/Auditable.ts +9 -0
- package/src/core/api/types/BaseOpenmrsData.ts +4 -0
- package/src/core/api/types/BaseOpenmrsMetadata.ts +6 -0
- package/src/core/api/types/BaseOpenmrsObject.ts +3 -0
- package/src/core/api/types/BatchJob.ts +121 -0
- package/src/core/api/types/DashboardExtension.ts +8 -0
- package/src/core/api/types/Location.ts +16 -0
- package/src/core/api/types/LocationTree.ts +7 -0
- package/src/core/api/types/OpenmrsData.ts +5 -0
- package/src/core/api/types/OpenmrsMetadata.ts +8 -0
- package/src/core/api/types/OpenmrsObject.ts +3 -0
- package/src/core/api/types/PageableResult.ts +15 -0
- package/src/core/api/types/Party.ts +8 -0
- package/src/core/api/types/RecordPermission.ts +9 -0
- package/src/core/api/types/Retireable.ts +9 -0
- package/src/core/api/types/Voidable.ts +9 -0
- package/src/core/api/types/concept/Concept.ts +24 -0
- package/src/core/api/types/concept/ConceptName.ts +14 -0
- package/src/core/api/types/concept/Drug.ts +14 -0
- package/src/core/api/types/identity/Credentials.ts +4 -0
- package/src/core/api/types/identity/Patient.ts +3 -0
- package/src/core/api/types/identity/Person.ts +4 -0
- package/src/core/api/types/identity/PriviledgeScope.ts +9 -0
- package/src/core/api/types/identity/Privilege.ts +5 -0
- package/src/core/api/types/identity/Role.ts +5 -0
- package/src/core/api/types/identity/Session.ts +16 -0
- package/src/core/api/types/identity/User.ts +19 -0
- package/src/core/api/types/identity/UserRoleScope.ts +17 -0
- package/src/core/api/types/identity/UserRoleScopeLocation.ts +7 -0
- package/src/core/api/types/identity/UserRoleScopeOperationType.ts +6 -0
- package/src/core/api/types/stockItem/ImportResult.ts +9 -0
- package/src/core/api/types/stockItem/StockBatch.ts +8 -0
- package/src/core/api/types/stockItem/StockBatchDTO.ts +8 -0
- package/src/core/api/types/stockItem/StockItem.ts +63 -0
- package/src/core/api/types/stockItem/StockItemInventory.ts +10 -0
- package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +20 -0
- package/src/core/api/types/stockItem/StockItemTransaction.ts +22 -0
- package/src/core/api/types/stockItem/StockRule.ts +28 -0
- package/src/core/api/types/stockOperation/LocationType.ts +4 -0
- package/src/core/api/types/stockOperation/StockOperation.ts +36 -0
- package/src/core/api/types/stockOperation/StockOperationAction.ts +24 -0
- package/src/core/api/types/stockOperation/StockOperationDTO.ts +64 -0
- package/src/core/api/types/stockOperation/StockOperationItem.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationItemCost.ts +14 -0
- package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +29 -0
- package/src/core/api/types/stockOperation/StockOperationLinkDTO.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationStatus.ts +18 -0
- package/src/core/api/types/stockOperation/StockOperationType.ts +162 -0
- package/src/core/api/types/stockOperation/StockSource.ts +8 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +37 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.scss +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.test.tsx +8 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +40 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.scss +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.test.tsx +8 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +44 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.scss +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.test.tsx +8 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +54 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.scss +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.test.tsx +8 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.scss +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.test.tsx +11 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.scss +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.test.tsx +8 -0
- package/src/core/components/carbon/types.ts +7 -0
- package/src/core/components/card/metrics-card-component.tsx +102 -0
- package/src/core/components/card/metrics-card.scss +78 -0
- package/src/core/components/overlay/hook.ts +47 -0
- package/src/core/components/overlay/overlay.component.tsx +52 -0
- package/src/core/components/overlay/overlay.scss +97 -0
- package/src/core/components/side-nav/side-nav.component.tsx +62 -0
- package/src/core/components/side-nav/side-nav.scss +126 -0
- package/src/core/components/side-nav/types.ts +6 -0
- package/src/core/components/table/table.component.tsx +239 -0
- package/src/core/components/table/table.scss +173 -0
- package/src/core/components/table/types.ts +8 -0
- package/src/core/components/tabs/types.ts +7 -0
- package/src/core/components/tabs/vertical-tabs.component.tsx +53 -0
- package/src/core/components/tabs/vertical-tabs.scss +126 -0
- package/src/core/hooks/debounce-hook.ts +35 -0
- package/src/core/print/PrintStyles.ts +774 -0
- package/src/core/print/PrintTemplate.ts +65 -0
- package/src/core/print/printUtils.ts +19 -0
- package/src/core/utils/alert.ts +10 -0
- package/src/core/utils/datetimeUtils.ts +84 -0
- package/src/core/utils/debounce.ts +21 -0
- package/src/core/utils/imageUtils.ts +82 -0
- package/src/core/utils/stringUtils.ts +27 -0
- package/src/core/utils/utils.ts +70 -0
- package/src/createDashboardLink.tsx +43 -0
- package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +50 -0
- package/src/dashboard/stock-management-dashboard.component.tsx +41 -0
- package/src/dashboard/stock-management-dashboard.scss +8 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +6 -0
- package/src/index.ts +64 -0
- package/src/root.component.tsx +12 -0
- package/src/root.scss +174 -0
- package/src/routes.json +53 -0
- package/src/setup-tests.ts +1 -0
- package/src/stock-app-menu-item/item.component.tsx +21 -0
- package/src/stock-app-menu-item/item.resource.ts +0 -0
- package/src/stock-app-menu-item/item.scss +17 -0
- package/src/stock-batch/stock-batch.resource.ts +79 -0
- package/src/stock-home/stock-home-detail-card.scss +211 -0
- package/src/stock-home/stock-home-detail-cards.component.tsx +62 -0
- package/src/stock-home/stock-home-inventory-card.component.tsx +80 -0
- package/src/stock-home/stock-home-inventory-expiry.resource.tsx +32 -0
- package/src/stock-home/stock-home-inventory-items.resource.tsx +28 -0
- package/src/stock-home/stock-home-issuing-card.component.tsx +84 -0
- package/src/stock-home/stock-home-issuing.resource.tsx +18 -0
- package/src/stock-home/stock-home-landing-page-component.tsx +14 -0
- package/src/stock-home/stock-home-metrics.tsx +112 -0
- package/src/stock-home/stock-home-receiving-card.component.tsx +66 -0
- package/src/stock-home/stock-home-receiving.resource.tsx +17 -0
- package/src/stock-home/stock-home.scss +13 -0
- package/src/stock-home/useDisposalList.tsx +18 -0
- package/src/stock-home/useStockList.tsx +36 -0
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +26 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +109 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +14 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.scss +0 -0
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +21 -0
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +84 -0
- package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +36 -0
- package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +98 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +71 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +79 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +76 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +66 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.scss +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +83 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +50 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.scss +0 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +255 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +38 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +21 -0
- package/src/stock-items/add-stock-item/packaging-units/validationSchema.ts +14 -0
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +95 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +70 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.scss +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/quantities/quantities.component.tsx +83 -0
- package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +69 -0
- package/src/stock-items/add-stock-item/quantities/quantities.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +239 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +14 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +30 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +424 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +18 -0
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +47 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +37 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +222 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +72 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +38 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +79 -0
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +132 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.component.tsx +16 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.scss +0 -0
- package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +151 -0
- package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +109 -0
- package/src/stock-items/add-stock-item/transactions/transactions.scss +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +28 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.resource.tsx +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.scss +3 -0
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +30 -0
- package/src/stock-items/stock-item.utils.tsx +62 -0
- package/src/stock-items/stock-items-table.component.tsx +266 -0
- package/src/stock-items/stock-items-table.resource.ts +58 -0
- package/src/stock-items/stock-items-table.scss +66 -0
- package/src/stock-items/stock-items.component.tsx +12 -0
- package/src/stock-items/stock-items.resource.ts +365 -0
- package/src/stock-items/types.ts +8 -0
- package/src/stock-items/validationSchema.ts +67 -0
- package/src/stock-locations/stock-locations-table.component.tsx +69 -0
- package/src/stock-locations/stock-locations-table.resource.tsx +73 -0
- package/src/stock-locations/stock-locations-table.scss +0 -0
- package/src/stock-locations/stock-locations.component.tsx +12 -0
- package/src/stock-locations/stock-locations.resource.ts +0 -0
- package/src/stock-lookups/stock-lookups.resource.ts +306 -0
- package/src/stock-management-admin-card-link.component.tsx +29 -0
- package/src/stock-management-header/stock-management-Illustration.tsx +35 -0
- package/src/stock-management-header/stock-management-header.component.tsx +37 -0
- package/src/stock-management-header/stock-management-header.scss +58 -0
- package/src/stock-management.component.tsx +6 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +491 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +33 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.scss +44 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +241 -0
- package/src/stock-operations/add-stock-operation/add-stock-utils.ts +110 -0
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +352 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +347 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +11 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +5 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +272 -0
- package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +22 -0
- package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +188 -0
- package/src/stock-operations/add-stock-operation/types.ts +55 -0
- package/src/stock-operations/add-stock-operation/validationSchema.ts +45 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +100 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.resource.tsx +46 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +11 -0
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +73 -0
- package/src/stock-operations/party-selector/party-selector.component.tsx +58 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +65 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +11 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +74 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.resource.tsx +47 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +11 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +27 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.scss +13 -0
- package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +65 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +30 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.scss +13 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +32 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.scss +13 -0
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +80 -0
- package/src/stock-operations/stock-operation.utils.tsx +106 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +167 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +14 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +58 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +160 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-table.component.tsx +524 -0
- package/src/stock-operations/stock-operations-table.resource.tsx +77 -0
- package/src/stock-operations/stock-operations-table.scss +0 -0
- package/src/stock-operations/stock-operations.component.tsx +12 -0
- package/src/stock-operations/stock-operations.resource.ts +238 -0
- package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +147 -0
- package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +153 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +133 -0
- package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +161 -0
- package/src/stock-operations/swr-revalidation.ts +7 -0
- package/src/stock-operations/users-selector/users-selector.component.tsx +77 -0
- package/src/stock-operations/users-selector/users-selector.resource.tsx +47 -0
- package/src/stock-operations/validation-schema.ts +195 -0
- package/src/stock-reports/ReportType.ts +63 -0
- package/src/stock-reports/stock-reports.component.tsx +0 -0
- package/src/stock-reports/stock-reports.resource.ts +0 -0
- package/src/stock-settings/stock-settings.component.tsx +11 -0
- package/src/stock-settings/stock-settings.resource.ts +0 -0
- package/src/stock-sources/add-stock-source-button.component.tsx +21 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +152 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +18 -0
- package/src/stock-sources/delete-stock-modal.component.tsx +47 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +35 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delate.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +72 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +35 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +13 -0
- package/src/stock-sources/stock-sources-items-table.component.tsx +213 -0
- package/src/stock-sources/stock-sources-items-table.resource.ts +56 -0
- package/src/stock-sources/stock-sources.component.tsx +12 -0
- package/src/stock-sources/stock-sources.resource.ts +80 -0
- package/src/stock-sources/stock-sources.scss +220 -0
- package/src/stock-sources/swr-revalidation.ts +7 -0
- package/src/stock-tabs/commodity-tabs.component.tsx +43 -0
- package/src/stock-tabs/commodity-tabs.scss +0 -0
- package/src/stock-user-role-scopes/add-stock-user-role-scope-button.component.tsx +21 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +525 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +37 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +73 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.scss +0 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +47 -0
- package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +35 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +284 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +31 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +12 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +76 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.scss +61 -0
- package/src/stock-user-role-scopes/swr-revalidation.ts +7 -0
- package/src/utils.ts +10 -0
- package/translations/en.json +24 -0
- package/tsconfig.json +23 -0
- package/webpack.config.js +1 -0
package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx
ADDED
@@ -0,0 +1,525 @@
|
|
1
|
+
import {
|
2
|
+
Button,
|
3
|
+
Checkbox,
|
4
|
+
CheckboxGroup,
|
5
|
+
Form,
|
6
|
+
ModalBody,
|
7
|
+
ModalFooter,
|
8
|
+
ModalHeader,
|
9
|
+
InlineLoading,
|
10
|
+
Toggle,
|
11
|
+
DatePickerInput,
|
12
|
+
DatePicker,
|
13
|
+
ComboBox,
|
14
|
+
Select,
|
15
|
+
SelectItem,
|
16
|
+
} from "@carbon/react";
|
17
|
+
import React, { ChangeEvent, useMemo, useState } from "react";
|
18
|
+
import styles from "./add-stock-user-role-scope.scss";
|
19
|
+
import {
|
20
|
+
UserFilterCriteria,
|
21
|
+
useRoles,
|
22
|
+
useStockOperationTypes,
|
23
|
+
useStockTagLocations,
|
24
|
+
useUser,
|
25
|
+
useUsers,
|
26
|
+
} from "../../stock-lookups/stock-lookups.resource";
|
27
|
+
import { ResourceRepresentation } from "../../core/api/api";
|
28
|
+
import { closeOverlay } from "../../core/components/overlay/hook";
|
29
|
+
import { useTranslation } from "react-i18next";
|
30
|
+
import { UserRoleScope } from "../../core/api/types/identity/UserRoleScope";
|
31
|
+
import { createOrUpdateUserRoleScope } from "../stock-user-role-scopes.resource";
|
32
|
+
import { showNotification, showToast } from "@openmrs/esm-framework";
|
33
|
+
import { UserRoleScopeOperationType } from "../../core/api/types/identity/UserRoleScopeOperationType";
|
34
|
+
import { UserRoleScopeLocation } from "../../core/api/types/identity/UserRoleScopeLocation";
|
35
|
+
import {
|
36
|
+
DATE_PICKER_CONTROL_FORMAT,
|
37
|
+
DATE_PICKER_FORMAT,
|
38
|
+
INVENTORY_ADMNISTRATOR_ROLE_UUID,
|
39
|
+
INVENTORY_CLERK_ROLE_UUID,
|
40
|
+
INVENTORY_DISPENSING_ROLE_UUID,
|
41
|
+
INVENTORY_MANAGER_ROLE_UUID,
|
42
|
+
INVENTORY_REPORTING_ROLE_UUID,
|
43
|
+
formatForDatePicker,
|
44
|
+
today,
|
45
|
+
} from "../../constants";
|
46
|
+
import { debounce } from "lodash-es";
|
47
|
+
import { User } from "../../core/api/types/identity/User";
|
48
|
+
import { Role } from "../../core/api/types/identity/Role";
|
49
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
50
|
+
import { handleMutate } from "../swr-revalidation";
|
51
|
+
|
52
|
+
const MinDate: Date = today();
|
53
|
+
|
54
|
+
interface AddStockUserRoleScopeProps {
|
55
|
+
model?: UserRoleScope;
|
56
|
+
}
|
57
|
+
|
58
|
+
const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
59
|
+
model,
|
60
|
+
}) => {
|
61
|
+
const { t } = useTranslation();
|
62
|
+
|
63
|
+
const [formModel, setFormModel] = useState<UserRoleScope>({ ...model });
|
64
|
+
|
65
|
+
const [roles, setRoles] = useState<Role[]>([]);
|
66
|
+
|
67
|
+
const { data: user } = useUser(model?.uuid);
|
68
|
+
|
69
|
+
// operation types
|
70
|
+
const {
|
71
|
+
types: { results: stockOperations },
|
72
|
+
isLoading,
|
73
|
+
} = useStockOperationTypes();
|
74
|
+
|
75
|
+
// get users
|
76
|
+
const {
|
77
|
+
items: users,
|
78
|
+
|
79
|
+
isLoading: loadingUsers,
|
80
|
+
} = useUsers({ v: ResourceRepresentation.Default });
|
81
|
+
|
82
|
+
// get roles
|
83
|
+
const { items: rolesData, isLoading: loadingRoles } = useRoles({
|
84
|
+
v: ResourceRepresentation.Default,
|
85
|
+
});
|
86
|
+
|
87
|
+
/* Only load locations tagged to perform stock related activities.
|
88
|
+
Unless a location is tag as main store, main pharmacy or dispensing, it will not be listed here.
|
89
|
+
|
90
|
+
*/
|
91
|
+
const { stockLocations } = useStockTagLocations();
|
92
|
+
const onEnabledChanged = (
|
93
|
+
cvt: React.ChangeEvent<HTMLInputElement>,
|
94
|
+
data: { checked: boolean; id: string }
|
95
|
+
): void => {
|
96
|
+
const isEnabled = !formModel?.enabled;
|
97
|
+
setFormModel({ ...formModel, enabled: isEnabled });
|
98
|
+
};
|
99
|
+
|
100
|
+
const onPermanentChanged = (
|
101
|
+
cvt: React.ChangeEvent<HTMLInputElement>,
|
102
|
+
data: { checked: boolean; id: string }
|
103
|
+
): void => {
|
104
|
+
const isPermanent = !formModel?.permanent;
|
105
|
+
setFormModel({
|
106
|
+
...formModel,
|
107
|
+
permanent: isPermanent,
|
108
|
+
activeFrom: undefined,
|
109
|
+
activeTo: undefined,
|
110
|
+
});
|
111
|
+
};
|
112
|
+
|
113
|
+
const onStockOperationTypeChanged = (
|
114
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
115
|
+
uuid: string,
|
116
|
+
isChecked: boolean
|
117
|
+
): void => {
|
118
|
+
const operationType = formModel?.operationTypes?.find(
|
119
|
+
(x) => x.operationTypeUuid === event?.target?.value
|
120
|
+
);
|
121
|
+
if (operationType) {
|
122
|
+
const newOperationTypes = [
|
123
|
+
...formModel.operationTypes.filter(
|
124
|
+
(x) => x.operationTypeUuid !== operationType?.operationTypeUuid
|
125
|
+
),
|
126
|
+
];
|
127
|
+
setFormModel({ ...formModel, operationTypes: newOperationTypes });
|
128
|
+
} else {
|
129
|
+
const stockOperationType = stockOperations?.find(
|
130
|
+
(x) => x.uuid === event?.target?.value
|
131
|
+
);
|
132
|
+
const operationType: UserRoleScopeOperationType = {
|
133
|
+
operationTypeName: stockOperationType?.name,
|
134
|
+
operationTypeUuid: stockOperationType?.uuid,
|
135
|
+
} as unknown as UserRoleScopeOperationType;
|
136
|
+
setFormModel({
|
137
|
+
...formModel,
|
138
|
+
operationTypes: [...(formModel?.operationTypes ?? []), operationType],
|
139
|
+
});
|
140
|
+
}
|
141
|
+
};
|
142
|
+
|
143
|
+
const onLocationCheckBoxChanged = (
|
144
|
+
event: ChangeEvent<HTMLInputElement>,
|
145
|
+
id: string
|
146
|
+
): void => {
|
147
|
+
const selectedLocation = formModel?.locations?.find(
|
148
|
+
(x) => x.locationUuid === event?.target?.value
|
149
|
+
);
|
150
|
+
if (selectedLocation) {
|
151
|
+
const newLocations = [
|
152
|
+
...(formModel?.locations?.filter(
|
153
|
+
(x) => x.locationUuid !== selectedLocation?.locationUuid
|
154
|
+
) ?? []),
|
155
|
+
];
|
156
|
+
setFormModel({ ...formModel, locations: newLocations });
|
157
|
+
} else {
|
158
|
+
const loc = stockLocations?.find((x) => x.id === event?.target?.value);
|
159
|
+
const newLocation: UserRoleScopeLocation = {
|
160
|
+
locationName: loc?.name,
|
161
|
+
locationUuid: loc?.id,
|
162
|
+
enableDescendants: false,
|
163
|
+
} as unknown as UserRoleScopeLocation;
|
164
|
+
const newLocations = [...(formModel?.locations ?? []), newLocation];
|
165
|
+
setFormModel({ ...formModel, locations: newLocations });
|
166
|
+
}
|
167
|
+
};
|
168
|
+
|
169
|
+
const findCheckedLocation = (
|
170
|
+
location: fhir.Location
|
171
|
+
): UserRoleScopeLocation | null => {
|
172
|
+
const result = formModel?.locations?.filter(
|
173
|
+
(x) => x.locationUuid === location.id
|
174
|
+
);
|
175
|
+
return result && result.length > 0 ? result[0] : null;
|
176
|
+
};
|
177
|
+
|
178
|
+
const onActiveDatesChange = (dates: Date[]): void => {
|
179
|
+
setFormModel({ ...formModel, activeFrom: dates[0], activeTo: dates[1] });
|
180
|
+
};
|
181
|
+
const handleUsersSearch = useMemo(
|
182
|
+
() =>
|
183
|
+
debounce((searchTerm) => {
|
184
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
185
|
+
useUsers({
|
186
|
+
v: ResourceRepresentation.Default,
|
187
|
+
q: searchTerm,
|
188
|
+
} as any as UserFilterCriteria);
|
189
|
+
}, 300),
|
190
|
+
[]
|
191
|
+
);
|
192
|
+
|
193
|
+
const onUserChanged = (data: { selectedItem: User }) => {
|
194
|
+
const stockRolesUUIDs = [
|
195
|
+
INVENTORY_CLERK_ROLE_UUID,
|
196
|
+
INVENTORY_MANAGER_ROLE_UUID,
|
197
|
+
INVENTORY_DISPENSING_ROLE_UUID,
|
198
|
+
INVENTORY_REPORTING_ROLE_UUID,
|
199
|
+
INVENTORY_ADMNISTRATOR_ROLE_UUID,
|
200
|
+
];
|
201
|
+
|
202
|
+
const filteredStockRoles = data.selectedItem?.roles.filter((role) =>
|
203
|
+
stockRolesUUIDs.includes(role.uuid)
|
204
|
+
);
|
205
|
+
setFormModel({ ...formModel, userUuid: data.selectedItem?.uuid });
|
206
|
+
setRoles(filteredStockRoles ?? []);
|
207
|
+
|
208
|
+
console.info(roles);
|
209
|
+
};
|
210
|
+
|
211
|
+
const onRoleChange = (e: ChangeEvent<HTMLSelectElement>) => {
|
212
|
+
const rootLocations = stockLocations
|
213
|
+
?.filter((x) => !x.id)
|
214
|
+
?.map((x) => x.id);
|
215
|
+
const filteredLocations =
|
216
|
+
formModel?.locations?.filter(
|
217
|
+
(x) =>
|
218
|
+
!rootLocations ||
|
219
|
+
rootLocations.length === 0 ||
|
220
|
+
!rootLocations.some((p) => p === x.locationUuid)
|
221
|
+
) ?? [];
|
222
|
+
|
223
|
+
setFormModel({
|
224
|
+
...formModel,
|
225
|
+
role: e.target.value,
|
226
|
+
locations: filteredLocations,
|
227
|
+
});
|
228
|
+
};
|
229
|
+
|
230
|
+
const onEnableDescendantsChanged = (event: ChangeEvent<HTMLInputElement>) => {
|
231
|
+
const selectedLocation = formModel?.locations?.find(
|
232
|
+
(x) => x.locationUuid === event?.target?.value
|
233
|
+
);
|
234
|
+
if (selectedLocation) {
|
235
|
+
const enableDescendants = !(selectedLocation.enableDescendants === true);
|
236
|
+
const newModifiedLocation = {
|
237
|
+
...selectedLocation,
|
238
|
+
enableDescendants: enableDescendants,
|
239
|
+
};
|
240
|
+
setFormModel({
|
241
|
+
...formModel,
|
242
|
+
locations: [
|
243
|
+
...(formModel?.locations?.filter(
|
244
|
+
(x) => x.locationUuid !== selectedLocation?.locationUuid
|
245
|
+
) ?? []),
|
246
|
+
newModifiedLocation,
|
247
|
+
],
|
248
|
+
});
|
249
|
+
}
|
250
|
+
};
|
251
|
+
|
252
|
+
const isOperationChecked = (operationType: StockOperationType) => {
|
253
|
+
return (
|
254
|
+
formModel?.operationTypes?.filter(
|
255
|
+
(x) => x.operationTypeUuid === operationType.uuid
|
256
|
+
)?.length > 0
|
257
|
+
);
|
258
|
+
};
|
259
|
+
|
260
|
+
const addStockUserRole = async (e) => {
|
261
|
+
e.preventDefault();
|
262
|
+
|
263
|
+
createOrUpdateUserRoleScope(formModel).then(
|
264
|
+
(res) => {
|
265
|
+
handleMutate("ws/rest/v1/stockmanagement/userrolescope");
|
266
|
+
showToast({
|
267
|
+
critical: true,
|
268
|
+
title: t("addUserRole", "Add User role"),
|
269
|
+
kind: "success",
|
270
|
+
description: t(
|
271
|
+
"successfullysaved",
|
272
|
+
`You have successfully saved user role scope `
|
273
|
+
),
|
274
|
+
});
|
275
|
+
closeOverlay();
|
276
|
+
},
|
277
|
+
(err) => {
|
278
|
+
showNotification({
|
279
|
+
title: t(
|
280
|
+
`errorSaving user role scope', 'Error Saving user role scope`
|
281
|
+
),
|
282
|
+
kind: "error",
|
283
|
+
critical: true,
|
284
|
+
description: err?.message,
|
285
|
+
});
|
286
|
+
|
287
|
+
closeOverlay();
|
288
|
+
}
|
289
|
+
);
|
290
|
+
};
|
291
|
+
|
292
|
+
if (isLoading || loadingRoles || loadingUsers) {
|
293
|
+
return (
|
294
|
+
<InlineLoading
|
295
|
+
status="active"
|
296
|
+
iconDescription="Loading"
|
297
|
+
description="Loading data..."
|
298
|
+
/>
|
299
|
+
);
|
300
|
+
}
|
301
|
+
|
302
|
+
return (
|
303
|
+
<div>
|
304
|
+
<Form>
|
305
|
+
<ModalHeader />
|
306
|
+
<ModalBody>
|
307
|
+
<section className={styles.section}>
|
308
|
+
<div>
|
309
|
+
{users?.results?.length > 0 && (
|
310
|
+
<>
|
311
|
+
<span className={styles.subTitle}>{t("user", "User")}</span>
|
312
|
+
<ComboBox
|
313
|
+
id="userName"
|
314
|
+
size="md"
|
315
|
+
labelText={t("user", "User")}
|
316
|
+
items={users?.results}
|
317
|
+
onChange={onUserChanged}
|
318
|
+
shouldFilterItem={(data) => true}
|
319
|
+
onFocus={() => users?.results || handleUsersSearch("")}
|
320
|
+
onToggleClick={() =>
|
321
|
+
users?.results || handleUsersSearch("")
|
322
|
+
}
|
323
|
+
itemToString={(item) =>
|
324
|
+
`${item?.person?.display ?? item?.display ?? ""}`
|
325
|
+
}
|
326
|
+
placeholder="Filter..."
|
327
|
+
/>
|
328
|
+
</>
|
329
|
+
)}
|
330
|
+
</div>
|
331
|
+
</section>
|
332
|
+
<section className={styles.section}>
|
333
|
+
<div>
|
334
|
+
<Select
|
335
|
+
name="role"
|
336
|
+
className="select-field"
|
337
|
+
labelText={t("role", "Role")}
|
338
|
+
id="select-role"
|
339
|
+
value={formModel.role ?? "placeholder-item"}
|
340
|
+
onChange={onRoleChange}
|
341
|
+
>
|
342
|
+
<SelectItem
|
343
|
+
disabled
|
344
|
+
hidden
|
345
|
+
value="placeholder-item"
|
346
|
+
text={t("Choose a role")}
|
347
|
+
/>
|
348
|
+
{(user?.roles ?? roles)?.map((role) => {
|
349
|
+
return (
|
350
|
+
<SelectItem
|
351
|
+
key={role.display}
|
352
|
+
value={role.display}
|
353
|
+
text={role.display}
|
354
|
+
/>
|
355
|
+
);
|
356
|
+
})}
|
357
|
+
</Select>
|
358
|
+
</div>
|
359
|
+
</section>
|
360
|
+
<section className={styles.section}>
|
361
|
+
<CheckboxGroup className={styles.checkboxGrid}>
|
362
|
+
<Checkbox
|
363
|
+
onChange={onEnabledChanged}
|
364
|
+
checked={formModel?.enabled}
|
365
|
+
labelText={t(`Enabled ?`)}
|
366
|
+
value={model?.enabled}
|
367
|
+
id="chk-userEnabled"
|
368
|
+
/>
|
369
|
+
<Checkbox
|
370
|
+
onChange={onPermanentChanged}
|
371
|
+
name="isPermanent"
|
372
|
+
checked={formModel?.permanent}
|
373
|
+
value={model?.permanent}
|
374
|
+
labelText={t(`Permanent ?`)}
|
375
|
+
id="chk-userPermanent"
|
376
|
+
/>
|
377
|
+
|
378
|
+
{!formModel?.permanent && (
|
379
|
+
<>
|
380
|
+
<DatePicker
|
381
|
+
datePickerType="range"
|
382
|
+
light
|
383
|
+
minDate={formatForDatePicker(MinDate)}
|
384
|
+
locale="en"
|
385
|
+
dateFormat={DATE_PICKER_CONTROL_FORMAT}
|
386
|
+
onChange={onActiveDatesChange}
|
387
|
+
>
|
388
|
+
<DatePickerInput
|
389
|
+
id="date-picker-input-id-start"
|
390
|
+
name="activeFrom"
|
391
|
+
placeholder={DATE_PICKER_FORMAT}
|
392
|
+
labelText={t("activeFrom", "Active From")}
|
393
|
+
value={formatForDatePicker(formModel?.activeFrom)}
|
394
|
+
/>
|
395
|
+
<DatePickerInput
|
396
|
+
id="date-picker-input-id-finish"
|
397
|
+
name="activeTo"
|
398
|
+
placeholder={DATE_PICKER_FORMAT}
|
399
|
+
labelText={t("activeTo", "Active To")}
|
400
|
+
value={formatForDatePicker(formModel?.activeTo)}
|
401
|
+
/>
|
402
|
+
</DatePicker>
|
403
|
+
</>
|
404
|
+
)}
|
405
|
+
</CheckboxGroup>
|
406
|
+
</section>
|
407
|
+
<br />
|
408
|
+
<section className={styles.section}>
|
409
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
410
|
+
<span className={styles.sectionTitle}>
|
411
|
+
{" "}
|
412
|
+
{t("stockOperation", "Stock Operations")}
|
413
|
+
</span>
|
414
|
+
<div className={styles.hr} />
|
415
|
+
<span className={styles.subTitle}>
|
416
|
+
{t(
|
417
|
+
"roleDescription",
|
418
|
+
"The role will be applicable to only selected stock operations."
|
419
|
+
)}
|
420
|
+
</span>
|
421
|
+
</div>
|
422
|
+
</section>
|
423
|
+
<section className={styles.section}>
|
424
|
+
<CheckboxGroup className={styles.checkboxGrid}>
|
425
|
+
{stockOperations.length > 0 &&
|
426
|
+
stockOperations.map((type) => {
|
427
|
+
return (
|
428
|
+
<div style={{ display: "flex", flexDirection: "row" }}>
|
429
|
+
<Checkbox
|
430
|
+
value={type.uuid}
|
431
|
+
checked={isOperationChecked(type)}
|
432
|
+
onChange={(event) =>
|
433
|
+
onStockOperationTypeChanged(
|
434
|
+
event,
|
435
|
+
type.uuid,
|
436
|
+
isOperationChecked(type)
|
437
|
+
)
|
438
|
+
}
|
439
|
+
className={styles.checkbox}
|
440
|
+
labelText={type.name}
|
441
|
+
id={type.uuid}
|
442
|
+
/>
|
443
|
+
</div>
|
444
|
+
);
|
445
|
+
})}
|
446
|
+
</CheckboxGroup>
|
447
|
+
</section>
|
448
|
+
<br />
|
449
|
+
<section className={styles.section}>
|
450
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
451
|
+
<span className={styles.sectionTitle}> {t("Locations")}</span>
|
452
|
+
<div className={styles.hr} />
|
453
|
+
<span className={styles.subTitle}>
|
454
|
+
{t(
|
455
|
+
"Use the toggle to apply this scope to the locations under the selected location."
|
456
|
+
)}
|
457
|
+
</span>
|
458
|
+
</div>
|
459
|
+
</section>
|
460
|
+
<section className={styles.section}>
|
461
|
+
<CheckboxGroup className={styles.checkboxGrid}>
|
462
|
+
{stockLocations?.length > 0 &&
|
463
|
+
stockLocations.map((type) => {
|
464
|
+
const checkedLocation = findCheckedLocation(type);
|
465
|
+
|
466
|
+
const getToggledValue = (locationUuid) => {
|
467
|
+
const location =
|
468
|
+
checkedLocation?.locationUuid === locationUuid
|
469
|
+
? checkedLocation
|
470
|
+
: null;
|
471
|
+
return location?.enableDescendants === true;
|
472
|
+
};
|
473
|
+
|
474
|
+
return (
|
475
|
+
<div
|
476
|
+
style={{
|
477
|
+
display: "flex",
|
478
|
+
flexDirection: "row",
|
479
|
+
margin: "4px",
|
480
|
+
padding: "5px",
|
481
|
+
}}
|
482
|
+
>
|
483
|
+
<Checkbox
|
484
|
+
name="location"
|
485
|
+
key={`chk-loc-child-key-${type.id}`}
|
486
|
+
id={`chk-loc-child-${type.id}`}
|
487
|
+
value={type.id}
|
488
|
+
onChange={(event) =>
|
489
|
+
onLocationCheckBoxChanged(event, type.id)
|
490
|
+
}
|
491
|
+
className={styles.checkbox}
|
492
|
+
labelText={type.name}
|
493
|
+
checked={checkedLocation != null}
|
494
|
+
/>
|
495
|
+
{checkedLocation && (
|
496
|
+
<Toggle
|
497
|
+
value={type.id}
|
498
|
+
hideLabel
|
499
|
+
className={styles.toggle}
|
500
|
+
size={"sm"}
|
501
|
+
onToggleClick={getToggledValue(type.id)}
|
502
|
+
key={`tg-loc-child-key-${type.id}`}
|
503
|
+
id={`tg-loc-child-${type.id}`}
|
504
|
+
/>
|
505
|
+
)}
|
506
|
+
</div>
|
507
|
+
);
|
508
|
+
})}
|
509
|
+
</CheckboxGroup>
|
510
|
+
</section>
|
511
|
+
</ModalBody>
|
512
|
+
<ModalFooter>
|
513
|
+
<Button kind="secondary" onClick={closeOverlay}>
|
514
|
+
{t("cancel", "Cancel")}
|
515
|
+
</Button>
|
516
|
+
<Button type="submit" onClick={addStockUserRole}>
|
517
|
+
{t("save", "Save")}
|
518
|
+
</Button>
|
519
|
+
</ModalFooter>
|
520
|
+
</Form>
|
521
|
+
</div>
|
522
|
+
);
|
523
|
+
};
|
524
|
+
|
525
|
+
export default AddStockUserRoleScope;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
4
|
+
|
5
|
+
section {
|
6
|
+
margin: spacing.$spacing-03;
|
7
|
+
}
|
8
|
+
|
9
|
+
.sectionTitle {
|
10
|
+
@include type.type-style('heading-compact-02');
|
11
|
+
color: $text-02;
|
12
|
+
margin-bottom: spacing.$spacing-04;
|
13
|
+
}
|
14
|
+
|
15
|
+
.subTitle {
|
16
|
+
font-size: 14px;
|
17
|
+
margin-bottom: spacing.$spacing-04;
|
18
|
+
}
|
19
|
+
|
20
|
+
.modalBody {
|
21
|
+
padding-bottom: spacing.$spacing-05;
|
22
|
+
}
|
23
|
+
|
24
|
+
.checkboxGrid {
|
25
|
+
display: grid;
|
26
|
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Adjust the values as needed */
|
27
|
+
gap: 16px; /* Adjust the gap between checkboxes */
|
28
|
+
}
|
29
|
+
.hr {
|
30
|
+
border: 1px solid #000;
|
31
|
+
}
|
32
|
+
.toggle {
|
33
|
+
margin: 5px;
|
34
|
+
}
|
35
|
+
.checkbox{
|
36
|
+
width: 100%;
|
37
|
+
}
|
package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, InlineLoading } from "@carbon/react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { TrashCan } from "@carbon/react/icons";
|
5
|
+
import { deleteUserRoleScopes } from "../stock-user-role-scopes.resource";
|
6
|
+
import { showModal, showNotification, showToast } from "@openmrs/esm-framework";
|
7
|
+
import { handleMutate } from "../swr-revalidation";
|
8
|
+
|
9
|
+
interface StockUserScopDeleteActionMenuProps {
|
10
|
+
uuid: string;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockUserScopeDeleteActionMenu: React.FC<
|
14
|
+
StockUserScopDeleteActionMenuProps
|
15
|
+
> = ({ uuid }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
|
18
|
+
const [deletingUserScope, setDeletingUserScope] = useState(false);
|
19
|
+
|
20
|
+
const handleDeleteStockUserScope = React.useCallback(() => {
|
21
|
+
const close = showModal("delete-stock-user-scope-modal", {
|
22
|
+
close: () => close(),
|
23
|
+
uuid: uuid,
|
24
|
+
onConfirmation: () => {
|
25
|
+
const ids = [];
|
26
|
+
ids.push(uuid);
|
27
|
+
deleteUserRoleScopes(ids)
|
28
|
+
.then(
|
29
|
+
() => {
|
30
|
+
handleMutate("ws/rest/v1/stockmanagement/userrolescope");
|
31
|
+
setDeletingUserScope(false);
|
32
|
+
showToast({
|
33
|
+
critical: true,
|
34
|
+
title: t("deletingstockUserScope", "Delete Stock User Scope"),
|
35
|
+
kind: "success",
|
36
|
+
description: t(
|
37
|
+
"stockuserscopedeletedsuccessfully",
|
38
|
+
"Stock User Scope Deleted Successfully"
|
39
|
+
),
|
40
|
+
});
|
41
|
+
},
|
42
|
+
(error) => {
|
43
|
+
setDeletingUserScope(false);
|
44
|
+
showNotification({
|
45
|
+
title: t(
|
46
|
+
`errorDeletingUserScope', 'error deleting a user scope`
|
47
|
+
),
|
48
|
+
kind: "error",
|
49
|
+
critical: true,
|
50
|
+
description: error?.message,
|
51
|
+
});
|
52
|
+
}
|
53
|
+
)
|
54
|
+
.catch();
|
55
|
+
close();
|
56
|
+
},
|
57
|
+
});
|
58
|
+
}, [t, uuid]);
|
59
|
+
|
60
|
+
const deleteButton = (
|
61
|
+
<Button
|
62
|
+
kind="ghost"
|
63
|
+
size="md"
|
64
|
+
onClick={handleDeleteStockUserScope}
|
65
|
+
iconDescription={t("deleteUserScope", "Delete Stock User Scope")}
|
66
|
+
renderIcon={(props) => <TrashCan size={16} {...props} />}
|
67
|
+
/>
|
68
|
+
);
|
69
|
+
|
70
|
+
return deletingUserScope ? <InlineLoading /> : deleteButton;
|
71
|
+
};
|
72
|
+
|
73
|
+
export default StockUserScopeDeleteActionMenu;
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { Button, ModalHeader, ModalBody, ModalFooter } from "@carbon/react";
|
4
|
+
import styles from "../root.scss";
|
5
|
+
|
6
|
+
interface DeleteConfirmationProps {
|
7
|
+
uuid?: string;
|
8
|
+
close: () => void;
|
9
|
+
onConfirmation: () => void;
|
10
|
+
}
|
11
|
+
|
12
|
+
const DeleteConfirmation: React.FC<DeleteConfirmationProps> = ({
|
13
|
+
close,
|
14
|
+
onConfirmation,
|
15
|
+
uuid,
|
16
|
+
}) => {
|
17
|
+
const { t } = useTranslation();
|
18
|
+
const handleCancel = () => close();
|
19
|
+
const handleDelete = () => onConfirmation?.();
|
20
|
+
|
21
|
+
return (
|
22
|
+
<>
|
23
|
+
<ModalHeader closeModal={close} className={styles.productiveHeading03}>
|
24
|
+
{t("deleteStockUserScope", "Delete Stock User Scope")}?
|
25
|
+
</ModalHeader>
|
26
|
+
<ModalBody>
|
27
|
+
<p className={styles.bodyLong01}>
|
28
|
+
{t(
|
29
|
+
"deleteConfirmationText",
|
30
|
+
`Are you sure you want to delete this User Scope? This action can't be undone.`,
|
31
|
+
{ encounter: uuid }
|
32
|
+
)}
|
33
|
+
</p>
|
34
|
+
</ModalBody>
|
35
|
+
<ModalFooter>
|
36
|
+
<Button size="lg" kind="secondary" onClick={handleCancel}>
|
37
|
+
{t("cancel", "Cancel")}
|
38
|
+
</Button>
|
39
|
+
<Button autoFocus kind="danger" onClick={handleDelete} size="lg">
|
40
|
+
{t("delete", "Delete")}
|
41
|
+
</Button>
|
42
|
+
</ModalFooter>
|
43
|
+
</>
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
export default DeleteConfirmation;
|