@sdcorejs/angular 19.3.2 → 19.3.4
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 +1 -0
- package/components/badge/src/badge.model.d.ts +19 -0
- package/components/query-bar/src/components/actions-bar/actions-bar.component.d.ts +6 -1
- package/components/query-bar/src/components/field-picker/field-picker.component.d.ts +21 -0
- package/components/query-bar/src/components/inline-chip/inline-chip.component.d.ts +7 -1
- package/components/query-bar/src/components/inline-value-chip/inline-value-chip.component.d.ts +7 -1
- package/components/query-bar/src/components/popover-chip/popover-chip.component.d.ts +16 -2
- package/components/query-bar/src/query-bar.component.d.ts +66 -8
- package/components/query-bar/src/query-bar.model.d.ts +44 -1
- package/components/section/index.d.ts +1 -0
- package/components/section/src/section-registry.d.ts +11 -0
- package/components/splitter/index.d.ts +1 -1
- package/components/tab-router/src/actions/tab-router.action.d.ts +1 -1
- package/components/tab-router/src/components/tab-router-item/tab-router-item.component.d.ts +4 -2
- package/components/tab-router/src/components/tab-router-nav/tab-router-nav.component.d.ts +31 -3
- package/components/tab-router/src/components/tab-router-outlet/tab-router-outlet.component.d.ts +6 -1
- package/components/tab-router/src/models/tab-router.model.d.ts +5 -0
- package/components/tab-router/src/pipes/tab-info.pipe.d.ts +7 -0
- package/components/tab-router/src/services/tab-router.service.d.ts +5 -0
- package/components/table/index.d.ts +2 -0
- package/components/table/src/components/config/config-width.util.d.ts +9 -0
- package/components/table/src/components/config/config.component.d.ts +58 -11
- package/components/table/src/components/filter/column-filter/column-filter.component.d.ts +5 -0
- package/components/table/src/components/filter/external-filter/external-filter.component.d.ts +5 -1
- package/components/table/src/components/mobile-cards/mobile-cards.component.d.ts +4 -0
- package/components/table/src/configurations/index.d.ts +1 -0
- package/components/table/src/configurations/table-layout.d.ts +16 -0
- package/components/table/src/configurations/table.configuration.d.ts +7 -1
- package/components/table/src/models/index.d.ts +1 -0
- package/components/table/src/models/table-column.model.d.ts +3 -10
- package/components/table/src/models/table-item.model.d.ts +4 -1
- package/components/table/src/models/table-option-loading.model.d.ts +42 -0
- package/components/table/src/models/table-option.model.d.ts +6 -0
- package/components/table/src/services/column-leaf.util.d.ts +6 -0
- package/components/table/src/services/config-custom.util.d.ts +14 -0
- package/components/table/src/services/table-filter/table-filter.model.d.ts +30 -0
- package/components/table/src/services/table-filter/table-query-bar.util.d.ts +110 -0
- package/components/table/src/services/table-loading/table-loading.util.d.ts +91 -0
- package/components/table/src/services/tree/tree.util.d.ts +2 -0
- package/components/table/src/table.component.d.ts +60 -1
- package/components/upload-file/src/components/file-type-icon/file-type-icon.component.d.ts +15 -0
- package/components/upload-file/src/components/preview/preview.component.d.ts +88 -10
- package/components/upload-file/src/configurations/upload-file.configuration.d.ts +1 -1
- package/components/upload-file/src/helpers/file-type.d.ts +25 -0
- package/components/upload-file/src/pipes/file-meta.pipe.d.ts +9 -0
- package/components/upload-file/src/pipes/file-reason.pipe.d.ts +11 -0
- package/components/upload-file/src/pipes/index.d.ts +2 -0
- package/components/upload-file/src/upload-file.component.d.ts +89 -8
- 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-query-bar.mjs +455 -37
- package/fesm2022/sdcorejs-angular-components-query-bar.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 +390 -75
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +1667 -124
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +886 -173
- 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 +421 -121
- 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 +350 -5
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-BFxO3eHX.mjs → sdcorejs-angular-modules-generic-generic-configuration.page-Bk3PrEf3.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-configuration.page-BFxO3eHX.mjs.map → sdcorejs-angular-modules-generic-generic-configuration.page-Bk3PrEf3.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-Csy2fShj.mjs → sdcorejs-angular-modules-generic-generic-form-host.page-CwUegGgG.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-form-host.page-Csy2fShj.mjs.map → sdcorejs-angular-modules-generic-generic-form-host.page-CwUegGgG.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BIIxNR6k.mjs → sdcorejs-angular-modules-generic-generic-list.page-lF2trhfp.mjs} +3 -3
- package/fesm2022/{sdcorejs-angular-modules-generic-generic-list.page-BIIxNR6k.mjs.map → sdcorejs-angular-modules-generic-generic-list.page-lF2trhfp.mjs.map} +1 -1
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DjDsau9C.mjs → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-BbmeOduc.mjs} +4 -4
- package/fesm2022/{sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-DjDsau9C.mjs.map → sdcorejs-angular-modules-generic-sdcorejs-angular-modules-generic-BbmeOduc.mjs.map} +1 -1
- package/fesm2022/sdcorejs-angular-modules-generic.mjs +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +347 -10
- 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-DK33LxHm.mjs +51 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-base-api.service-DK33LxHm.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-B1BUBiag.mjs +145 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-B1BUBiag.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-B27ZX8Co.mjs +144 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create-side-drawer.component-B27ZX8Co.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-Bi2tMFHf.mjs +460 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-Bi2tMFHf.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-CPwGkrNk.mjs +142 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-CPwGkrNk.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-VCbA_FkZ.mjs +113 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-create.component-VCbA_FkZ.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-CehsdBRP.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-customer.service-CehsdBRP.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-CPhLTiyx.mjs +148 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail-side-drawer.component-CPhLTiyx.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-5kI7wGdX.mjs +484 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-5kI7wGdX.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CjAy-B9K.mjs +172 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CjAy-B9K.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CnL2FzCx.mjs +90 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-detail.component-CnL2FzCx.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-DObN_wCR.mjs +514 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-flow.component-DObN_wCR.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-DpnYSG2j.mjs +61 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-form-api-errors-DpnYSG2j.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-C_ST-ld5.mjs +170 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-C_ST-ld5.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-D6eKR2cq.mjs +87 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-D6eKR2cq.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-FcJS3Nbd.mjs +232 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-form.component-FcJS3Nbd.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-BA-3FR1J.mjs +70 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-general-information-view.component-BA-3FR1J.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-TTrWCXIT.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-index.component-TTrWCXIT.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-table-form.component-B1qePLfk.mjs +812 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-lines-table-form.component-B1qePLfk.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-BY5gjtNS.mjs +71 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-BY5gjtNS.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CJ38CJXg.mjs +629 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CJ38CJXg.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CdgPtSjJ.mjs +164 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-CdgPtSjJ.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DKIwrluh.mjs +118 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-DKIwrluh.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-W9vY7HrT.mjs +115 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-list.component-W9vY7HrT.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-CI0H_5a4.mjs +1069 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-mock-backend.factory-CI0H_5a4.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BqHwKfoc.mjs +193 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source-viewer-BqHwKfoc.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-CIiLOizq.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-pattern-source.generated-CIiLOizq.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-D829aEk5.mjs +48 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-product.service-D829aEk5.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-BEFVmSSj.mjs +295 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-profile.component-BEFVmSSj.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-1kDb9T7_.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-1kDb9T7_.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-B-TJUSV_.mjs +66 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-B-TJUSV_.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-B6z7KO0P.mjs +45 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-B6z7KO0P.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DS39vgzU.mjs +50 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DS39vgzU.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DVlcUUzh.mjs +43 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DVlcUUzh.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DxWDWUdo.mjs +165 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-DxWDWUdo.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-r9CTj-8C.mjs +74 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-r9CTj-8C.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-xI1XYRo6.mjs +99 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-routes-xI1XYRo6.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-nV5dVFx2.mjs +406 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-sdcorejs-angular-modules-pattern-nV5dVFx2.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-0rRaWsuo.mjs +317 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-shell.component-0rRaWsuo.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-6uH7sDEg.mjs +143 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-6uH7sDEg.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-DglN2sS_.mjs +132 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update-side-drawer.component-DglN2sS_.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-BmsOgENL.mjs +359 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-BmsOgENL.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DPZ_ucNB.mjs +138 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DPZ_ucNB.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DkAcDmsZ.mjs +100 -0
- package/fesm2022/sdcorejs-angular-modules-pattern-update.component-DkAcDmsZ.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-api.mjs +11 -11
- package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-cache.mjs +7 -5
- package/fesm2022/sdcorejs-angular-services-cache.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-storage.mjs +6 -4
- package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs +104 -4
- package/fesm2022/sdcorejs-angular-services-unsaved-changes.mjs.map +1 -1
- package/forms/chip/src/chip.component.d.ts +135 -19
- package/forms/chip/src/index.d.ts +0 -1
- package/i18n/src/en.d.ts +70 -1
- package/modules/layout/components/index.d.ts +2 -0
- package/modules/layout/components/page/page-form-leave.guard.d.ts +9 -0
- package/modules/layout/components/page/page.component.d.ts +38 -2
- package/modules/layout/components/page-list/page-list.component.d.ts +42 -0
- package/modules/layout/components/shared/context-switcher/context-switcher.component.d.ts +1 -1
- package/modules/pattern/README.md +76 -0
- package/modules/pattern/configurations/pattern.configuration.d.ts +30 -0
- package/modules/pattern/configurations/provide-sd-patterns.d.ts +19 -0
- package/modules/pattern/core/mock-api/mock-api.interceptor.d.ts +8 -0
- package/modules/pattern/core/mock-api/mock-api.model.d.ts +62 -0
- package/modules/pattern/core/mock-api/mock-api.state.d.ts +36 -0
- package/modules/pattern/core/mock-api/mock-backend.d.ts +18 -0
- package/modules/pattern/core/mock-api/mock-backend.factory.d.ts +3 -0
- package/modules/pattern/core/mock-api/prng.d.ts +4 -0
- package/modules/pattern/core/mock-api/resources/approval.resource.d.ts +14 -0
- package/modules/pattern/core/mock-api/resources/category.resource.d.ts +9 -0
- package/modules/pattern/core/mock-api/resources/customer.resource.d.ts +22 -0
- package/modules/pattern/core/mock-api/resources/index.d.ts +3 -0
- package/modules/pattern/core/mock-api/resources/names.d.ts +5 -0
- package/modules/pattern/core/mock-api/resources/order.resource.d.ts +44 -0
- package/modules/pattern/core/mock-api/resources/partner.resource.d.ts +16 -0
- package/modules/pattern/core/mock-api/resources/product.resource.d.ts +13 -0
- package/modules/pattern/core/mock-api/resources/settings.resource.d.ts +18 -0
- package/modules/pattern/core/pattern-shell/catalog/pattern-catalog.d.ts +24 -0
- package/modules/pattern/core/pattern-shell/index/index.component.d.ts +9 -0
- package/modules/pattern/core/pattern-shell/settings/pattern-settings.store.d.ts +57 -0
- package/modules/pattern/core/pattern-shell/settings/settings-button.component.d.ts +44 -0
- package/modules/pattern/core/pattern-shell/shell/pattern-source-viewer.d.ts +8 -0
- package/modules/pattern/core/pattern-shell/shell/shell.component.d.ts +13 -0
- package/modules/pattern/core/pattern-shell/source/pattern-source.generated.d.ts +1 -0
- package/modules/pattern/core/pattern-shell/source/source-drawer.component.d.ts +27 -0
- package/modules/pattern/core/pattern-shell/toolbar/toolbar.component.d.ts +24 -0
- package/modules/pattern/core/permission/pattern-permission.d.ts +15 -0
- package/modules/pattern/core/permission/pattern-role.store.d.ts +13 -0
- package/modules/pattern/core/session-state.d.ts +4 -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 +815 -0
- package/modules/pattern/docs/header-actions.md +344 -0
- package/modules/pattern/docs/list.md +247 -0
- package/modules/pattern/docs/relation.md +180 -0
- package/modules/pattern/docs/select.md +214 -0
- package/modules/pattern/docs/split.md +350 -0
- package/modules/pattern/docs/states.md +168 -0
- package/modules/pattern/features/approval/entity.resolver.d.ts +4 -0
- package/modules/pattern/features/approval/entity.resolver.ts +21 -0
- package/modules/pattern/features/approval/pages/detail/detail.component.d.ts +13 -0
- package/modules/pattern/features/approval/pages/detail/detail.component.ts +139 -0
- package/modules/pattern/features/approval/pages/list/approval-inbox.d.ts +7 -0
- package/modules/pattern/features/approval/pages/list/approval-inbox.ts +7 -0
- package/modules/pattern/features/approval/pages/list/list.component.d.ts +26 -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.d.ts +3 -0
- package/modules/pattern/features/approval/routes.ts +30 -0
- package/modules/pattern/features/approval/services/approval.model.d.ts +37 -0
- package/modules/pattern/features/approval/services/approval.model.ts +38 -0
- package/modules/pattern/features/approval/services/approval.service.d.ts +12 -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.d.ts +23 -0
- package/modules/pattern/features/category/components/create-side-drawer/create-side-drawer.component.ts +130 -0
- package/modules/pattern/features/category/components/general-information-form/general-information-form.component.d.ts +20 -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.d.ts +23 -0
- package/modules/pattern/features/category/components/update-side-drawer/update-side-drawer.component.ts +134 -0
- package/modules/pattern/features/category/entity.resolver.d.ts +6 -0
- package/modules/pattern/features/category/entity.resolver.ts +27 -0
- package/modules/pattern/features/category/pages/list/list.component.d.ts +17 -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.d.ts +3 -0
- package/modules/pattern/features/category/routes.ts +42 -0
- package/modules/pattern/features/category/services/category.model.d.ts +34 -0
- package/modules/pattern/features/category/services/category.model.ts +39 -0
- package/modules/pattern/features/category/services/category.service.d.ts +17 -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.d.ts +24 -0
- package/modules/pattern/features/customer/components/create-side-drawer/create-side-drawer.component.ts +138 -0
- package/modules/pattern/features/customer/components/customer-select/customer-select.component.d.ts +20 -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.d.ts +20 -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.d.ts +11 -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.d.ts +20 -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.d.ts +14 -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.d.ts +33 -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.d.ts +9 -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.d.ts +11 -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.d.ts +22 -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.d.ts +24 -0
- package/modules/pattern/features/customer/components/update-side-drawer/update-side-drawer.component.ts +127 -0
- package/modules/pattern/features/customer/entity.resolver.d.ts +4 -0
- package/modules/pattern/features/customer/entity.resolver.ts +21 -0
- package/modules/pattern/features/customer/pages/list/list.component.d.ts +19 -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.d.ts +31 -0
- package/modules/pattern/features/customer/pages/profile/profile.component.ts +120 -0
- package/modules/pattern/features/customer/pipes/customer-detail.pipe.d.ts +14 -0
- package/modules/pattern/features/customer/pipes/customer-detail.pipe.ts +18 -0
- package/modules/pattern/features/customer/routes.d.ts +6 -0
- package/modules/pattern/features/customer/routes.ts +59 -0
- package/modules/pattern/features/customer/services/customer.model.d.ts +77 -0
- package/modules/pattern/features/customer/services/customer.model.ts +87 -0
- package/modules/pattern/features/customer/services/customer.service.d.ts +24 -0
- package/modules/pattern/features/customer/services/customer.service.ts +79 -0
- package/modules/pattern/features/import/components/mapping-form/mapping-form.component.d.ts +21 -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.d.ts +10 -0
- package/modules/pattern/features/import/components/preview-view/preview-view.component.ts +44 -0
- package/modules/pattern/features/import/pages/flow/flow.component.d.ts +43 -0
- package/modules/pattern/features/import/pages/flow/flow.component.ts +269 -0
- package/modules/pattern/features/import/routes.d.ts +2 -0
- package/modules/pattern/features/import/routes.ts +19 -0
- package/modules/pattern/features/import/services/import.model.d.ts +38 -0
- package/modules/pattern/features/import/services/import.model.ts +82 -0
- package/modules/pattern/features/import/services/import.service.d.ts +15 -0
- package/modules/pattern/features/import/services/import.service.ts +18 -0
- package/modules/pattern/features/order/components/approval-steps/approval-steps.component.d.ts +9 -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.d.ts +22 -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.d.ts +30 -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.d.ts +19 -0
- package/modules/pattern/features/order/components/lines-form/lines-form.component.ts +182 -0
- package/modules/pattern/features/order/components/lines-form/order-lines.d.ts +35 -0
- package/modules/pattern/features/order/components/lines-form/order-lines.ts +101 -0
- package/modules/pattern/features/order/components/lines-table-form/lines-table-form.component.d.ts +34 -0
- package/modules/pattern/features/order/components/lines-table-form/lines-table-form.component.ts +196 -0
- package/modules/pattern/features/order/components/lines-view/lines-view.component.d.ts +12 -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.d.ts +25 -0
- package/modules/pattern/features/order/components/summary-cards/summary-cards.component.ts +128 -0
- package/modules/pattern/features/order/entity.resolver.d.ts +9 -0
- package/modules/pattern/features/order/entity.resolver.ts +37 -0
- package/modules/pattern/features/order/pages/create/create.component.d.ts +18 -0
- package/modules/pattern/features/order/pages/create/create.component.ts +113 -0
- package/modules/pattern/features/order/pages/detail/detail.component.d.ts +27 -0
- package/modules/pattern/features/order/pages/detail/detail.component.ts +224 -0
- package/modules/pattern/features/order/pages/list/list.component.d.ts +29 -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.d.ts +22 -0
- package/modules/pattern/features/order/pages/update/update.component.ts +126 -0
- package/modules/pattern/features/order/routes.d.ts +7 -0
- package/modules/pattern/features/order/routes.ts +54 -0
- package/modules/pattern/features/order/services/order.model.d.ts +106 -0
- package/modules/pattern/features/order/services/order.model.ts +109 -0
- package/modules/pattern/features/order/services/order.service.d.ts +25 -0
- package/modules/pattern/features/order/services/order.service.ts +63 -0
- package/modules/pattern/features/partner/pages/create/create.component.d.ts +41 -0
- package/modules/pattern/features/partner/pages/create/create.component.ts +324 -0
- package/modules/pattern/features/partner/routes.d.ts +2 -0
- package/modules/pattern/features/partner/routes.ts +20 -0
- package/modules/pattern/features/partner/services/partner.model.d.ts +30 -0
- package/modules/pattern/features/partner/services/partner.model.ts +30 -0
- package/modules/pattern/features/partner/services/partner.service.d.ts +13 -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.d.ts +23 -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.d.ts +26 -0
- package/modules/pattern/features/product/components/product-select/product-select.component.ts +73 -0
- package/modules/pattern/features/product/components/product-status-select/product-status-select.component.d.ts +22 -0
- package/modules/pattern/features/product/components/product-status-select/product-status-select.component.ts +30 -0
- package/modules/pattern/features/product/entity.resolver.d.ts +4 -0
- package/modules/pattern/features/product/entity.resolver.ts +21 -0
- package/modules/pattern/features/product/pages/create/create.component.d.ts +15 -0
- package/modules/pattern/features/product/pages/create/create.component.ts +92 -0
- package/modules/pattern/features/product/pages/detail/detail.component.d.ts +10 -0
- package/modules/pattern/features/product/pages/detail/detail.component.ts +53 -0
- package/modules/pattern/features/product/pages/list/list.component.d.ts +15 -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.d.ts +16 -0
- package/modules/pattern/features/product/pages/update/update.component.ts +86 -0
- package/modules/pattern/features/product/pipes/product-detail.pipe.d.ts +14 -0
- package/modules/pattern/features/product/pipes/product-detail.pipe.ts +18 -0
- package/modules/pattern/features/product/routes.d.ts +3 -0
- package/modules/pattern/features/product/routes.ts +48 -0
- package/modules/pattern/features/product/services/product.model.d.ts +34 -0
- package/modules/pattern/features/product/services/product.model.ts +38 -0
- package/modules/pattern/features/product/services/product.service.d.ts +17 -0
- package/modules/pattern/features/product/services/product.service.ts +48 -0
- package/modules/pattern/features/settings/pages/update/update.component.d.ts +26 -0
- package/modules/pattern/features/settings/pages/update/update.component.ts +228 -0
- package/modules/pattern/features/settings/routes.d.ts +3 -0
- package/modules/pattern/features/settings/routes.ts +24 -0
- package/modules/pattern/features/settings/services/settings.model.d.ts +17 -0
- package/modules/pattern/features/settings/services/settings.model.ts +18 -0
- package/modules/pattern/features/settings/services/settings.service.d.ts +10 -0
- package/modules/pattern/features/settings/services/settings.service.ts +15 -0
- package/modules/pattern/features/settings/settings.resolver.d.ts +4 -0
- package/modules/pattern/features/settings/settings.resolver.ts +8 -0
- package/modules/pattern/index.d.ts +3 -0
- package/modules/pattern/routes.d.ts +6 -0
- package/modules/pattern/services/base-api.service.d.ts +16 -0
- package/modules/pattern/utils/api-error.d.ts +4 -0
- package/modules/pattern/utils/focus-first-invalid.d.ts +5 -0
- package/modules/pattern/utils/form-api-errors.d.ts +16 -0
- package/modules/pattern/utils/resource-url.d.ts +2 -0
- package/package.json +13 -9
- package/services/api/src/api-handler-registry.d.ts +3 -3
- package/services/api/src/api-route-configurations.d.ts +2 -2
- package/services/api/src/api.model.d.ts +2 -2
- package/services/cache/src/cache.model.d.ts +3 -1
- package/services/storage/src/storage.model.d.ts +2 -0
- package/services/unsaved-changes/src/unsaved-changes.adapters.d.ts +9 -0
- package/services/unsaved-changes/src/unsaved-changes.model.d.ts +2 -0
- package/forms/chip/src/pipes/index.d.ts +0 -1
- package/forms/chip/src/pipes/removable-chip.pipe.d.ts +0 -8
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
3
|
+
import { SdFormatDatetimePipe } from '@sdcorejs/angular/pipes';
|
|
4
|
+
import type { OrderApprovalStepDto } from '../../services/order.model';
|
|
5
|
+
|
|
6
|
+
const ACTION_NAME: Readonly<Record<OrderApprovalStepDto['action'], string>> = {
|
|
7
|
+
submit: 'Gửi duyệt',
|
|
8
|
+
approve: 'Duyệt',
|
|
9
|
+
reject: 'Từ chối',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** Quy trình duyệt của đơn, mới nhất ở cuối; dùng ở cột phụ của trang chi tiết. */
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'approval-steps',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [SdSection, SdFormatDatetimePipe],
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
|
+
template: `
|
|
19
|
+
<sd-section title="Quy trình duyệt">
|
|
20
|
+
<ol class="approval-steps">
|
|
21
|
+
<li class="approval-steps__item approval-steps__item--done">
|
|
22
|
+
<span class="T14M">Tạo đơn</span>
|
|
23
|
+
</li>
|
|
24
|
+
@for (step of steps(); track $index) {
|
|
25
|
+
<li class="approval-steps__item" [class.approval-steps__item--rejected]="step.action === 'reject'">
|
|
26
|
+
<span class="T14M">{{ actionName[step.action] }}</span>
|
|
27
|
+
<span class="T12R text-secondary">{{ step.by }} · {{ step.at | sdFormatDatetime }}</span>
|
|
28
|
+
@if (step.reason) {
|
|
29
|
+
<span class="T12R">Lý do: {{ step.reason }}</span>
|
|
30
|
+
}
|
|
31
|
+
</li>
|
|
32
|
+
} @empty {
|
|
33
|
+
<li class="approval-steps__item approval-steps__item--pending">
|
|
34
|
+
<span class="T12R text-secondary">Chưa gửi duyệt</span>
|
|
35
|
+
</li>
|
|
36
|
+
}
|
|
37
|
+
</ol>
|
|
38
|
+
</sd-section>
|
|
39
|
+
`,
|
|
40
|
+
styles: `
|
|
41
|
+
.approval-steps {
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 16px 16px 16px 32px;
|
|
44
|
+
list-style: none;
|
|
45
|
+
}
|
|
46
|
+
.approval-steps__item {
|
|
47
|
+
position: relative;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: 2px;
|
|
51
|
+
padding-bottom: 16px;
|
|
52
|
+
}
|
|
53
|
+
.approval-steps__item::before {
|
|
54
|
+
content: '';
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 4px;
|
|
57
|
+
left: -18px;
|
|
58
|
+
width: 10px;
|
|
59
|
+
height: 10px;
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
background: var(--sd-primary);
|
|
62
|
+
}
|
|
63
|
+
.approval-steps__item--rejected::before {
|
|
64
|
+
background: var(--sd-error, currentColor);
|
|
65
|
+
}
|
|
66
|
+
.approval-steps__item--pending::before {
|
|
67
|
+
background: var(--sd-border-strong);
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
})
|
|
71
|
+
export class ApprovalStepsComponent {
|
|
72
|
+
readonly steps = input.required<readonly OrderApprovalStepDto[]>();
|
|
73
|
+
protected readonly actionName = ACTION_NAME;
|
|
74
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/** Kết quả của một tác vụ hàng loạt: số thành công trên tổng và từng đơn lỗi. */
|
|
3
|
+
export interface OrderBulkSummary {
|
|
4
|
+
/** Động từ của tác vụ, ví dụ "Đã xác nhận". */
|
|
5
|
+
readonly done: string;
|
|
6
|
+
readonly total: number;
|
|
7
|
+
readonly failed: readonly {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/** Báo kết quả từng phần (E13): "Đã xác nhận 8/10. 2 đơn lỗi." kèm lỗi từng đơn và nút thử lại phần lỗi. */
|
|
14
|
+
export declare class BulkResultComponent {
|
|
15
|
+
readonly result: import("@angular/core").InputSignal<OrderBulkSummary>;
|
|
16
|
+
readonly retry: import("@angular/core").OutputEmitterRef<void>;
|
|
17
|
+
readonly dismiss: import("@angular/core").OutputEmitterRef<void>;
|
|
18
|
+
protected readonly title: import("@angular/core").Signal<string>;
|
|
19
|
+
protected readonly failures: import("@angular/core").Signal<string | undefined>;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BulkResultComponent, never>;
|
|
21
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<BulkResultComponent, "bulk-result", never, { "result": { "alias": "result"; "required": true; "isSignal": true; }; }, { "retry": "retry"; "dismiss": "dismiss"; }, never, never, true, never>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
|
2
|
+
import { SdInform } from '@sdcorejs/angular/components/inform';
|
|
3
|
+
|
|
4
|
+
/** Kết quả của một tác vụ hàng loạt: số thành công trên tổng và từng đơn lỗi. */
|
|
5
|
+
export interface OrderBulkSummary {
|
|
6
|
+
/** Động từ của tác vụ, ví dụ "Đã xác nhận". */
|
|
7
|
+
readonly done: string;
|
|
8
|
+
readonly total: number;
|
|
9
|
+
readonly failed: readonly { readonly id: string; readonly code: string; readonly message: string }[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Báo kết quả từng phần (E13): "Đã xác nhận 8/10. 2 đơn lỗi." kèm lỗi từng đơn và nút thử lại phần lỗi. */
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'bulk-result',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [SdInform],
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
|
+
template: `
|
|
19
|
+
@let _result = result();
|
|
20
|
+
<sd-inform
|
|
21
|
+
autoId="order-bulk-result"
|
|
22
|
+
[color]="_result.failed.length ? 'warning' : 'success'"
|
|
23
|
+
[title]="title()"
|
|
24
|
+
[description]="failures()"
|
|
25
|
+
[actionLabel]="_result.failed.length ? 'Thử lại phần lỗi' : undefined"
|
|
26
|
+
closable
|
|
27
|
+
(sdAction)="retry.emit()"
|
|
28
|
+
(sdClosed)="dismiss.emit()" />
|
|
29
|
+
`,
|
|
30
|
+
})
|
|
31
|
+
export class BulkResultComponent {
|
|
32
|
+
readonly result = input.required<OrderBulkSummary>();
|
|
33
|
+
readonly retry = output<void>();
|
|
34
|
+
readonly dismiss = output<void>();
|
|
35
|
+
protected readonly title = computed(() => {
|
|
36
|
+
const { done, total, failed } = this.result();
|
|
37
|
+
return `${done} ${total - failed.length}/${total}.` + (failed.length ? ` ${failed.length} đơn lỗi.` : '');
|
|
38
|
+
});
|
|
39
|
+
// why: nội dung chiếu vào sd-inform thay cả tiêu đề lẫn nút hành động; lỗi từng đơn đi qua `description`.
|
|
40
|
+
protected readonly failures = computed(
|
|
41
|
+
() =>
|
|
42
|
+
this.result()
|
|
43
|
+
.failed.map(item => `${item.code}: ${item.message}`)
|
|
44
|
+
.join(' ') || undefined
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FormArray, FormControl, FormGroup } from '@angular/forms';
|
|
2
|
+
import { type OrderSaveReq } from '../../services/order.model';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/** Form đơn hàng: field của đầu chứng từ do Core tự đăng ký; `lines` là FormArray do `lines-form` quản lý. */
|
|
5
|
+
export type OrderForm = FormGroup<{
|
|
6
|
+
customerId?: FormControl<string | null>;
|
|
7
|
+
channel?: FormControl<string>;
|
|
8
|
+
warehouse?: FormControl<string>;
|
|
9
|
+
payment?: FormControl<string>;
|
|
10
|
+
note?: FormControl<string | null>;
|
|
11
|
+
lines?: FormArray<FormGroup>;
|
|
12
|
+
}>;
|
|
13
|
+
/** Giá trị form → request lưu. */
|
|
14
|
+
export declare function orderSaveReq(form: OrderForm): OrderSaveReq;
|
|
15
|
+
/** Nhóm "Thông tin chung" của đơn hàng. */
|
|
16
|
+
export declare class GeneralInformationFormComponent {
|
|
17
|
+
readonly form: import("@angular/core").InputSignal<OrderForm>;
|
|
18
|
+
readonly seed: import("@angular/core").InputSignal<OrderSaveReq>;
|
|
19
|
+
protected readonly channels: {
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
protected readonly warehouses: {
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
protected readonly payments: {
|
|
26
|
+
value: string;
|
|
27
|
+
}[];
|
|
28
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GeneralInformationFormComponent, never>;
|
|
29
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GeneralInformationFormComponent, "general-information-form", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "seed": { "alias": "seed"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
import type { FormArray, FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
4
|
+
import { SdSelect } from '@sdcorejs/angular/forms/select';
|
|
5
|
+
import { CustomerSelectComponent } from '../../../customer/components/customer-select/customer-select.component';
|
|
6
|
+
import { ORDER_CHANNELS, ORDER_PAYMENTS, ORDER_WAREHOUSES, type OrderLineDto, type OrderSaveReq } from '../../services/order.model';
|
|
7
|
+
|
|
8
|
+
/** Form đơn hàng: field của đầu chứng từ do Core tự đăng ký; `lines` là FormArray do `lines-form` quản lý. */
|
|
9
|
+
export type OrderForm = FormGroup<{
|
|
10
|
+
customerId?: FormControl<string | null>;
|
|
11
|
+
channel?: FormControl<string>;
|
|
12
|
+
warehouse?: FormControl<string>;
|
|
13
|
+
payment?: FormControl<string>;
|
|
14
|
+
note?: FormControl<string | null>;
|
|
15
|
+
lines?: FormArray<FormGroup>;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
/** Giá trị form → request lưu. */
|
|
19
|
+
export function orderSaveReq(form: OrderForm): OrderSaveReq {
|
|
20
|
+
const value = form.getRawValue();
|
|
21
|
+
const lines = (value.lines ?? []) as Partial<OrderLineDto>[];
|
|
22
|
+
return {
|
|
23
|
+
customerId: value.customerId ?? '',
|
|
24
|
+
channel: value.channel ?? ORDER_CHANNELS[0],
|
|
25
|
+
warehouse: value.warehouse ?? ORDER_WAREHOUSES[0],
|
|
26
|
+
payment: value.payment ?? ORDER_PAYMENTS[0],
|
|
27
|
+
note: value.note || null,
|
|
28
|
+
lines: lines.map(line => ({
|
|
29
|
+
productId: line.productId ?? '',
|
|
30
|
+
quantity: Number(line.quantity ?? 0),
|
|
31
|
+
unitPrice: Number(line.unitPrice ?? 0),
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const options = (values: readonly string[]) => values.map(value => ({ value }));
|
|
37
|
+
|
|
38
|
+
/** Nhóm "Thông tin chung" của đơn hàng. */
|
|
39
|
+
@Component({
|
|
40
|
+
selector: 'general-information-form',
|
|
41
|
+
standalone: true,
|
|
42
|
+
imports: [SdSection, SdSelect, CustomerSelectComponent],
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
44
|
+
template: `
|
|
45
|
+
<sd-section title="Thông tin chung">
|
|
46
|
+
<div class="row px-16 pt-16 pb-8">
|
|
47
|
+
<div class="col-12 col-md-6">
|
|
48
|
+
<customer-select autoId="order-customer" [form]="form()" [model]="seed().customerId || null" required />
|
|
49
|
+
</div>
|
|
50
|
+
<div class="col-12 col-md-6">
|
|
51
|
+
<sd-select
|
|
52
|
+
label="Kênh bán"
|
|
53
|
+
name="channel"
|
|
54
|
+
[form]="form()"
|
|
55
|
+
[model]="seed().channel"
|
|
56
|
+
[items]="channels"
|
|
57
|
+
valueField="value"
|
|
58
|
+
displayField="value"
|
|
59
|
+
[clearable]="false"
|
|
60
|
+
required />
|
|
61
|
+
</div>
|
|
62
|
+
<div class="col-12 col-md-6">
|
|
63
|
+
<sd-select
|
|
64
|
+
label="Kho xuất"
|
|
65
|
+
name="warehouse"
|
|
66
|
+
[form]="form()"
|
|
67
|
+
[model]="seed().warehouse"
|
|
68
|
+
[items]="warehouses"
|
|
69
|
+
valueField="value"
|
|
70
|
+
displayField="value"
|
|
71
|
+
[clearable]="false"
|
|
72
|
+
required />
|
|
73
|
+
</div>
|
|
74
|
+
<div class="col-12 col-md-6">
|
|
75
|
+
<sd-select
|
|
76
|
+
label="Thanh toán"
|
|
77
|
+
name="payment"
|
|
78
|
+
[form]="form()"
|
|
79
|
+
[model]="seed().payment"
|
|
80
|
+
[items]="payments"
|
|
81
|
+
valueField="value"
|
|
82
|
+
displayField="value"
|
|
83
|
+
[clearable]="false"
|
|
84
|
+
required />
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</sd-section>
|
|
88
|
+
`,
|
|
89
|
+
})
|
|
90
|
+
export class GeneralInformationFormComponent {
|
|
91
|
+
readonly form = input.required<OrderForm>();
|
|
92
|
+
readonly seed = input.required<OrderSaveReq>();
|
|
93
|
+
protected readonly channels = options(ORDER_CHANNELS);
|
|
94
|
+
protected readonly warehouses = options(ORDER_WAREHOUSES);
|
|
95
|
+
protected readonly payments = options(ORDER_PAYMENTS);
|
|
96
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
2
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Bảng dòng hàng nhập trực tiếp, dựng bằng `<table>`: mỗi dòng là một FormGroup trong `form.lines` (FormArray, do
|
|
6
|
+
* `orderLines()` quản lý), các field Core tự đăng ký vào dòng. Chọn sản phẩm điền đơn giá; thành tiền và tổng tự
|
|
7
|
+
* tính. Field trong ô dùng `size="sm"` và `hideInlineError`: lỗi, kể cả lỗi API theo dòng (`lines.<i>.<field>`), là
|
|
8
|
+
* icon kèm tooltip ngay trên ô đó, dòng không cao thêm. Cùng bảng dựng bằng `sd-table`: `lines-table-form`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LinesFormComponent {
|
|
11
|
+
readonly form: import("@angular/core").InputSignal<OrderForm>;
|
|
12
|
+
/** Dòng ban đầu (cập nhật) hoặc một dòng trống (tạo mới). */
|
|
13
|
+
readonly seed: import("@angular/core").InputSignal<readonly OrderLineDto[]>;
|
|
14
|
+
/** Lỗi theo field do API trả về, khoá dạng `lines.<index>.<field>`. */
|
|
15
|
+
readonly errors: import("@angular/core").InputSignal<Readonly<Record<string, string>>>;
|
|
16
|
+
protected readonly lines: import("./order-lines").OrderLines;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LinesFormComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LinesFormComponent, "lines-form", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "seed": { "alias": "seed"; "required": true; "isSignal": true; }; "errors": { "alias": "errors"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
3
|
+
import { SdSection } from '@sdcorejs/angular/components/section';
|
|
4
|
+
import { SdInputNumber } from '@sdcorejs/angular/forms/input-number';
|
|
5
|
+
import { SdFormatNumberPipe } from '@sdcorejs/angular/pipes';
|
|
6
|
+
import { ProductSelectComponent } from '../../../product/components/product-select/product-select.component';
|
|
7
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
8
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
9
|
+
import { orderLines } from './order-lines';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Bảng dòng hàng nhập trực tiếp, dựng bằng `<table>`: mỗi dòng là một FormGroup trong `form.lines` (FormArray, do
|
|
13
|
+
* `orderLines()` quản lý), các field Core tự đăng ký vào dòng. Chọn sản phẩm điền đơn giá; thành tiền và tổng tự
|
|
14
|
+
* tính. Field trong ô dùng `size="sm"` và `hideInlineError`: lỗi, kể cả lỗi API theo dòng (`lines.<i>.<field>`), là
|
|
15
|
+
* icon kèm tooltip ngay trên ô đó, dòng không cao thêm. Cùng bảng dựng bằng `sd-table`: `lines-table-form`.
|
|
16
|
+
*/
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'lines-form',
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [SdSection, SdButton, SdInputNumber, SdFormatNumberPipe, ProductSelectComponent],
|
|
21
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
22
|
+
template: `
|
|
23
|
+
<sd-section title="Dòng hàng">
|
|
24
|
+
<div sdHeaderRight>
|
|
25
|
+
<sd-button title="Thêm dòng" prefixIcon="add" type="text" autoId="order-line-add" (click)="lines.add()" />
|
|
26
|
+
</div>
|
|
27
|
+
<div class="lines-scroll">
|
|
28
|
+
<table class="lines">
|
|
29
|
+
<colgroup>
|
|
30
|
+
<col />
|
|
31
|
+
<col class="lines__quantity" />
|
|
32
|
+
<col class="lines__money" />
|
|
33
|
+
<col class="lines__money" />
|
|
34
|
+
<col class="lines__action" />
|
|
35
|
+
</colgroup>
|
|
36
|
+
<thead>
|
|
37
|
+
<tr>
|
|
38
|
+
<th scope="col">Sản phẩm <span class="text-error" aria-hidden="true">*</span></th>
|
|
39
|
+
<th scope="col" class="lines__number">Số lượng <span class="text-error" aria-hidden="true">*</span></th>
|
|
40
|
+
<th scope="col" class="lines__number">Đơn giá (₫) <span class="text-error" aria-hidden="true">*</span></th>
|
|
41
|
+
<th scope="col" class="lines__number">Thành tiền (₫)</th>
|
|
42
|
+
<th scope="col" class="lines__action"><span class="sd-visually-hidden">Xoá dòng</span></th>
|
|
43
|
+
</tr>
|
|
44
|
+
</thead>
|
|
45
|
+
<tbody>
|
|
46
|
+
@for (row of lines.rows(); track row.key; let index = $index) {
|
|
47
|
+
<tr [attr.data-line]="index">
|
|
48
|
+
<td>
|
|
49
|
+
<product-select
|
|
50
|
+
size="sm"
|
|
51
|
+
hideInlineError
|
|
52
|
+
[label]="undefined"
|
|
53
|
+
[form]="row.group"
|
|
54
|
+
[model]="row.seed.productId || null"
|
|
55
|
+
[inlineError]="errors()['lines.' + index + '.productId']"
|
|
56
|
+
[autoId]="'order-line-' + index + '-product'"
|
|
57
|
+
(modelChange)="lines.pick(row, $event)"
|
|
58
|
+
required />
|
|
59
|
+
</td>
|
|
60
|
+
<td class="lines__number">
|
|
61
|
+
<sd-input-number
|
|
62
|
+
name="quantity"
|
|
63
|
+
size="sm"
|
|
64
|
+
hideInlineError
|
|
65
|
+
type="positive"
|
|
66
|
+
[precision]="0"
|
|
67
|
+
[form]="row.group"
|
|
68
|
+
[model]="row.seed.quantity"
|
|
69
|
+
[inlineError]="errors()['lines.' + index + '.quantity']"
|
|
70
|
+
[autoId]="'order-line-' + index + '-quantity'"
|
|
71
|
+
required />
|
|
72
|
+
</td>
|
|
73
|
+
<td class="lines__number">
|
|
74
|
+
<sd-input-number
|
|
75
|
+
name="unitPrice"
|
|
76
|
+
size="sm"
|
|
77
|
+
hideInlineError
|
|
78
|
+
type="positive"
|
|
79
|
+
[precision]="0"
|
|
80
|
+
[form]="row.group"
|
|
81
|
+
[model]="row.seed.unitPrice"
|
|
82
|
+
[inlineError]="errors()['lines.' + index + '.unitPrice']"
|
|
83
|
+
[autoId]="'order-line-' + index + '-unit-price'"
|
|
84
|
+
required />
|
|
85
|
+
</td>
|
|
86
|
+
<td class="lines__number" [attr.data-autoid]="'order-line-' + index + '-amount'">
|
|
87
|
+
{{ lines.amounts()[index] | sdFormatNumber: 0 }}
|
|
88
|
+
</td>
|
|
89
|
+
<td class="lines__action">
|
|
90
|
+
<sd-button
|
|
91
|
+
prefixIcon="delete"
|
|
92
|
+
type="text"
|
|
93
|
+
color="error"
|
|
94
|
+
tooltip="Xoá dòng"
|
|
95
|
+
[autoId]="'order-line-' + index + '-remove'"
|
|
96
|
+
[disabled]="lines.rows().length === 1"
|
|
97
|
+
(click)="lines.remove(row)" />
|
|
98
|
+
</td>
|
|
99
|
+
</tr>
|
|
100
|
+
}
|
|
101
|
+
</tbody>
|
|
102
|
+
<tfoot>
|
|
103
|
+
<tr>
|
|
104
|
+
<th scope="row" colspan="3" class="lines__number">Tổng tiền (₫)</th>
|
|
105
|
+
<td class="lines__number lines__total" data-autoid="order-total">{{ lines.total() | sdFormatNumber: 0 }}</td>
|
|
106
|
+
<td class="lines__action"></td>
|
|
107
|
+
</tr>
|
|
108
|
+
</tfoot>
|
|
109
|
+
</table>
|
|
110
|
+
</div>
|
|
111
|
+
</sd-section>
|
|
112
|
+
`,
|
|
113
|
+
styles: `
|
|
114
|
+
/* Màn hẹp thì cuộn ngang trong section thay vì bóp cột sản phẩm. */
|
|
115
|
+
.lines-scroll {
|
|
116
|
+
overflow-x: auto;
|
|
117
|
+
}
|
|
118
|
+
/* Cột cố định, sản phẩm lấy phần còn lại: vừa thân 576px của sd-page-form. */
|
|
119
|
+
.lines {
|
|
120
|
+
width: 100%;
|
|
121
|
+
min-width: 544px;
|
|
122
|
+
border-collapse: collapse;
|
|
123
|
+
table-layout: fixed;
|
|
124
|
+
}
|
|
125
|
+
.lines__quantity {
|
|
126
|
+
width: 88px;
|
|
127
|
+
}
|
|
128
|
+
.lines__money {
|
|
129
|
+
width: 120px;
|
|
130
|
+
}
|
|
131
|
+
.lines__action {
|
|
132
|
+
width: 48px;
|
|
133
|
+
}
|
|
134
|
+
.lines th,
|
|
135
|
+
.lines td {
|
|
136
|
+
padding: 8px;
|
|
137
|
+
text-align: left;
|
|
138
|
+
vertical-align: middle;
|
|
139
|
+
}
|
|
140
|
+
/* Cột đầu và cuối thẳng lề 16px với title và nút "Thêm dòng" của section. */
|
|
141
|
+
.lines th:first-child,
|
|
142
|
+
.lines td:first-child {
|
|
143
|
+
padding-left: 16px;
|
|
144
|
+
}
|
|
145
|
+
.lines th:last-child,
|
|
146
|
+
.lines td:last-child {
|
|
147
|
+
padding-right: 16px;
|
|
148
|
+
}
|
|
149
|
+
.lines thead th {
|
|
150
|
+
color: var(--sd-text-secondary);
|
|
151
|
+
font-size: 12px;
|
|
152
|
+
font-weight: 500;
|
|
153
|
+
border-bottom: 1px solid var(--sd-border);
|
|
154
|
+
}
|
|
155
|
+
.lines tbody tr:first-child td {
|
|
156
|
+
padding-top: 12px;
|
|
157
|
+
}
|
|
158
|
+
.lines tbody tr:last-child td {
|
|
159
|
+
padding-bottom: 12px;
|
|
160
|
+
}
|
|
161
|
+
.lines__number {
|
|
162
|
+
text-align: right !important;
|
|
163
|
+
}
|
|
164
|
+
.lines tfoot th,
|
|
165
|
+
.lines tfoot td {
|
|
166
|
+
padding-top: 12px;
|
|
167
|
+
padding-bottom: 12px;
|
|
168
|
+
border-top: 1px solid var(--sd-border);
|
|
169
|
+
}
|
|
170
|
+
.lines__total {
|
|
171
|
+
font-weight: 500;
|
|
172
|
+
}
|
|
173
|
+
`,
|
|
174
|
+
})
|
|
175
|
+
export class LinesFormComponent {
|
|
176
|
+
readonly form = input.required<OrderForm>();
|
|
177
|
+
/** Dòng ban đầu (cập nhật) hoặc một dòng trống (tạo mới). */
|
|
178
|
+
readonly seed = input.required<readonly OrderLineDto[]>();
|
|
179
|
+
/** Lỗi theo field do API trả về, khoá dạng `lines.<index>.<field>`. */
|
|
180
|
+
readonly errors = input<Readonly<Record<string, string>>>({});
|
|
181
|
+
protected readonly lines = orderLines(this.form, this.seed);
|
|
182
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { FormGroup } from '@angular/forms';
|
|
3
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
4
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
5
|
+
/** Một dòng đang nhập: field Core của dòng tự đăng ký vào `group`; `seed` là giá trị ban đầu của dòng. */
|
|
6
|
+
export interface OrderLineRow {
|
|
7
|
+
readonly key: number;
|
|
8
|
+
readonly group: FormGroup;
|
|
9
|
+
readonly seed: OrderLineDto;
|
|
10
|
+
}
|
|
11
|
+
export interface OrderLines {
|
|
12
|
+
readonly rows: Signal<readonly OrderLineRow[]>;
|
|
13
|
+
/** Thành tiền theo thứ tự của `rows`. */
|
|
14
|
+
readonly amounts: Signal<readonly number[]>;
|
|
15
|
+
readonly total: Signal<number>;
|
|
16
|
+
add(): void;
|
|
17
|
+
remove(row: OrderLineRow): void;
|
|
18
|
+
/** Chọn sản phẩm thì điền đơn giá hiện hành của sản phẩm. */
|
|
19
|
+
pick(row: OrderLineRow, productId: string | null | undefined): Promise<void>;
|
|
20
|
+
/** Gắn `form.lines` vào form khi field của các dòng vừa nạp đã đăng ký; gọi lại khi đã gắn thì không làm gì. */
|
|
21
|
+
attach(): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Dòng hàng của form đơn: mỗi dòng là một FormGroup trong `form.lines` (FormArray). Thành tiền và tổng tính lại khi
|
|
25
|
+
* giá trị đổi. `lines-form` (bảng HTML) và `lines-table-form` (`sd-table`) dùng chung, chỉ khác phần hiển thị.
|
|
26
|
+
* Gọi trong injection context của component.
|
|
27
|
+
*
|
|
28
|
+
* `registerSdUnsavedChangesForm(..., { dirty: 'value' })` lấy giá trị của một control lúc nó vào form làm giá trị đã
|
|
29
|
+
* lưu, nên `form.lines` chỉ vào form khi field của các dòng đã đăng ký; vào sớm hơn thì form vừa mở đã bị coi là có
|
|
30
|
+
* thay đổi. `<table>` vẽ dòng ngay trong lượt change detection đó (`attach: 'now'`); `sd-table` vẽ dòng sau lần đọc
|
|
31
|
+
* đầu, nên `lines-table-form` dùng `attach: 'manual'` rồi gọi `attach()` khi bảng đã vẽ.
|
|
32
|
+
*/
|
|
33
|
+
export declare function orderLines(form: Signal<OrderForm>, seed: Signal<readonly OrderLineDto[]>, options?: {
|
|
34
|
+
readonly attach: 'now' | 'manual';
|
|
35
|
+
}): OrderLines;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { computed, DestroyRef, effect, inject, signal, untracked, type Signal } from '@angular/core';
|
|
2
|
+
import { FormArray, FormGroup } from '@angular/forms';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
|
+
import { ProductService } from '../../../product/services/product.service';
|
|
5
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
6
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
7
|
+
|
|
8
|
+
/** Một dòng đang nhập: field Core của dòng tự đăng ký vào `group`; `seed` là giá trị ban đầu của dòng. */
|
|
9
|
+
export interface OrderLineRow {
|
|
10
|
+
readonly key: number;
|
|
11
|
+
readonly group: FormGroup;
|
|
12
|
+
readonly seed: OrderLineDto;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OrderLines {
|
|
16
|
+
readonly rows: Signal<readonly OrderLineRow[]>;
|
|
17
|
+
/** Thành tiền theo thứ tự của `rows`. */
|
|
18
|
+
readonly amounts: Signal<readonly number[]>;
|
|
19
|
+
readonly total: Signal<number>;
|
|
20
|
+
add(): void;
|
|
21
|
+
remove(row: OrderLineRow): void;
|
|
22
|
+
/** Chọn sản phẩm thì điền đơn giá hiện hành của sản phẩm. */
|
|
23
|
+
pick(row: OrderLineRow, productId: string | null | undefined): Promise<void>;
|
|
24
|
+
/** Gắn `form.lines` vào form khi field của các dòng vừa nạp đã đăng ký; gọi lại khi đã gắn thì không làm gì. */
|
|
25
|
+
attach(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Dòng hàng của form đơn: mỗi dòng là một FormGroup trong `form.lines` (FormArray). Thành tiền và tổng tính lại khi
|
|
30
|
+
* giá trị đổi. `lines-form` (bảng HTML) và `lines-table-form` (`sd-table`) dùng chung, chỉ khác phần hiển thị.
|
|
31
|
+
* Gọi trong injection context của component.
|
|
32
|
+
*
|
|
33
|
+
* `registerSdUnsavedChangesForm(..., { dirty: 'value' })` lấy giá trị của một control lúc nó vào form làm giá trị đã
|
|
34
|
+
* lưu, nên `form.lines` chỉ vào form khi field của các dòng đã đăng ký; vào sớm hơn thì form vừa mở đã bị coi là có
|
|
35
|
+
* thay đổi. `<table>` vẽ dòng ngay trong lượt change detection đó (`attach: 'now'`); `sd-table` vẽ dòng sau lần đọc
|
|
36
|
+
* đầu, nên `lines-table-form` dùng `attach: 'manual'` rồi gọi `attach()` khi bảng đã vẽ.
|
|
37
|
+
*/
|
|
38
|
+
export function orderLines(
|
|
39
|
+
form: Signal<OrderForm>,
|
|
40
|
+
seed: Signal<readonly OrderLineDto[]>,
|
|
41
|
+
options: { readonly attach: 'now' | 'manual' } = { attach: 'now' }
|
|
42
|
+
): OrderLines {
|
|
43
|
+
const productService = inject(ProductService);
|
|
44
|
+
const array = new FormArray<FormGroup>([]);
|
|
45
|
+
const version = signal(0);
|
|
46
|
+
const rows = signal<readonly OrderLineRow[]>([]);
|
|
47
|
+
let nextKey = 0;
|
|
48
|
+
|
|
49
|
+
const attach = (): void => {
|
|
50
|
+
if (form().get('lines') !== array) form().setControl('lines', array);
|
|
51
|
+
};
|
|
52
|
+
const push = (line: OrderLineDto): void => {
|
|
53
|
+
const group = new FormGroup({});
|
|
54
|
+
array.push(group);
|
|
55
|
+
rows.update(items => [...items, { key: nextKey++, group, seed: line }]);
|
|
56
|
+
};
|
|
57
|
+
const load = (lines: readonly OrderLineDto[]): void => {
|
|
58
|
+
// why: gỡ ra rồi gắn lại, để giá trị đã lưu của `lines` là các dòng mới chứ không phải dòng của đơn trước.
|
|
59
|
+
if (form().get('lines') === array) form().removeControl('lines');
|
|
60
|
+
array.clear();
|
|
61
|
+
rows.set([]);
|
|
62
|
+
(lines.length ? lines : [{ productId: '', quantity: 1, unitPrice: 0 }]).forEach(push);
|
|
63
|
+
if (options.attach === 'now') attach();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const subscription = array.valueChanges.subscribe(() => version.update(value => value + 1));
|
|
67
|
+
inject(DestroyRef).onDestroy(() => subscription.unsubscribe());
|
|
68
|
+
// 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.
|
|
69
|
+
effect(() => {
|
|
70
|
+
const lines = seed();
|
|
71
|
+
untracked(() => load(lines));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const amounts = computed(() => {
|
|
75
|
+
version();
|
|
76
|
+
return rows().map(
|
|
77
|
+
row => Number(row.group.get('quantity')?.value ?? row.seed.quantity) * Number(row.group.get('unitPrice')?.value ?? row.seed.unitPrice)
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
rows: rows.asReadonly(),
|
|
83
|
+
amounts,
|
|
84
|
+
total: computed(() => amounts().reduce((sum, amount) => sum + amount, 0)),
|
|
85
|
+
add: () => push({ productId: '', quantity: 1, unitPrice: 0 }),
|
|
86
|
+
remove: row => {
|
|
87
|
+
const index = rows().indexOf(row);
|
|
88
|
+
if (index < 0) return;
|
|
89
|
+
// 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.
|
|
90
|
+
array.markAsDirty();
|
|
91
|
+
array.removeAt(index);
|
|
92
|
+
rows.update(items => items.filter(item => item !== row));
|
|
93
|
+
},
|
|
94
|
+
pick: async (row, productId) => {
|
|
95
|
+
if (!productId) return;
|
|
96
|
+
const product = await firstValueFrom(productService.cachedDetail(productId));
|
|
97
|
+
row.group.get('unitPrice')?.setValue(product.price);
|
|
98
|
+
},
|
|
99
|
+
attach,
|
|
100
|
+
};
|
|
101
|
+
}
|
package/modules/pattern/features/order/components/lines-table-form/lines-table-form.component.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
2
|
+
import type { OrderLineDto } from '../../services/order.model';
|
|
3
|
+
import type { OrderForm } from '../general-information-form/general-information-form.component';
|
|
4
|
+
import { type OrderLineRow } from '../lines-form/order-lines';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/** Dòng của `sd-table`: dòng form cộng tên các cột. Ô của mọi cột vẽ bằng `sdTableCellDef` từ `group`/`seed`. */
|
|
7
|
+
interface LineItem extends OrderLineRow {
|
|
8
|
+
readonly productId?: string;
|
|
9
|
+
readonly quantity?: number;
|
|
10
|
+
readonly unitPrice?: number;
|
|
11
|
+
readonly amount?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Dòng hàng nhập trực tiếp, dựng bằng `sd-table` thay cho `<table>` của `lines-form`; trạng thái dòng vẫn là
|
|
15
|
+
* `orderLines()`. Bảng local, không phân trang, không lọc. Nút thêm dòng nằm ở header cột command
|
|
16
|
+
* (`sdTableCommandHeaderDef`), ngay trên nút xoá của từng dòng; field trong ô dùng `size="sm"` và `hideInlineError`,
|
|
17
|
+
* cột bắt buộc có `*` ở title; số dòng và tổng tiền ở dưới bảng. Dòng đổi thì `reload()` bảng; `rowKey` giữ view
|
|
18
|
+
* của các dòng còn lại nên giá trị đang nhập không mất. `form.lines` chỉ vào form khi bảng đã vẽ dòng (`attach`).
|
|
19
|
+
*/
|
|
20
|
+
export declare class LinesTableFormComponent {
|
|
21
|
+
#private;
|
|
22
|
+
readonly form: import("@angular/core").InputSignal<OrderForm>;
|
|
23
|
+
/** Dòng ban đầu (cập nhật) hoặc một dòng trống (tạo mới). */
|
|
24
|
+
readonly seed: import("@angular/core").InputSignal<readonly OrderLineDto[]>;
|
|
25
|
+
/** Lỗi theo field do API trả về, khoá dạng `lines.<index>.<field>`. */
|
|
26
|
+
readonly errors: import("@angular/core").InputSignal<Readonly<Record<string, string>>>;
|
|
27
|
+
private readonly table;
|
|
28
|
+
protected readonly lines: import("../lines-form/order-lines").OrderLines;
|
|
29
|
+
protected readonly option: SdTableOption<LineItem>;
|
|
30
|
+
constructor();
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LinesTableFormComponent, never>;
|
|
32
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LinesTableFormComponent, "lines-table-form", never, { "form": { "alias": "form"; "required": true; "isSignal": true; }; "seed": { "alias": "seed"; "required": true; "isSignal": true; }; "errors": { "alias": "errors"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|