monkey-front-components 0.0.381 → 0.0.384
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/karma.conf.js +44 -0
- package/monkey-front-components-0.0.384.tgz +0 -0
- package/ng-package.json +10 -0
- package/package.json +7 -27
- package/src/lib/components/base/base-component.ts +359 -0
- package/src/lib/components/base/base-dynamic-array.ts +233 -0
- package/src/lib/components/base/base-dynamic.ts +90 -0
- package/src/lib/components/base/base-scroll-component.ts +52 -0
- package/src/lib/components/base/base-validators.ts +19 -0
- package/{lib/components/base/index.d.ts → src/lib/components/base/index.ts} +5 -5
- package/src/lib/components/dynamic/button/button.component.html +4 -0
- package/src/lib/components/dynamic/button/button.component.scss +7 -0
- package/src/lib/components/dynamic/button/button.component.ts +47 -0
- package/{lib/components/dynamic/button/index.d.ts → src/lib/components/dynamic/button/index.ts} +1 -1
- package/src/lib/components/dynamic/dynamic-directive.ts +102 -0
- package/src/lib/components/dynamic/dynamic.module.ts +53 -0
- package/src/lib/components/dynamic/file-upload/file-upload.component.html +10 -0
- package/src/lib/components/dynamic/file-upload/file-upload.component.ts +46 -0
- package/{lib/components/dynamic/file-upload/index.d.ts → src/lib/components/dynamic/file-upload/index.ts} +1 -1
- package/src/lib/components/dynamic/form/dynamic-form-array.component.html +19 -0
- package/src/lib/components/dynamic/form/dynamic-form-array.component.scss +10 -0
- package/src/lib/components/dynamic/form/dynamic-form-array.component.ts +75 -0
- package/src/lib/components/dynamic/form/dynamic-form.component.html +7 -0
- package/src/lib/components/dynamic/form/dynamic-form.component.ts +49 -0
- package/{lib/components/dynamic/form/index.d.ts → src/lib/components/dynamic/form/index.ts} +2 -2
- package/{lib/components/dynamic/index.d.ts → src/lib/components/dynamic/index.ts} +8 -8
- package/{lib/components/dynamic/input/index.d.ts → src/lib/components/dynamic/input/index.ts} +1 -1
- package/src/lib/components/dynamic/input/input.component.html +9 -0
- package/src/lib/components/dynamic/input/input.component.ts +58 -0
- package/{lib/components/dynamic/input-phone/index.d.ts → src/lib/components/dynamic/input-phone/index.ts} +1 -1
- package/src/lib/components/dynamic/input-phone/input-phone.component.html +7 -0
- package/src/lib/components/dynamic/input-phone/input-phone.component.ts +58 -0
- package/{lib/components/dynamic/radio/index.d.ts → src/lib/components/dynamic/radio/index.ts} +1 -1
- package/src/lib/components/dynamic/radio/radio.component.html +8 -0
- package/src/lib/components/dynamic/radio/radio.component.ts +22 -0
- package/{lib/components/dynamic/select/index.d.ts → src/lib/components/dynamic/select/index.ts} +1 -1
- package/src/lib/components/dynamic/select/select.component.html +14 -0
- package/src/lib/components/dynamic/select/select.component.ts +75 -0
- package/{lib/components/dynamic/select-search/index.d.ts → src/lib/components/dynamic/select-search/index.ts} +1 -1
- package/src/lib/components/dynamic/select-search/select-search.component.html +15 -0
- package/src/lib/components/dynamic/select-search/select-search.component.ts +76 -0
- package/{lib/components/index.d.ts → src/lib/components/index.ts} +3 -3
- package/src/lib/components/shared/filter/filter.component.html +51 -0
- package/src/lib/components/shared/filter/filter.component.scss +79 -0
- package/src/lib/components/shared/filter/filter.component.ts +117 -0
- package/src/lib/components/shared/filter/filter.module.ts +36 -0
- package/{lib/components/shared/filter/index.d.ts → src/lib/components/shared/filter/index.ts} +2 -2
- package/{lib/components/shared/filter/menu/index.d.ts → src/lib/components/shared/filter/menu/index.ts} +1 -1
- package/src/lib/components/shared/filter/menu/menu.component.html +28 -0
- package/src/lib/components/shared/filter/menu/menu.component.scss +62 -0
- package/src/lib/components/shared/filter/menu/menu.component.ts +122 -0
- package/src/lib/components/shared/filter/menu/menu.module.ts +41 -0
- package/src/lib/components/shared/filter/options/children/children.component.html +6 -0
- package/src/lib/components/shared/filter/options/children/children.component.scss +30 -0
- package/src/lib/components/shared/filter/options/children/children.component.ts +58 -0
- package/{lib/components/shared/filter/options/children/index.d.ts → src/lib/components/shared/filter/options/children/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/currency/currency.component.html +3 -0
- package/src/lib/components/shared/filter/options/currency/currency.component.scss +19 -0
- package/src/lib/components/shared/filter/options/currency/currency.component.ts +52 -0
- package/{lib/components/shared/filter/options/currency/index.d.ts → src/lib/components/shared/filter/options/currency/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/date-range/date-range.component.html +3 -0
- package/src/lib/components/shared/filter/options/date-range/date-range.component.scss +34 -0
- package/src/lib/components/shared/filter/options/date-range/date-range.component.ts +72 -0
- package/{lib/components/shared/filter/options/date-range/index.d.ts → src/lib/components/shared/filter/options/date-range/index.ts} +1 -1
- package/{lib/components/shared/filter/options/index.d.ts → src/lib/components/shared/filter/options/index.ts} +1 -1
- package/{lib/components/shared/filter/options/input/index.d.ts → src/lib/components/shared/filter/options/input/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/input/input.component.html +3 -0
- package/src/lib/components/shared/filter/options/input/input.component.scss +19 -0
- package/src/lib/components/shared/filter/options/input/input.component.ts +52 -0
- package/src/lib/components/shared/filter/options/options.component.html +43 -0
- package/src/lib/components/shared/filter/options/options.component.scss +56 -0
- package/src/lib/components/shared/filter/options/options.component.ts +58 -0
- package/src/lib/components/shared/filter/options/options.module.ts +58 -0
- package/{lib/components/shared/filter/options/status/index.d.ts → src/lib/components/shared/filter/options/status/index.ts} +1 -1
- package/src/lib/components/shared/filter/options/status/status.component.html +4 -0
- package/src/lib/components/shared/filter/options/status/status.component.scss +29 -0
- package/src/lib/components/shared/filter/options/status/status.component.ts +73 -0
- package/{lib/components/shared/filter/selected/index.d.ts → src/lib/components/shared/filter/selected/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/children/children.component.html +19 -0
- package/src/lib/components/shared/filter/selected/item/children/children.component.scss +68 -0
- package/src/lib/components/shared/filter/selected/item/children/children.component.ts +49 -0
- package/{lib/components/shared/filter/selected/item/children/index.d.ts → src/lib/components/shared/filter/selected/item/children/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/currency/currency.component.ts +26 -0
- package/{lib/components/shared/filter/selected/item/currency/index.d.ts → src/lib/components/shared/filter/selected/item/currency/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.html +2 -0
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/date-range/date-range.component.ts +39 -0
- package/{lib/components/shared/filter/selected/item/date-range/index.d.ts → src/lib/components/shared/filter/selected/item/date-range/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.ts +29 -0
- package/{lib/components/shared/filter/selected/item/date-with-action/index.d.ts → src/lib/components/shared/filter/selected/item/date-with-action/index.ts} +1 -1
- package/{lib/components/shared/filter/selected/item/index.d.ts → src/lib/components/shared/filter/selected/item/index.ts} +7 -7
- package/{lib/components/shared/filter/selected/item/input/index.d.ts → src/lib/components/shared/filter/selected/item/input/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/input/input.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/input/input.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/input/input.component.ts +26 -0
- package/src/lib/components/shared/filter/selected/item/item.component.html +38 -0
- package/src/lib/components/shared/filter/selected/item/item.component.scss +72 -0
- package/src/lib/components/shared/filter/selected/item/item.component.ts +71 -0
- package/{lib/components/shared/filter/selected/item/status/index.d.ts → src/lib/components/shared/filter/selected/item/status/index.ts} +1 -1
- package/src/lib/components/shared/filter/selected/item/status/status.component.html +1 -0
- package/src/lib/components/shared/filter/selected/item/status/status.component.scss +4 -0
- package/src/lib/components/shared/filter/selected/item/status/status.component.ts +36 -0
- package/src/lib/components/shared/filter/selected/selected.component.html +3 -0
- package/src/lib/components/shared/filter/selected/selected.component.scss +9 -0
- package/src/lib/components/shared/filter/selected/selected.component.ts +76 -0
- package/src/lib/components/shared/filter/selected/selected.module.ts +60 -0
- package/{lib/components/shared/index.d.ts → src/lib/components/shared/index.ts} +4 -4
- package/{lib/components/shared/password-strength/index.d.ts → src/lib/components/shared/password-strength/index.ts} +2 -2
- package/src/lib/components/shared/password-strength/password-strength.component.html +50 -0
- package/src/lib/components/shared/password-strength/password-strength.component.scss +70 -0
- package/src/lib/components/shared/password-strength/password-strength.component.ts +89 -0
- package/src/lib/components/shared/password-strength/password-strength.module.ts +24 -0
- package/src/lib/components/shared/password-strength/password-strength.ts +5 -0
- package/src/lib/components/shared/products/filter/filter.component.html +6 -0
- package/src/lib/components/shared/products/filter/filter.component.scss +20 -0
- package/src/lib/components/shared/products/filter/filter.component.ts +34 -0
- package/{lib/components/shared/products/index.d.ts → src/lib/components/shared/products/index.ts} +2 -2
- package/src/lib/components/shared/products/products.component.html +15 -0
- package/src/lib/components/shared/products/products.component.scss +70 -0
- package/src/lib/components/shared/products/products.component.ts +104 -0
- package/src/lib/components/shared/products/products.module.ts +13 -0
- package/{lib/components/shared/products/providers/index.d.ts → src/lib/components/shared/products/providers/index.ts} +1 -1
- package/src/lib/components/shared/products/providers/products.model.ts +60 -0
- package/{lib/components/shared/progress-bar/index.d.ts → src/lib/components/shared/progress-bar/index.ts} +3 -3
- package/src/lib/components/shared/progress-bar/progress-bar.component.html +3 -0
- package/src/lib/components/shared/progress-bar/progress-bar.component.scss +6 -0
- package/src/lib/components/shared/progress-bar/progress-bar.component.ts +27 -0
- package/src/lib/components/shared/progress-bar/progress-bar.module.ts +10 -0
- package/src/lib/components/shared/progress-bar/progress-bar.service.ts +59 -0
- package/src/lib/interfaces/field-config.ts +58 -0
- package/{lib/interfaces/index.d.ts → src/lib/interfaces/index.ts} +1 -1
- package/src/public-api.ts +5 -0
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2020/lib/components/base/base-component.mjs +0 -322
- package/esm2020/lib/components/base/base-dynamic-array.mjs +0 -221
- package/esm2020/lib/components/base/base-dynamic.mjs +0 -99
- package/esm2020/lib/components/base/base-scroll-component.mjs +0 -55
- package/esm2020/lib/components/base/base-validators.mjs +0 -19
- package/esm2020/lib/components/base/index.mjs +0 -6
- package/esm2020/lib/components/dynamic/button/button.component.mjs +0 -52
- package/esm2020/lib/components/dynamic/button/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/dynamic-directive.mjs +0 -95
- package/esm2020/lib/components/dynamic/dynamic.module.mjs +0 -84
- package/esm2020/lib/components/dynamic/file-upload/file-upload.component.mjs +0 -52
- package/esm2020/lib/components/dynamic/file-upload/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/form/dynamic-form-array.component.mjs +0 -72
- package/esm2020/lib/components/dynamic/form/dynamic-form.component.mjs +0 -46
- package/esm2020/lib/components/dynamic/form/index.mjs +0 -3
- package/esm2020/lib/components/dynamic/index.mjs +0 -9
- package/esm2020/lib/components/dynamic/input/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/input/input.component.mjs +0 -65
- package/esm2020/lib/components/dynamic/input-phone/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/input-phone/input-phone.component.mjs +0 -65
- package/esm2020/lib/components/dynamic/radio/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/radio/radio.component.mjs +0 -33
- package/esm2020/lib/components/dynamic/select/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/select/select.component.mjs +0 -80
- package/esm2020/lib/components/dynamic/select-search/index.mjs +0 -2
- package/esm2020/lib/components/dynamic/select-search/select-search.component.mjs +0 -80
- package/esm2020/lib/components/index.mjs +0 -4
- package/esm2020/lib/components/shared/filter/filter.component.mjs +0 -119
- package/esm2020/lib/components/shared/filter/filter.module.mjs +0 -63
- package/esm2020/lib/components/shared/filter/index.mjs +0 -3
- package/esm2020/lib/components/shared/filter/menu/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/menu/menu.component.mjs +0 -120
- package/esm2020/lib/components/shared/filter/menu/menu.module.mjs +0 -70
- package/esm2020/lib/components/shared/filter/options/children/children.component.mjs +0 -50
- package/esm2020/lib/components/shared/filter/options/children/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/currency/currency.component.mjs +0 -46
- package/esm2020/lib/components/shared/filter/options/currency/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/date-range/date-range.component.mjs +0 -65
- package/esm2020/lib/components/shared/filter/options/date-range/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/input/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/input/input.component.mjs +0 -46
- package/esm2020/lib/components/shared/filter/options/options.component.mjs +0 -68
- package/esm2020/lib/components/shared/filter/options/options.module.mjs +0 -95
- package/esm2020/lib/components/shared/filter/options/status/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/options/status/status.component.mjs +0 -66
- package/esm2020/lib/components/shared/filter/selected/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/children/children.component.mjs +0 -57
- package/esm2020/lib/components/shared/filter/selected/item/children/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/currency/currency.component.mjs +0 -29
- package/esm2020/lib/components/shared/filter/selected/item/currency/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/date-range/date-range.component.mjs +0 -42
- package/esm2020/lib/components/shared/filter/selected/item/date-range/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.mjs +0 -33
- package/esm2020/lib/components/shared/filter/selected/item/date-with-action/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/index.mjs +0 -8
- package/esm2020/lib/components/shared/filter/selected/item/input/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/input/input.component.mjs +0 -28
- package/esm2020/lib/components/shared/filter/selected/item/item.component.mjs +0 -74
- package/esm2020/lib/components/shared/filter/selected/item/status/index.mjs +0 -2
- package/esm2020/lib/components/shared/filter/selected/item/status/status.component.mjs +0 -39
- package/esm2020/lib/components/shared/filter/selected/selected.component.mjs +0 -80
- package/esm2020/lib/components/shared/filter/selected/selected.module.mjs +0 -90
- package/esm2020/lib/components/shared/index.mjs +0 -5
- package/esm2020/lib/components/shared/password-strength/index.mjs +0 -3
- package/esm2020/lib/components/shared/password-strength/password-strength.component.mjs +0 -85
- package/esm2020/lib/components/shared/password-strength/password-strength.mjs +0 -2
- package/esm2020/lib/components/shared/password-strength/password-strength.module.mjs +0 -50
- package/esm2020/lib/components/shared/products/filter/filter.component.mjs +0 -36
- package/esm2020/lib/components/shared/products/index.mjs +0 -3
- package/esm2020/lib/components/shared/products/products.component.mjs +0 -91
- package/esm2020/lib/components/shared/products/products.module.mjs +0 -22
- package/esm2020/lib/components/shared/products/providers/index.mjs +0 -2
- package/esm2020/lib/components/shared/products/providers/products.model.mjs +0 -38
- package/esm2020/lib/components/shared/progress-bar/index.mjs +0 -4
- package/esm2020/lib/components/shared/progress-bar/progress-bar.component.mjs +0 -28
- package/esm2020/lib/components/shared/progress-bar/progress-bar.module.mjs +0 -18
- package/esm2020/lib/components/shared/progress-bar/progress-bar.service.mjs +0 -49
- package/esm2020/lib/interfaces/field-config.mjs +0 -2
- package/esm2020/lib/interfaces/index.mjs +0 -2
- package/esm2020/monkey-front-components.mjs +0 -5
- package/esm2020/public-api.mjs +0 -5
- package/fesm2015/monkey-front-components.mjs +0 -2877
- package/fesm2015/monkey-front-components.mjs.map +0 -1
- package/fesm2020/monkey-front-components.mjs +0 -2859
- package/fesm2020/monkey-front-components.mjs.map +0 -1
- package/lib/components/base/base-component.d.ts +0 -50
- package/lib/components/base/base-dynamic-array.d.ts +0 -34
- package/lib/components/base/base-dynamic.d.ts +0 -24
- package/lib/components/base/base-scroll-component.d.ts +0 -16
- package/lib/components/base/base-validators.d.ts +0 -1
- package/lib/components/dynamic/button/button.component.d.ts +0 -17
- package/lib/components/dynamic/dynamic-directive.d.ts +0 -22
- package/lib/components/dynamic/dynamic.module.d.ts +0 -20
- package/lib/components/dynamic/file-upload/file-upload.component.d.ts +0 -17
- package/lib/components/dynamic/form/dynamic-form-array.component.d.ts +0 -16
- package/lib/components/dynamic/form/dynamic-form.component.d.ts +0 -14
- package/lib/components/dynamic/input/input.component.d.ts +0 -20
- package/lib/components/dynamic/input-phone/input-phone.component.d.ts +0 -20
- package/lib/components/dynamic/radio/radio.component.d.ts +0 -11
- package/lib/components/dynamic/select/select.component.d.ts +0 -16
- package/lib/components/dynamic/select-search/select-search.component.d.ts +0 -16
- package/lib/components/shared/filter/filter.component.d.ts +0 -32
- package/lib/components/shared/filter/filter.module.d.ts +0 -14
- package/lib/components/shared/filter/menu/menu.component.d.ts +0 -24
- package/lib/components/shared/filter/menu/menu.module.d.ts +0 -14
- package/lib/components/shared/filter/options/children/children.component.d.ts +0 -17
- package/lib/components/shared/filter/options/currency/currency.component.d.ts +0 -17
- package/lib/components/shared/filter/options/date-range/date-range.component.d.ts +0 -24
- package/lib/components/shared/filter/options/input/input.component.d.ts +0 -17
- package/lib/components/shared/filter/options/options.component.d.ts +0 -20
- package/lib/components/shared/filter/options/options.module.d.ts +0 -18
- package/lib/components/shared/filter/options/status/status.component.d.ts +0 -19
- package/lib/components/shared/filter/selected/item/children/children.component.d.ts +0 -16
- package/lib/components/shared/filter/selected/item/currency/currency.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/date-range/date-range.component.d.ts +0 -12
- package/lib/components/shared/filter/selected/item/date-with-action/date-with-action.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/input/input.component.d.ts +0 -11
- package/lib/components/shared/filter/selected/item/item.component.d.ts +0 -20
- package/lib/components/shared/filter/selected/item/status/status.component.d.ts +0 -13
- package/lib/components/shared/filter/selected/selected.component.d.ts +0 -18
- package/lib/components/shared/filter/selected/selected.module.d.ts +0 -21
- package/lib/components/shared/password-strength/password-strength.component.d.ts +0 -23
- package/lib/components/shared/password-strength/password-strength.d.ts +0 -5
- package/lib/components/shared/password-strength/password-strength.module.d.ts +0 -12
- package/lib/components/shared/products/filter/filter.component.d.ts +0 -12
- package/lib/components/shared/products/products.component.d.ts +0 -20
- package/lib/components/shared/products/products.module.d.ts +0 -11
- package/lib/components/shared/products/providers/products.model.d.ts +0 -13
- package/lib/components/shared/progress-bar/progress-bar.component.d.ts +0 -12
- package/lib/components/shared/progress-bar/progress-bar.module.d.ts +0 -8
- package/lib/components/shared/progress-bar/progress-bar.service.d.ts +0 -14
- package/lib/interfaces/field-config.d.ts +0 -54
- package/monkey-front-components-0.0.381.tgz +0 -0
- package/monkey-front-components.d.ts +0 -5
- package/public-api.d.ts +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Directive, EventEmitter, Input, OnInit, OnChanges, Output } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { MonkeyUtils } from 'monkey-style-guide';
|
|
4
|
+
import { MECXFieldConfig, MECXFieldConfigValidator } from '../../interfaces';
|
|
5
|
+
import { BaseComponent } from './base-component';
|
|
6
|
+
import { validators } from './base-validators';
|
|
7
|
+
|
|
8
|
+
@Directive({
|
|
9
|
+
selector: '[baseDynamic]'
|
|
10
|
+
})
|
|
11
|
+
export abstract class BaseDynamic extends BaseComponent implements OnInit, OnChanges {
|
|
12
|
+
@Input() onHandleSubmit = new EventEmitter<any>();
|
|
13
|
+
|
|
14
|
+
@Input() onHandleUpdateForm = new EventEmitter<any>();
|
|
15
|
+
|
|
16
|
+
@Output() onHandleSubmitFormReady: EventEmitter<any> = new EventEmitter<any>();
|
|
17
|
+
|
|
18
|
+
@Input() self: any;
|
|
19
|
+
|
|
20
|
+
@Input() fields: MECXFieldConfig[] = [];
|
|
21
|
+
|
|
22
|
+
@Input() data: any;
|
|
23
|
+
|
|
24
|
+
@Input() disabled: boolean = false;
|
|
25
|
+
|
|
26
|
+
_form: FormGroup | null = null;
|
|
27
|
+
|
|
28
|
+
constructor(private fb: FormBuilder) {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private createControl() {
|
|
33
|
+
const { fields } = this;
|
|
34
|
+
if (!fields) return null;
|
|
35
|
+
// eslint-disable-next-line object-curly-newline
|
|
36
|
+
const group = this.fb.group({});
|
|
37
|
+
fields.forEach((field: MECXFieldConfig) => {
|
|
38
|
+
const { fieldType, validations, name, disabled } = field;
|
|
39
|
+
let { value } = field;
|
|
40
|
+
if (fieldType === 'button') return;
|
|
41
|
+
if (fieldType === 'radiobutton' || fieldType === 'checkbox' || fieldType === 'select') {
|
|
42
|
+
value = '';
|
|
43
|
+
}
|
|
44
|
+
const control = this.fb.control(value, this.bindValidations(validations || []));
|
|
45
|
+
if (disabled || this.disabled) control.disable();
|
|
46
|
+
group.addControl(name as string, control);
|
|
47
|
+
});
|
|
48
|
+
return group;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private bindValidations(validations: MECXFieldConfigValidator[]) {
|
|
52
|
+
if (validations.length > 0) {
|
|
53
|
+
const validList: any[] = [];
|
|
54
|
+
validations.forEach((valid: MECXFieldConfigValidator) => {
|
|
55
|
+
const validated = valid.param
|
|
56
|
+
? validators[valid.name](valid.param)
|
|
57
|
+
: validators[valid.name];
|
|
58
|
+
validList.push(validated);
|
|
59
|
+
});
|
|
60
|
+
return Validators.compose(validList);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public fillValues() {
|
|
66
|
+
const { data } = this;
|
|
67
|
+
if (!data || !this._form) return;
|
|
68
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
69
|
+
if (MonkeyUtils.persistNullEmptyUndefined(value) && this._form?.controls[key]) {
|
|
70
|
+
this._form?.controls[key]?.setValue(value);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ngOnInit() {
|
|
76
|
+
this._form = this.createControl();
|
|
77
|
+
this.fillValues();
|
|
78
|
+
|
|
79
|
+
this.onHandleUpdateForm.subscribe(() => {
|
|
80
|
+
this.fillValues();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ngOnChanges() {
|
|
85
|
+
if (!this._form) {
|
|
86
|
+
this._form = this.createControl();
|
|
87
|
+
}
|
|
88
|
+
this.fillValues();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { Directive, OnInit } from '@angular/core';
|
|
3
|
+
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
|
|
4
|
+
import { BaseComponent } from './base-component';
|
|
5
|
+
|
|
6
|
+
@Directive({
|
|
7
|
+
selector: '[baseScrollComponent]'
|
|
8
|
+
})
|
|
9
|
+
export abstract class BaseScrollComponent extends BaseComponent implements OnInit {
|
|
10
|
+
private routeScrollPositions: { [url: string]: number } = {};
|
|
11
|
+
|
|
12
|
+
constructor(private _pId: Object, private _rt: Router) {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private saveScroll(url: string) {
|
|
17
|
+
const element: any = document.getElementById('container-3');
|
|
18
|
+
this.routeScrollPositions[url] = element.scrollTop;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private restoreScroll(url: string) {
|
|
22
|
+
const savedScroll = this.routeScrollPositions[url];
|
|
23
|
+
const element: any = document.getElementById('container-3');
|
|
24
|
+
if (!savedScroll) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
element.scrollTop = savedScroll;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private addScrollTopListeners() {
|
|
32
|
+
if ('scrollRestoration' in history) {
|
|
33
|
+
history.scrollRestoration = 'manual';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this._rt.events.subscribe(event => {
|
|
37
|
+
if (event instanceof NavigationStart) {
|
|
38
|
+
this.saveScroll(this._rt.url);
|
|
39
|
+
} else if (event instanceof NavigationEnd) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
this.restoreScroll(event.url);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ngOnInit(): void {
|
|
48
|
+
if (isPlatformBrowser(this._pId)) {
|
|
49
|
+
this.addScrollTopListeners();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Validators as Validators_ } from '@angular/forms';
|
|
2
|
+
import { Validators } from 'monkey-front-core';
|
|
3
|
+
|
|
4
|
+
export const validators: any = {
|
|
5
|
+
required: Validators_.required,
|
|
6
|
+
email: Validators.email,
|
|
7
|
+
governmentId: Validators.documentBR,
|
|
8
|
+
governmentIdRut: Validators.documentCL,
|
|
9
|
+
documentBR: Validators.documentBR,
|
|
10
|
+
documentCL: Validators.documentCL,
|
|
11
|
+
date: Validators.date,
|
|
12
|
+
zipCode: Validators.zipCode,
|
|
13
|
+
minLength: (param: number) => {
|
|
14
|
+
return Validators_.minLength(param);
|
|
15
|
+
},
|
|
16
|
+
maxLength: (param: number) => {
|
|
17
|
+
return Validators_.maxLength(param);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './base-component';
|
|
2
|
-
export * from './base-dynamic-array';
|
|
3
|
-
export * from './base-dynamic';
|
|
4
|
-
export * from './base-scroll-component';
|
|
5
|
-
export * from './base-validators';
|
|
1
|
+
export * from './base-component';
|
|
2
|
+
export * from './base-dynamic-array';
|
|
3
|
+
export * from './base-dynamic';
|
|
4
|
+
export * from './base-scroll-component';
|
|
5
|
+
export * from './base-validators';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, HostBinding, Input, OnChanges, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { FormGroup } from '@angular/forms';
|
|
3
|
+
import { MECXFieldConfig } from '../../../interfaces';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'mecx-dynamic-button',
|
|
7
|
+
templateUrl: './button.component.html',
|
|
8
|
+
styleUrls: ['./button.component.scss'],
|
|
9
|
+
encapsulation: ViewEncapsulation.None
|
|
10
|
+
})
|
|
11
|
+
export class MECXDynamicButtonComponent implements OnChanges {
|
|
12
|
+
@Input() _field: MECXFieldConfig | null = null;
|
|
13
|
+
|
|
14
|
+
@Input() _form: FormGroup | null = null;
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line object-curly-newline
|
|
17
|
+
@Input() _formErrors: any | any[] = {};
|
|
18
|
+
|
|
19
|
+
@Input() self: any;
|
|
20
|
+
|
|
21
|
+
constructor(private cdr: ChangeDetectorRef) {
|
|
22
|
+
// not to do
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@HostBinding('class')
|
|
26
|
+
get className() {
|
|
27
|
+
return this._field?.style?.class;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ngOnChanges() {
|
|
31
|
+
this.cdr.detectChanges();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onClick() {
|
|
35
|
+
const { _form, _field, self } = this;
|
|
36
|
+
if (_form?.disabled || !_field) return;
|
|
37
|
+
const { name, value } = _field;
|
|
38
|
+
const func = _field?.functions?.onClick;
|
|
39
|
+
if (func) {
|
|
40
|
+
self[func]({
|
|
41
|
+
name,
|
|
42
|
+
value,
|
|
43
|
+
form: _form
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/{lib/components/dynamic/button/index.d.ts → src/lib/components/dynamic/button/index.ts}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './button.component';
|
|
1
|
+
export * from './button.component';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
ComponentFactoryResolver,
|
|
4
|
+
Directive,
|
|
5
|
+
Input,
|
|
6
|
+
OnChanges,
|
|
7
|
+
OnInit,
|
|
8
|
+
ViewContainerRef
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { FormGroup } from '@angular/forms';
|
|
11
|
+
import { MECXFieldConfig } from '../../interfaces';
|
|
12
|
+
import { MECXDynamicButtonComponent } from './button';
|
|
13
|
+
import { MECXDynamicFileUploadComponent } from './file-upload';
|
|
14
|
+
import { MECXDynamicInputComponent } from './input';
|
|
15
|
+
import { MECXDynamicInputPhoneComponent } from './input-phone';
|
|
16
|
+
import { MECXDynamicRadioComponent } from './radio';
|
|
17
|
+
import { MECXDynamicSelectComponent } from './select';
|
|
18
|
+
import { MECXDynamicSelectSearchComponent } from './select-search';
|
|
19
|
+
|
|
20
|
+
const componentMapper: any = {
|
|
21
|
+
input: MECXDynamicInputComponent,
|
|
22
|
+
'input-phone': MECXDynamicInputPhoneComponent,
|
|
23
|
+
radiobutton: MECXDynamicRadioComponent,
|
|
24
|
+
select: MECXDynamicSelectComponent,
|
|
25
|
+
'select-search': MECXDynamicSelectSearchComponent,
|
|
26
|
+
'file-upload': MECXDynamicFileUploadComponent,
|
|
27
|
+
button: MECXDynamicButtonComponent
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
@Directive({
|
|
31
|
+
selector: '[MECXDynamic]'
|
|
32
|
+
})
|
|
33
|
+
export class MECXDynamicDirective implements OnInit, OnChanges {
|
|
34
|
+
@Input() field: MECXFieldConfig | null = null;
|
|
35
|
+
|
|
36
|
+
@Input() form: FormGroup | null = null;
|
|
37
|
+
|
|
38
|
+
@Input() formErrors: any;
|
|
39
|
+
|
|
40
|
+
@Input() self: any;
|
|
41
|
+
|
|
42
|
+
@Input() plusValidations: any;
|
|
43
|
+
|
|
44
|
+
componentRef: any;
|
|
45
|
+
|
|
46
|
+
constructor(private resolver: ComponentFactoryResolver, private container: ViewContainerRef,
|
|
47
|
+
private cdr: ChangeDetectorRef) {
|
|
48
|
+
// not to do
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private handleInternalPlusValidation() {
|
|
52
|
+
if (!this.field?.alwaysShowPlusValidation) return false;
|
|
53
|
+
const { operator, value, field } = this.field?.alwaysShowPlusValidation;
|
|
54
|
+
const validators: any = {
|
|
55
|
+
e: (val1: any, val2: string) => { return val1 === val2; },
|
|
56
|
+
lt: (val1: any, val2: string) => { return val1 < val2; },
|
|
57
|
+
gt: (val1: any, val2: string) => { return val1 > val2; }
|
|
58
|
+
};
|
|
59
|
+
const data = this.form?.controls[field as string]?.value;
|
|
60
|
+
|
|
61
|
+
return validators[operator as string](data, value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private buildComponent() {
|
|
65
|
+
if (this.componentRef?.instance) return;
|
|
66
|
+
const factory = this.resolver.resolveComponentFactory(
|
|
67
|
+
componentMapper[this.field?.fieldType as string]
|
|
68
|
+
);
|
|
69
|
+
this.componentRef = this.container.createComponent(factory);
|
|
70
|
+
this.componentRef.instance._field = this.field;
|
|
71
|
+
this.componentRef.instance._form = this.form;
|
|
72
|
+
// eslint-disable-next-line object-curly-newline
|
|
73
|
+
this.componentRef.instance._formErrors = this.formErrors || {};
|
|
74
|
+
this.componentRef.instance.self = this.self;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ngOnInit() {
|
|
78
|
+
if (!this.field?.alwaysShow && !this.handleInternalPlusValidation()) return;
|
|
79
|
+
this.buildComponent();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ngOnChanges() {
|
|
83
|
+
if (this.plusValidations && this.plusValidations[this.field?.name as string]) {
|
|
84
|
+
if (!this.field?.alwaysShow && this.plusValidations[this.field?.name as string].alwaysShow) {
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
this.buildComponent();
|
|
87
|
+
this.cdr.detectChanges();
|
|
88
|
+
}, 1);
|
|
89
|
+
}
|
|
90
|
+
if (this.componentRef?.instance &&
|
|
91
|
+
!this.plusValidations[this.field?.name as string].alwaysShow) {
|
|
92
|
+
this.componentRef.destroy();
|
|
93
|
+
this.componentRef = null;
|
|
94
|
+
this.form?.controls[this.field?.name as string]?.setValue(null);
|
|
95
|
+
this.form?.controls[this.field?.name as string]?.clearValidators();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!this.componentRef?.instance) return;
|
|
99
|
+
this.componentRef.instance._formErrors = this.formErrors || {
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
import {
|
|
6
|
+
MonkeyButtonModule,
|
|
7
|
+
MonkeyFileUploadModule,
|
|
8
|
+
MonkeyInputModule,
|
|
9
|
+
MonkeyInputPhoneModule,
|
|
10
|
+
MonkeyOptionModule,
|
|
11
|
+
MonkeyRadioButtonModule,
|
|
12
|
+
MonkeySelectModule
|
|
13
|
+
} from 'monkey-style-guide';
|
|
14
|
+
import { MECXDynamicButtonComponent } from './button';
|
|
15
|
+
import { MECXDynamicDirective } from './dynamic-directive';
|
|
16
|
+
import { MECXDynamicFileUploadComponent } from './file-upload';
|
|
17
|
+
import { MECXDynamicFormComponent, MECXDynamicFormArrayComponent } from './form';
|
|
18
|
+
import { MECXDynamicInputComponent } from './input';
|
|
19
|
+
import { MECXDynamicInputPhoneComponent } from './input-phone';
|
|
20
|
+
import { MECXDynamicRadioComponent } from './radio';
|
|
21
|
+
import { MECXDynamicSelectComponent } from './select';
|
|
22
|
+
import { MECXDynamicSelectSearchComponent } from './select-search';
|
|
23
|
+
|
|
24
|
+
@NgModule({
|
|
25
|
+
declarations: [
|
|
26
|
+
MECXDynamicButtonComponent,
|
|
27
|
+
MECXDynamicFileUploadComponent,
|
|
28
|
+
MECXDynamicFormComponent,
|
|
29
|
+
MECXDynamicFormArrayComponent,
|
|
30
|
+
MECXDynamicInputComponent,
|
|
31
|
+
MECXDynamicInputPhoneComponent,
|
|
32
|
+
MECXDynamicRadioComponent,
|
|
33
|
+
MECXDynamicSelectComponent,
|
|
34
|
+
MECXDynamicSelectSearchComponent,
|
|
35
|
+
MECXDynamicDirective
|
|
36
|
+
],
|
|
37
|
+
imports: [
|
|
38
|
+
CommonModule,
|
|
39
|
+
FormsModule,
|
|
40
|
+
ReactiveFormsModule,
|
|
41
|
+
MonkeyInputModule,
|
|
42
|
+
MonkeySelectModule,
|
|
43
|
+
MonkeyRadioButtonModule,
|
|
44
|
+
MonkeyOptionModule,
|
|
45
|
+
MonkeyFileUploadModule,
|
|
46
|
+
MonkeyButtonModule,
|
|
47
|
+
MonkeyInputPhoneModule,
|
|
48
|
+
TranslateModule.forChild()
|
|
49
|
+
],
|
|
50
|
+
exports: [MECXDynamicDirective, MECXDynamicFormComponent, MECXDynamicFormArrayComponent],
|
|
51
|
+
entryComponents: [MECXDynamicInputComponent]
|
|
52
|
+
})
|
|
53
|
+
export class MECXDynamicModule {}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<monkey-file-upload
|
|
2
|
+
errorMessage="{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}"
|
|
3
|
+
[icon]="_field?.icon" [formControl]="_form.controls[_field?.name]"
|
|
4
|
+
[placeholder]="_field?.placeholder | translate"
|
|
5
|
+
[helperMessage]="_field?.helperMessage | translate" [label]="_field?.label | translate"
|
|
6
|
+
[maxSize]="_field?.maxSize || 5242880" [fileUpload]="_function"
|
|
7
|
+
[maxSizeErrorMessage]="'FIELD.FILE.MAX-FILE' | translate"
|
|
8
|
+
[allowedExtensionErrorMessage]="'FIELD.FILE.ALLOWED-EXTENSION' | translate"
|
|
9
|
+
[allowedExtensions]="_field?.allowedExtensions || []" *ngIf="_field">
|
|
10
|
+
</monkey-file-upload>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, HostBinding, Input, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { FormGroup } from '@angular/forms';
|
|
3
|
+
import { MECXFieldConfig } from '../../../interfaces';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'mecx-dynamic-file-upload',
|
|
7
|
+
templateUrl: './file-upload.component.html',
|
|
8
|
+
encapsulation: ViewEncapsulation.None
|
|
9
|
+
})
|
|
10
|
+
export class MECXDynamicFileUploadComponent {
|
|
11
|
+
@Input() _field: MECXFieldConfig;
|
|
12
|
+
|
|
13
|
+
@Input() _form: FormGroup;
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line object-curly-newline
|
|
16
|
+
@Input() _formErrors: any | any[] = {};
|
|
17
|
+
|
|
18
|
+
@Input() self: any;
|
|
19
|
+
|
|
20
|
+
_function: Function = (file: any, callback?: Function) => {
|
|
21
|
+
if (this._form?.disabled) return;
|
|
22
|
+
if (!this._field?.functions?.onHandleUpload) {
|
|
23
|
+
console.error('onHandleUpload not declared');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const { func, type } = this._field?.functions?.onHandleUpload;
|
|
27
|
+
if (!func || !this.self[func]) {
|
|
28
|
+
console.error('onHandleUpload not declared');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.self[func](file, type, callback);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
constructor(private cdr: ChangeDetectorRef) {
|
|
35
|
+
// not to do
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@HostBinding('class')
|
|
39
|
+
get className() {
|
|
40
|
+
return this._field?.style?.class;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ngOnChanges() {
|
|
44
|
+
this.cdr.detectChanges();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './file-upload.component';
|
|
1
|
+
export * from './file-upload.component';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<form name="form" [formGroup]="_form" *ngIf="_form">
|
|
2
|
+
<div formArrayName="fields">
|
|
3
|
+
<div *ngFor="let item of formValues.controls; let indForm=index" [formGroupName]="indForm">
|
|
4
|
+
<monkey-button type="secondary" color="error" icon="close-20" iconPosition="right"
|
|
5
|
+
[label]="'BUTTONS.REMOVE' | translate" (click)="onHandleRemove(indForm)"
|
|
6
|
+
*ngIf="formValues.controls.length > 1 && !disabled">
|
|
7
|
+
</monkey-button>
|
|
8
|
+
<div class="row mt-3">
|
|
9
|
+
<div *ngFor="let field of fields;" MECXDynamic [field]="field" [form]="item" [self]="self"
|
|
10
|
+
[formErrors]="__monkeyecxFormErrors[indForm]"
|
|
11
|
+
[plusValidations]="_plusValidations[indForm]" [style.display]="'none'">
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</form>
|
|
17
|
+
<monkey-button type="secondary" color="theme" icon="more-20" iconPosition="right"
|
|
18
|
+
[label]="'BUTTONS.ADD' | translate" (click)="onHandleAdd()" *ngIf="!disabled">
|
|
19
|
+
</monkey-button>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Component, OnInit, ViewEncapsulation, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
import { BaseDynamicArray } from '../../base';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'mecx-dynamic-form-array',
|
|
9
|
+
templateUrl: './dynamic-form-array.component.html',
|
|
10
|
+
styleUrls: ['./dynamic-form-array.component.scss'],
|
|
11
|
+
encapsulation: ViewEncapsulation.None
|
|
12
|
+
})
|
|
13
|
+
export class MECXDynamicFormArrayComponent extends BaseDynamicArray implements OnInit, OnDestroy {
|
|
14
|
+
private unsubscribeAll = new Subject();
|
|
15
|
+
|
|
16
|
+
constructor(fb: FormBuilder, private cdr: ChangeDetectorRef) {
|
|
17
|
+
super(fb);
|
|
18
|
+
this.__monkeyecxFormErrors = [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ngOnInit() {
|
|
22
|
+
super.ngOnInit();
|
|
23
|
+
|
|
24
|
+
this.onHandleSubmit.pipe(takeUntil(this.unsubscribeAll)).subscribe((func: Function) => {
|
|
25
|
+
this.onSubmit(func);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ngOnDestroy() {
|
|
30
|
+
this.unsubscribeAll.next();
|
|
31
|
+
this.unsubscribeAll.complete();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onSubmit(callback: Function) {
|
|
35
|
+
const { _form } = this;
|
|
36
|
+
// eslint-disable-next-line object-curly-newline
|
|
37
|
+
this.__monkeyecxFormErrors = [];
|
|
38
|
+
|
|
39
|
+
let validate = {
|
|
40
|
+
isValid: false
|
|
41
|
+
};
|
|
42
|
+
let hasErrors: boolean = false;
|
|
43
|
+
if (this.formValues) {
|
|
44
|
+
this.__monkeyecxFormErrors = [this.formValues.length];
|
|
45
|
+
this.formValues.controls.forEach((item: any, index: number) => {
|
|
46
|
+
if (item instanceof FormGroup) {
|
|
47
|
+
if (!this.validateForm(item, index)) {
|
|
48
|
+
hasErrors = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
validate = {
|
|
54
|
+
isValid: !hasErrors
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.cdr.detectChanges();
|
|
58
|
+
|
|
59
|
+
this.onHandleSubmitFormReady.next({
|
|
60
|
+
validate,
|
|
61
|
+
callback,
|
|
62
|
+
form: _form
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onHandleAdd() {
|
|
67
|
+
this.formValues?.push(this.formBase() as any);
|
|
68
|
+
this.cdr.detectChanges();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onHandleRemove(index: number) {
|
|
72
|
+
this.formValues?.removeAt(index);
|
|
73
|
+
this._plusValidations.splice(index, 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component, OnInit, ViewEncapsulation, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { FormBuilder } from '@angular/forms';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
import { BaseDynamic } from '../../base/base-dynamic';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'mecx-dynamic-form',
|
|
9
|
+
templateUrl: './dynamic-form.component.html',
|
|
10
|
+
styles: [],
|
|
11
|
+
encapsulation: ViewEncapsulation.None
|
|
12
|
+
})
|
|
13
|
+
export class MECXDynamicFormComponent extends BaseDynamic implements OnInit, OnDestroy {
|
|
14
|
+
private unsubscribeAll = new Subject();
|
|
15
|
+
|
|
16
|
+
constructor(fb: FormBuilder, private cdr: ChangeDetectorRef) {
|
|
17
|
+
super(fb);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ngOnInit() {
|
|
21
|
+
super.ngOnInit();
|
|
22
|
+
|
|
23
|
+
this.onHandleSubmit.pipe(takeUntil(this.unsubscribeAll)).subscribe((func: Function) => {
|
|
24
|
+
this.onSubmit(func);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ngOnDestroy() {
|
|
29
|
+
this.unsubscribeAll.next();
|
|
30
|
+
this.unsubscribeAll.complete();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onSubmit(callback: Function) {
|
|
34
|
+
const { _form } = this;
|
|
35
|
+
// eslint-disable-next-line object-curly-newline
|
|
36
|
+
this.__monkeyecxFormErrors = {};
|
|
37
|
+
|
|
38
|
+
const isValid = this.validateForm(_form as any);
|
|
39
|
+
this.cdr.detectChanges();
|
|
40
|
+
|
|
41
|
+
this.onHandleSubmitFormReady.next({
|
|
42
|
+
validate: {
|
|
43
|
+
isValid
|
|
44
|
+
},
|
|
45
|
+
callback,
|
|
46
|
+
form: _form
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './dynamic-form.component';
|
|
2
|
-
export * from './dynamic-form-array.component';
|
|
1
|
+
export * from './dynamic-form.component';
|
|
2
|
+
export * from './dynamic-form-array.component';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './file-upload';
|
|
2
|
-
export * from './form';
|
|
3
|
-
export * from './input';
|
|
4
|
-
export * from './input-phone';
|
|
5
|
-
export * from './radio';
|
|
6
|
-
export * from './select';
|
|
7
|
-
export * from './dynamic-directive';
|
|
8
|
-
export * from './dynamic.module';
|
|
1
|
+
export * from './file-upload';
|
|
2
|
+
export * from './form';
|
|
3
|
+
export * from './input';
|
|
4
|
+
export * from './input-phone';
|
|
5
|
+
export * from './radio';
|
|
6
|
+
export * from './select';
|
|
7
|
+
export * from './dynamic-directive';
|
|
8
|
+
export * from './dynamic.module';
|
package/{lib/components/dynamic/input/index.d.ts → src/lib/components/dynamic/input/index.ts}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './input.component';
|
|
1
|
+
export * from './input.component';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<monkey-input
|
|
2
|
+
errorMessage="{{ _formErrors[_field?.name]?.firstMessage | translate }} {{ _formErrors[_field?.name]?.lastMessage }}"
|
|
3
|
+
[mask]="_field?.mask" [prefix]="_field?.prefix" [name]="_field?.name"
|
|
4
|
+
[formControl]="_form.controls[_field?.name]" [placeholder]="_field?.placeholder | translate"
|
|
5
|
+
[helperMessage]="_field?.helperMessage | translate" [label]="_field?.label | translate"
|
|
6
|
+
[type]="_field?.type" #inputElement (onChange)="onChange($event)"
|
|
7
|
+
[onlyNumber]="_field?.onlyNumber" [currency]="_field?.currency" [maxLength]="_field?.maxLength"
|
|
8
|
+
[maxDateToday]="_field?.maxDateToday">
|
|
9
|
+
</monkey-input>
|