@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {AfterContentInit, ChangeDetectionStrategy, Component, ContentChildren, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, QueryList, ViewChild} from '@angular/core';
|
|
2
|
+
import {FormGroup} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core';
|
|
5
|
+
import {Message} from 'primeng/api';
|
|
6
|
+
import {Observable, of, Subscription} from 'rxjs';
|
|
7
|
+
import {TranslateService} from '@ngx-translate/core';
|
|
8
|
+
|
|
9
|
+
import {EditorDescriptor} from '../../../descriptors';
|
|
10
|
+
import {MngFormEditorSubmitEvent} from '../models';
|
|
11
|
+
import {MngTemplateDirective} from '../../../directives';
|
|
12
|
+
import {EditorFormlyUtil, ToastUtil} from '../../../utils';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'mng-form-editor',
|
|
16
|
+
templateUrl: './form-editor.component.html',
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
18
|
+
})
|
|
19
|
+
export class MngFormEditorComponent<T> implements OnInit, AfterContentInit, OnDestroy {
|
|
20
|
+
|
|
21
|
+
// metadata and editor mode input
|
|
22
|
+
@Input() public descriptor!: EditorDescriptor<T>;
|
|
23
|
+
@Input() public submitLoading: Observable<boolean>|boolean = false;
|
|
24
|
+
|
|
25
|
+
// data source inputs;
|
|
26
|
+
@Input() public item?: T;
|
|
27
|
+
|
|
28
|
+
// extra features input
|
|
29
|
+
@Input() public isSubmitButtonVisible = false;
|
|
30
|
+
@Input() public isFormDisabled = null;
|
|
31
|
+
|
|
32
|
+
// event outputs
|
|
33
|
+
@Output('onSubmit') private submitEventEmitter = new EventEmitter<MngFormEditorSubmitEvent<T>>();
|
|
34
|
+
|
|
35
|
+
// content and view queries
|
|
36
|
+
@ContentChildren(MngTemplateDirective) templates!: QueryList<MngTemplateDirective>;
|
|
37
|
+
|
|
38
|
+
@ViewChild('submitButton')
|
|
39
|
+
public submitButtonElementRef?: ElementRef;
|
|
40
|
+
|
|
41
|
+
public form: FormGroup = new FormGroup({});
|
|
42
|
+
public formOptions: FormlyFormOptions = {
|
|
43
|
+
formState: {
|
|
44
|
+
add: false,
|
|
45
|
+
edit: false,
|
|
46
|
+
disabled: false
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
public formFields!: FormlyFieldConfig[];
|
|
50
|
+
public formOrigItem?: T;
|
|
51
|
+
public formModel: any = {};
|
|
52
|
+
public formMessages: Message[] = [];
|
|
53
|
+
public submitLoading$!: Observable<boolean>;
|
|
54
|
+
|
|
55
|
+
private subscriptions: Subscription[] = [];
|
|
56
|
+
|
|
57
|
+
constructor(private translateService: TranslateService) { }
|
|
58
|
+
|
|
59
|
+
public ngOnInit() {
|
|
60
|
+
|
|
61
|
+
this.updateFormModel(this.item);
|
|
62
|
+
this.submitLoading$ = this.submitLoading instanceof Observable ? this.submitLoading : of(this.submitLoading);
|
|
63
|
+
|
|
64
|
+
// init fields for formly
|
|
65
|
+
this.formFields = EditorFormlyUtil.createFormlyConfigFromDescriptor(this.descriptor);
|
|
66
|
+
this.updateFormState();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public ngAfterContentInit() {
|
|
70
|
+
this.templates.forEach(template => {
|
|
71
|
+
switch(template.getType()) {
|
|
72
|
+
// case 'caption':
|
|
73
|
+
// this.captionTemplate = template.template;
|
|
74
|
+
// break;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public ngOnDestroy() {
|
|
80
|
+
this.subscriptions.forEach(s => s.unsubscribe());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public submit() {
|
|
84
|
+
this.submitButtonElementRef?.nativeElement.click();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public onSubmit(event: Event) {
|
|
88
|
+
this.formOptions.formState.submittedOn = Date.now();
|
|
89
|
+
this.formMessages = [];
|
|
90
|
+
|
|
91
|
+
const formSubmitItem = this.form.getRawValue() as T;
|
|
92
|
+
if (this.form.valid) {
|
|
93
|
+
this.descriptor.fields.forEach(field => {
|
|
94
|
+
if (field && field.setter) {
|
|
95
|
+
field.setter(formSubmitItem, this.form.value[field.property]);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this.submitEventEmitter.next(new MngFormEditorSubmitEvent(formSubmitItem));
|
|
100
|
+
} else {
|
|
101
|
+
// find and mark invalid tabs
|
|
102
|
+
if (this.formFields[0].type === 'tabs' && this.formFields[0].fieldGroup) {
|
|
103
|
+
for (const tab of this.formFields[0].fieldGroup) {
|
|
104
|
+
const isInvalid = this.isAnyFieldInvalid(tab.fieldGroup);
|
|
105
|
+
this.formOptions.formState['tab_' + (tab.id ? tab.id : tab.templateOptions?.label) + '_invalid'] = isInvalid;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const event = new MngFormEditorSubmitEvent(formSubmitItem);
|
|
109
|
+
event.success = false;
|
|
110
|
+
this.formMessages.push(ToastUtil.getFormEditorWarningMessage(this.translateService, 'mngEditor.invalidFormToastTitle', 'mngEditor.invalidFormToastMessage'));
|
|
111
|
+
this.submitEventEmitter.next(event);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private isAnyFieldInvalid(fields: FormlyFieldConfig[] = []): boolean {
|
|
116
|
+
for (const field of fields) {
|
|
117
|
+
let fieldInvalid = false;
|
|
118
|
+
if (Array.isArray(field.fieldGroup)) {
|
|
119
|
+
fieldInvalid = this.isAnyFieldInvalid(field.fieldGroup);
|
|
120
|
+
} else if (typeof field.type !== 'undefined') {
|
|
121
|
+
fieldInvalid = !field.formControl?.valid;
|
|
122
|
+
}
|
|
123
|
+
if (fieldInvalid) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private updateFormModel(item?: T) {
|
|
131
|
+
this.formOrigItem = item;
|
|
132
|
+
// TODO: to check if this is ok, could be problems with dates, if so, try lodash
|
|
133
|
+
const formModel = JSON.parse(JSON.stringify(item ?? {}));
|
|
134
|
+
|
|
135
|
+
this.descriptor.fields.forEach(field => {
|
|
136
|
+
if (field.getter && item) {
|
|
137
|
+
formModel[field.property] = field.getter(item);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
if (typeof this.formOptions.resetModel === 'function') { // could not be initiated yet
|
|
141
|
+
this.formOptions.resetModel(this.formModel);
|
|
142
|
+
}
|
|
143
|
+
this.formModel = formModel;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private updateFormState() {
|
|
147
|
+
this.formOptions.formState.disabled = this.isFormDisabled !== null ? this.isFormDisabled === true : this.descriptor.disabled;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<mng-autocomplete [id]="$any(key)"
|
|
2
|
+
[formControl]="aFormControl"
|
|
3
|
+
[formlyAttributes]="field"
|
|
4
|
+
[dataProvider]="$any(descriptor.dataProvider)"
|
|
5
|
+
[dataKeyProperty]="$any(descriptor.dataKeyProperty)"
|
|
6
|
+
[itemsLabelProperty]="$any(descriptor.itemsLabelProperty)">
|
|
7
|
+
</mng-autocomplete>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
|
2
|
+
import {FormControl} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import {FieldType} from '@ngx-formly/core';
|
|
5
|
+
import {FieldLookupDescriptor} from '../../../../../descriptors';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'mng-formly-field-autocomplete',
|
|
9
|
+
templateUrl: './formly-field-autocomplete.component.html',
|
|
10
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
11
|
+
})
|
|
12
|
+
export class MngFormlyFieldAutocompleteComponent<T> extends FieldType {
|
|
13
|
+
|
|
14
|
+
public aFormControl!: FormControl;
|
|
15
|
+
public descriptor!: FieldLookupDescriptor<T, any>;
|
|
16
|
+
|
|
17
|
+
public ngOnInit() {
|
|
18
|
+
this.aFormControl = this.formControl as FormControl;
|
|
19
|
+
this.descriptor = this.to['descriptor'];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<mng-dropdown [id]="$any(key)"
|
|
2
|
+
[formControl]="dFormControl"
|
|
3
|
+
[formlyAttributes]="field"
|
|
4
|
+
[placeholder]="$any(descriptor.placeholder)"
|
|
5
|
+
[itemsLabelProperty]="$any(descriptor.itemsLabelProperty)"
|
|
6
|
+
[itemsValueProperty]="$any(descriptor.itemsValueProperty)"
|
|
7
|
+
[showClear]="!this.to.required"
|
|
8
|
+
[dataKeyProperty]="$any(descriptor.dataKeyProperty)">
|
|
9
|
+
</mng-dropdown>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
|
2
|
+
import {FormControl} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import {FieldType} from '@ngx-formly/core';
|
|
5
|
+
|
|
6
|
+
import {FieldLookupDescriptor} from '../../../../../descriptors';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'mng-formly-field-dropdown',
|
|
10
|
+
templateUrl: './formly-field-dropdown.component.html',
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
+
})
|
|
13
|
+
export class MngFormlyFieldDropdownComponent<T> extends FieldType {
|
|
14
|
+
|
|
15
|
+
public dFormControl!: FormControl;
|
|
16
|
+
public descriptor!: FieldLookupDescriptor<T, any>;
|
|
17
|
+
|
|
18
|
+
public ngOnInit() {
|
|
19
|
+
this.dFormControl = this.formControl as FormControl;
|
|
20
|
+
this.descriptor = this.to['descriptor'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<ng-container *ngFor="let group of field.fieldGroup; let i = index; let last = last;">
|
|
2
|
+
<p-fieldset *ngIf="!group.templateOptions?.['descriptor']?.default; else defaultSet" [legend]="group.templateOptions?.label! | translate">
|
|
3
|
+
<formly-field [field]="group"></formly-field>
|
|
4
|
+
</p-fieldset>
|
|
5
|
+
<ng-template #defaultSet>
|
|
6
|
+
<formly-field [field]="group"></formly-field>
|
|
7
|
+
</ng-template>
|
|
8
|
+
</ng-container>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {Component, ChangeDetectionStrategy} from '@angular/core';
|
|
2
|
+
import { FieldType } from '@ngx-formly/core';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'mng-formly-field-fieldset',
|
|
6
|
+
templateUrl: './formly-field-fieldset.component.html',
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
})
|
|
9
|
+
export class MngFormlyFieldFieldsetComponent extends FieldType {
|
|
10
|
+
}
|
package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.html
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<ng-container [ngSwitch]="to.type">
|
|
2
|
+
<p-inputNumber *ngSwitchCase="'number'"
|
|
3
|
+
[id]="$any(key)"
|
|
4
|
+
[formControl]="iFormControl"
|
|
5
|
+
[formlyAttributes]="field"
|
|
6
|
+
[min]="$any(descriptor.numberMin)"
|
|
7
|
+
[max]="$any(descriptor.numberMax)"
|
|
8
|
+
[step]="$any(descriptor.numberStep)"
|
|
9
|
+
[minFractionDigits]="descriptor.numberMinFractionDigits || 0"
|
|
10
|
+
[maxFractionDigits]="descriptor.numberMaxFractionDigits || 0">
|
|
11
|
+
</p-inputNumber>
|
|
12
|
+
|
|
13
|
+
<div *ngSwitchCase="'switch'" class="flex flex-column">
|
|
14
|
+
<label [for]="key">{{ to?.label! | translate }} <span *ngIf="to.required && to['hideRequiredMarker'] !== true">*</span></label>
|
|
15
|
+
<p-inputSwitch [id]="$any(key)"
|
|
16
|
+
[formControl]="iFormControl"
|
|
17
|
+
[formlyAttributes]="field">
|
|
18
|
+
</p-inputSwitch>
|
|
19
|
+
<small *ngIf="showError" class="p-error">
|
|
20
|
+
<formly-validation-message [field]="field"></formly-validation-message>
|
|
21
|
+
</small>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<ng-container *ngSwitchCase="'radio'">
|
|
25
|
+
<div *ngFor="let category of descriptor.radioOptions" [id]="$any(key)" class="p-field-radiobutton">
|
|
26
|
+
<p-radioButton [value]="category" [formControl]="iFormControl" [formlyAttributes]="field"></p-radioButton>
|
|
27
|
+
<label [for]="category" class="mng-radio-button-label">{{category}}</label>
|
|
28
|
+
</div>
|
|
29
|
+
</ng-container>
|
|
30
|
+
|
|
31
|
+
<textarea *ngSwitchCase="'textarea'"
|
|
32
|
+
[id]="$any(key)"
|
|
33
|
+
[formControl]="iFormControl"
|
|
34
|
+
[formlyAttributes]="field"
|
|
35
|
+
[rows]="descriptor.rows ?? 3"
|
|
36
|
+
pInputTextarea>
|
|
37
|
+
</textarea>
|
|
38
|
+
|
|
39
|
+
<p-calendar *ngSwitchCase="'datepicker'"
|
|
40
|
+
[formControl]="iFormControl"
|
|
41
|
+
[formlyAttributes]="field"
|
|
42
|
+
[dateFormat]="$any(descriptor.datePickerFormat)"
|
|
43
|
+
[minDate]="$any(descriptor.datePickerMin)"
|
|
44
|
+
[maxDate]="$any(descriptor.datePickerMax)"
|
|
45
|
+
[showTime]="descriptor.datePickerShowTime"
|
|
46
|
+
[showIcon]="true">
|
|
47
|
+
</p-calendar>
|
|
48
|
+
|
|
49
|
+
<input *ngSwitchDefault
|
|
50
|
+
pInputText
|
|
51
|
+
[id]="$any(key)"
|
|
52
|
+
[type]="to.type || 'text'"
|
|
53
|
+
[formControl]="iFormControl"
|
|
54
|
+
[formlyAttributes]="field"
|
|
55
|
+
/>
|
|
56
|
+
</ng-container>
|
package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Component, ChangeDetectionStrategy, OnInit} from '@angular/core';
|
|
2
|
+
import {FormControl} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import { FieldType } from '@ngx-formly/core';
|
|
5
|
+
|
|
6
|
+
import {FieldInputDescriptor} from '../../../../../descriptors';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'mng-formly-field-input',
|
|
10
|
+
templateUrl: './formly-field-input.component.html',
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
+
})
|
|
13
|
+
export class MngFormlyFieldInputComponent extends FieldType implements OnInit {
|
|
14
|
+
|
|
15
|
+
public iFormControl!: FormControl;
|
|
16
|
+
public descriptor!: FieldInputDescriptor<any>;
|
|
17
|
+
|
|
18
|
+
ngOnInit(): void {
|
|
19
|
+
this.iFormControl = this.formControl as FormControl;
|
|
20
|
+
this.descriptor = this.to['descriptor'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<mng-table [descriptor]="descriptor.tableDescriptor" [items]="items$">
|
|
2
|
+
<ng-template mngTemplate="caption">
|
|
3
|
+
<div class="flex flex-column md:flex-row md:justify-content-end table-header">
|
|
4
|
+
<label class="mng-datatable-form-label p-m-0" [for]="key">{{ to?.label! | translate }} <span *ngIf="to.required && to['hideRequiredMarker'] !== true">*</span></label>
|
|
5
|
+
<mng-action *ngFor="let action of toolbarActions" [action]="action"></mng-action>
|
|
6
|
+
</div>
|
|
7
|
+
</ng-template>
|
|
8
|
+
<ng-template mngTemplate="columnAction" let-item="rowItem" let-idx="rowIndex">
|
|
9
|
+
<mng-action *ngFor="let action of rowActions"
|
|
10
|
+
[action]="action" [item]="item" [itemId]="descriptor.tableviewDescriptor.model.idPropertyName ? item[descriptor.tableviewDescriptor.model.idPropertyName] : undefined" [actionData]="{ itemIndex: idx }">
|
|
11
|
+
</mng-action>
|
|
12
|
+
</ng-template>
|
|
13
|
+
</mng-table>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import {FieldType} from '@ngx-formly/core';
|
|
4
|
+
import {Observable, of, ReplaySubject, Subject, Subscription} from 'rxjs';
|
|
5
|
+
import {startWith} from 'rxjs/operators';
|
|
6
|
+
|
|
7
|
+
import {FieldManyEditorDescriptor, ActionDescriptor, ActionEditorDescriptor, ActionLevelEnum} from '../../../../../descriptors';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'mng-formly-table-dialog-form-field',
|
|
11
|
+
templateUrl: './formly-field-table-dialog-form.component.html',
|
|
12
|
+
styleUrls: ['./formly-field-table-dialog-form.component.scss'],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
14
|
+
})
|
|
15
|
+
export class MngFormlyFieldTableDialogFormComponent<T, ET> extends FieldType implements OnInit, OnDestroy {
|
|
16
|
+
|
|
17
|
+
public descriptor!: FieldManyEditorDescriptor<T, ET>;
|
|
18
|
+
|
|
19
|
+
public itemsSubject: Subject<Array<T>> = new ReplaySubject(1);
|
|
20
|
+
public items$: Observable<Array<T>> = this.itemsSubject.asObservable();
|
|
21
|
+
|
|
22
|
+
public toolbarActions: Array<ActionDescriptor<T>> = [];
|
|
23
|
+
public rowActions: Array<ActionDescriptor<T>> = [];
|
|
24
|
+
|
|
25
|
+
private subscriptions: Subscription[] = [];
|
|
26
|
+
|
|
27
|
+
public ngOnInit() {
|
|
28
|
+
|
|
29
|
+
this.descriptor = this.to['descriptor'];
|
|
30
|
+
const hasAddAction = this.descriptor.actions.some(a => a === FieldManyEditorDescriptor.ActionEnum.Add);
|
|
31
|
+
const hasEditAction = this.descriptor.actions.some(a => a === FieldManyEditorDescriptor.ActionEnum.Edit);
|
|
32
|
+
const hasDeleteAction = this.descriptor.actions.some(a => a === FieldManyEditorDescriptor.ActionEnum.Delete);
|
|
33
|
+
|
|
34
|
+
if (hasAddAction) {
|
|
35
|
+
console.log(this.descriptor.tableviewDescriptor.addEditor);
|
|
36
|
+
const addAction = new ActionEditorDescriptor(this.descriptor.tableviewDescriptor.addEditor, 'add', this.descriptor.editor.model.type, this.descriptor.property)
|
|
37
|
+
.withTitle(null)
|
|
38
|
+
.withIcon('pi pi-plus')
|
|
39
|
+
.withClassName('mng-formly-field-table-form-dialog')
|
|
40
|
+
.withSubmitFunction(ctx => {
|
|
41
|
+
if (!ctx.data?.item) {
|
|
42
|
+
throw new Error(`No item was provided in context, edit cannot be done.`);
|
|
43
|
+
}
|
|
44
|
+
this.formState.submittedOn = Date.now();
|
|
45
|
+
let value = this.formControl.value;
|
|
46
|
+
value = [...value, ctx.data.item];
|
|
47
|
+
this.formControl.patchValue(value);
|
|
48
|
+
return of(ctx.data.item);
|
|
49
|
+
})
|
|
50
|
+
.withIsVisibleFunction(ctx => of(!this.options?.formState.disabled));
|
|
51
|
+
this.toolbarActions.push(addAction as ActionDescriptor<T>);
|
|
52
|
+
}
|
|
53
|
+
if (hasEditAction) {
|
|
54
|
+
const editAction = new ActionEditorDescriptor(this.descriptor.tableviewDescriptor.editEditor, 'edit', this.descriptor.editor.model.type, this.descriptor.property)
|
|
55
|
+
.withTitle(null)
|
|
56
|
+
.withIcon('pi pi-pencil')
|
|
57
|
+
.withClassName('mng-formly-field-table-form-dialog')
|
|
58
|
+
.withSubmitFunction(ctx => {
|
|
59
|
+
if (!ctx.data?.item) {
|
|
60
|
+
throw new Error(`No item was provided in context, edit cannot be done.`);
|
|
61
|
+
}
|
|
62
|
+
this.formState.submittedOn = Date.now();
|
|
63
|
+
let formControlValue = this.formControl.value;
|
|
64
|
+
formControlValue[ctx.data.actionData?.['itemIndex']] = ctx.data.item;
|
|
65
|
+
this.formControl.patchValue(formControlValue);
|
|
66
|
+
return of(ctx.data.item);
|
|
67
|
+
})
|
|
68
|
+
.withIsVisibleFunction(ctx => of(!this.options?.formState.disabled));
|
|
69
|
+
this.rowActions.push(editAction as ActionDescriptor<T>);
|
|
70
|
+
}
|
|
71
|
+
if (hasDeleteAction) {
|
|
72
|
+
const deleteAction = new ActionDescriptor(this.descriptor.tableviewDescriptor.model, 'delete', this.descriptor.editor.model.type, this.descriptor.property)
|
|
73
|
+
.withLevel(ActionLevelEnum.Danger)
|
|
74
|
+
.withTitle(null)
|
|
75
|
+
.withIcon('pi pi-trash')
|
|
76
|
+
.withRunFunction(ctx => {
|
|
77
|
+
if (!ctx.data?.item) {
|
|
78
|
+
throw new Error(`No item was provided in context, delete cannot be done.`);
|
|
79
|
+
}
|
|
80
|
+
let formControlValue = this.formControl.value;
|
|
81
|
+
const compareProperty = this.descriptor.tableDescriptor.dataKeyProperty ? this.descriptor.tableDescriptor.dataKeyProperty : this.descriptor.tableDescriptor.model.idPropertyName;
|
|
82
|
+
if (!compareProperty) {
|
|
83
|
+
throw new Error('Cannot compare items, please provide main table data key property or model id property.');
|
|
84
|
+
}
|
|
85
|
+
const ctxItem: any = ctx.data.item;
|
|
86
|
+
if (!ctxItem?.[compareProperty]) {
|
|
87
|
+
return formControlValue;
|
|
88
|
+
}
|
|
89
|
+
formControlValue = formControlValue.filter((i: any) => i[compareProperty] !== ctxItem[compareProperty]);
|
|
90
|
+
this.formControl.patchValue(formControlValue);
|
|
91
|
+
return of(ctx.data.item);
|
|
92
|
+
})
|
|
93
|
+
.withIsVisibleFunction(ctx => of(!this.options?.formState.disabled));
|
|
94
|
+
this.rowActions.push(deleteAction);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// init values
|
|
98
|
+
if (typeof this.formControl.value === 'undefined' || this.formControl.value === null) {
|
|
99
|
+
this.formControl.patchValue([]);
|
|
100
|
+
}
|
|
101
|
+
const subscription = this.formControl.valueChanges
|
|
102
|
+
.pipe(
|
|
103
|
+
startWith(this.formControl.value)
|
|
104
|
+
)
|
|
105
|
+
.subscribe(v => {
|
|
106
|
+
this.itemsSubject.next(v);
|
|
107
|
+
});
|
|
108
|
+
this.subscriptions.push(subscription);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public ngOnDestroy() {
|
|
112
|
+
this.subscriptions.forEach(s => s.unsubscribe());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<mng-table [descriptor]="descriptor.mainTableDescriptor" [items]="itemsAsync">
|
|
2
|
+
<ng-template mngTemplate="caption">
|
|
3
|
+
<div class="flex flex-column md:flex-row md:justify-content-end table-header">
|
|
4
|
+
<label class="mng-datatable-form-label p-m-0" [for]="key">{{ to?.label! | translate }} <span *ngIf="to.required && to['hideRequiredMarker'] !== true">*</span></label>
|
|
5
|
+
<button *ngIf="hasAddAction && !formControl.disabled" pButton pRipple type="button" icon="pi pi-plus" class="p-button-rounded p-button-success"
|
|
6
|
+
(click)="openAddDialog()">
|
|
7
|
+
</button>
|
|
8
|
+
</div>
|
|
9
|
+
</ng-template>
|
|
10
|
+
<ng-template mngTemplate="columnAction" let-item="rowItem">
|
|
11
|
+
<button *ngIf="hasDeleteAction && !formControl.disabled" pButton pRipple type="button" icon="pi pi-trash" class="p-button-rounded p-button-danger"
|
|
12
|
+
(click)="removeItem(item)">
|
|
13
|
+
</button>
|
|
14
|
+
</ng-template>
|
|
15
|
+
</mng-table>
|
|
16
|
+
|
|
17
|
+
<p-dialog *ngIf="hasAddAction" [(visible)]="isDialogVisible"
|
|
18
|
+
[draggable]="false"
|
|
19
|
+
[header]="'general.addItem' | translate: {item: to?.label!}"
|
|
20
|
+
[modal]="true"
|
|
21
|
+
appendTo="body"
|
|
22
|
+
styleClass="p-fluid mng-formly-field-table-multiselect-dialog">
|
|
23
|
+
<ng-template pTemplate="content">
|
|
24
|
+
<mng-table [descriptor]="descriptor.mainTableDescriptor"
|
|
25
|
+
[queryResult]="addItemsAsync"
|
|
26
|
+
[selectionEnabled]="true"
|
|
27
|
+
[loading]="dialogIsLoading$"
|
|
28
|
+
(onSelectionChange)="onSelectionChange($event)">
|
|
29
|
+
</mng-table>
|
|
30
|
+
<p-messages [value]="dialogMessages"></p-messages>
|
|
31
|
+
</ng-template>
|
|
32
|
+
|
|
33
|
+
<ng-template pTemplate="footer">
|
|
34
|
+
<button pButton pRipple type="button" [label]="'general.cancel' | translate" icon="pi pi-times" class="p-button-text" (click)="hideDialog()"></button>
|
|
35
|
+
<button pButton pRipple type="button" [label]="'general.add' | translate" icon="pi pi-check" class="p-button-text" (click)="addItems()" [loading]="(dialogIsLoading$ | async) ?? false" [disabled]="form.disabled"></button>
|
|
36
|
+
</ng-template>
|
|
37
|
+
</p-dialog>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, Injector, OnDestroy, OnInit} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import {FieldType} from '@ngx-formly/core';
|
|
4
|
+
import {Message} from 'primeng/api';
|
|
5
|
+
import {finalize, first, startWith} from 'rxjs/operators';
|
|
6
|
+
import {Observable, ReplaySubject, Subject, Subscription} from 'rxjs';
|
|
7
|
+
|
|
8
|
+
import {MediusFilterMatchType, MediusQueryParamBuilder, MediusQueryResult} from '../../../../../api/models';
|
|
9
|
+
import {FieldManyToManyEditorDescriptor} from '../../../../../descriptors';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'mng-formly-table-multiselect-add-field',
|
|
13
|
+
templateUrl: './formly-field-table-dialog-multiselect.component.html',
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
15
|
+
})
|
|
16
|
+
export class MngFormlyFieldTableDialogMultiselectComponent<T, ET> extends FieldType implements OnInit, OnDestroy {
|
|
17
|
+
|
|
18
|
+
public descriptor!: FieldManyToManyEditorDescriptor<T, ET>;
|
|
19
|
+
|
|
20
|
+
public itemsSubject: Subject<Array<T>> = new ReplaySubject(1);
|
|
21
|
+
public itemsAsync: Observable<Array<T>> = this.itemsSubject.asObservable();
|
|
22
|
+
public addItemsSubject: Subject<MediusQueryResult<T>> = new ReplaySubject(1);
|
|
23
|
+
public addItemsAsync: Observable<MediusQueryResult<T>> = this.addItemsSubject.asObservable();
|
|
24
|
+
|
|
25
|
+
public dialogUseDataProvider: boolean = false;
|
|
26
|
+
private dialogDataProviderService: any = null;
|
|
27
|
+
private dialogIsLoadingSubject = new ReplaySubject<boolean>(1);
|
|
28
|
+
|
|
29
|
+
public isDialogVisible = false;
|
|
30
|
+
public dialogAreItemsLoaded = false;
|
|
31
|
+
public dialogSelectedAddItems: Array<any> = [];
|
|
32
|
+
public dialogMessages: Message[] = [];
|
|
33
|
+
public dialogIsLoading$ = this.dialogIsLoadingSubject.asObservable();
|
|
34
|
+
|
|
35
|
+
public hasAddAction: boolean = false;
|
|
36
|
+
public hasDeleteAction: boolean = false;
|
|
37
|
+
|
|
38
|
+
private subscriptions: Subscription[] = [];
|
|
39
|
+
|
|
40
|
+
constructor(private injector: Injector) {
|
|
41
|
+
super();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public ngOnInit() {
|
|
45
|
+
|
|
46
|
+
this.descriptor = this.to['descriptor'];
|
|
47
|
+
if (this.descriptor.lookupTableDataProvider?.serviceType) {
|
|
48
|
+
this.dialogUseDataProvider = true;
|
|
49
|
+
this.dialogDataProviderService = this.injector.get<any>(this.descriptor.lookupTableDataProvider.serviceType);
|
|
50
|
+
}
|
|
51
|
+
this.hasAddAction = this.descriptor.actions.some(a => a === FieldManyToManyEditorDescriptor.ActionEnum.Add);
|
|
52
|
+
this.hasDeleteAction = this.descriptor.actions.some(a => a === FieldManyToManyEditorDescriptor.ActionEnum.Delete);
|
|
53
|
+
|
|
54
|
+
// init values
|
|
55
|
+
if (typeof this.formControl.value === 'undefined' || this.formControl.value === null) {
|
|
56
|
+
this.formControl.patchValue([]);
|
|
57
|
+
}
|
|
58
|
+
const subscription = this.formControl.valueChanges
|
|
59
|
+
.pipe(
|
|
60
|
+
startWith(this.formControl.value)
|
|
61
|
+
)
|
|
62
|
+
.subscribe(v => {
|
|
63
|
+
this.itemsSubject.next(v);
|
|
64
|
+
});
|
|
65
|
+
this.subscriptions.push(subscription);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public ngOnDestroy() {
|
|
69
|
+
this.subscriptions.forEach(s => s.unsubscribe());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
openAddDialog() {
|
|
73
|
+
if (!this.dialogAreItemsLoaded && this.dialogUseDataProvider) {
|
|
74
|
+
this.dialogIsLoadingSubject.next(true);
|
|
75
|
+
const queryParamBuilder = MediusQueryParamBuilder.create(50);
|
|
76
|
+
if (this.descriptor.lookupTableDescriptor.hasDefaultSort) {
|
|
77
|
+
this.descriptor.lookupTableDescriptor.defaultSortProperty.forEach((p, idx) => queryParamBuilder.withSort(p, this.descriptor.lookupTableDescriptor.defaultSortAsc[idx]));
|
|
78
|
+
}
|
|
79
|
+
if (this.descriptor.hasLookupExcludeValues) {
|
|
80
|
+
const filterValues = this.formControl.value.map((i: any) => i[this.descriptor.excludeValueProperty])
|
|
81
|
+
queryParamBuilder.withFilter(this.descriptor.excludeFilterProperty, filterValues, undefined, MediusFilterMatchType.NotIn);
|
|
82
|
+
}
|
|
83
|
+
this.descriptor.lookupTableDataProvider?.getAll(queryParamBuilder.build(), this.dialogDataProviderService)
|
|
84
|
+
.pipe(
|
|
85
|
+
first(),
|
|
86
|
+
finalize(() => this.dialogIsLoadingSubject.next(false))
|
|
87
|
+
)
|
|
88
|
+
.subscribe(res => {
|
|
89
|
+
this.addItemsSubject.next(res);
|
|
90
|
+
this.dialogAreItemsLoaded = true;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
this.dialogSelectedAddItems = [];
|
|
94
|
+
this.isDialogVisible = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onSelectionChange(items: Array<any>) {
|
|
98
|
+
this.dialogSelectedAddItems = items;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
hideDialog() {
|
|
102
|
+
this.isDialogVisible = false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
addItems() {
|
|
106
|
+
let value = this.formControl.value;
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
value = [...value, ...this.dialogSelectedAddItems];
|
|
109
|
+
this.formControl.patchValue(value);
|
|
110
|
+
this.dialogSelectedAddItems = [];
|
|
111
|
+
this.dialogAreItemsLoaded = false;
|
|
112
|
+
this.hideDialog();
|
|
113
|
+
} else {
|
|
114
|
+
console.error("Values are not an valid array, cannot add selected items to array");
|
|
115
|
+
this.dialogMessages = [{ severity: 'error', summary: 'Error', detail: 'Selected items could not be added' }];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
removeItem(item: any) {
|
|
120
|
+
let value = this.formControl.value;
|
|
121
|
+
if (Array.isArray(value)) {
|
|
122
|
+
const compareProperty = this.descriptor.mainTableDescriptor.dataKeyProperty ? this.descriptor.mainTableDescriptor.dataKeyProperty : this.descriptor.mainTableDescriptor.model.idPropertyName;
|
|
123
|
+
if (!compareProperty) {
|
|
124
|
+
throw new Error('Cannot compare items, please provide main table data key property or model id property.');
|
|
125
|
+
}
|
|
126
|
+
value = value.filter(i => i[compareProperty] !== item[compareProperty]);
|
|
127
|
+
this.formControl.patchValue(value);
|
|
128
|
+
this.dialogAreItemsLoaded = false;
|
|
129
|
+
} else {
|
|
130
|
+
console.error("Values are not an valid array, cannot delete selected item from array");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<p-tabView>
|
|
2
|
+
<p-tabPanel *ngFor="let tab of field.fieldGroup; let i = index; let last = last;"
|
|
3
|
+
[header]="tab.templateOptions?.label!"
|
|
4
|
+
[headerStyleClass]="formControl.valid ? 'p-tabview-title' : 'bla'">
|
|
5
|
+
<ng-template pTemplate="header">
|
|
6
|
+
<span class="p-tabview-title" [class.p-tabview-title-error]="formState.submittedOn && formState['tab_' + (tab.id ? tab.id : tab.templateOptions?.label!) + '_invalid']">{{ tab.templateOptions?.label! | translate }}</span>
|
|
7
|
+
</ng-template>
|
|
8
|
+
<formly-field [field]="tab"></formly-field>
|
|
9
|
+
</p-tabPanel>
|
|
10
|
+
</p-tabView>
|
package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {Component, ChangeDetectionStrategy} from '@angular/core';
|
|
2
|
+
import { FieldType } from '@ngx-formly/core';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'mng-formly-field-tabs',
|
|
6
|
+
templateUrl: './formly-field-tabs.component.html',
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
})
|
|
9
|
+
export class MngFormlyFieldTabsComponent extends FieldType {
|
|
10
|
+
}
|