@sdcorejs/angular 20.3.2 → 20.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/components/badge/index.d.ts +19 -1
- package/components/section/index.d.ts +13 -1
- package/components/splitter/index.d.ts +1 -1
- package/components/tab-router/index.d.ts +47 -5
- package/components/table/index.d.ts +127 -13
- package/components/upload-file/index.d.ts +181 -21
- 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 +422 -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-DnbDCdcz.mjs → sdcorejs-angular-modules-generic-generic-configuration.page-D_1BxDC9.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-DnbDCdcz.mjs.map → sdcorejs-angular-modules-generic-generic-configuration.page-D_1BxDC9.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs → sdcorejs-angular-modules-generic-generic-form-host.page-CgH8Qi25.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-EBHM4kx2.mjs.map → sdcorejs-angular-modules-generic-generic-form-host.page-CgH8Qi25.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs → sdcorejs-angular-modules-generic-generic-list.page-CyCGqW9W.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BtHe8YIW.mjs.map → sdcorejs-angular-modules-generic-generic-list.page-CyCGqW9W.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DTmU8Te4.mjs} +4 -4
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-eFshU7ew.mjs.map → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DTmU8Te4.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-BubUwgBK.mjs +51 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-BubUwgBK.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-C9WQdsEi.mjs +131 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-C9WQdsEi.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-s7ZXoakT.mjs +130 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-s7ZXoakT.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-BxfQux1Q.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-BxfQux1Q.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-D4GrcahQ.mjs +460 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-D4GrcahQ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DlYVJqHo.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-DlYVJqHo.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-Bfx6_CmA.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-Bfx6_CmA.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-3PUIy1Vi.mjs +148 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-3PUIy1Vi.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CbYMo3D1.mjs +172 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CbYMo3D1.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-awjgX7ph.mjs +90 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-awjgX7ph.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-c__NdSt3.mjs +467 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-c__NdSt3.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-Bjvq6wJz.mjs +514 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-Bjvq6wJz.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-FwmYVkag.mjs +61 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-FwmYVkag.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BRsdOwWy.mjs +87 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-BRsdOwWy.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-DalxHa8D.mjs +232 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-DalxHa8D.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-pqT7lnS6.mjs +170 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-pqT7lnS6.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-kdEZ9s7K.mjs +70 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-kdEZ9s7K.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-DZXPZuM4.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-DZXPZuM4.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-form.component-BjMOON6K.mjs +522 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-form.component-BjMOON6K.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Bf9QWXBp.mjs +115 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-Bf9QWXBp.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CuDjsIzi.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CuDjsIzi.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DkVrMSPZ.mjs +164 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DkVrMSPZ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DkxheDVz.mjs +629 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DkxheDVz.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-E8rkFCkK.mjs +71 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-E8rkFCkK.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-DgmM-wTI.mjs +1069 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-DgmM-wTI.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-C3coYwmZ.mjs +48 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-C3coYwmZ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-YsWsrKWJ.mjs +297 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-YsWsrKWJ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-9ujH01cX.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-9ujH01cX.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BfpsCkim.mjs +45 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-BfpsCkim.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-C7b5dRrJ.mjs +165 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-C7b5dRrJ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CGeqkySv.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-CGeqkySv.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DoBxGoRE.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DoBxGoRE.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-dBuQqYkO.mjs +43 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-dBuQqYkO.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-quSIwMOx.mjs +50 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-quSIwMOx.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-rR-MpQFh.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-rR-MpQFh.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-LQNpFSmN.mjs +406 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-LQNpFSmN.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-CcmrUIvP.mjs +317 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-CcmrUIvP.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Cq72tG9h.mjs +143 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-Cq72tG9h.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-xFbutFLY.mjs +132 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-xFbutFLY.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-CsfGgGJb.mjs +128 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-CsfGgGJb.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DYPI_CRD.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DYPI_CRD.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-lHmdUXWT.mjs +357 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-lHmdUXWT.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/forms/chip/index.d.ts +136 -26
- package/i18n/index.d.ts +42 -0
- package/modules/layout/index.d.ts +89 -6
- 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/modules/pattern/index.d.ts +50 -0
- package/package.json +5 -1
- package/services/unsaved-changes/index.d.ts +11 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input, linkedSignal } from '@angular/core';
|
|
2
|
+
import type { FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { SdInform } from '@sdcorejs/angular/components/inform';
|
|
4
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
5
|
+
import { SdInput } from '@sdcorejs/angular/forms/input';
|
|
6
|
+
import { SdSwitch } from '@sdcorejs/angular/forms/switch';
|
|
7
|
+
import { SdTextarea } from '@sdcorejs/angular/forms/textarea';
|
|
8
|
+
import type { CustomerSaveReq, CustomerStatus, CustomerTier, CustomerType } from '../../services/customer.model';
|
|
9
|
+
import { CustomerTypeSelectComponent } from '../customer-type-select/customer-type-select.component';
|
|
10
|
+
|
|
11
|
+
/** Các field Core tự đăng ký control qua `[form]` + `name`. */
|
|
12
|
+
export type CustomerForm = FormGroup<{
|
|
13
|
+
name?: FormControl<string>;
|
|
14
|
+
type?: FormControl<CustomerType>;
|
|
15
|
+
taxCode?: FormControl<string | null>;
|
|
16
|
+
vip?: FormControl<boolean>;
|
|
17
|
+
email?: FormControl<string>;
|
|
18
|
+
phone?: FormControl<string>;
|
|
19
|
+
address?: FormControl<string>;
|
|
20
|
+
active?: FormControl<boolean>;
|
|
21
|
+
note?: FormControl<string | null>;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
/** Ba nhóm của form; nhóm còn lỗi sau khi bấm Lưu hiện `sd-inform` cảnh báo ngay trong nhóm. */
|
|
25
|
+
export type CustomerFormGroup = 'general' | 'contact' | 'other';
|
|
26
|
+
|
|
27
|
+
const GROUP_FIELDS: Readonly<Record<CustomerFormGroup, readonly string[]>> = {
|
|
28
|
+
general: ['name', 'type', 'taxCode', 'vip'],
|
|
29
|
+
contact: ['email', 'phone', 'address'],
|
|
30
|
+
other: ['active', 'note'],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Nhóm có field không hợp lệ: field còn lỗi validate hoặc lỗi do API trả về. */
|
|
34
|
+
export function invalidCustomerGroups(form: CustomerForm, apiErrors: Readonly<Record<string, string>>): CustomerFormGroup[] {
|
|
35
|
+
return (Object.keys(GROUP_FIELDS) as CustomerFormGroup[]).filter(group =>
|
|
36
|
+
GROUP_FIELDS[group].some(field => form.get(field)?.invalid || !!apiErrors[field])
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Giá trị form → request lưu. */
|
|
41
|
+
export function customerSaveReq(form: CustomerForm): CustomerSaveReq {
|
|
42
|
+
const value = form.getRawValue();
|
|
43
|
+
const type: CustomerType = value.type ?? 'individual';
|
|
44
|
+
const tier: CustomerTier = value.vip ? 'vip' : 'standard';
|
|
45
|
+
const status: CustomerStatus = value.active === false ? 'inactive' : 'active';
|
|
46
|
+
return {
|
|
47
|
+
name: value.name ?? '',
|
|
48
|
+
type,
|
|
49
|
+
tier,
|
|
50
|
+
email: value.email ?? '',
|
|
51
|
+
phone: value.phone ?? '',
|
|
52
|
+
address: value.address ?? '',
|
|
53
|
+
taxCode: type === 'business' ? (value.taxCode ?? null) : null,
|
|
54
|
+
status,
|
|
55
|
+
note: value.note || null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Form khách hàng ba nhóm, dùng chung cho drawer tạo mới và cập nhật. */
|
|
60
|
+
@Component({
|
|
61
|
+
selector: 'general-information-form',
|
|
62
|
+
standalone: true,
|
|
63
|
+
imports: [SdSection, SdInput, SdTextarea, SdSwitch, SdInform, CustomerTypeSelectComponent],
|
|
64
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
65
|
+
template: `
|
|
66
|
+
@let invalid = invalidGroups();
|
|
67
|
+
<div class="d-flex flex-column gap-16">
|
|
68
|
+
<sd-section title="Thông tin chung">
|
|
69
|
+
<div class="d-flex flex-column gap-8 p-16">
|
|
70
|
+
@if (invalid.includes('general')) {
|
|
71
|
+
<sd-inform warning description="Kiểm tra tên và loại khách hàng." autoId="customer-general-warning" />
|
|
72
|
+
}
|
|
73
|
+
<sd-input
|
|
74
|
+
label="Tên khách hàng"
|
|
75
|
+
name="name"
|
|
76
|
+
autoId="customer-name"
|
|
77
|
+
[form]="form()"
|
|
78
|
+
[model]="seed().name"
|
|
79
|
+
[inlineError]="errors()['name']"
|
|
80
|
+
maxlength="120"
|
|
81
|
+
required />
|
|
82
|
+
<customer-type-select [form]="form()" [model]="seed().type" (modelChange)="type.set($event ?? 'individual')" />
|
|
83
|
+
@if (type() === 'business') {
|
|
84
|
+
<sd-input
|
|
85
|
+
label="Mã số thuế"
|
|
86
|
+
name="taxCode"
|
|
87
|
+
autoId="customer-tax-code"
|
|
88
|
+
[form]="form()"
|
|
89
|
+
[model]="seed().taxCode"
|
|
90
|
+
[inlineError]="errors()['taxCode']"
|
|
91
|
+
maxlength="14"
|
|
92
|
+
required />
|
|
93
|
+
}
|
|
94
|
+
<sd-switch label="Khách VIP" name="vip" [form]="form()" [model]="seed().tier === 'vip'" />
|
|
95
|
+
</div>
|
|
96
|
+
</sd-section>
|
|
97
|
+
<sd-section title="Liên hệ">
|
|
98
|
+
<div class="d-flex flex-column gap-8 p-16">
|
|
99
|
+
@if (invalid.includes('contact')) {
|
|
100
|
+
<sd-inform warning description="Kiểm tra email và số điện thoại." autoId="customer-contact-warning" />
|
|
101
|
+
}
|
|
102
|
+
<sd-input
|
|
103
|
+
label="Email"
|
|
104
|
+
name="email"
|
|
105
|
+
autoId="customer-email"
|
|
106
|
+
[form]="form()"
|
|
107
|
+
[model]="seed().email"
|
|
108
|
+
[inlineError]="errors()['email']"
|
|
109
|
+
pattern="EMAIL"
|
|
110
|
+
required />
|
|
111
|
+
<sd-input
|
|
112
|
+
label="Điện thoại"
|
|
113
|
+
name="phone"
|
|
114
|
+
autoId="customer-phone"
|
|
115
|
+
[form]="form()"
|
|
116
|
+
[model]="seed().phone"
|
|
117
|
+
[inlineError]="errors()['phone']"
|
|
118
|
+
maxlength="15"
|
|
119
|
+
required />
|
|
120
|
+
<sd-input label="Địa chỉ" name="address" autoId="customer-address" [form]="form()" [model]="seed().address" maxlength="200" />
|
|
121
|
+
</div>
|
|
122
|
+
</sd-section>
|
|
123
|
+
<sd-section title="Khác">
|
|
124
|
+
<div class="d-flex flex-column gap-8 p-16">
|
|
125
|
+
<sd-switch label="Đang hoạt động" name="active" [form]="form()" [model]="seed().status !== 'inactive'" />
|
|
126
|
+
<sd-textarea label="Ghi chú" name="note" [form]="form()" [model]="seed().note" maxlength="500" />
|
|
127
|
+
</div>
|
|
128
|
+
</sd-section>
|
|
129
|
+
</div>
|
|
130
|
+
`,
|
|
131
|
+
})
|
|
132
|
+
export class GeneralInformationFormComponent {
|
|
133
|
+
readonly form = input.required<CustomerForm>();
|
|
134
|
+
readonly seed = input.required<CustomerSaveReq>();
|
|
135
|
+
/** Lỗi theo field do API trả về. */
|
|
136
|
+
readonly errors = input<Readonly<Record<string, string>>>({});
|
|
137
|
+
readonly invalidGroups = input<readonly CustomerFormGroup[]>([]);
|
|
138
|
+
/** Loại khách đang chọn: doanh nghiệp mới có mã số thuế. */
|
|
139
|
+
protected readonly type = linkedSignal(() => this.seed().type);
|
|
140
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
|
+
import { SdSection, SdSectionItem } from '@sdcorejs/angular/components/section';
|
|
3
|
+
import { SdEmptyPipe, SdFormatDatePipe, SdFormatNumberPipe } from '@sdcorejs/angular/pipes';
|
|
4
|
+
import { customerTypeName, type CustomerDto } from '../../services/customer.model';
|
|
5
|
+
|
|
6
|
+
/** Thông tin khách hàng dạng hàng `sd-section-item`: nhãn bên trái, giá trị bên phải. */
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'general-information-view',
|
|
9
|
+
standalone: true,
|
|
10
|
+
imports: [SdSection, SdSectionItem, SdEmptyPipe, SdFormatDatePipe, SdFormatNumberPipe],
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
+
template: `
|
|
13
|
+
@let item = customer();
|
|
14
|
+
<div class="d-flex flex-column gap-16">
|
|
15
|
+
<sd-section title="Thông tin chung">
|
|
16
|
+
<sd-section-item label="Mã khách hàng">{{ item.code }}</sd-section-item>
|
|
17
|
+
<sd-section-item label="Tên khách hàng">{{ item.name }}</sd-section-item>
|
|
18
|
+
<sd-section-item label="Loại khách hàng">{{ typeName() }}{{ item.tier === 'vip' ? ' · VIP' : '' }}</sd-section-item>
|
|
19
|
+
@if (item.type === 'business') {
|
|
20
|
+
<sd-section-item label="Mã số thuế">{{ item.taxCode | sdEmpty }}</sd-section-item>
|
|
21
|
+
}
|
|
22
|
+
<sd-section-item label="Ngày tạo">{{ item.createdAt | sdFormatDate }}</sd-section-item>
|
|
23
|
+
</sd-section>
|
|
24
|
+
<sd-section title="Liên hệ">
|
|
25
|
+
<sd-section-item label="Email">{{ item.email }}</sd-section-item>
|
|
26
|
+
<sd-section-item label="Điện thoại">{{ item.phone }}</sd-section-item>
|
|
27
|
+
<sd-section-item label="Địa chỉ">{{ item.address | sdEmpty }}</sd-section-item>
|
|
28
|
+
</sd-section>
|
|
29
|
+
<sd-section title="Khác">
|
|
30
|
+
<sd-section-item label="Công nợ (₫)">{{ item.debt | sdFormatNumber: 0 }}</sd-section-item>
|
|
31
|
+
<sd-section-item label="Ghi chú">{{ item.note | sdEmpty }}</sd-section-item>
|
|
32
|
+
</sd-section>
|
|
33
|
+
</div>
|
|
34
|
+
`,
|
|
35
|
+
})
|
|
36
|
+
export class GeneralInformationViewComponent {
|
|
37
|
+
readonly customer = input.required<CustomerDto>();
|
|
38
|
+
protected readonly typeName = computed(() => customerTypeName(this.customer().type));
|
|
39
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
|
|
2
|
+
import { RouterLink } from '@angular/router';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
|
+
import { SdTable, SdTableCellDefDirective, type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
5
|
+
import { CustomerService } from '../../services/customer.service';
|
|
6
|
+
import type { CustomerOrderDto } from '../../services/customer.model';
|
|
7
|
+
|
|
8
|
+
/** Tab Đơn hàng của hồ sơ 360°: tải khi tab được mở lần đầu; bảng tự có trạng thái đang tải, rỗng và lỗi. */
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'orders-view',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [RouterLink, SdTable, SdTableCellDefDirective],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
template: `
|
|
15
|
+
<sd-table autoId="customer-orders" [option]="option">
|
|
16
|
+
<ng-template sdTableCellDef="code" let-order="item">
|
|
17
|
+
<a [routerLink]="['../../../order', order.id, 'detail']">{{ order.code }}</a>
|
|
18
|
+
</ng-template>
|
|
19
|
+
</sd-table>
|
|
20
|
+
`,
|
|
21
|
+
})
|
|
22
|
+
export class OrdersViewComponent {
|
|
23
|
+
readonly #customerService = inject(CustomerService);
|
|
24
|
+
readonly customerId = input.required<string>();
|
|
25
|
+
protected readonly option: SdTableOption<CustomerOrderDto> = {
|
|
26
|
+
type: 'server',
|
|
27
|
+
items: () => firstValueFrom(this.#customerService.orders(this.customerId())),
|
|
28
|
+
paginate: { pageSize: 10 },
|
|
29
|
+
columns: [
|
|
30
|
+
{ field: 'code', title: 'Mã đơn', type: 'string', width: '140px' },
|
|
31
|
+
{ field: 'createdAt', title: 'Ngày tạo', type: 'date', width: '160px' },
|
|
32
|
+
{ field: 'total', title: 'Tổng tiền (₫)', type: 'number', align: 'right' },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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 { CustomerCounts, CustomerSegment } from '../../services/customer.model';
|
|
5
|
+
|
|
6
|
+
const CARDS: readonly { readonly key: 'all' | CustomerSegment; readonly label: string }[] = [
|
|
7
|
+
{ key: 'all', label: 'Tất cả khách hàng' },
|
|
8
|
+
{ key: 'individual', label: 'Cá nhân' },
|
|
9
|
+
{ key: 'business', label: 'Doanh nghiệp' },
|
|
10
|
+
{ key: 'vip', label: 'Khách VIP' },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Score card của danh sách khách hàng: mỗi thẻ là một nhóm khách và là bộ lọc của danh sách.
|
|
15
|
+
* Khi `sd-page-list` thu gọn (màn thấp), các thẻ thành một dòng 36px.
|
|
16
|
+
*/
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'summary-cards',
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [SdCard, SdCardGroup],
|
|
21
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
22
|
+
template: `
|
|
23
|
+
<sd-card-group
|
|
24
|
+
class="summary"
|
|
25
|
+
autoId="customer-segments"
|
|
26
|
+
aria-label="Nhóm khách hàng"
|
|
27
|
+
[class.summary--compact]="compact()"
|
|
28
|
+
[(model)]="selected"
|
|
29
|
+
(sdChange)="choose($event)">
|
|
30
|
+
@for (card of cards(); track card.key) {
|
|
31
|
+
<sd-card class="summary__card" [value]="card.key" [autoId]="'customer-segment-' + card.key">
|
|
32
|
+
<span class="summary__label">{{ card.label }}</span>
|
|
33
|
+
<strong class="summary__value">{{ card.value }}</strong>
|
|
34
|
+
</sd-card>
|
|
35
|
+
}
|
|
36
|
+
</sd-card-group>
|
|
37
|
+
`,
|
|
38
|
+
styles: `
|
|
39
|
+
.summary {
|
|
40
|
+
display: grid;
|
|
41
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
42
|
+
gap: 12px;
|
|
43
|
+
}
|
|
44
|
+
.summary__card {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
gap: 4px;
|
|
48
|
+
padding: 12px 16px;
|
|
49
|
+
}
|
|
50
|
+
.summary__label {
|
|
51
|
+
color: var(--sd-text-secondary);
|
|
52
|
+
font-size: 13px;
|
|
53
|
+
}
|
|
54
|
+
.summary__value {
|
|
55
|
+
font-size: 22px;
|
|
56
|
+
line-height: 28px;
|
|
57
|
+
font-weight: 500;
|
|
58
|
+
font-variant-numeric: tabular-nums;
|
|
59
|
+
}
|
|
60
|
+
.summary--compact {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 8px;
|
|
64
|
+
height: 36px;
|
|
65
|
+
}
|
|
66
|
+
.summary--compact .summary__card {
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
align-items: baseline;
|
|
69
|
+
gap: 6px;
|
|
70
|
+
padding: 4px 10px;
|
|
71
|
+
}
|
|
72
|
+
.summary--compact .summary__value {
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
line-height: 20px;
|
|
75
|
+
}
|
|
76
|
+
@media (max-width: 767px) {
|
|
77
|
+
.summary {
|
|
78
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`,
|
|
82
|
+
})
|
|
83
|
+
export class SummaryCardsComponent {
|
|
84
|
+
readonly #list = inject(SD_PAGE_LIST);
|
|
85
|
+
readonly counts = input<CustomerCounts | null>(null);
|
|
86
|
+
/** Nhóm đang lọc; `null` là tất cả. */
|
|
87
|
+
readonly segment = model<CustomerSegment | null>(null);
|
|
88
|
+
protected readonly compact = this.#list.compact;
|
|
89
|
+
protected readonly selected = linkedSignal<'all' | CustomerSegment | null>(() => this.segment() ?? 'all');
|
|
90
|
+
protected readonly cards = computed(() => {
|
|
91
|
+
const counts = this.counts();
|
|
92
|
+
return CARDS.map(card => ({ ...card, value: counts ? counts[card.key].toLocaleString('vi-VN') : '…' }));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
protected choose(key: unknown): void {
|
|
96
|
+
// Bấm lại thẻ đang chọn (model về null) hoặc thẻ "Tất cả" đều là bỏ lọc.
|
|
97
|
+
const segment = key === null || key === 'all' ? null : (key as CustomerSegment);
|
|
98
|
+
this.selected.set(segment ?? 'all');
|
|
99
|
+
this.segment.set(segment);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterNextRender,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
DestroyRef,
|
|
6
|
+
ElementRef,
|
|
7
|
+
inject,
|
|
8
|
+
Injector,
|
|
9
|
+
signal,
|
|
10
|
+
viewChild,
|
|
11
|
+
} from '@angular/core';
|
|
12
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
13
|
+
import { FormGroup } from '@angular/forms';
|
|
14
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
15
|
+
import { firstValueFrom, map } from 'rxjs';
|
|
16
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
17
|
+
import { SdSideDrawer } from '@sdcorejs/angular/components/side-drawer';
|
|
18
|
+
import { SdConfirmService } from '@sdcorejs/angular/services/confirm';
|
|
19
|
+
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
|
|
20
|
+
import { registerSdUnsavedChangesForm, SdUnsavedChangesService } from '@sdcorejs/angular/services/unsaved-changes';
|
|
21
|
+
import { apiErrorMessage } from '../../../../utils/api-error';
|
|
22
|
+
import { focusFirstInvalid } from '../../../../utils/focus-first-invalid';
|
|
23
|
+
import { formApiErrors } from '../../../../utils/form-api-errors';
|
|
24
|
+
import { CustomerService } from '../../services/customer.service';
|
|
25
|
+
import type { CustomerDto } from '../../services/customer.model';
|
|
26
|
+
import {
|
|
27
|
+
customerSaveReq,
|
|
28
|
+
GeneralInformationFormComponent,
|
|
29
|
+
invalidCustomerGroups,
|
|
30
|
+
type CustomerForm,
|
|
31
|
+
type CustomerFormGroup,
|
|
32
|
+
} from '../general-information-form/general-information-form.component';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Cập nhật khách hàng trong drawer (route con `:id/update`). X, Esc và backdrop đi qua `beforeClose`: còn thay đổi
|
|
36
|
+
* thì hỏi trước khi bỏ. Lưu thành công thì đóng drawer; danh sách tải lại và focus trở về dòng đã mở.
|
|
37
|
+
*/
|
|
38
|
+
@Component({
|
|
39
|
+
selector: 'update-side-drawer',
|
|
40
|
+
standalone: true,
|
|
41
|
+
imports: [SdSideDrawer, SdButton, GeneralInformationFormComponent],
|
|
42
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
43
|
+
template: `
|
|
44
|
+
<sd-side-drawer
|
|
45
|
+
[title]="'Cập nhật khách hàng #' + entity().code"
|
|
46
|
+
width="600px"
|
|
47
|
+
autoId="customer-update"
|
|
48
|
+
[beforeClose]="beforeClose"
|
|
49
|
+
(sdClosed)="closed()">
|
|
50
|
+
<general-information-form [form]="form" [seed]="entity()" [errors]="apiErrors.errors()" [invalidGroups]="invalidGroups()" />
|
|
51
|
+
<div sdFooterRight class="d-flex align-items-center gap-8">
|
|
52
|
+
<sd-button title="Lưu" type="fill" color="primary" autoId="customer-save" [loading]="saving()" (click)="save()" />
|
|
53
|
+
</div>
|
|
54
|
+
</sd-side-drawer>
|
|
55
|
+
`,
|
|
56
|
+
})
|
|
57
|
+
export class UpdateSideDrawerComponent {
|
|
58
|
+
readonly #customerService = inject(CustomerService);
|
|
59
|
+
readonly #confirm = inject(SdConfirmService);
|
|
60
|
+
readonly #notify = inject(SdNotifyService);
|
|
61
|
+
readonly #router = inject(Router);
|
|
62
|
+
readonly #route = inject(ActivatedRoute);
|
|
63
|
+
readonly #injector = inject(Injector);
|
|
64
|
+
private readonly drawer = viewChild.required(SdSideDrawer);
|
|
65
|
+
// why: sd-side-drawer chuyển nội dung ra body, nên tìm field lỗi trong form chứ không trong host của component.
|
|
66
|
+
private readonly formElement = viewChild.required(GeneralInformationFormComponent, { read: ElementRef });
|
|
67
|
+
protected readonly entity = toSignal(this.#route.data.pipe(map(data => data['entity'] as CustomerDto)), { requireSync: true });
|
|
68
|
+
protected readonly form: CustomerForm = new FormGroup({});
|
|
69
|
+
protected readonly saving = signal(false);
|
|
70
|
+
protected readonly apiErrors = formApiErrors(this.form);
|
|
71
|
+
protected readonly invalidGroups = signal<CustomerFormGroup[]>([]);
|
|
72
|
+
readonly #unsaved = registerSdUnsavedChangesForm(inject(SdUnsavedChangesService), this.form, { id: 'customer-update', dirty: 'value' });
|
|
73
|
+
|
|
74
|
+
/** Đóng khi còn thay đổi chưa lưu: hỏi, đồng ý thì bỏ thay đổi (guard rời route không hỏi lại). */
|
|
75
|
+
protected readonly beforeClose = async (): Promise<boolean> => {
|
|
76
|
+
if (!this.#unsaved.dirty() || this.saving()) return !this.saving();
|
|
77
|
+
try {
|
|
78
|
+
await this.#confirm.confirm('Thay đổi chưa lưu sẽ bị mất.', {
|
|
79
|
+
title: 'Đóng khi chưa lưu?',
|
|
80
|
+
yesTitle: 'Bỏ thay đổi',
|
|
81
|
+
noTitle: 'Tiếp tục sửa',
|
|
82
|
+
yesButtonColor: 'warning',
|
|
83
|
+
});
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
this.#unsaved.markPristine();
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
constructor() {
|
|
92
|
+
afterNextRender(() => this.drawer().open());
|
|
93
|
+
inject(DestroyRef).onDestroy(() => this.#unsaved.destroy());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
protected closed(): void {
|
|
97
|
+
void this.#router.navigate(['../..'], { relativeTo: this.#route });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected async save(): Promise<void> {
|
|
101
|
+
if (this.saving()) return;
|
|
102
|
+
this.form.markAllAsTouched();
|
|
103
|
+
if (this.form.invalid) {
|
|
104
|
+
this.#showErrors();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.saving.set(true);
|
|
108
|
+
try {
|
|
109
|
+
await firstValueFrom(this.#customerService.update(this.entity().id, customerSaveReq(this.form)));
|
|
110
|
+
this.#unsaved.markPristine();
|
|
111
|
+
this.#notify.success('Đã cập nhật khách hàng.');
|
|
112
|
+
this.saving.set(false);
|
|
113
|
+
this.drawer().close();
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (this.apiErrors.set(error)) this.#showErrors();
|
|
116
|
+
else this.#notify.error(apiErrorMessage(error, 'Không thể lưu. Dữ liệu đã nhập vẫn được giữ.'));
|
|
117
|
+
} finally {
|
|
118
|
+
this.saving.set(false);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `sd-inform` trong từng nhóm có lỗi, rồi focus field lỗi đầu tiên. */
|
|
123
|
+
#showErrors(): void {
|
|
124
|
+
this.invalidGroups.set(invalidCustomerGroups(this.form, this.apiErrors.errors()));
|
|
125
|
+
afterNextRender(() => focusFirstInvalid(this.formElement().nativeElement), { injector: this.#injector });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { inject } from '@angular/core';
|
|
3
|
+
import type { ResolveFn } from '@angular/router';
|
|
4
|
+
import { map, timeout } from 'rxjs';
|
|
5
|
+
import { CustomerService } from './services/customer.service';
|
|
6
|
+
import type { CustomerDto } from './services/customer.model';
|
|
7
|
+
|
|
8
|
+
/** Tải khách hàng bằng `detail(id)` trước khi mở drawer/trang; lỗi đi tới navigation error handler của host. */
|
|
9
|
+
export const entityResolver: ResolveFn<CustomerDto> = route => {
|
|
10
|
+
const id = route.paramMap.get('id');
|
|
11
|
+
if (!id?.trim()) throw new HttpErrorResponse({ status: 404 });
|
|
12
|
+
return inject(CustomerService)
|
|
13
|
+
.detail(id)
|
|
14
|
+
.pipe(
|
|
15
|
+
timeout(10_000),
|
|
16
|
+
map(entity => {
|
|
17
|
+
if (!entity || entity.id !== id) throw new HttpErrorResponse({ status: 404 });
|
|
18
|
+
return entity;
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<sd-page-list title="Khách hàng" description="Khách cá nhân và doanh nghiệp đang giao dịch." [detail]="detailMode()">
|
|
2
|
+
<sd-button
|
|
3
|
+
headerRight
|
|
4
|
+
*sdPermission="'PATTERN_CUSTOMER_C_CREATE'"
|
|
5
|
+
title="Tạo khách hàng"
|
|
6
|
+
prefixIcon="add"
|
|
7
|
+
type="fill"
|
|
8
|
+
color="primary"
|
|
9
|
+
autoId="customer-create"
|
|
10
|
+
[routerLink]="['create']" />
|
|
11
|
+
|
|
12
|
+
<summary-cards [counts]="counts()" [(segment)]="segment" />
|
|
13
|
+
|
|
14
|
+
<sd-table autoId="customer-list" [option]="tableOption">
|
|
15
|
+
<ng-template sdTableCellDef="code" let-customer="item">
|
|
16
|
+
<a *sdPermission="'PATTERN_CUSTOMER_R_DETAIL'" [routerLink]="[customer.id, 'detail']">{{ customer.code }}</a>
|
|
17
|
+
@if (!canOpenDetail) {
|
|
18
|
+
<span>{{ customer.code }}</span>
|
|
19
|
+
}
|
|
20
|
+
</ng-template>
|
|
21
|
+
</sd-table>
|
|
22
|
+
</sd-page-list>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, effect, inject, signal, untracked, viewChild } from '@angular/core';
|
|
2
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from '@angular/router';
|
|
4
|
+
import { filter, firstValueFrom, map, startWith } from 'rxjs';
|
|
5
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
6
|
+
import { SdTable, SdTableCellDefDirective, type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
7
|
+
import { SdPageList, type SdPageListDetail } from '@sdcorejs/angular/modules/layout';
|
|
8
|
+
import { SdPermissionDirective, SdPermissionService } from '@sdcorejs/angular/modules/permission';
|
|
9
|
+
import type { Filter } from '@sdcorejs/utils/models';
|
|
10
|
+
import { SummaryCardsComponent } from '../../components/summary-cards/summary-cards.component';
|
|
11
|
+
import { CustomerService } from '../../services/customer.service';
|
|
12
|
+
import {
|
|
13
|
+
CUSTOMER_STATUS_OPTIONS,
|
|
14
|
+
CUSTOMER_TYPE_OPTIONS,
|
|
15
|
+
customerStatusBadge,
|
|
16
|
+
type CustomerCounts,
|
|
17
|
+
type CustomerDto,
|
|
18
|
+
type CustomerSegment,
|
|
19
|
+
} from '../../services/customer.model';
|
|
20
|
+
|
|
21
|
+
/** Điều kiện của nhóm khách đang chọn trên score card. */
|
|
22
|
+
const SEGMENT_FILTER: Readonly<Record<CustomerSegment, Filter<CustomerDto>>> = {
|
|
23
|
+
individual: { field: 'type', operator: 'EQUAL', data: 'individual' },
|
|
24
|
+
business: { field: 'type', operator: 'EQUAL', data: 'business' },
|
|
25
|
+
vip: { field: 'tier', operator: 'EQUAL', data: 'vip' },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@Component({
|
|
29
|
+
selector: 'list',
|
|
30
|
+
standalone: true,
|
|
31
|
+
templateUrl: './list.component.html',
|
|
32
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
33
|
+
imports: [RouterLink, SdPageList, SdButton, SdTable, SdTableCellDefDirective, SdPermissionDirective, SummaryCardsComponent],
|
|
34
|
+
})
|
|
35
|
+
export class ListComponent {
|
|
36
|
+
readonly #customerService = inject(CustomerService);
|
|
37
|
+
readonly #router = inject(Router);
|
|
38
|
+
readonly #route = inject(ActivatedRoute);
|
|
39
|
+
private readonly pageList = viewChild.required(SdPageList);
|
|
40
|
+
private readonly table = viewChild.required(SdTable);
|
|
41
|
+
protected readonly canOpenDetail = inject(SdPermissionService).hasPermission('PATTERN_CUSTOMER_R_DETAIL');
|
|
42
|
+
|
|
43
|
+
/** Một state cho score card và request: đổi nhóm thì đọc lại từ trang 1. */
|
|
44
|
+
protected readonly segment = signal<CustomerSegment | null>(null);
|
|
45
|
+
protected readonly counts = signal<CustomerCounts | null>(null);
|
|
46
|
+
/** Detail, create, update mở trong drawer; hồ sơ 360° (`data.detail: 'page'`) thay chỗ danh sách. */
|
|
47
|
+
protected readonly detailMode = toSignal(
|
|
48
|
+
this.#router.events.pipe(
|
|
49
|
+
filter(event => event instanceof NavigationEnd),
|
|
50
|
+
startWith(null),
|
|
51
|
+
map((): SdPageListDetail => (this.#route.firstChild?.snapshot.data['detail'] === 'page' ? 'page' : 'drawer'))
|
|
52
|
+
),
|
|
53
|
+
{ requireSync: true }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
protected readonly tableOption: SdTableOption<CustomerDto> = {
|
|
57
|
+
type: 'server',
|
|
58
|
+
rowKey: 'id',
|
|
59
|
+
items: async (_, req) => {
|
|
60
|
+
const segment = untracked(this.segment);
|
|
61
|
+
// Số trên thẻ theo cùng bộ lọc của bảng, chưa tính nhóm đang chọn.
|
|
62
|
+
void firstValueFrom(this.#customerService.counts(req.filters ?? [])).then(counts => this.counts.set(counts));
|
|
63
|
+
const filters = segment ? [...(req.filters ?? []), SEGMENT_FILTER[segment]] : req.filters;
|
|
64
|
+
return firstValueFrom(this.#customerService.list({ ...req, filters }));
|
|
65
|
+
},
|
|
66
|
+
sort: { enable: true },
|
|
67
|
+
filter: {
|
|
68
|
+
quickSearch: { containFields: ['code', 'name', 'phone'], placeholder: 'Tìm theo mã, tên hoặc số điện thoại' },
|
|
69
|
+
},
|
|
70
|
+
columns: [
|
|
71
|
+
{ field: 'code', title: 'Mã khách hàng', type: 'string', width: '150px', sortable: true },
|
|
72
|
+
{ field: 'name', title: 'Tên khách hàng', type: 'string', minWidth: '220px', sortable: true },
|
|
73
|
+
{
|
|
74
|
+
field: 'type',
|
|
75
|
+
title: 'Loại',
|
|
76
|
+
type: 'values',
|
|
77
|
+
width: '140px',
|
|
78
|
+
option: { items: CUSTOMER_TYPE_OPTIONS, valueField: 'id', displayField: 'name' },
|
|
79
|
+
// Score card là chỗ lọc theo loại khách: mỗi field chỉ một chỗ lọc (E6).
|
|
80
|
+
filter: { disabled: true },
|
|
81
|
+
},
|
|
82
|
+
{ field: 'phone', title: 'Điện thoại', type: 'string', width: '140px' },
|
|
83
|
+
{ field: 'email', title: 'Email', type: 'string', minWidth: '200px' },
|
|
84
|
+
{ field: 'debt', title: 'Công nợ (₫)', type: 'number', width: '150px', align: 'right', sortable: true },
|
|
85
|
+
{
|
|
86
|
+
field: 'status',
|
|
87
|
+
title: 'Trạng thái',
|
|
88
|
+
type: 'values',
|
|
89
|
+
width: '170px',
|
|
90
|
+
option: { items: CUSTOMER_STATUS_OPTIONS, valueField: 'id', displayField: 'name' },
|
|
91
|
+
useBadge: status => customerStatusBadge(status),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
constructor() {
|
|
97
|
+
let segment = this.segment();
|
|
98
|
+
effect(() => {
|
|
99
|
+
const next = this.segment();
|
|
100
|
+
if (next === segment) return;
|
|
101
|
+
segment = next;
|
|
102
|
+
untracked(() => void this.table().reloadFirstPage());
|
|
103
|
+
});
|
|
104
|
+
// Chỉ tải lại danh sách khi drawer/trang con đã lưu thành công, không phải mỗi lần đóng.
|
|
105
|
+
let changes = this.#customerService.changes();
|
|
106
|
+
effect(() => {
|
|
107
|
+
const next = this.#customerService.changes();
|
|
108
|
+
if (this.pageList().childActive() || next === changes) return;
|
|
109
|
+
changes = next;
|
|
110
|
+
untracked(() => void this.table().reload(true, false));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|