@mediusinc/mng-commons 0.2.0 → 0.2.1-rc
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/.browserslistrc +16 -0
- package/karma.conf.js +51 -0
- package/ng-package.json +14 -0
- package/package.json +3 -24
- package/src/lib/api/models/builders/query-param.builder.ts +54 -0
- package/src/lib/api/models/filter-match-type.model.ts +25 -0
- package/src/lib/api/models/filter-param.model.ts +59 -0
- package/{lib/api/models/index.d.ts → src/lib/api/models/index.ts} +10 -8
- package/src/lib/api/models/mappers.ts +18 -0
- package/{lib/api/models/filter-match-type.model.d.ts → src/lib/api/models/query-mode.model.ts} +18 -23
- package/src/lib/api/models/query-param.model.ts +99 -0
- package/src/lib/api/models/query-result.model.ts +77 -0
- package/{lib/api/models/serialization.model.d.ts → src/lib/api/models/serialization.model.ts} +9 -8
- package/src/lib/api/services/crud-api.abstract.service.ts +113 -0
- package/{lib/api/services/index.d.ts → src/lib/api/services/index.ts} +1 -1
- package/{lib/api/utils/index.d.ts → src/lib/api/utils/index.ts} +2 -2
- package/src/lib/api/utils/medius-rest.util.ts +146 -0
- package/src/lib/api/utils/object-serializer.util.ts +227 -0
- package/src/lib/components/action/action.component.html +30 -0
- package/src/lib/components/action/action.component.ts +77 -0
- package/src/lib/components/action/dialog/action-dialog.component.html +26 -0
- package/src/lib/components/action/dialog/action-dialog.component.ts +171 -0
- package/{lib/components/action/index.d.ts → src/lib/components/action/index.ts} +3 -3
- package/{lib/components/action/models/action-confirmation-service.model.d.ts → src/lib/components/action/models/action-confirmation-service.model.ts} +7 -6
- package/src/lib/components/action/models/action-execution.model.ts +81 -0
- package/{lib/components/action/models/index.d.ts → src/lib/components/action/models/index.ts} +2 -2
- package/src/lib/components/action/route/action-route.component.html +1 -0
- package/src/lib/components/action/route/action-route.component.ts +159 -0
- package/src/lib/components/form/autocomplete/autocomplete.component.html +16 -0
- package/src/lib/components/form/autocomplete/autocomplete.component.ts +113 -0
- package/src/lib/components/form/dropdown/dropdown.component.html +29 -0
- package/src/lib/components/form/dropdown/dropdown.component.ts +109 -0
- package/src/lib/components/form/editor/form-editor.component.html +5 -0
- package/src/lib/components/form/editor/form-editor.component.ts +149 -0
- package/src/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.html +7 -0
- package/src/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.ts +21 -0
- package/src/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.html +9 -0
- package/src/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.ts +22 -0
- package/src/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.html +8 -0
- package/src/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.ts +10 -0
- package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.html +56 -0
- package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.ts +22 -0
- package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.html +13 -0
- package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.scss +4 -0
- package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.ts +114 -0
- package/src/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.html +37 -0
- package/src/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.ts +133 -0
- package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.html +10 -0
- package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.ts +10 -0
- package/{lib/components/form/formly/fields/index.d.ts → src/lib/components/form/formly/fields/index.ts} +7 -7
- package/src/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.html +7 -0
- package/src/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.ts +13 -0
- package/src/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.html +6 -0
- package/src/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.ts +13 -0
- package/{lib/components/form/formly/wrappers/index.d.ts → src/lib/components/form/formly/wrappers/index.ts} +2 -2
- package/{lib/components/form/index.d.ts → src/lib/components/form/index.ts} +3 -3
- package/src/lib/components/form/models/form-editor.event.ts +7 -0
- package/{lib/components/form/models/index.d.ts → src/lib/components/form/models/index.ts} +1 -1
- package/src/lib/components/layout/breadcrumb.component.html +5 -0
- package/src/lib/components/layout/breadcrumb.component.ts +12 -0
- package/src/lib/components/layout/footer.component.html +7 -0
- package/src/lib/components/layout/footer.component.ts +15 -0
- package/{lib/components/layout/index.d.ts → src/lib/components/layout/index.ts} +6 -6
- package/src/lib/components/layout/main-layout.component.html +26 -0
- package/src/lib/components/layout/main-layout.component.ts +54 -0
- package/src/lib/components/layout/menu-item.component.html +41 -0
- package/src/lib/components/layout/menu-item.component.ts +170 -0
- package/src/lib/components/layout/menu.component.html +27 -0
- package/src/lib/components/layout/menu.component.ts +17 -0
- package/{lib/components/layout/services/index.d.ts → src/lib/components/layout/services/index.ts} +1 -1
- package/src/lib/components/layout/services/main-layout.component.service.ts +231 -0
- package/src/lib/components/layout/topbar.component.html +38 -0
- package/src/lib/components/layout/topbar.component.ts +62 -0
- package/{lib/components/tableview/index.d.ts → src/lib/components/tableview/index.ts} +5 -5
- package/{lib/components/tableview/models/index.d.ts → src/lib/components/tableview/models/index.ts} +1 -1
- package/src/lib/components/tableview/models/table.event.ts +22 -0
- package/src/lib/components/tableview/route/tableview-route.abstract.component.ts +31 -0
- package/{lib/components/tableview/services/index.d.ts → src/lib/components/tableview/services/index.ts} +1 -1
- package/src/lib/components/tableview/services/tableview.component.service.ts +22 -0
- package/src/lib/components/tableview/table/column-filter/column-filter.component.html +36 -0
- package/src/lib/components/tableview/table/column-filter/column-filter.component.ts +70 -0
- package/src/lib/components/tableview/table/column-value/column-value.component.html +14 -0
- package/src/lib/components/tableview/table/column-value/column-value.component.ts +19 -0
- package/src/lib/components/tableview/table/table.component.html +110 -0
- package/src/lib/components/tableview/table/table.component.ts +327 -0
- package/src/lib/components/tableview/tableview.component.html +37 -0
- package/src/lib/components/tableview/tableview.component.ts +78 -0
- package/src/lib/config/formly.config.ts +154 -0
- package/{lib/config/index.d.ts → src/lib/config/index.ts} +1 -1
- package/{lib/config/models/index.d.ts → src/lib/config/models/index.ts} +1 -1
- package/{lib/config/models/mng-config.model.d.ts → src/lib/config/models/mng-config.model.ts} +35 -34
- package/src/lib/data-providers/base.data-provider.ts +42 -0
- package/src/lib/data-providers/editor.data-provider.ts +60 -0
- package/{lib/data-providers/index.d.ts → src/lib/data-providers/index.ts} +5 -5
- package/src/lib/data-providers/lookup.data-provider.ts +29 -0
- package/{lib/data-providers/table.data-provider.d.ts → src/lib/data-providers/table.data-provider.ts} +8 -6
- package/src/lib/data-providers/tableview.data-provider.ts +29 -0
- package/src/lib/descriptors/action.descriptor.ts +439 -0
- package/src/lib/descriptors/editor.descriptor.ts +880 -0
- package/src/lib/descriptors/field.validator.ts +35 -0
- package/{lib/descriptors/index.d.ts → src/lib/descriptors/index.ts} +7 -7
- package/{lib/descriptors/lookup.descriptor.d.ts → src/lib/descriptors/lookup.descriptor.ts} +20 -17
- package/src/lib/descriptors/model.descriptor.ts +47 -0
- package/src/lib/descriptors/table.descriptor.ts +514 -0
- package/src/lib/descriptors/tableview.descriptor.ts +180 -0
- package/src/lib/directives/component.directive.ts +18 -0
- package/{lib/directives/index.d.ts → src/lib/directives/index.ts} +2 -2
- package/src/lib/directives/template.directive.ts +24 -0
- package/src/lib/mng-commons.module.ts +240 -0
- package/{lib/models/index.d.ts → src/lib/models/index.ts} +2 -2
- package/src/lib/models/router.model.ts +16 -0
- package/{lib/models/user.model.d.ts → src/lib/models/user.model.ts} +9 -8
- package/src/lib/pipes/boolean.pipe.ts +17 -0
- package/{lib/pipes/index.d.ts → src/lib/pipes/index.ts} +2 -2
- package/src/lib/pipes/property-path.pipe.ts +30 -0
- package/src/lib/services/action.service.ts +310 -0
- package/src/lib/services/commons.service.ts +407 -0
- package/src/lib/services/configuration.service.ts +98 -0
- package/{lib/services/index.d.ts → src/lib/services/index.ts} +4 -4
- package/src/lib/services/navigation.service.ts +42 -0
- package/src/lib/services/providers/commons-init.provider.ts +5 -0
- package/src/lib/services/providers/config-service.provider.ts +22 -0
- package/src/lib/services/providers/formly-config.provider.ts +39 -0
- package/{lib/services/providers/index.d.ts → src/lib/services/providers/index.ts} +3 -3
- package/src/lib/services/tokens/browser-storage.token.ts +9 -0
- package/{lib/services/tokens/index.d.ts → src/lib/services/tokens/index.ts} +2 -2
- package/src/lib/services/tokens/module-config.token.ts +5 -0
- package/{lib/types/index.d.ts → src/lib/types/index.ts} +2 -2
- package/src/lib/types/type.decorator.ts +7 -0
- package/src/lib/types/type.model.ts +12 -0
- package/src/lib/utils/editor-formly.util.ts +193 -0
- package/src/lib/utils/i18n.util.ts +148 -0
- package/{lib/utils/index.d.ts → src/lib/utils/index.ts} +5 -5
- package/src/lib/utils/model.util.ts +66 -0
- package/src/lib/utils/toast.util.ts +49 -0
- package/src/lib/utils/type.util.ts +44 -0
- package/{public-api.d.ts → src/public-api.ts} +42 -25
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2020/lib/api/models/builders/query-param.builder.mjs +0 -48
- package/esm2020/lib/api/models/filter-match-type.model.mjs +0 -26
- package/esm2020/lib/api/models/filter-param.model.mjs +0 -46
- package/esm2020/lib/api/models/index.mjs +0 -9
- package/esm2020/lib/api/models/mappers.mjs +0 -17
- package/esm2020/lib/api/models/query-mode.model.mjs +0 -19
- package/esm2020/lib/api/models/query-param.model.mjs +0 -69
- package/esm2020/lib/api/models/query-result.model.mjs +0 -45
- package/esm2020/lib/api/models/serialization.model.mjs +0 -2
- package/esm2020/lib/api/services/crud-api.abstract.service.mjs +0 -72
- package/esm2020/lib/api/services/index.mjs +0 -2
- package/esm2020/lib/api/utils/index.mjs +0 -3
- package/esm2020/lib/api/utils/medius-rest.util.mjs +0 -122
- package/esm2020/lib/api/utils/object-serializer.util.mjs +0 -226
- package/esm2020/lib/components/action/action.component.mjs +0 -65
- package/esm2020/lib/components/action/dialog/action-dialog.component.mjs +0 -148
- package/esm2020/lib/components/action/index.mjs +0 -4
- package/esm2020/lib/components/action/models/action-confirmation-service.model.mjs +0 -2
- package/esm2020/lib/components/action/models/action-execution.model.mjs +0 -58
- package/esm2020/lib/components/action/models/index.mjs +0 -3
- package/esm2020/lib/components/action/route/action-route.component.mjs +0 -144
- package/esm2020/lib/components/form/autocomplete/autocomplete.component.mjs +0 -114
- package/esm2020/lib/components/form/dropdown/dropdown.component.mjs +0 -113
- package/esm2020/lib/components/form/editor/form-editor.component.mjs +0 -141
- package/esm2020/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +0 -19
- package/esm2020/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +0 -19
- package/esm2020/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +0 -16
- package/esm2020/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.mjs +0 -26
- package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +0 -109
- package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +0 -122
- package/esm2020/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +0 -17
- package/esm2020/lib/components/form/formly/fields/index.mjs +0 -8
- package/esm2020/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +0 -17
- package/esm2020/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.mjs +0 -16
- package/esm2020/lib/components/form/formly/wrappers/index.mjs +0 -3
- package/esm2020/lib/components/form/index.mjs +0 -4
- package/esm2020/lib/components/form/models/form-editor.event.mjs +0 -7
- package/esm2020/lib/components/form/models/index.mjs +0 -2
- package/esm2020/lib/components/layout/breadcrumb.component.mjs +0 -17
- package/esm2020/lib/components/layout/footer.component.mjs +0 -17
- package/esm2020/lib/components/layout/index.mjs +0 -7
- package/esm2020/lib/components/layout/main-layout.component.mjs +0 -54
- package/esm2020/lib/components/layout/menu-item.component.mjs +0 -173
- package/esm2020/lib/components/layout/menu.component.mjs +0 -20
- package/esm2020/lib/components/layout/services/index.mjs +0 -2
- package/esm2020/lib/components/layout/services/main-layout.component.service.mjs +0 -190
- package/esm2020/lib/components/layout/topbar.component.mjs +0 -59
- package/esm2020/lib/components/tableview/index.mjs +0 -6
- package/esm2020/lib/components/tableview/models/index.mjs +0 -2
- package/esm2020/lib/components/tableview/models/table.event.mjs +0 -16
- package/esm2020/lib/components/tableview/route/tableview-route.abstract.component.mjs +0 -24
- package/esm2020/lib/components/tableview/services/index.mjs +0 -2
- package/esm2020/lib/components/tableview/services/tableview.component.service.mjs +0 -17
- package/esm2020/lib/components/tableview/table/column-filter/column-filter.component.mjs +0 -74
- package/esm2020/lib/components/tableview/table/column-value/column-value.component.mjs +0 -25
- package/esm2020/lib/components/tableview/table/table.component.mjs +0 -307
- package/esm2020/lib/components/tableview/tableview.component.mjs +0 -82
- package/esm2020/lib/config/formly.config.mjs +0 -136
- package/esm2020/lib/config/index.mjs +0 -2
- package/esm2020/lib/config/models/index.mjs +0 -2
- package/esm2020/lib/config/models/mng-config.model.mjs +0 -2
- package/esm2020/lib/data-providers/base.data-provider.mjs +0 -24
- package/esm2020/lib/data-providers/editor.data-provider.mjs +0 -37
- package/esm2020/lib/data-providers/index.mjs +0 -6
- package/esm2020/lib/data-providers/lookup.data-provider.mjs +0 -16
- package/esm2020/lib/data-providers/table.data-provider.mjs +0 -2
- package/esm2020/lib/data-providers/tableview.data-provider.mjs +0 -17
- package/esm2020/lib/descriptors/action.descriptor.mjs +0 -332
- package/esm2020/lib/descriptors/editor.descriptor.mjs +0 -670
- package/esm2020/lib/descriptors/field.validator.mjs +0 -21
- package/esm2020/lib/descriptors/index.mjs +0 -8
- package/esm2020/lib/descriptors/lookup.descriptor.mjs +0 -2
- package/esm2020/lib/descriptors/model.descriptor.mjs +0 -34
- package/esm2020/lib/descriptors/table.descriptor.mjs +0 -401
- package/esm2020/lib/descriptors/tableview.descriptor.mjs +0 -131
- package/esm2020/lib/directives/component.directive.mjs +0 -23
- package/esm2020/lib/directives/index.mjs +0 -3
- package/esm2020/lib/directives/template.directive.mjs +0 -29
- package/esm2020/lib/mng-commons.module.mjs +0 -410
- package/esm2020/lib/models/index.mjs +0 -3
- package/esm2020/lib/models/router.model.mjs +0 -2
- package/esm2020/lib/models/user.model.mjs +0 -2
- package/esm2020/lib/pipes/boolean.pipe.mjs +0 -22
- package/esm2020/lib/pipes/index.mjs +0 -3
- package/esm2020/lib/pipes/property-path.pipe.mjs +0 -36
- package/esm2020/lib/services/action.service.mjs +0 -269
- package/esm2020/lib/services/commons.service.mjs +0 -353
- package/esm2020/lib/services/configuration.service.mjs +0 -78
- package/esm2020/lib/services/index.mjs +0 -5
- package/esm2020/lib/services/navigation.service.mjs +0 -48
- package/esm2020/lib/services/providers/commons-init.provider.mjs +0 -4
- package/esm2020/lib/services/providers/config-service.provider.mjs +0 -20
- package/esm2020/lib/services/providers/formly-config.provider.mjs +0 -31
- package/esm2020/lib/services/providers/index.mjs +0 -4
- package/esm2020/lib/services/tokens/browser-storage.token.mjs +0 -6
- package/esm2020/lib/services/tokens/index.mjs +0 -3
- package/esm2020/lib/services/tokens/module-config.token.mjs +0 -3
- package/esm2020/lib/types/index.mjs +0 -3
- package/esm2020/lib/types/type.decorator.mjs +0 -7
- package/esm2020/lib/types/type.model.mjs +0 -2
- package/esm2020/lib/utils/editor-formly.util.mjs +0 -176
- package/esm2020/lib/utils/i18n.util.mjs +0 -125
- package/esm2020/lib/utils/index.mjs +0 -6
- package/esm2020/lib/utils/model.util.mjs +0 -57
- package/esm2020/lib/utils/toast.util.mjs +0 -39
- package/esm2020/lib/utils/type.util.mjs +0 -39
- package/esm2020/mediusinc-mng-commons.mjs +0 -5
- package/esm2020/public-api.mjs +0 -36
- package/fesm2015/mediusinc-mng-commons.mjs +0 -6250
- package/fesm2015/mediusinc-mng-commons.mjs.map +0 -1
- package/fesm2020/mediusinc-mng-commons.mjs +0 -6176
- package/fesm2020/mediusinc-mng-commons.mjs.map +0 -1
- package/lib/api/models/builders/query-param.builder.d.ts +0 -11
- package/lib/api/models/filter-param.model.d.ts +0 -23
- package/lib/api/models/mappers.d.ts +0 -6
- package/lib/api/models/query-mode.model.d.ts +0 -16
- package/lib/api/models/query-param.model.d.ts +0 -31
- package/lib/api/models/query-result.model.d.ts +0 -36
- package/lib/api/services/crud-api.abstract.service.d.ts +0 -23
- package/lib/api/utils/medius-rest.util.d.ts +0 -12
- package/lib/api/utils/object-serializer.util.d.ts +0 -30
- package/lib/components/action/action.component.d.ts +0 -36
- package/lib/components/action/dialog/action-dialog.component.d.ts +0 -46
- package/lib/components/action/models/action-execution.model.d.ts +0 -53
- package/lib/components/action/route/action-route.component.d.ts +0 -32
- package/lib/components/form/autocomplete/autocomplete.component.d.ts +0 -36
- package/lib/components/form/dropdown/dropdown.component.d.ts +0 -34
- package/lib/components/form/editor/form-editor.component.d.ts +0 -39
- package/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.d.ts +0 -11
- package/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.d.ts +0 -11
- package/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.d.ts +0 -6
- package/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.d.ts +0 -12
- package/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.d.ts +0 -17
- package/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +0 -36
- package/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.d.ts +0 -6
- package/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.d.ts +0 -8
- package/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.d.ts +0 -8
- package/lib/components/form/models/form-editor.event.d.ts +0 -5
- package/lib/components/layout/breadcrumb.component.d.ts +0 -8
- package/lib/components/layout/footer.component.d.ts +0 -9
- package/lib/components/layout/main-layout.component.d.ts +0 -21
- package/lib/components/layout/menu-item.component.d.ts +0 -29
- package/lib/components/layout/menu.component.d.ts +0 -10
- package/lib/components/layout/services/main-layout.component.service.d.ts +0 -65
- package/lib/components/layout/topbar.component.d.ts +0 -25
- package/lib/components/tableview/models/table.event.d.ts +0 -17
- package/lib/components/tableview/route/tableview-route.abstract.component.d.ts +0 -14
- package/lib/components/tableview/services/tableview.component.service.d.ts +0 -13
- package/lib/components/tableview/table/column-filter/column-filter.component.d.ts +0 -22
- package/lib/components/tableview/table/column-value/column-value.component.d.ts +0 -12
- package/lib/components/tableview/table/table.component.d.ts +0 -79
- package/lib/components/tableview/tableview.component.d.ts +0 -35
- package/lib/config/formly.config.d.ts +0 -14
- package/lib/data-providers/base.data-provider.d.ts +0 -17
- package/lib/data-providers/editor.data-provider.d.ts +0 -25
- package/lib/data-providers/lookup.data-provider.d.ts +0 -14
- package/lib/data-providers/tableview.data-provider.d.ts +0 -15
- package/lib/descriptors/action.descriptor.d.ts +0 -148
- package/lib/descriptors/editor.descriptor.d.ts +0 -255
- package/lib/descriptors/field.validator.d.ts +0 -18
- package/lib/descriptors/model.descriptor.d.ts +0 -15
- package/lib/descriptors/table.descriptor.d.ts +0 -164
- package/lib/descriptors/tableview.descriptor.d.ts +0 -39
- package/lib/directives/component.directive.d.ts +0 -11
- package/lib/directives/template.directive.d.ts +0 -13
- package/lib/mng-commons.module.d.ts +0 -79
- package/lib/models/router.model.d.ts +0 -14
- package/lib/pipes/boolean.pipe.d.ts +0 -7
- package/lib/pipes/property-path.pipe.d.ts +0 -7
- package/lib/services/action.service.d.ts +0 -92
- package/lib/services/commons.service.d.ts +0 -72
- package/lib/services/configuration.service.d.ts +0 -35
- package/lib/services/navigation.service.d.ts +0 -14
- package/lib/services/providers/commons-init.provider.d.ts +0 -2
- package/lib/services/providers/config-service.provider.d.ts +0 -5
- package/lib/services/providers/formly-config.provider.d.ts +0 -4
- package/lib/services/tokens/browser-storage.token.d.ts +0 -2
- package/lib/services/tokens/module-config.token.d.ts +0 -3
- package/lib/types/type.decorator.d.ts +0 -2
- package/lib/types/type.model.d.ts +0 -10
- package/lib/utils/editor-formly.util.d.ts +0 -9
- package/lib/utils/i18n.util.d.ts +0 -18
- package/lib/utils/model.util.d.ts +0 -7
- package/lib/utils/toast.util.d.ts +0 -13
- package/lib/utils/type.util.d.ts +0 -15
- package/mediusinc-mng-commons-0.2.0.tgz +0 -0
- package/mediusinc-mng-commons.d.ts +0 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './action.component';
|
|
2
|
-
export * from './route/action-route.component';
|
|
3
|
-
export * from './dialog/action-dialog.component';
|
|
1
|
+
export * from './action.component';
|
|
2
|
+
export * from './route/action-route.component';
|
|
3
|
+
export * from './dialog/action-dialog.component';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {ConfirmationService} from 'primeng/api';
|
|
2
|
+
import {ActionDescriptor} from '../../../descriptors';
|
|
3
|
+
|
|
4
|
+
export interface IActionConfirmationService {
|
|
5
|
+
getConfirmationService(): ConfirmationService;
|
|
6
|
+
getConfirmationServiceInstanceKey(action: ActionDescriptor<any>): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
|
2
|
+
import {Observable} from 'rxjs';
|
|
3
|
+
|
|
4
|
+
import {IdType} from '../../../types';
|
|
5
|
+
import {IDataProvider} from '../../../data-providers';
|
|
6
|
+
import {TableviewComponentService} from '../../tableview/services';
|
|
7
|
+
|
|
8
|
+
export class ActionExecContext<T, S, DP extends IDataProvider<T, S>> {
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly dataProvider?: DP,
|
|
11
|
+
public readonly serviceInstance?: S,
|
|
12
|
+
public readonly data?: {
|
|
13
|
+
item?: T;
|
|
14
|
+
itemId?: IdType;
|
|
15
|
+
actionData?: ActionData;
|
|
16
|
+
},
|
|
17
|
+
public readonly sourceComponent: any = null,
|
|
18
|
+
public readonly tableview: TableviewComponentService<T, S>|null = null
|
|
19
|
+
) {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ActionError {
|
|
23
|
+
constructor(
|
|
24
|
+
public readonly error: any, // error details
|
|
25
|
+
public readonly dismissed: boolean = false // by user
|
|
26
|
+
) {}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ActionRunResult<T, S, DP extends IDataProvider<T, S>> {
|
|
30
|
+
constructor(
|
|
31
|
+
public readonly context?: ActionExecContext<T, S, DP>,
|
|
32
|
+
public readonly result?: T,
|
|
33
|
+
public readonly error?: ActionError
|
|
34
|
+
) {}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class ActionActivationResult<T, S, DP extends IDataProvider<T, S>> {
|
|
38
|
+
constructor(
|
|
39
|
+
public readonly runResult?: ActionRunResult<T, S, DP>,
|
|
40
|
+
public readonly dialogRef?: DynamicDialogRef
|
|
41
|
+
) {}
|
|
42
|
+
|
|
43
|
+
public get runContext() {
|
|
44
|
+
return this.runResult ? this.runResult.context : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get result() {
|
|
48
|
+
return this.runResult ? this.runResult.result : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public get error() {
|
|
52
|
+
return this.runResult ? this.runResult.error : null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class ActionTriggerResult<T, S, DP extends IDataProvider<T, S>> {
|
|
57
|
+
constructor(
|
|
58
|
+
public readonly activationResult?: ActionActivationResult<T, S, DP>,
|
|
59
|
+
public readonly routerNavigation?: Observable<boolean>
|
|
60
|
+
) {}
|
|
61
|
+
|
|
62
|
+
public get runContext() {
|
|
63
|
+
return this.activationResult ? this.activationResult.runResult : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public get result() {
|
|
67
|
+
return this.activationResult ? this.activationResult.result : null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public get error() {
|
|
71
|
+
return this.activationResult ? this.activationResult.error : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public get dialogRef() {
|
|
75
|
+
return this.activationResult ? this.activationResult.dialogRef : null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ActionData = {
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
};
|
package/{lib/components/action/models/index.d.ts → src/lib/components/action/models/index.ts}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './action-confirmation-service.model';
|
|
2
|
-
export * from './action-execution.model';
|
|
1
|
+
export * from './action-confirmation-service.model';
|
|
2
|
+
export * from './action-execution.model';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p-confirmDialog [key]="'actionRoute_' + cmpId" [baseZIndex]="50" appendTo="body"></p-confirmDialog>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
|
|
2
|
+
import {ActivatedRoute, Params, Router} from '@angular/router';
|
|
3
|
+
|
|
4
|
+
import {ConfirmationService, MessageService} from 'primeng/api';
|
|
5
|
+
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
|
6
|
+
import {Subscription} from 'rxjs';
|
|
7
|
+
import {first} from 'rxjs/operators';
|
|
8
|
+
|
|
9
|
+
import {ActionDescriptor, ActionActivationTriggerEnum} from '../../../descriptors';
|
|
10
|
+
import {IActionConfirmationService, ActionData, ActionRunResult} from '../models';
|
|
11
|
+
import {MngActionService, MngNavigationService} from '../../../services';
|
|
12
|
+
import {TableviewComponentService} from '../../tableview/services';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'mng-action-route',
|
|
16
|
+
templateUrl: './action-route.component.html',
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18
|
+
providers: [MessageService, ConfirmationService]
|
|
19
|
+
})
|
|
20
|
+
export class MngActionRouteComponent<T, S> implements OnInit, OnDestroy, IActionConfirmationService {
|
|
21
|
+
|
|
22
|
+
private actions: Array<ActionDescriptor<T>> = [];
|
|
23
|
+
private activeAction?: ActionDescriptor<T>;
|
|
24
|
+
|
|
25
|
+
private dialogRef?: DynamicDialogRef;
|
|
26
|
+
private dialogCloseSubscription?: Subscription;
|
|
27
|
+
|
|
28
|
+
private subscriptions: Array<Subscription> = [];
|
|
29
|
+
|
|
30
|
+
public cmpId: string = Math.random().toString(36).substring(2);
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
private router: Router,
|
|
34
|
+
private route: ActivatedRoute,
|
|
35
|
+
private confirmationService: ConfirmationService,
|
|
36
|
+
private navigationService: MngNavigationService,
|
|
37
|
+
private actionService: MngActionService,
|
|
38
|
+
private tableviewService: TableviewComponentService<T, S>
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
public ngOnInit() {
|
|
42
|
+
|
|
43
|
+
this.actions = this.tableviewService?.actions.filter(a => a.activationTrigger === ActionActivationTriggerEnum.OnRoute) ?? [];
|
|
44
|
+
const subscription = this.route.params.subscribe(p => {
|
|
45
|
+
const action = this.findActiveAction(p);
|
|
46
|
+
if (action) {
|
|
47
|
+
this.activateAction(action, p, this.route.snapshot.queryParams);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
this.subscriptions.push(subscription);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public ngOnDestroy() {
|
|
54
|
+
this.subscriptions.forEach(s => s.unsubscribe());
|
|
55
|
+
if (this.dialogRef) {
|
|
56
|
+
this.dialogRef.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getConfirmationService() {
|
|
61
|
+
return this.confirmationService;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public getConfirmationServiceInstanceKey(action: ActionDescriptor<any>) {
|
|
65
|
+
return `actionRoute_${this.cmpId}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private activateAction(action: ActionDescriptor<T>, p: Params, qp: Params) {
|
|
69
|
+
this.activeAction = action;
|
|
70
|
+
const itemId = p['itemId'];
|
|
71
|
+
const actionData: ActionData = {};
|
|
72
|
+
for (let key in p) {
|
|
73
|
+
if (key === 'itemId') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
actionData[key] = p[key];
|
|
77
|
+
}
|
|
78
|
+
for (let key in qp) {
|
|
79
|
+
actionData[key] = p[key];
|
|
80
|
+
}
|
|
81
|
+
this.actionService.activateAction(action, itemId, undefined, actionData, this.tableviewService, this)
|
|
82
|
+
.pipe(first())
|
|
83
|
+
.subscribe(res => {
|
|
84
|
+
if (res.dialogRef) {
|
|
85
|
+
this.dialogRef = res.dialogRef;
|
|
86
|
+
this.dialogCloseSubscription = this.dialogRef?.onClose.subscribe(e => {
|
|
87
|
+
const actionEv = e as ActionRunResult<T, S, any>;
|
|
88
|
+
if (!actionEv?.error || !actionEv?.error?.dismissed) {
|
|
89
|
+
this.tableviewService.reloadTable(); // reload only if no error in action and
|
|
90
|
+
}
|
|
91
|
+
this.deactivateAction();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private deactivateAction() {
|
|
98
|
+
if (this.dialogCloseSubscription) {
|
|
99
|
+
this.dialogCloseSubscription.unsubscribe();
|
|
100
|
+
this.dialogCloseSubscription = undefined;
|
|
101
|
+
}
|
|
102
|
+
if (this.navigationService.getPreviousLocation()) {
|
|
103
|
+
// there are internal history records, so back can be normally called
|
|
104
|
+
this.navigationService.back();
|
|
105
|
+
} else {
|
|
106
|
+
// there is no internal history records, figure out the base url by eliminating action specific url
|
|
107
|
+
let url = this.navigationService.getCurrentLocation();
|
|
108
|
+
if (!url) {
|
|
109
|
+
this.navigationService.back();
|
|
110
|
+
} else {
|
|
111
|
+
if (url.startsWith('/')) {
|
|
112
|
+
url = url.substring(1);
|
|
113
|
+
}
|
|
114
|
+
const urlPathSegments = url.split('?')[0].split('#')[0].split('/');
|
|
115
|
+
let actionUrl = this.activeAction?.routeUrl ?? '';
|
|
116
|
+
if (actionUrl.startsWith('/')) {
|
|
117
|
+
actionUrl = actionUrl.substring(1);
|
|
118
|
+
}
|
|
119
|
+
const actionUrlSegments = actionUrl.split('/');
|
|
120
|
+
const redirectUrl = urlPathSegments.slice(0, urlPathSegments.length - actionUrlSegments.length).join('/');
|
|
121
|
+
this.router.navigateByUrl(`/${redirectUrl}`, { replaceUrl: true });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
this.activeAction = undefined;
|
|
125
|
+
this.dialogRef = undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private findActiveAction(params: Params): ActionDescriptor<T>|null {
|
|
129
|
+
const urlSegments = this.route.snapshot.url;
|
|
130
|
+
for (const action of this.actions) {
|
|
131
|
+
let actionUrl = action.routeUrl ?? '';
|
|
132
|
+
// TODO: dont strip '/', but use it accordingly with Angular's router patterns (/, ./, ../)
|
|
133
|
+
if (actionUrl.startsWith('/')) {
|
|
134
|
+
actionUrl = actionUrl.substring(1);
|
|
135
|
+
}
|
|
136
|
+
const actionUrlSegments = actionUrl.split('/');
|
|
137
|
+
if (actionUrlSegments.length !== urlSegments.length) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
let isMatch = true;
|
|
141
|
+
for (let i = 0; i < actionUrlSegments.length; i++) {
|
|
142
|
+
if (actionUrlSegments[i].startsWith(':')) {
|
|
143
|
+
const paramName = actionUrlSegments[i].substring(1);
|
|
144
|
+
if (!params[paramName]) {
|
|
145
|
+
isMatch = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
} else if (actionUrlSegments[i] !== urlSegments[i].path) {
|
|
149
|
+
isMatch = false;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (isMatch) {
|
|
154
|
+
return action;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<p-autoComplete [formControl]="autocompleteFormControl"
|
|
2
|
+
[placeholder]="$any(placeholder)"
|
|
3
|
+
[dropdown]="true"
|
|
4
|
+
[dataKey]="$any(dataKeyProperty)"
|
|
5
|
+
[field]="$any(itemsLabelProperty)"
|
|
6
|
+
[suggestions]="(suggestions$ | async) ?? []"
|
|
7
|
+
[multiple]="multiselect"
|
|
8
|
+
[showEmptyMessage]="true"
|
|
9
|
+
[emptyMessage]="'mngAutcomplete.noMatches' | translate"
|
|
10
|
+
[styleClass]="$any(className)"
|
|
11
|
+
[panelStyleClass]="$any(dropdownClassName)"
|
|
12
|
+
(completeMethod)="onSearch($event)"
|
|
13
|
+
(onSelect)="onSelect($event)"
|
|
14
|
+
appendTo="body"
|
|
15
|
+
dropdownMode="current">
|
|
16
|
+
</p-autoComplete>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, EventEmitter, ExistingProvider, forwardRef, Injector, Input, OnInit, Output, ViewChild} from '@angular/core';
|
|
2
|
+
import {ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import {Observable, Subject, Subscription} from 'rxjs';
|
|
5
|
+
import {finalize, first} from 'rxjs/operators';
|
|
6
|
+
import {AutoComplete} from 'primeng/autocomplete';
|
|
7
|
+
|
|
8
|
+
import {MediusFilterMatchType, MediusQueryParamBuilder} from '../../../api/models';
|
|
9
|
+
import {ILookupDataProvider} from '../../../data-providers';
|
|
10
|
+
|
|
11
|
+
export const MNG_AUTOCOMPLETE_VALUE_ACCESSOR: ExistingProvider = {
|
|
12
|
+
provide: NG_VALUE_ACCESSOR,
|
|
13
|
+
useExisting: forwardRef(() => MngAutocompleteComponent),
|
|
14
|
+
multi: true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'mng-autocomplete',
|
|
19
|
+
templateUrl: './autocomplete.component.html',
|
|
20
|
+
providers: [MNG_AUTOCOMPLETE_VALUE_ACCESSOR],
|
|
21
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
22
|
+
})
|
|
23
|
+
export class MngAutocompleteComponent implements OnInit, ControlValueAccessor {
|
|
24
|
+
|
|
25
|
+
@Input() dataProvider?: ILookupDataProvider<any, any>;
|
|
26
|
+
@Input() dataKeyProperty?: string;
|
|
27
|
+
@Input() itemsLabelProperty?: string;
|
|
28
|
+
@Input() multiselect: boolean = false;
|
|
29
|
+
@Input() placeholder?: string;
|
|
30
|
+
@Input() className: string|null = null;
|
|
31
|
+
@Input() dropdownClassName: string|null = null;
|
|
32
|
+
|
|
33
|
+
@Output() onChange = new EventEmitter();
|
|
34
|
+
|
|
35
|
+
@ViewChild(AutoComplete) private primeAutocomplete?: AutoComplete;
|
|
36
|
+
|
|
37
|
+
private suggestionsSubject: Subject<Array<any>> = new Subject<Array<any>>();
|
|
38
|
+
private searchSubscription: Subscription|null = null;
|
|
39
|
+
private dataProviderService: any = null;
|
|
40
|
+
private onChangeFn: any = () => { };
|
|
41
|
+
private onTouchedFn: any = () => { };
|
|
42
|
+
|
|
43
|
+
public autocompleteFormControl: FormControl = new FormControl();
|
|
44
|
+
public suggestions$: Observable<Array<any>> = this.suggestionsSubject.asObservable();
|
|
45
|
+
public isLoading = false;
|
|
46
|
+
|
|
47
|
+
constructor(private injector: Injector) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnInit() {
|
|
51
|
+
if (this.dataProvider) {
|
|
52
|
+
this.dataProviderService = this.dataProvider.serviceType
|
|
53
|
+
? this.injector.get<any>(this.dataProvider.serviceType)
|
|
54
|
+
: null;
|
|
55
|
+
} else {
|
|
56
|
+
console.warn(`Data provider should be provided for MngAutocompleteComponent.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onSearch(event: any) {
|
|
61
|
+
if (this.searchSubscription) {
|
|
62
|
+
// try to cancel existing HTTP request subscription
|
|
63
|
+
this.searchSubscription.unsubscribe();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.dataProvider) {
|
|
67
|
+
this.isLoading = true;
|
|
68
|
+
const queryParamBuilder = MediusQueryParamBuilder.create();
|
|
69
|
+
if (this.itemsLabelProperty) {
|
|
70
|
+
queryParamBuilder.withSort(this.itemsLabelProperty);
|
|
71
|
+
}
|
|
72
|
+
if (event.query && event.query.length > 0 && this.itemsLabelProperty) {
|
|
73
|
+
queryParamBuilder.withFilter(this.itemsLabelProperty, event.query, undefined, MediusFilterMatchType.StartsWith)
|
|
74
|
+
}
|
|
75
|
+
this.searchSubscription = this.dataProvider.lookup(queryParamBuilder.build(), this.dataProviderService, event.query)
|
|
76
|
+
.pipe(
|
|
77
|
+
first(),
|
|
78
|
+
finalize(() => this.isLoading = false)
|
|
79
|
+
)
|
|
80
|
+
.subscribe((res: any) => {
|
|
81
|
+
this.suggestionsSubject.next(res);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onSelect(value: any) {
|
|
87
|
+
this.onChangeFn(value);
|
|
88
|
+
this.onChange.next(value);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
registerOnChange(fn: any): void {
|
|
92
|
+
this.onChangeFn = fn;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
registerOnTouched(fn: any): void {
|
|
96
|
+
this.onTouchedFn = fn;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setDisabledState(isDisabled: boolean): void {
|
|
100
|
+
if (isDisabled) {
|
|
101
|
+
this.autocompleteFormControl.disable();
|
|
102
|
+
} else {
|
|
103
|
+
this.autocompleteFormControl.enable();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
writeValue(obj: any): void {
|
|
108
|
+
this.autocompleteFormControl.setValue(obj, { emitEvent: false });
|
|
109
|
+
if (this.primeAutocomplete) {
|
|
110
|
+
this.primeAutocomplete.writeValue(obj);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<p-dropdown *ngIf="!multiselect; else pMultiselect"
|
|
2
|
+
[formControl]="dropdownFormControl"
|
|
3
|
+
[placeholder]="$any(placeholder)"
|
|
4
|
+
[dataKey]="$any(dataKeyProperty)"
|
|
5
|
+
[optionLabel]="$any(itemsLabelProperty)"
|
|
6
|
+
[optionValue]="$any(itemsValueProperty)"
|
|
7
|
+
[options]="(items$ | async) ?? []"
|
|
8
|
+
[showClear]="showClear"
|
|
9
|
+
[autoDisplayFirst]="false"
|
|
10
|
+
[styleClass]="$any(className)"
|
|
11
|
+
[panelStyleClass]="$any(dropdownClassName)"
|
|
12
|
+
(onChange)="onChange.emit($event.value)"
|
|
13
|
+
appendTo="body">
|
|
14
|
+
</p-dropdown>
|
|
15
|
+
<ng-template #pMultiselect>
|
|
16
|
+
<p-multiSelect display="chip"
|
|
17
|
+
[formControl]="dropdownFormControl"
|
|
18
|
+
[defaultLabel]="$any(placeholder)"
|
|
19
|
+
[dataKey]="$any(dataKeyProperty)"
|
|
20
|
+
[optionLabel]="$any(itemsLabelProperty)"
|
|
21
|
+
[optionValue]="$any(itemsValueProperty)"
|
|
22
|
+
[options]="(items$ | async) ?? []"
|
|
23
|
+
[styleClass]="$any(className)"
|
|
24
|
+
[panelStyleClass]="$any(dropdownClassName)"
|
|
25
|
+
[filter]="false"
|
|
26
|
+
(onChange)="onChange.emit($event.value)"
|
|
27
|
+
appendTo="body">
|
|
28
|
+
</p-multiSelect>
|
|
29
|
+
</ng-template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, EventEmitter, ExistingProvider, forwardRef, Injector, Input, OnInit, Output, ViewChild} from '@angular/core';
|
|
2
|
+
import {ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import {Observable, ReplaySubject, Subject} from 'rxjs';
|
|
5
|
+
import {first} from 'rxjs/operators';
|
|
6
|
+
import {Dropdown} from 'primeng/dropdown';
|
|
7
|
+
|
|
8
|
+
import {ILookupDataProvider} from '../../../data-providers';
|
|
9
|
+
import {MediusQueryParamBuilder} from '../../../api/models';
|
|
10
|
+
|
|
11
|
+
export const MNG_DROPDOWN_VALUE_ACCESSOR: ExistingProvider = {
|
|
12
|
+
provide: NG_VALUE_ACCESSOR,
|
|
13
|
+
useExisting: forwardRef(() => MngDropdownComponent),
|
|
14
|
+
multi: true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'mng-dropdown',
|
|
19
|
+
templateUrl: './dropdown.component.html',
|
|
20
|
+
providers: [MNG_DROPDOWN_VALUE_ACCESSOR],
|
|
21
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
22
|
+
})
|
|
23
|
+
export class MngDropdownComponent implements OnInit, ControlValueAccessor {
|
|
24
|
+
|
|
25
|
+
@Input() dataProvider?: ILookupDataProvider<any, any>;
|
|
26
|
+
@Input() dataKeyProperty?: string;
|
|
27
|
+
@Input() itemsLabelProperty?: string;
|
|
28
|
+
@Input() itemsValueProperty?: string;
|
|
29
|
+
@Input() multiselect: boolean = false;
|
|
30
|
+
@Input() placeholder?: string;
|
|
31
|
+
@Input() showClear = true;
|
|
32
|
+
@Input() className: string|null = null;
|
|
33
|
+
@Input() dropdownClassName: string|null = null;
|
|
34
|
+
|
|
35
|
+
@Output() onChange = new EventEmitter();
|
|
36
|
+
|
|
37
|
+
@ViewChild(Dropdown) private primeDropdown?: Dropdown;
|
|
38
|
+
|
|
39
|
+
private itemsSubject: Subject<Array<any>> = new ReplaySubject<Array<any>>(1);
|
|
40
|
+
private dataProviderService: any = null;
|
|
41
|
+
private onChangeFn: any = () => { };
|
|
42
|
+
private onTouchedFn: any = () => { };
|
|
43
|
+
|
|
44
|
+
public dropdownFormControl: FormControl = new FormControl();
|
|
45
|
+
public items$: Observable<Array<any>> = this.itemsSubject.asObservable();
|
|
46
|
+
|
|
47
|
+
constructor(private injector: Injector) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnInit(): void {
|
|
51
|
+
|
|
52
|
+
this.dropdownFormControl.valueChanges
|
|
53
|
+
.subscribe(v => {
|
|
54
|
+
this.onChangeFn(v);
|
|
55
|
+
this.onChange.next(v);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (this.dataProvider) {
|
|
59
|
+
this.dataProviderService = this.dataProvider.serviceType
|
|
60
|
+
? this.injector.get<any>(this.dataProvider.serviceType)
|
|
61
|
+
: null;
|
|
62
|
+
|
|
63
|
+
const queryParamBuilder = MediusQueryParamBuilder.create();
|
|
64
|
+
this.dataProvider.lookup(queryParamBuilder.build(), this.dataProviderService)
|
|
65
|
+
.pipe(
|
|
66
|
+
first()
|
|
67
|
+
)
|
|
68
|
+
.subscribe(res => {
|
|
69
|
+
this.itemsSubject.next(res);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (!this.dropdownFormControl?.value) {
|
|
73
|
+
this.items$.pipe(first()).subscribe(res => {
|
|
74
|
+
// TODO: check if really only way
|
|
75
|
+
if (res.length === 1) {
|
|
76
|
+
const value = this.itemsValueProperty ? res[0][this.itemsValueProperty] : res[0];
|
|
77
|
+
this.dropdownFormControl?.patchValue(value);
|
|
78
|
+
console.log('patched dropdown form value with', value);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
console.warn(`Data provider should be provided for MngDropdownComponent.`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
registerOnChange(fn: any): void {
|
|
88
|
+
this.onChangeFn = fn;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
registerOnTouched(fn: any): void {
|
|
92
|
+
this.onTouchedFn = fn;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setDisabledState(isDisabled: boolean): void {
|
|
96
|
+
if (isDisabled) {
|
|
97
|
+
this.dropdownFormControl.disable();
|
|
98
|
+
} else {
|
|
99
|
+
this.dropdownFormControl.enable();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
writeValue(obj: any): void {
|
|
104
|
+
this.dropdownFormControl.setValue(obj, { emitEvent: false });
|
|
105
|
+
if (this.primeDropdown) {
|
|
106
|
+
this.primeDropdown.writeValue(obj);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<form [formGroup]="form" (ngSubmit)="onSubmit($event)">
|
|
2
|
+
<formly-form [form]="form" [fields]="formFields" [options]="formOptions" [model]="formModel"></formly-form>
|
|
3
|
+
<button #submitButton pButton type="submit" [class.hidden]="!isSubmitButtonVisible" [disabled]="form.disabled" [loading]="(submitLoading$ | async) ?? false"></button>
|
|
4
|
+
</form>
|
|
5
|
+
<p-messages [value]="formMessages" [enableService]="false"></p-messages>
|