@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,139 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, inject, linkedSignal, signal } from '@angular/core';
|
|
2
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
|
4
|
+
import { firstValueFrom, map } from 'rxjs';
|
|
5
|
+
import { SdBadge } from '@sdcorejs/angular/components/badge';
|
|
6
|
+
import { SdButton } from '@sdcorejs/angular/components/button';
|
|
7
|
+
import { SdSection, SdSectionItem } from '@sdcorejs/angular/components/section';
|
|
8
|
+
import { SdPermissionDirective } from '@sdcorejs/angular/modules/permission';
|
|
9
|
+
import { SdEmptyPipe, SdFormatDatetimePipe, SdFormatNumberPipe } from '@sdcorejs/angular/pipes';
|
|
10
|
+
import { SdConfirmService } from '@sdcorejs/angular/services/confirm';
|
|
11
|
+
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
|
|
12
|
+
import { apiErrorMessage } from '../../../../utils/api-error';
|
|
13
|
+
import { ApprovalService } from '../../services/approval.service';
|
|
14
|
+
import { approvalStatusBadge, type ApprovalDto } from '../../services/approval.model';
|
|
15
|
+
import { ApprovalInbox } from '../list/approval-inbox';
|
|
16
|
+
|
|
17
|
+
/** Chi tiết một đề nghị trong panel phải của hộp duyệt (route con `:id`). */
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'detail',
|
|
20
|
+
standalone: true,
|
|
21
|
+
imports: [
|
|
22
|
+
RouterLink,
|
|
23
|
+
SdBadge,
|
|
24
|
+
SdButton,
|
|
25
|
+
SdSection,
|
|
26
|
+
SdSectionItem,
|
|
27
|
+
SdPermissionDirective,
|
|
28
|
+
SdEmptyPipe,
|
|
29
|
+
SdFormatDatetimePipe,
|
|
30
|
+
SdFormatNumberPipe,
|
|
31
|
+
],
|
|
32
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
33
|
+
template: `
|
|
34
|
+
@let item = entity();
|
|
35
|
+
<article class="d-flex flex-column gap-16 p-16" [attr.aria-label]="'Đề nghị ' + item.code">
|
|
36
|
+
<header class="d-flex align-items-start justify-content-between gap-16 flex-wrap">
|
|
37
|
+
<div class="d-flex flex-column gap-4">
|
|
38
|
+
<!-- Màn hẹp: chi tiết thay danh sách, quay lại bằng liên kết này. -->
|
|
39
|
+
<a class="approval-back" [routerLink]="['..']">← Danh sách</a>
|
|
40
|
+
<div class="d-flex align-items-center gap-8">
|
|
41
|
+
<h2 class="T18M m-0">{{ item.code }} · {{ item.title }}</h2>
|
|
42
|
+
<sd-badge size="md" type="round" [title]="badge().title" [color]="badge().color" />
|
|
43
|
+
</div>
|
|
44
|
+
<span class="T14R text-secondary">{{ item.requester }} · {{ item.department }}</span>
|
|
45
|
+
</div>
|
|
46
|
+
@if (item.status === 'pending') {
|
|
47
|
+
<div class="d-flex align-items-center gap-8">
|
|
48
|
+
<sd-button
|
|
49
|
+
*sdPermission="'PATTERN_APPROVAL_U_REJECT'"
|
|
50
|
+
title="Từ chối"
|
|
51
|
+
prefixIcon="close"
|
|
52
|
+
type="light"
|
|
53
|
+
color="warning"
|
|
54
|
+
autoId="approval-reject"
|
|
55
|
+
[disabled]="pending()"
|
|
56
|
+
(click)="decide('reject')" />
|
|
57
|
+
<sd-button
|
|
58
|
+
*sdPermission="'PATTERN_APPROVAL_U_APPROVE'"
|
|
59
|
+
title="Duyệt"
|
|
60
|
+
prefixIcon="check"
|
|
61
|
+
type="fill"
|
|
62
|
+
color="success"
|
|
63
|
+
autoId="approval-approve"
|
|
64
|
+
[disabled]="pending()"
|
|
65
|
+
(click)="decide('approve')" />
|
|
66
|
+
</div>
|
|
67
|
+
}
|
|
68
|
+
</header>
|
|
69
|
+
<sd-section title="Thông tin đề nghị">
|
|
70
|
+
<sd-section-item label="Số tiền (₫)">{{ item.amount | sdFormatNumber: 0 }}</sd-section-item>
|
|
71
|
+
<sd-section-item label="Ngày gửi">{{ item.submittedAt | sdFormatDatetime }}</sd-section-item>
|
|
72
|
+
<sd-section-item label="Ghi chú">{{ item.note | sdEmpty }}</sd-section-item>
|
|
73
|
+
<sd-section-item label="Lý do từ chối">{{ item.reason | sdEmpty }}</sd-section-item>
|
|
74
|
+
</sd-section>
|
|
75
|
+
</article>
|
|
76
|
+
`,
|
|
77
|
+
styles: `
|
|
78
|
+
.approval-back {
|
|
79
|
+
display: none;
|
|
80
|
+
font-size: 13px;
|
|
81
|
+
}
|
|
82
|
+
@media (max-width: 767.98px) {
|
|
83
|
+
.approval-back {
|
|
84
|
+
display: inline;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`,
|
|
88
|
+
})
|
|
89
|
+
export class DetailComponent {
|
|
90
|
+
readonly #approvalService = inject(ApprovalService);
|
|
91
|
+
readonly #inbox = inject(ApprovalInbox);
|
|
92
|
+
readonly #confirm = inject(SdConfirmService);
|
|
93
|
+
readonly #notify = inject(SdNotifyService);
|
|
94
|
+
readonly #router = inject(Router);
|
|
95
|
+
readonly #route = inject(ActivatedRoute);
|
|
96
|
+
readonly #resolved = toSignal(this.#route.data.pipe(map(data => data['entity'] as ApprovalDto)), { requireSync: true });
|
|
97
|
+
protected readonly entity = linkedSignal(() => this.#resolved());
|
|
98
|
+
protected readonly badge = computed(() => approvalStatusBadge(this.entity().status));
|
|
99
|
+
protected readonly pending = signal(false);
|
|
100
|
+
|
|
101
|
+
/** Hỏi xác nhận (Từ chối kèm lý do), xử lý, rồi tự mở mục kế trong danh sách đang lọc. */
|
|
102
|
+
protected async decide(action: 'approve' | 'reject'): Promise<void> {
|
|
103
|
+
const item = this.entity();
|
|
104
|
+
let reason: string | undefined;
|
|
105
|
+
try {
|
|
106
|
+
if (action === 'reject') {
|
|
107
|
+
reason = await this.#confirm.withInput(`Từ chối ${item.code}. Lý do được gửi cho ${item.requester}.`, {
|
|
108
|
+
title: 'Từ chối đề nghị',
|
|
109
|
+
label: 'Lý do từ chối',
|
|
110
|
+
required: true,
|
|
111
|
+
maxlength: 200,
|
|
112
|
+
yesTitle: 'Từ chối',
|
|
113
|
+
noTitle: 'Không',
|
|
114
|
+
yesButtonColor: 'warning',
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
await this.#confirm.confirm(`Duyệt ${item.code}: ${item.title}?`, { title: 'Duyệt đề nghị', yesTitle: 'Duyệt', noTitle: 'Không' });
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.pending.set(true);
|
|
123
|
+
try {
|
|
124
|
+
const next = this.#inbox.nextOf(item.id);
|
|
125
|
+
this.entity.set(
|
|
126
|
+
await firstValueFrom(
|
|
127
|
+
action === 'approve' ? this.#approvalService.approve({ id: item.id }) : this.#approvalService.reject({ id: item.id, reason })
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
this.#notify.success(action === 'approve' ? `Đã duyệt ${item.code}.` : `Đã từ chối ${item.code}.`);
|
|
131
|
+
await this.#inbox.refresh();
|
|
132
|
+
await this.#router.navigate(next ? ['..', next] : ['..'], { relativeTo: this.#route });
|
|
133
|
+
} catch (error) {
|
|
134
|
+
this.#notify.error(apiErrorMessage(error));
|
|
135
|
+
} finally {
|
|
136
|
+
this.pending.set(false);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Hộp duyệt mà panel chi tiết dùng để tự chọn mục kế sau khi duyệt hoặc từ chối. */
|
|
2
|
+
export declare abstract class ApprovalInbox {
|
|
3
|
+
/** Mục sau `id` trong các dòng đang hiện (mục trước nếu `id` là dòng cuối); `null` khi không còn mục nào. */
|
|
4
|
+
abstract nextOf(id: string): string | null;
|
|
5
|
+
/** Đọc lại danh sách, giữ bộ lọc, trang và vị trí cuộn. */
|
|
6
|
+
abstract refresh(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Hộp duyệt mà panel chi tiết dùng để tự chọn mục kế sau khi duyệt hoặc từ chối. */
|
|
2
|
+
export abstract class ApprovalInbox {
|
|
3
|
+
/** Mục sau `id` trong các dòng đang hiện (mục trước nếu `id` là dòng cuối); `null` khi không còn mục nào. */
|
|
4
|
+
abstract nextOf(id: string): string | null;
|
|
5
|
+
/** Đọc lại danh sách, giữ bộ lọc, trang và vị trí cuộn. */
|
|
6
|
+
abstract refresh(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type SdSplitterOption } from '@sdcorejs/angular/components/splitter';
|
|
2
|
+
import { type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
3
|
+
import { type ApprovalDto } from '../../services/approval.model';
|
|
4
|
+
import { ApprovalInbox } from './approval-inbox';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Hộp duyệt (pattern split): danh sách bên trái, chi tiết là route con `:id` trong panel phải. ↑ ↓ chuyển mục;
|
|
8
|
+
* duyệt hoặc từ chối xong panel chi tiết tự chọn mục kế, bộ lọc và vị trí cuộn của danh sách giữ nguyên.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ListComponent extends ApprovalInbox {
|
|
11
|
+
#private;
|
|
12
|
+
private readonly table;
|
|
13
|
+
protected readonly active: import("@angular/core").WritableSignal<boolean>;
|
|
14
|
+
protected readonly narrow: import("@angular/core").WritableSignal<boolean>;
|
|
15
|
+
/** ID đang mở ở panel phải, đọc từ route con. */
|
|
16
|
+
protected readonly selectedId: import("@angular/core").Signal<string | null>;
|
|
17
|
+
protected readonly splitter: SdSplitterOption;
|
|
18
|
+
protected readonly option: SdTableOption<ApprovalDto>;
|
|
19
|
+
constructor();
|
|
20
|
+
nextOf(id: string): string | null;
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
/** ↑ ↓ chuyển sang dòng trước/sau; bỏ qua khi đang gõ trong ô nhập. */
|
|
23
|
+
protected move(event: KeyboardEvent): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ListComponent, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ListComponent, "list", never, {}, {}, never, never, true, never>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<sd-page-list title="Phê duyệt" description="Đề nghị thanh toán chờ xử lý. Dùng ↑ ↓ để chuyển mục." detail="none">
|
|
2
|
+
<div sdPageListMain class="approval" [class.approval--narrow]="narrow()" [class.approval--active]="active()">
|
|
3
|
+
<sd-splitter [option]="splitter">
|
|
4
|
+
<!-- Kéo trong khoảng 360–760px; panel chi tiết nhận phần còn lại (unit flex: minSize là trọng số, không phải px). -->
|
|
5
|
+
<sd-splitter-panel class="approval__list" panelId="list" [size]="520" unit="px" [minSize]="360" [maxSize]="760">
|
|
6
|
+
<sd-table autoId="approval-list" [option]="option">
|
|
7
|
+
<ng-template sdTableCellDef="code" let-item="item">
|
|
8
|
+
<a [routerLink]="[item.id]" [attr.aria-current]="item.id === selectedId() ? 'true' : null">{{ item.code }}</a>
|
|
9
|
+
</ng-template>
|
|
10
|
+
</sd-table>
|
|
11
|
+
</sd-splitter-panel>
|
|
12
|
+
<sd-splitter-panel class="approval__detail" panelId="detail" [size]="1">
|
|
13
|
+
<router-outlet (activate)="active.set(true)" (deactivate)="active.set(false)" />
|
|
14
|
+
@if (!active()) {
|
|
15
|
+
<sd-data-state state="empty" icon="inbox" title="Chọn một mục" message="Chọn một đề nghị bên trái để xem chi tiết và xử lý." />
|
|
16
|
+
}
|
|
17
|
+
</sd-splitter-panel>
|
|
18
|
+
</sd-splitter>
|
|
19
|
+
</div>
|
|
20
|
+
</sd-page-list>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, effect, forwardRef, inject, signal, untracked, viewChild } from '@angular/core';
|
|
2
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
3
|
+
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router';
|
|
4
|
+
import { filter, firstValueFrom, map, startWith } from 'rxjs';
|
|
5
|
+
import { SdDataState } from '@sdcorejs/angular/components/data-state';
|
|
6
|
+
import { SdSplitterComponent, SdSplitterPanelComponent, type SdSplitterOption } from '@sdcorejs/angular/components/splitter';
|
|
7
|
+
import { SdTable, SdTableCellDefDirective, type SdTableOption } from '@sdcorejs/angular/components/table';
|
|
8
|
+
import { SdPageList } from '@sdcorejs/angular/modules/layout';
|
|
9
|
+
import { ApprovalService } from '../../services/approval.service';
|
|
10
|
+
import { APPROVAL_STATUS_OPTIONS, approvalStatusBadge, type ApprovalDto } from '../../services/approval.model';
|
|
11
|
+
import { ApprovalInbox } from './approval-inbox';
|
|
12
|
+
|
|
13
|
+
/** Dưới bề rộng này chi tiết thay hẳn danh sách, có nút quay lại. */
|
|
14
|
+
const NARROW = '(max-width: 767.98px)';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hộp duyệt (pattern split): danh sách bên trái, chi tiết là route con `:id` trong panel phải. ↑ ↓ chuyển mục;
|
|
18
|
+
* duyệt hoặc từ chối xong panel chi tiết tự chọn mục kế, bộ lọc và vị trí cuộn của danh sách giữ nguyên.
|
|
19
|
+
*/
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'list',
|
|
22
|
+
standalone: true,
|
|
23
|
+
templateUrl: './list.component.html',
|
|
24
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
25
|
+
// Phím ↑ ↓ nổi lên từ dòng hay nút đang focus trong danh sách hoặc panel chi tiết.
|
|
26
|
+
host: { '(keydown)': 'move($event)' },
|
|
27
|
+
imports: [
|
|
28
|
+
RouterLink,
|
|
29
|
+
RouterOutlet,
|
|
30
|
+
SdPageList,
|
|
31
|
+
SdSplitterComponent,
|
|
32
|
+
SdSplitterPanelComponent,
|
|
33
|
+
SdTable,
|
|
34
|
+
SdTableCellDefDirective,
|
|
35
|
+
SdDataState,
|
|
36
|
+
],
|
|
37
|
+
providers: [{ provide: ApprovalInbox, useExisting: forwardRef(() => ListComponent) }],
|
|
38
|
+
styles: `
|
|
39
|
+
.approval > sd-splitter {
|
|
40
|
+
flex: 1 1 0;
|
|
41
|
+
min-height: 0;
|
|
42
|
+
}
|
|
43
|
+
.approval sd-splitter-panel {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
}
|
|
47
|
+
.approval__list {
|
|
48
|
+
background: var(--sd-surface, #ffffff);
|
|
49
|
+
border: 1px solid var(--sd-border, #e3e5ea);
|
|
50
|
+
border-radius: 8px;
|
|
51
|
+
}
|
|
52
|
+
.approval__list > sd-table {
|
|
53
|
+
flex: 1 1 0;
|
|
54
|
+
min-height: 0;
|
|
55
|
+
}
|
|
56
|
+
.approval__detail {
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
}
|
|
59
|
+
.approval--narrow.approval--active sd-splitter-panel:first-child,
|
|
60
|
+
.approval--narrow:not(.approval--active) sd-splitter-panel:last-of-type {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
})
|
|
65
|
+
export class ListComponent extends ApprovalInbox {
|
|
66
|
+
readonly #approvalService = inject(ApprovalService);
|
|
67
|
+
readonly #router = inject(Router);
|
|
68
|
+
readonly #route = inject(ActivatedRoute);
|
|
69
|
+
private readonly table = viewChild.required(SdTable);
|
|
70
|
+
protected readonly active = signal(false);
|
|
71
|
+
protected readonly narrow = signal(false);
|
|
72
|
+
/** ID đang mở ở panel phải, đọc từ route con. */
|
|
73
|
+
protected readonly selectedId = toSignal(
|
|
74
|
+
this.#router.events.pipe(
|
|
75
|
+
filter(event => event instanceof NavigationEnd),
|
|
76
|
+
startWith(null),
|
|
77
|
+
map(() => this.#route.firstChild?.snapshot.paramMap.get('id') ?? null)
|
|
78
|
+
),
|
|
79
|
+
{ requireSync: true }
|
|
80
|
+
);
|
|
81
|
+
protected readonly splitter: SdSplitterOption = { storageKey: 'sd-pattern.approval.splitter' };
|
|
82
|
+
protected readonly option: SdTableOption<ApprovalDto> = {
|
|
83
|
+
type: 'server',
|
|
84
|
+
rowKey: 'id',
|
|
85
|
+
items: (_, req) => firstValueFrom(this.#approvalService.list(req)),
|
|
86
|
+
filter: {
|
|
87
|
+
quickSearch: { containFields: ['code', 'title', 'requester'], placeholder: 'Tìm theo mã, nội dung, người đề nghị' },
|
|
88
|
+
},
|
|
89
|
+
paginate: { pageSize: 20, pages: [20, 50] },
|
|
90
|
+
columns: [
|
|
91
|
+
{ field: 'code', title: 'Mã', type: 'string', width: '96px' },
|
|
92
|
+
{ field: 'title', title: 'Nội dung', type: 'string', minWidth: '140px' },
|
|
93
|
+
{ field: 'amount', title: 'Số tiền (₫)', type: 'number', width: '120px', align: 'right' },
|
|
94
|
+
{
|
|
95
|
+
field: 'status',
|
|
96
|
+
title: 'Trạng thái',
|
|
97
|
+
type: 'values',
|
|
98
|
+
width: '128px',
|
|
99
|
+
option: { items: APPROVAL_STATUS_OPTIONS, valueField: 'id', displayField: 'name' },
|
|
100
|
+
useBadge: status => approvalStatusBadge(status),
|
|
101
|
+
// Hộp duyệt mở sẵn các đề nghị đang chờ; đổi bộ lọc để xem đề nghị đã xử lý.
|
|
102
|
+
filter: { default: 'pending' },
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
style: {
|
|
106
|
+
rowCss: (row): Record<string, string> => (row.id === this.selectedId() ? { background: 'var(--sd-primary-light)' } : {}),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
constructor() {
|
|
111
|
+
super();
|
|
112
|
+
// Dòng đang mở được tô nền: vẽ lại bảng khi chọn mục khác.
|
|
113
|
+
effect(() => {
|
|
114
|
+
this.selectedId();
|
|
115
|
+
untracked(() => this.table().detectChanges());
|
|
116
|
+
});
|
|
117
|
+
const media = typeof matchMedia === 'function' ? matchMedia(NARROW) : null;
|
|
118
|
+
if (media) {
|
|
119
|
+
this.narrow.set(media.matches);
|
|
120
|
+
const onChange = (event: MediaQueryListEvent): void => this.narrow.set(event.matches);
|
|
121
|
+
media.addEventListener('change', onChange);
|
|
122
|
+
inject(DestroyRef).onDestroy(() => media.removeEventListener('change', onChange));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
nextOf(id: string): string | null {
|
|
127
|
+
const rows = this.table().dataItems;
|
|
128
|
+
const index = rows.findIndex(row => row.id === id);
|
|
129
|
+
if (index < 0) return rows[0]?.id ?? null;
|
|
130
|
+
return rows[index + 1]?.id ?? rows[index - 1]?.id ?? null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async refresh(): Promise<void> {
|
|
134
|
+
await this.table().reload(true, false);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** ↑ ↓ chuyển sang dòng trước/sau; bỏ qua khi đang gõ trong ô nhập. */
|
|
138
|
+
protected move(event: KeyboardEvent): void {
|
|
139
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;
|
|
140
|
+
const target = event.target as HTMLElement | null;
|
|
141
|
+
if (target?.closest('input, textarea, select, [contenteditable="true"], mat-select, [role="separator"]')) return;
|
|
142
|
+
const rows = this.table().dataItems;
|
|
143
|
+
if (!rows.length) return;
|
|
144
|
+
const index = rows.findIndex(row => row.id === this.selectedId());
|
|
145
|
+
const next = rows[Math.min(rows.length - 1, Math.max(0, index < 0 ? 0 : index + (event.key === 'ArrowDown' ? 1 : -1)))];
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
if (next.id !== this.selectedId()) void this.#router.navigate([next.id], { relativeTo: this.#route });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Routes } from '@angular/router';
|
|
2
|
+
import { SdPermissionGuard } from '@sdcorejs/angular/modules/permission';
|
|
3
|
+
import { entityResolver } from './entity.resolver';
|
|
4
|
+
import { ApprovalService } from './services/approval.service';
|
|
5
|
+
|
|
6
|
+
/** Chi tiết là route con `:id`, hiện trong panel phải của danh sách (pattern split). */
|
|
7
|
+
export const routes: Routes = [
|
|
8
|
+
{
|
|
9
|
+
path: '',
|
|
10
|
+
providers: [ApprovalService],
|
|
11
|
+
canActivateChild: [SdPermissionGuard],
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
path: '',
|
|
15
|
+
title: 'Phê duyệt',
|
|
16
|
+
data: { permission: 'PATTERN_APPROVAL_R_LIST' },
|
|
17
|
+
loadComponent: () => import('./pages/list/list.component').then(module => module.ListComponent),
|
|
18
|
+
children: [
|
|
19
|
+
{
|
|
20
|
+
path: ':id',
|
|
21
|
+
data: { permission: 'PATTERN_APPROVAL_R_DETAIL' },
|
|
22
|
+
resolve: { entity: entityResolver },
|
|
23
|
+
runGuardsAndResolvers: 'paramsChange',
|
|
24
|
+
loadComponent: () => import('./pages/detail/detail.component').then(module => module.DetailComponent),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SdBadgeData } from '@sdcorejs/angular/components/badge';
|
|
2
|
+
import type { PagingReq, PagingRes } from '@sdcorejs/utils/models';
|
|
3
|
+
export type ApprovalStatus = 'pending' | 'approved' | 'rejected';
|
|
4
|
+
export declare const APPROVAL_STATUS_OPTIONS: ({
|
|
5
|
+
id: "pending";
|
|
6
|
+
name: string;
|
|
7
|
+
color: "warning";
|
|
8
|
+
} | {
|
|
9
|
+
id: "approved";
|
|
10
|
+
name: string;
|
|
11
|
+
color: "success";
|
|
12
|
+
} | {
|
|
13
|
+
id: "rejected";
|
|
14
|
+
name: string;
|
|
15
|
+
color: "error";
|
|
16
|
+
})[];
|
|
17
|
+
/** Đề nghị thanh toán chờ người duyệt xử lý. */
|
|
18
|
+
export interface ApprovalDto {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly code: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly requester: string;
|
|
23
|
+
readonly department: string;
|
|
24
|
+
/** Số tiền đề nghị (₫). */
|
|
25
|
+
readonly amount: number;
|
|
26
|
+
readonly submittedAt: string;
|
|
27
|
+
readonly status: ApprovalStatus;
|
|
28
|
+
readonly reason: string | null;
|
|
29
|
+
readonly note: string | null;
|
|
30
|
+
}
|
|
31
|
+
export type ApprovalListReq = PagingReq<ApprovalDto>;
|
|
32
|
+
export type ApprovalListRes = PagingRes<ApprovalDto>;
|
|
33
|
+
export interface ApprovalDecisionReq {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly reason?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function approvalStatusBadge(status: ApprovalStatus): SdBadgeData;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SdBadgeData } from '@sdcorejs/angular/components/badge';
|
|
2
|
+
import type { PagingReq, PagingRes } from '@sdcorejs/utils/models';
|
|
3
|
+
|
|
4
|
+
export type ApprovalStatus = 'pending' | 'approved' | 'rejected';
|
|
5
|
+
|
|
6
|
+
export const APPROVAL_STATUS_OPTIONS = [
|
|
7
|
+
{ id: 'pending', name: 'Chờ duyệt', color: 'warning' },
|
|
8
|
+
{ id: 'approved', name: 'Đã duyệt', color: 'success' },
|
|
9
|
+
{ id: 'rejected', name: 'Bị từ chối', color: 'error' },
|
|
10
|
+
] satisfies { id: ApprovalStatus; name: string; color: SdBadgeData['color'] }[];
|
|
11
|
+
|
|
12
|
+
/** Đề nghị thanh toán chờ người duyệt xử lý. */
|
|
13
|
+
export interface ApprovalDto {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly code: string;
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly requester: string;
|
|
18
|
+
readonly department: string;
|
|
19
|
+
/** Số tiền đề nghị (₫). */
|
|
20
|
+
readonly amount: number;
|
|
21
|
+
readonly submittedAt: string;
|
|
22
|
+
readonly status: ApprovalStatus;
|
|
23
|
+
readonly reason: string | null;
|
|
24
|
+
readonly note: string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ApprovalListReq = PagingReq<ApprovalDto>;
|
|
28
|
+
export type ApprovalListRes = PagingRes<ApprovalDto>;
|
|
29
|
+
|
|
30
|
+
export interface ApprovalDecisionReq {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly reason?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function approvalStatusBadge(status: ApprovalStatus): SdBadgeData {
|
|
36
|
+
const option = APPROVAL_STATUS_OPTIONS.find(item => item.id === status);
|
|
37
|
+
return { type: 'round', title: option?.name ?? status, color: option?.color };
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import { BaseApiService } from '../../../services/base-api.service';
|
|
3
|
+
import type { ApprovalDecisionReq, ApprovalDto, ApprovalListReq, ApprovalListRes } from './approval.model';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class ApprovalService extends BaseApiService {
|
|
6
|
+
list(req: ApprovalListReq): Observable<ApprovalListRes>;
|
|
7
|
+
detail(id: string): Observable<ApprovalDto>;
|
|
8
|
+
approve(req: ApprovalDecisionReq): Observable<ApprovalDto>;
|
|
9
|
+
reject(req: ApprovalDecisionReq): Observable<ApprovalDto>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ApprovalService, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ApprovalService>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import { BaseApiService } from '../../../services/base-api.service';
|
|
4
|
+
import type { ApprovalDecisionReq, ApprovalDto, ApprovalListReq, ApprovalListRes } from './approval.model';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class ApprovalService extends BaseApiService {
|
|
8
|
+
list(req: ApprovalListReq): Observable<ApprovalListRes> {
|
|
9
|
+
return this.http.get<ApprovalListRes>(this.apiUrl('approvals'), { params: this.buildPagingReq(req) });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
detail(id: string): Observable<ApprovalDto> {
|
|
13
|
+
return this.http.get<ApprovalDto>(this.apiUrl('approvals', id));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
approve(req: ApprovalDecisionReq): Observable<ApprovalDto> {
|
|
17
|
+
return this.http.post<ApprovalDto>(this.apiUrl('approvals', req.id, 'approve'), {});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
reject(req: ApprovalDecisionReq): Observable<ApprovalDto> {
|
|
21
|
+
return this.http.post<ApprovalDto>(this.apiUrl('approvals', req.id, 'reject'), { reason: req.reason });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CategoryDto, CategorySaveReq } from '../../services/category.model';
|
|
2
|
+
import { type CategoryForm } from '../general-information-form/general-information-form.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Tạo danh mục trong drawer (route con `create`, `?parent=<id>` cho danh mục con). Danh mục cha do resolver tải.
|
|
6
|
+
* X, Esc và backdrop hỏi trước khi bỏ thay đổi; lưu xong đóng drawer và danh sách tải lại.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CreateSideDrawerComponent {
|
|
9
|
+
#private;
|
|
10
|
+
private readonly drawer;
|
|
11
|
+
private readonly formElement;
|
|
12
|
+
protected readonly parent: import("@angular/core").Signal<CategoryDto | null>;
|
|
13
|
+
protected readonly seed: CategorySaveReq;
|
|
14
|
+
protected readonly form: CategoryForm;
|
|
15
|
+
protected readonly saving: import("@angular/core").WritableSignal<boolean>;
|
|
16
|
+
protected readonly apiErrors: import("../../../../utils/form-api-errors").FormApiErrors;
|
|
17
|
+
protected readonly beforeClose: () => Promise<boolean>;
|
|
18
|
+
constructor();
|
|
19
|
+
protected closed(): void;
|
|
20
|
+
protected save(): Promise<void>;
|
|
21
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CreateSideDrawerComponent, never>;
|
|
22
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CreateSideDrawerComponent, "create-side-drawer", never, {}, {}, never, never, true, never>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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 { CategoryService } from '../../services/category.service';
|
|
25
|
+
import type { CategoryDto, CategorySaveReq } from '../../services/category.model';
|
|
26
|
+
import {
|
|
27
|
+
categorySaveReq,
|
|
28
|
+
GeneralInformationFormComponent,
|
|
29
|
+
type CategoryForm,
|
|
30
|
+
} from '../general-information-form/general-information-form.component';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Tạo danh mục trong drawer (route con `create`, `?parent=<id>` cho danh mục con). Danh mục cha do resolver tải.
|
|
34
|
+
* X, Esc và backdrop hỏi trước khi bỏ thay đổi; lưu xong đóng drawer và danh sách tải lại.
|
|
35
|
+
*/
|
|
36
|
+
@Component({
|
|
37
|
+
selector: 'create-side-drawer',
|
|
38
|
+
standalone: true,
|
|
39
|
+
imports: [SdSideDrawer, SdButton, GeneralInformationFormComponent],
|
|
40
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
41
|
+
template: `
|
|
42
|
+
<sd-side-drawer
|
|
43
|
+
[title]="parent() ? 'Thêm danh mục con của ' + parent()!.name : 'Tạo danh mục'"
|
|
44
|
+
autoId="category-create"
|
|
45
|
+
[beforeClose]="beforeClose"
|
|
46
|
+
(sdClosed)="closed()">
|
|
47
|
+
<general-information-form [form]="form" [seed]="seed" [parentName]="parent()?.name ?? null" [errors]="apiErrors.errors()" />
|
|
48
|
+
<div sdFooterRight class="d-flex align-items-center gap-8">
|
|
49
|
+
<sd-button
|
|
50
|
+
title="Tạo danh mục"
|
|
51
|
+
prefixIcon="save"
|
|
52
|
+
type="fill"
|
|
53
|
+
color="primary"
|
|
54
|
+
autoId="category-save"
|
|
55
|
+
[loading]="saving()"
|
|
56
|
+
(click)="save()" />
|
|
57
|
+
</div>
|
|
58
|
+
</sd-side-drawer>
|
|
59
|
+
`,
|
|
60
|
+
})
|
|
61
|
+
export class CreateSideDrawerComponent {
|
|
62
|
+
readonly #categoryService = inject(CategoryService);
|
|
63
|
+
readonly #confirm = inject(SdConfirmService);
|
|
64
|
+
readonly #notify = inject(SdNotifyService);
|
|
65
|
+
readonly #router = inject(Router);
|
|
66
|
+
readonly #route = inject(ActivatedRoute);
|
|
67
|
+
readonly #injector = inject(Injector);
|
|
68
|
+
private readonly drawer = viewChild.required(SdSideDrawer);
|
|
69
|
+
private readonly formElement = viewChild.required(GeneralInformationFormComponent, { read: ElementRef });
|
|
70
|
+
protected readonly parent = toSignal(this.#route.data.pipe(map(data => (data['parent'] as CategoryDto | null) ?? null)), {
|
|
71
|
+
requireSync: true,
|
|
72
|
+
});
|
|
73
|
+
protected readonly seed: CategorySaveReq = { code: '', name: '', parentId: null, status: 'active' };
|
|
74
|
+
protected readonly form: CategoryForm = new FormGroup({});
|
|
75
|
+
protected readonly saving = signal(false);
|
|
76
|
+
protected readonly apiErrors = formApiErrors(this.form);
|
|
77
|
+
readonly #unsaved = registerSdUnsavedChangesForm(inject(SdUnsavedChangesService), this.form, { id: 'category-create', dirty: 'value' });
|
|
78
|
+
|
|
79
|
+
protected readonly beforeClose = async (): Promise<boolean> => {
|
|
80
|
+
if (this.saving()) return false;
|
|
81
|
+
if (!this.#unsaved.dirty()) return true;
|
|
82
|
+
try {
|
|
83
|
+
await this.#confirm.confirm('Thay đổi chưa lưu sẽ bị mất.', {
|
|
84
|
+
title: 'Đóng khi chưa lưu?',
|
|
85
|
+
yesTitle: 'Bỏ thay đổi',
|
|
86
|
+
noTitle: 'Tiếp tục sửa',
|
|
87
|
+
yesButtonColor: 'warning',
|
|
88
|
+
});
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
this.#unsaved.markPristine();
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
constructor() {
|
|
97
|
+
afterNextRender(() => this.drawer().open());
|
|
98
|
+
inject(DestroyRef).onDestroy(() => this.#unsaved.destroy());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected closed(): void {
|
|
102
|
+
void this.#router.navigate(['..'], { relativeTo: this.#route });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected async save(): Promise<void> {
|
|
106
|
+
if (this.saving()) return;
|
|
107
|
+
this.form.markAllAsTouched();
|
|
108
|
+
if (this.form.invalid) {
|
|
109
|
+
this.#focusFirstInvalid();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.saving.set(true);
|
|
113
|
+
try {
|
|
114
|
+
const category = await firstValueFrom(this.#categoryService.create(categorySaveReq(this.form, this.parent()?.id ?? null)));
|
|
115
|
+
this.#unsaved.markPristine();
|
|
116
|
+
this.#notify.success(`Đã tạo danh mục ${category.name}.`);
|
|
117
|
+
this.saving.set(false);
|
|
118
|
+
this.drawer().close();
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (this.apiErrors.set(error)) this.#focusFirstInvalid();
|
|
121
|
+
else this.#notify.error(apiErrorMessage(error, 'Không thể lưu. Dữ liệu đã nhập vẫn được giữ.'));
|
|
122
|
+
} finally {
|
|
123
|
+
this.saving.set(false);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#focusFirstInvalid(): void {
|
|
128
|
+
afterNextRender(() => focusFirstInvalid(this.formElement().nativeElement), { injector: this.#injector });
|
|
129
|
+
}
|
|
130
|
+
}
|