@sdcorejs/angular 21.3.2 → 21.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/THEME.md +58 -6
- package/assets/scss/core/form.scss +291 -3
- package/assets/scss/themes/_component-tokens.scss +35 -6
- package/fesm2022/sdcorejs-angular-components-badge.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +15 -3
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-splitter.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs +393 -78
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +444 -16
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +887 -174
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +7 -2
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +5 -2
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip.mjs +414 -122
- package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs +17 -2
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input.mjs +4 -0
- package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +26 -20
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs +14 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +210 -0
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-MlNJ6DDc.mjs → sdcorejs-angular-modules-generic-generic-configuration.page-BR6jxyYd.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-MlNJ6DDc.mjs.map → sdcorejs-angular-modules-generic-generic-configuration.page-BR6jxyYd.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-_PcU75h9.mjs → sdcorejs-angular-modules-generic-generic-form-host.page-BsEL-y-M.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-_PcU75h9.mjs.map → sdcorejs-angular-modules-generic-generic-form-host.page-BsEL-y-M.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-qcvv7QK6.mjs → sdcorejs-angular-modules-generic-generic-list.page-qTFKh4UG.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-qcvv7QK6.mjs.map → sdcorejs-angular-modules-generic-generic-list.page-qTFKh4UG.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-B1fYY5yX.mjs → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-Cq0GFfo1.mjs} +4 -4
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-B1fYY5yX.mjs.map → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-Cq0GFfo1.mjs.map} +1 -1
- package/fesm2022/sdcorejs-angular-modules-generic.mjs +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +266 -11
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-pattern-api-error-BBWwQ6h2.mjs +23 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-api-error-BBWwQ6h2.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-approval-inbox-BMwD6_FC.mjs +16 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-approval-inbox-BMwD6_FC.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-p8-V_Ol9.mjs +51 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-p8-V_Ol9.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-DTcpSsbe.mjs +130 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-DTcpSsbe.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-T2ox0oMZ.mjs +131 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-T2ox0oMZ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DAjVXHXc.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DAjVXHXc.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DkHR_ix2.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DkHR_ix2.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DxWuy1ul.mjs +460 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DxWuy1ul.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.model-C3fr4yNw.mjs +18 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.model-C3fr4yNw.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-Cbs05A2j.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-Cbs05A2j.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-Bkk3_Lf0.mjs +148 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-Bkk3_Lf0.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-BIuEchUV.mjs +467 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-BIuEchUV.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CH21RSWx.mjs +172 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CH21RSWx.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CX4WWzER.mjs +90 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CX4WWzER.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-D1kpfcf_.mjs +514 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-D1kpfcf_.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-DYyFPZUU.mjs +61 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-DYyFPZUU.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-B9vCzIT6.mjs +232 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-B9vCzIT6.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BnROr-Wg.mjs +87 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BnROr-Wg.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-qs8Yoxn0.mjs +170 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-qs8Yoxn0.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-Cbwdhc0Z.mjs +70 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-Cbwdhc0Z.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-DYphTR6C.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-DYphTR6C.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-form.component-C692P-z0.mjs +522 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-form.component-C692P-z0.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-5sLtmhG1.mjs +71 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-5sLtmhG1.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-BIFg9bUW.mjs +629 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-BIFg9bUW.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CZ1NoLIo.mjs +115 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CZ1NoLIo.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CmZeYoF7.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CmZeYoF7.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Dy2Rkh8f.mjs +164 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Dy2Rkh8f.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-BdxQkZXW.mjs +1069 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-BdxQkZXW.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BpLQaYP5.mjs +186 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BpLQaYP5.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-BrejHvB2.mjs +97 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-BrejHvB2.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.model-BoHLJ8vf.mjs +12 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.model-BoHLJ8vf.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-BpSTfkeT.mjs +48 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-BpSTfkeT.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-D3QP1i9v.mjs +293 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-D3QP1i9v.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BA64XAgv.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BA64XAgv.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CWTlhZzo.mjs +50 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CWTlhZzo.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-ClRXOw9g.mjs +165 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-ClRXOw9g.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DYT6cDVo.mjs +45 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DYT6cDVo.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Dww3V1b9.mjs +43 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-Dww3V1b9.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-HwJm344-.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-HwJm344-.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-ZkBSRFv_.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-ZkBSRFv_.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-px1VU73r.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-px1VU73r.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-BSDQaT9e.mjs +406 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-BSDQaT9e.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-2EN7PuIE.mjs +317 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-2EN7PuIE.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Crg1J2V5.mjs +132 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Crg1J2V5.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-LIBiOZLn.mjs +143 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-LIBiOZLn.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-4Mm8-ehz.mjs +128 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-4Mm8-ehz.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-ClEGOr5D.mjs +357 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-ClEGOr5D.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-CoGA7wxY.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-CoGA7wxY.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern.mjs +2 -0
- package/fesm2022/sdcorejs-angular-modules-pattern.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs +104 -4
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs.map +1 -1
- package/modules/pattern/README.md +76 -0
- package/modules/pattern/docs/detail.md +237 -0
- package/modules/pattern/docs/drawer.md +484 -0
- package/modules/pattern/docs/flow.md +631 -0
- package/modules/pattern/docs/form.md +518 -0
- package/modules/pattern/docs/header-actions.md +342 -0
- package/modules/pattern/docs/list.md +247 -0
- package/modules/pattern/docs/relation.md +180 -0
- package/modules/pattern/docs/select.md +206 -0
- package/modules/pattern/docs/split.md +350 -0
- package/modules/pattern/docs/states.md +168 -0
- package/modules/pattern/features/approval/entity.resolver.ts +21 -0
- package/modules/pattern/features/approval/pages/detail/detail.component.ts +139 -0
- package/modules/pattern/features/approval/pages/list/approval-inbox.ts +7 -0
- package/modules/pattern/features/approval/pages/list/list.component.html +20 -0
- package/modules/pattern/features/approval/pages/list/list.component.ts +149 -0
- package/modules/pattern/features/approval/routes.ts +30 -0
- package/modules/pattern/features/approval/services/approval.model.ts +38 -0
- package/modules/pattern/features/approval/services/approval.service.ts +23 -0
- package/modules/pattern/features/category/components/create-side-drawer/create-side-drawer.component.ts +123 -0
- package/modules/pattern/features/category/components/general-information-form/general-information-form.component.ts +61 -0
- package/modules/pattern/features/category/components/update-side-drawer/update-side-drawer.component.ts +134 -0
- package/modules/pattern/features/category/entity.resolver.ts +27 -0
- package/modules/pattern/features/category/pages/list/list.component.html +20 -0
- package/modules/pattern/features/category/pages/list/list.component.ts +105 -0
- package/modules/pattern/features/category/routes.ts +42 -0
- package/modules/pattern/features/category/services/category.model.ts +39 -0
- package/modules/pattern/features/category/services/category.service.ts +36 -0
- package/modules/pattern/features/customer/components/create-side-drawer/create-side-drawer.component.ts +131 -0
- package/modules/pattern/features/customer/components/customer-select/customer-select.component.ts +72 -0
- package/modules/pattern/features/customer/components/customer-type-select/customer-type-select.component.ts +30 -0
- package/modules/pattern/features/customer/components/debts-view/debts-view.component.ts +28 -0
- package/modules/pattern/features/customer/components/detail-side-drawer/detail-side-drawer.component.ts +106 -0
- package/modules/pattern/features/customer/components/documents-view/documents-view.component.ts +50 -0
- package/modules/pattern/features/customer/components/general-information-form/general-information-form.component.ts +140 -0
- package/modules/pattern/features/customer/components/general-information-view/general-information-view.component.ts +39 -0
- package/modules/pattern/features/customer/components/orders-view/orders-view.component.ts +35 -0
- package/modules/pattern/features/customer/components/summary-cards/summary-cards.component.ts +101 -0
- package/modules/pattern/features/customer/components/update-side-drawer/update-side-drawer.component.ts +127 -0
- package/modules/pattern/features/customer/entity.resolver.ts +21 -0
- package/modules/pattern/features/customer/pages/list/list.component.html +22 -0
- package/modules/pattern/features/customer/pages/list/list.component.ts +113 -0
- package/modules/pattern/features/customer/pages/profile/profile.component.ts +120 -0
- package/modules/pattern/features/customer/pipes/customer-detail.pipe.ts +18 -0
- package/modules/pattern/features/customer/routes.ts +59 -0
- package/modules/pattern/features/customer/services/customer.model.ts +87 -0
- package/modules/pattern/features/customer/services/customer.service.ts +79 -0
- package/modules/pattern/features/import/components/mapping-form/mapping-form.component.ts +41 -0
- package/modules/pattern/features/import/components/preview-view/preview-view.component.ts +44 -0
- package/modules/pattern/features/import/pages/flow/flow.component.ts +269 -0
- package/modules/pattern/features/import/routes.ts +19 -0
- package/modules/pattern/features/import/services/import.model.ts +82 -0
- package/modules/pattern/features/import/services/import.service.ts +18 -0
- package/modules/pattern/features/order/components/approval-steps/approval-steps.component.ts +74 -0
- package/modules/pattern/features/order/components/bulk-result/bulk-result.component.ts +46 -0
- package/modules/pattern/features/order/components/general-information-form/general-information-form.component.ts +96 -0
- package/modules/pattern/features/order/components/lines-form/lines-form.component.ts +205 -0
- package/modules/pattern/features/order/components/lines-view/lines-view.component.ts +42 -0
- package/modules/pattern/features/order/components/summary-cards/summary-cards.component.ts +128 -0
- package/modules/pattern/features/order/entity.resolver.ts +37 -0
- package/modules/pattern/features/order/pages/create/create.component.ts +99 -0
- package/modules/pattern/features/order/pages/detail/detail.component.ts +222 -0
- package/modules/pattern/features/order/pages/list/list.component.html +38 -0
- package/modules/pattern/features/order/pages/list/list.component.ts +291 -0
- package/modules/pattern/features/order/pages/update/update.component.ts +119 -0
- package/modules/pattern/features/order/routes.ts +54 -0
- package/modules/pattern/features/order/services/order.model.ts +109 -0
- package/modules/pattern/features/order/services/order.service.ts +63 -0
- package/modules/pattern/features/partner/pages/create/create.component.ts +324 -0
- package/modules/pattern/features/partner/routes.ts +20 -0
- package/modules/pattern/features/partner/services/partner.model.ts +30 -0
- package/modules/pattern/features/partner/services/partner.service.ts +17 -0
- package/modules/pattern/features/product/components/general-information-form/general-information-form.component.ts +88 -0
- package/modules/pattern/features/product/components/product-select/product-select.component.ts +65 -0
- package/modules/pattern/features/product/components/product-status-select/product-status-select.component.ts +30 -0
- package/modules/pattern/features/product/entity.resolver.ts +21 -0
- package/modules/pattern/features/product/pages/create/create.component.ts +85 -0
- package/modules/pattern/features/product/pages/detail/detail.component.ts +53 -0
- package/modules/pattern/features/product/pages/list/list.component.html +30 -0
- package/modules/pattern/features/product/pages/list/list.component.ts +71 -0
- package/modules/pattern/features/product/pages/update/update.component.ts +86 -0
- package/modules/pattern/features/product/pipes/product-detail.pipe.ts +18 -0
- package/modules/pattern/features/product/routes.ts +48 -0
- package/modules/pattern/features/product/services/product.model.ts +38 -0
- package/modules/pattern/features/product/services/product.service.ts +48 -0
- package/modules/pattern/features/settings/pages/update/update.component.ts +227 -0
- package/modules/pattern/features/settings/routes.ts +24 -0
- package/modules/pattern/features/settings/services/settings.model.ts +18 -0
- package/modules/pattern/features/settings/services/settings.service.ts +15 -0
- package/modules/pattern/features/settings/settings.resolver.ts +8 -0
- package/package.json +5 -1
- package/types/sdcorejs-angular-components-badge.d.ts +19 -1
- package/types/sdcorejs-angular-components-section.d.ts +13 -1
- package/types/sdcorejs-angular-components-splitter.d.ts +1 -1
- package/types/sdcorejs-angular-components-tab-router.d.ts +47 -5
- package/types/sdcorejs-angular-components-table.d.ts +127 -13
- package/types/sdcorejs-angular-components-upload-file.d.ts +181 -21
- package/types/sdcorejs-angular-forms-chip.d.ts +136 -26
- package/types/sdcorejs-angular-i18n.d.ts +42 -0
- package/types/sdcorejs-angular-modules-layout.d.ts +89 -6
- package/types/sdcorejs-angular-modules-pattern.d.ts +50 -0
- package/types/sdcorejs-angular-services-unsaved-changes.d.ts +11 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, DestroyRef, effect, inject, input, signal, untracked } from '@angular/core';
|
|
2
|
+
import { FormArray, FormGroup } from '@angular/forms';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
5
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
6
|
+
import { SdInputNumber } from '@sdcorejs/angular/forms/input-number';
|
|
7
|
+
import { SdFormatNumberPipe } from '@sdcorejs/angular/pipes';
|
|
8
|
+
import { ProductSelectComponent } from '../../../product/components/product-select/product-select.component';
|
|
9
|
+
import { ProductService } from '../../../product/services/product.service';
|
|
10
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
11
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
12
|
+
|
|
13
|
+
interface LineRow {
|
|
14
|
+
readonly key: number;
|
|
15
|
+
readonly group: FormGroup;
|
|
16
|
+
readonly seed: OrderLineDto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Bảng dòng hàng nhập trực tiếp: mỗi dòng là một FormGroup trong `form.lines` (FormArray), các field Core tự đăng
|
|
21
|
+
* ký vào dòng. Chọn sản phẩm điền đơn giá; thành tiền và tổng tự tính. Lỗi API theo dòng (`lines.<i>.<field>`) hiện
|
|
22
|
+
* ngay trên ô của dòng đó.
|
|
23
|
+
*/
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'lines-form',
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [SdSection, SdButton, SdInputNumber, SdFormatNumberPipe, ProductSelectComponent],
|
|
28
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
29
|
+
template: `
|
|
30
|
+
<sd-section title="Dòng hàng">
|
|
31
|
+
<div sdHeaderRight>
|
|
32
|
+
<sd-button title="Thêm dòng" prefixIcon="add" type="text" autoId="order-line-add" (click)="add()" />
|
|
33
|
+
</div>
|
|
34
|
+
<table class="lines">
|
|
35
|
+
<thead>
|
|
36
|
+
<tr>
|
|
37
|
+
<th scope="col">Sản phẩm</th>
|
|
38
|
+
<th scope="col" class="lines__number">Số lượng</th>
|
|
39
|
+
<th scope="col" class="lines__number">Đơn giá (₫)</th>
|
|
40
|
+
<th scope="col" class="lines__number">Thành tiền (₫)</th>
|
|
41
|
+
<th scope="col"><span class="sd-visually-hidden">Xoá dòng</span></th>
|
|
42
|
+
</tr>
|
|
43
|
+
</thead>
|
|
44
|
+
<tbody>
|
|
45
|
+
@for (row of rows(); track row.key; let index = $index) {
|
|
46
|
+
<tr [attr.data-line]="index">
|
|
47
|
+
<td>
|
|
48
|
+
<product-select
|
|
49
|
+
[label]="undefined"
|
|
50
|
+
[form]="row.group"
|
|
51
|
+
[model]="row.seed.productId || null"
|
|
52
|
+
[autoId]="'order-line-' + index + '-product'"
|
|
53
|
+
(modelChange)="pick(row, $event)"
|
|
54
|
+
required />
|
|
55
|
+
@if (errors()['lines.' + index + '.productId']; as error) {
|
|
56
|
+
<span class="lines__error" role="alert">{{ error }}</span>
|
|
57
|
+
}
|
|
58
|
+
</td>
|
|
59
|
+
<td class="lines__number">
|
|
60
|
+
<sd-input-number
|
|
61
|
+
name="quantity"
|
|
62
|
+
type="positive"
|
|
63
|
+
[precision]="0"
|
|
64
|
+
[form]="row.group"
|
|
65
|
+
[model]="row.seed.quantity"
|
|
66
|
+
[inlineError]="errors()['lines.' + index + '.quantity']"
|
|
67
|
+
[autoId]="'order-line-' + index + '-quantity'"
|
|
68
|
+
required />
|
|
69
|
+
</td>
|
|
70
|
+
<td class="lines__number">
|
|
71
|
+
<sd-input-number
|
|
72
|
+
name="unitPrice"
|
|
73
|
+
type="positive"
|
|
74
|
+
[precision]="0"
|
|
75
|
+
[form]="row.group"
|
|
76
|
+
[model]="row.seed.unitPrice"
|
|
77
|
+
required />
|
|
78
|
+
</td>
|
|
79
|
+
<td class="lines__number">{{ amounts()[index] | sdFormatNumber: 0 }}</td>
|
|
80
|
+
<td>
|
|
81
|
+
<sd-button
|
|
82
|
+
prefixIcon="delete"
|
|
83
|
+
type="text"
|
|
84
|
+
color="error"
|
|
85
|
+
tooltip="Xoá dòng"
|
|
86
|
+
[autoId]="'order-line-' + index + '-remove'"
|
|
87
|
+
[disabled]="rows().length === 1"
|
|
88
|
+
(click)="remove(row)" />
|
|
89
|
+
</td>
|
|
90
|
+
</tr>
|
|
91
|
+
}
|
|
92
|
+
</tbody>
|
|
93
|
+
<tfoot>
|
|
94
|
+
<tr>
|
|
95
|
+
<th scope="row" colspan="3" class="lines__number">Tổng tiền (₫)</th>
|
|
96
|
+
<td class="lines__number lines__total" data-autoid="order-total">{{ total() | sdFormatNumber: 0 }}</td>
|
|
97
|
+
<td></td>
|
|
98
|
+
</tr>
|
|
99
|
+
</tfoot>
|
|
100
|
+
</table>
|
|
101
|
+
</sd-section>
|
|
102
|
+
`,
|
|
103
|
+
styles: `
|
|
104
|
+
.lines {
|
|
105
|
+
width: 100%;
|
|
106
|
+
border-collapse: collapse;
|
|
107
|
+
}
|
|
108
|
+
.lines th,
|
|
109
|
+
.lines td {
|
|
110
|
+
padding: 4px 8px;
|
|
111
|
+
text-align: left;
|
|
112
|
+
vertical-align: top;
|
|
113
|
+
}
|
|
114
|
+
.lines thead th {
|
|
115
|
+
color: var(--sd-text-secondary);
|
|
116
|
+
font-size: 12px;
|
|
117
|
+
font-weight: 500;
|
|
118
|
+
border-bottom: 1px solid var(--sd-border);
|
|
119
|
+
}
|
|
120
|
+
.lines td:first-child {
|
|
121
|
+
min-width: 240px;
|
|
122
|
+
}
|
|
123
|
+
.lines__number {
|
|
124
|
+
width: 150px;
|
|
125
|
+
text-align: right !important;
|
|
126
|
+
}
|
|
127
|
+
.lines td.lines__number {
|
|
128
|
+
padding-top: 14px;
|
|
129
|
+
}
|
|
130
|
+
.lines tfoot th,
|
|
131
|
+
.lines tfoot td {
|
|
132
|
+
padding-top: 12px;
|
|
133
|
+
border-top: 1px solid var(--sd-border);
|
|
134
|
+
}
|
|
135
|
+
.lines__total {
|
|
136
|
+
font-weight: 500;
|
|
137
|
+
}
|
|
138
|
+
.lines__error {
|
|
139
|
+
color: var(--sd-error, currentColor);
|
|
140
|
+
font-size: 12px;
|
|
141
|
+
}
|
|
142
|
+
`,
|
|
143
|
+
})
|
|
144
|
+
export class LinesFormComponent {
|
|
145
|
+
readonly #productService = inject(ProductService);
|
|
146
|
+
readonly form = input.required<OrderForm>();
|
|
147
|
+
/** Dòng ban đầu (cập nhật) hoặc một dòng trống (tạo mới). */
|
|
148
|
+
readonly seed = input.required<readonly OrderLineDto[]>();
|
|
149
|
+
/** Lỗi theo field do API trả về, khoá dạng `lines.<index>.<field>`. */
|
|
150
|
+
readonly errors = input<Readonly<Record<string, string>>>({});
|
|
151
|
+
readonly #array = new FormArray<FormGroup>([]);
|
|
152
|
+
readonly #version = signal(0);
|
|
153
|
+
#nextKey = 0;
|
|
154
|
+
protected readonly rows = signal<readonly LineRow[]>([]);
|
|
155
|
+
protected readonly amounts = computed(() => {
|
|
156
|
+
this.#version();
|
|
157
|
+
return this.rows().map(
|
|
158
|
+
row => Number(row.group.get('quantity')?.value ?? row.seed.quantity) * Number(row.group.get('unitPrice')?.value ?? row.seed.unitPrice)
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
protected readonly total = computed(() => this.amounts().reduce((sum, amount) => sum + amount, 0));
|
|
162
|
+
|
|
163
|
+
constructor() {
|
|
164
|
+
const subscription = this.#array.valueChanges.subscribe(() => this.#version.update(version => version + 1));
|
|
165
|
+
inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
|
|
166
|
+
// why: trang cập nhật được dùng lại khi chỉ đổi `:id`; dòng hàng phải theo đơn mới, không giữ dòng của đơn trước.
|
|
167
|
+
effect(() => {
|
|
168
|
+
const seed = this.seed();
|
|
169
|
+
untracked(() => this.#load(seed));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
protected add(): void {
|
|
174
|
+
this.#push({ productId: '', quantity: 1, unitPrice: 0 });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
protected remove(row: LineRow): void {
|
|
178
|
+
const index = this.rows().indexOf(row);
|
|
179
|
+
if (index < 0) return;
|
|
180
|
+
// why: đánh dấu đã sửa TRƯỚC khi gỡ, để dirty theo giá trị so với danh sách dòng lúc trước.
|
|
181
|
+
this.#array.markAsDirty();
|
|
182
|
+
this.#array.removeAt(index);
|
|
183
|
+
this.rows.update(rows => rows.filter(item => item !== row));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Chọn sản phẩm thì điền đơn giá hiện hành của sản phẩm. */
|
|
187
|
+
protected async pick(row: LineRow, productId: string | null | undefined): Promise<void> {
|
|
188
|
+
if (!productId) return;
|
|
189
|
+
const product = await firstValueFrom(this.#productService.cachedDetail(productId));
|
|
190
|
+
row.group.get('unitPrice')?.setValue(product.price);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
#load(seed: readonly OrderLineDto[]): void {
|
|
194
|
+
this.#array.clear();
|
|
195
|
+
this.rows.set([]);
|
|
196
|
+
(seed.length ? seed : [{ productId: '', quantity: 1, unitPrice: 0 }]).forEach(line => this.#push(line));
|
|
197
|
+
if (this.form().get('lines') !== this.#array) this.form().setControl('lines', this.#array);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#push(seed: OrderLineDto): void {
|
|
201
|
+
const group = new FormGroup({});
|
|
202
|
+
this.#array.push(group);
|
|
203
|
+
this.rows.update(rows => [...rows, { key: this.#nextKey++, group, seed }]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AsyncPipe } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
3
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
4
|
+
import { SdTable, SdTableCellDefDirective, type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
5
|
+
import { ProductDetailPipe } from '../../../product/pipes/product-detail.pipe';
|
|
6
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
7
|
+
|
|
8
|
+
/** Dòng hàng chỉ đọc; tên sản phẩm lấy qua relation `productDetail`, không hiện ID thô. */
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'lines-view',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [AsyncPipe, SdSection, SdTable, SdTableCellDefDirective, ProductDetailPipe],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
template: `
|
|
15
|
+
<sd-section title="Dòng hàng">
|
|
16
|
+
<sd-table autoId="order-lines" [option]="option()">
|
|
17
|
+
<ng-template sdTableCellDef="productId" let-line="item">
|
|
18
|
+
@let product = line.productId | productDetail | async;
|
|
19
|
+
{{ product?.name ?? '…' }}
|
|
20
|
+
</ng-template>
|
|
21
|
+
</sd-table>
|
|
22
|
+
</sd-section>
|
|
23
|
+
`,
|
|
24
|
+
})
|
|
25
|
+
export class LinesViewComponent {
|
|
26
|
+
readonly lines = input.required<readonly OrderLineDto[]>();
|
|
27
|
+
protected readonly option = computed<SdTableOption<OrderLineDto & { amount: number }>>(() => {
|
|
28
|
+
const items = this.lines().map(line => ({ ...line, amount: line.quantity * line.unitPrice }));
|
|
29
|
+
return {
|
|
30
|
+
type: 'local',
|
|
31
|
+
items: () => items,
|
|
32
|
+
paginate: { pageSize: 50 },
|
|
33
|
+
filter: { hideInlineFilter: 'auto' },
|
|
34
|
+
columns: [
|
|
35
|
+
{ field: 'productId', title: 'Sản phẩm', type: 'string', minWidth: '200px' },
|
|
36
|
+
{ field: 'quantity', title: 'Số lượng', type: 'number', width: '110px', align: 'right' },
|
|
37
|
+
{ field: 'unitPrice', title: 'Đơn giá (₫)', type: 'number', width: '140px', align: 'right' },
|
|
38
|
+
{ field: 'amount', title: 'Thành tiền (₫)', type: 'number', width: '150px', align: 'right' },
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, inject, input, linkedSignal, model } from '@angular/core';
|
|
2
|
+
import { SdCard, SdCardGroup } from '@sdcorejs/angular/components/card';
|
|
3
|
+
import { SD_PAGE_LIST } from '@sdcorejs/angular/modules/layout';
|
|
4
|
+
import type { OrderCounts, OrderStatus } from '../../services/order.model';
|
|
5
|
+
|
|
6
|
+
type CardKey = 'all' | 'pending' | 'shipping';
|
|
7
|
+
|
|
8
|
+
const CARDS: readonly { readonly key: CardKey; readonly label: string }[] = [
|
|
9
|
+
{ key: 'all', label: 'Tổng đơn' },
|
|
10
|
+
{ key: 'pending', label: 'Chờ xác nhận' },
|
|
11
|
+
{ key: 'shipping', label: 'Đang giao' },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
/** 1.234.567.890 → "1,2 tỷ"; 350.000.000 → "350 triệu". */
|
|
15
|
+
function money(value: number): string {
|
|
16
|
+
if (value >= 1_000_000_000) return `${(value / 1_000_000_000).toLocaleString('vi-VN', { maximumFractionDigits: 1 })} tỷ`;
|
|
17
|
+
return `${Math.round(value / 1_000_000).toLocaleString('vi-VN')} triệu`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Score card của danh sách đơn: ba thẻ đầu lọc theo trạng thái, đồng bộ với tab vì cùng một state; thẻ doanh thu
|
|
22
|
+
* chỉ để xem. Khi `sd-page-list` thu gọn (màn thấp), các thẻ thành một dòng 36px.
|
|
23
|
+
*/
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'summary-cards',
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [SdCard, SdCardGroup],
|
|
28
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
29
|
+
template: `
|
|
30
|
+
<sd-card-group
|
|
31
|
+
class="summary"
|
|
32
|
+
autoId="order-summary"
|
|
33
|
+
aria-label="Tóm tắt đơn hàng"
|
|
34
|
+
[class.summary--compact]="compact()"
|
|
35
|
+
[(model)]="selected"
|
|
36
|
+
(sdChange)="choose($event)">
|
|
37
|
+
@for (card of cards(); track card.key) {
|
|
38
|
+
<sd-card class="summary__card" [value]="card.key" [autoId]="'order-summary-' + card.key">
|
|
39
|
+
<span class="summary__label">{{ card.label }}</span>
|
|
40
|
+
<strong class="summary__value">{{ card.value }}</strong>
|
|
41
|
+
</sd-card>
|
|
42
|
+
}
|
|
43
|
+
<div class="summary__card summary__card--static" data-autoid="order-summary-revenue">
|
|
44
|
+
<span class="summary__label">Doanh thu hoàn tất</span>
|
|
45
|
+
<strong class="summary__value">{{ revenue() }}</strong>
|
|
46
|
+
</div>
|
|
47
|
+
</sd-card-group>
|
|
48
|
+
`,
|
|
49
|
+
styles: `
|
|
50
|
+
.summary {
|
|
51
|
+
display: grid;
|
|
52
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
53
|
+
gap: 12px;
|
|
54
|
+
}
|
|
55
|
+
.summary__card {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 4px;
|
|
59
|
+
padding: 12px 16px;
|
|
60
|
+
}
|
|
61
|
+
.summary__card--static {
|
|
62
|
+
border: 1px solid var(--sd-border);
|
|
63
|
+
border-radius: 8px;
|
|
64
|
+
background: var(--sd-surface);
|
|
65
|
+
}
|
|
66
|
+
.summary__label {
|
|
67
|
+
color: var(--sd-text-secondary);
|
|
68
|
+
font-size: 13px;
|
|
69
|
+
}
|
|
70
|
+
.summary__value {
|
|
71
|
+
font-size: 22px;
|
|
72
|
+
line-height: 28px;
|
|
73
|
+
font-weight: 500;
|
|
74
|
+
font-variant-numeric: tabular-nums;
|
|
75
|
+
}
|
|
76
|
+
.summary--compact {
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: 8px;
|
|
80
|
+
height: 36px;
|
|
81
|
+
}
|
|
82
|
+
.summary--compact .summary__card {
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
align-items: baseline;
|
|
85
|
+
gap: 6px;
|
|
86
|
+
padding: 4px 10px;
|
|
87
|
+
}
|
|
88
|
+
.summary--compact .summary__card--static {
|
|
89
|
+
border: 0;
|
|
90
|
+
background: transparent;
|
|
91
|
+
}
|
|
92
|
+
.summary--compact .summary__value {
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
line-height: 20px;
|
|
95
|
+
}
|
|
96
|
+
@media (max-width: 767px) {
|
|
97
|
+
.summary {
|
|
98
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
`,
|
|
102
|
+
})
|
|
103
|
+
export class SummaryCardsComponent {
|
|
104
|
+
readonly counts = input<OrderCounts | null>(null);
|
|
105
|
+
/** Trạng thái đang lọc; `null` là tất cả. */
|
|
106
|
+
readonly status = model<OrderStatus | null>(null);
|
|
107
|
+
protected readonly cards = computed(() => {
|
|
108
|
+
const counts = this.counts();
|
|
109
|
+
return CARDS.map(card => ({ ...card, value: counts ? counts[card.key].toLocaleString('vi-VN') : '…' }));
|
|
110
|
+
});
|
|
111
|
+
protected readonly compact = inject(SD_PAGE_LIST).compact;
|
|
112
|
+
/** Trạng thái chọn từ tab mà không có thẻ (Hoàn tất, Đã huỷ): không thẻ nào sáng. */
|
|
113
|
+
protected readonly selected = linkedSignal<CardKey | null>(() => {
|
|
114
|
+
const status = this.status();
|
|
115
|
+
return status === null ? 'all' : status === 'pending' || status === 'shipping' ? status : null;
|
|
116
|
+
});
|
|
117
|
+
protected readonly revenue = computed(() => {
|
|
118
|
+
const counts = this.counts();
|
|
119
|
+
return counts ? money(counts.revenue) : '…';
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
protected choose(key: unknown): void {
|
|
123
|
+
// Bấm lại thẻ đang chọn (model về null) hoặc thẻ Tổng đơn đều là bỏ lọc.
|
|
124
|
+
const card = (key as CardKey | null) ?? 'all';
|
|
125
|
+
this.selected.set(card);
|
|
126
|
+
this.status.set(card === 'all' ? null : card);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { inject } from '@angular/core';
|
|
3
|
+
import { createUrlTreeFromSnapshot, RedirectCommand, type ResolveFn } from '@angular/router';
|
|
4
|
+
import { map, timeout, type Observable } from 'rxjs';
|
|
5
|
+
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
|
|
6
|
+
import { OrderService } from './services/order.service';
|
|
7
|
+
import { canUpdateOrder, type OrderDto } from './services/order.model';
|
|
8
|
+
|
|
9
|
+
/** Tải đơn hàng bằng `detail(id)` trước khi mở chi tiết hoặc form; lỗi đi tới navigation error handler của host. */
|
|
10
|
+
export const entityResolver: ResolveFn<OrderDto> = route => {
|
|
11
|
+
const id = route.paramMap.get('id');
|
|
12
|
+
if (!id?.trim()) throw new HttpErrorResponse({ status: 404 });
|
|
13
|
+
return inject(OrderService)
|
|
14
|
+
.detail(id)
|
|
15
|
+
.pipe(
|
|
16
|
+
timeout(10_000),
|
|
17
|
+
map(entity => {
|
|
18
|
+
if (!entity || entity.id !== id) throw new HttpErrorResponse({ status: 404 });
|
|
19
|
+
return entity;
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Như `entityResolver`, cho trang cập nhật: đơn không còn sửa được (đã xác nhận, đang duyệt…) mở trang chi tiết, thay vì
|
|
26
|
+
* mở form rồi mới bị API từ chối khi lưu.
|
|
27
|
+
*/
|
|
28
|
+
export const updatableEntityResolver: ResolveFn<OrderDto> = (route, state) => {
|
|
29
|
+
const notify = inject(SdNotifyService);
|
|
30
|
+
return (entityResolver(route, state) as Observable<OrderDto>).pipe(
|
|
31
|
+
map(order => {
|
|
32
|
+
if (canUpdateOrder(order)) return order;
|
|
33
|
+
notify.info(`Đơn ${order.code} không còn sửa được.`);
|
|
34
|
+
return new RedirectCommand(createUrlTreeFromSnapshot(route, ['../detail']));
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { afterNextRender, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, inject, Injector, signal } from '@angular/core';
|
|
2
|
+
import { FormGroup } from '@angular/forms';
|
|
3
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
4
|
+
import { firstValueFrom } from 'rxjs';
|
|
5
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
6
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
7
|
+
import { SdTextarea } from '@sdcorejs/angular/forms/textarea';
|
|
8
|
+
import { SdPageComponent } from '@sdcorejs/angular/modules/layout';
|
|
9
|
+
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
|
|
10
|
+
import { registerSdUnsavedChangesForm, SdUnsavedChangesService } from '@sdcorejs/angular/services/unsaved-changes';
|
|
11
|
+
import { apiErrorMessage } from '../../../../utils/api-error';
|
|
12
|
+
import { focusFirstInvalid } from '../../../../utils/focus-first-invalid';
|
|
13
|
+
import { formApiErrors } from '../../../../utils/form-api-errors';
|
|
14
|
+
import {
|
|
15
|
+
GeneralInformationFormComponent,
|
|
16
|
+
orderSaveReq,
|
|
17
|
+
type OrderForm,
|
|
18
|
+
} from '../../components/general-information-form/general-information-form.component';
|
|
19
|
+
import { LinesFormComponent } from '../../components/lines-form/lines-form.component';
|
|
20
|
+
import { OrderService } from '../../services/order.service';
|
|
21
|
+
import { ORDER_CHANNELS, ORDER_PAYMENTS, ORDER_WAREHOUSES, type OrderSaveReq } from '../../services/order.model';
|
|
22
|
+
|
|
23
|
+
/** Tạo đơn hàng: form nhiều nhóm có mục lục (`toc`), dòng hàng nhập trực tiếp, lưu xong sang chi tiết. */
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'create',
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [SdPageComponent, SdButton, SdSection, SdTextarea, GeneralInformationFormComponent, LinesFormComponent],
|
|
28
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
29
|
+
template: `
|
|
30
|
+
<sd-page-form title="Tạo mới đơn hàng" [backLink]="['..']" toc>
|
|
31
|
+
<div headerRight class="d-flex align-items-center gap-8">
|
|
32
|
+
<sd-button title="Huỷ" type="outline" autoId="order-cancel" (click)="cancel()" />
|
|
33
|
+
<sd-button title="Lưu" type="fill" color="primary" autoId="order-save" [loading]="saving()" (click)="save()" />
|
|
34
|
+
</div>
|
|
35
|
+
<div class="d-flex flex-column gap-16 py-16">
|
|
36
|
+
<general-information-form [form]="form" [seed]="seed" />
|
|
37
|
+
<lines-form [form]="form" [seed]="seed.lines" [errors]="apiErrors.errors()" />
|
|
38
|
+
<sd-section title="Ghi chú">
|
|
39
|
+
<div class="p-16">
|
|
40
|
+
<sd-textarea label="Ghi chú nội bộ" name="note" [form]="form" [model]="seed.note" maxlength="500" />
|
|
41
|
+
</div>
|
|
42
|
+
</sd-section>
|
|
43
|
+
</div>
|
|
44
|
+
</sd-page-form>
|
|
45
|
+
`,
|
|
46
|
+
})
|
|
47
|
+
export class CreateComponent {
|
|
48
|
+
readonly #orderService = inject(OrderService);
|
|
49
|
+
readonly #notify = inject(SdNotifyService);
|
|
50
|
+
readonly #router = inject(Router);
|
|
51
|
+
readonly #route = inject(ActivatedRoute);
|
|
52
|
+
readonly #host: HTMLElement = inject(ElementRef).nativeElement;
|
|
53
|
+
readonly #injector = inject(Injector);
|
|
54
|
+
protected readonly seed: OrderSaveReq = {
|
|
55
|
+
customerId: '',
|
|
56
|
+
channel: ORDER_CHANNELS[0],
|
|
57
|
+
warehouse: ORDER_WAREHOUSES[0],
|
|
58
|
+
payment: ORDER_PAYMENTS[0],
|
|
59
|
+
note: null,
|
|
60
|
+
lines: [],
|
|
61
|
+
};
|
|
62
|
+
protected readonly form: OrderForm = new FormGroup({});
|
|
63
|
+
protected readonly saving = signal(false);
|
|
64
|
+
protected readonly apiErrors = formApiErrors(this.form);
|
|
65
|
+
readonly #unsaved = registerSdUnsavedChangesForm(inject(SdUnsavedChangesService), this.form, { id: 'order-create', dirty: 'value' });
|
|
66
|
+
|
|
67
|
+
constructor() {
|
|
68
|
+
inject(DestroyRef).onDestroy(() => this.#unsaved.destroy());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected cancel(): void {
|
|
72
|
+
void this.#router.navigate(['..'], { relativeTo: this.#route });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected async save(): Promise<void> {
|
|
76
|
+
if (this.saving()) return;
|
|
77
|
+
this.form.markAllAsTouched();
|
|
78
|
+
if (this.form.invalid) {
|
|
79
|
+
this.#focusFirstInvalid();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.saving.set(true);
|
|
83
|
+
try {
|
|
84
|
+
const order = await firstValueFrom(this.#orderService.create(orderSaveReq(this.form)));
|
|
85
|
+
this.#unsaved.markPristine();
|
|
86
|
+
this.#notify.success(`Đã tạo đơn ${order.code}.`);
|
|
87
|
+
await this.#router.navigate(['..', order.id, 'detail'], { relativeTo: this.#route, replaceUrl: true });
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (this.apiErrors.set(error)) this.#focusFirstInvalid();
|
|
90
|
+
else this.#notify.error(apiErrorMessage(error, 'Không thể lưu. Dữ liệu đã nhập vẫn được giữ.'));
|
|
91
|
+
} finally {
|
|
92
|
+
this.saving.set(false);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#focusFirstInvalid(): void {
|
|
97
|
+
afterNextRender(() => focusFirstInvalid(this.#host), { injector: this.#injector });
|
|
98
|
+
}
|
|
99
|
+
}
|