Skip to content

Commit dfe08ac

Browse files
committed
Merge branch 'master' into feature/generic-types
2 parents 9432f95 + d765e4f commit dfe08ac

35 files changed

+1283
-390
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
id: extended-form-array
3+
title: ExtendedFormArray
4+
sidebar_label: ExtendedFormArray
5+
---
6+
7+
`ExtendedFormArray` extends `FormArray`. Tracks the value and validity state of its elements - `FormControl`, `FormGroup`, `FormStore` or `FormArray` instances.
8+
9+
## Constructor
10+
11+
```ts
12+
constructor(
13+
controls: Array<AbstractControl>,
14+
validatorOrOpts?: ValidatorFn | Array<ValidatorFn> | AbstractControlOptions | null,
15+
asyncValidator?: AsyncValidatorFn | Array<AsyncValidatorFn> | null,
16+
propertyOptions?: PropertyOptions
17+
)
18+
```
19+
20+
## Properties
21+
22+
### get isChanged
23+
24+
Returns `true` if current value is not equal to initial value, `false` otherwise.
25+
26+
| Property | Return type |
27+
| --------- | ------------- |
28+
| `get isChanged()` | `boolean` |
29+
30+
### get currentValue
31+
32+
Returns the current value of the control.
33+
34+
| Property | Return type |
35+
| --------- | ------------- |
36+
| `get currentValue()` | `Array<any>` |
37+
38+
### get currentRawValue
39+
40+
Returns the current value of the array, regardless of the `disabled` status of its controls .
41+
42+
| Property | Return type |
43+
| --------- | ------------- |
44+
| `get currentRawValue()` | `Array<any>` |
45+
46+
### initialValue
47+
48+
Getter and setter for initial value of the control.
49+
50+
| Property | Return type |
51+
| --------- | ------------- |
52+
| `get initialValue()` | `Array<any>` |
53+
| `set initialValue()` | `Array<any>` |
54+
55+
## Methods
56+
57+
### clear()
58+
59+
Removes all controls from the array. If `clearFlags` is `true` it also resets the array making it `pristine` and `untouched`, and sets the current value to `[]`.
60+
61+
| Method | Return type |
62+
| --------- | ------------- |
63+
| `clear(clearFlags?: boolean)` | `void` |
64+
65+
### replaceWith()
66+
67+
Replaces all controls from the array with new ones. If `clearFlags` is `true` it also resets the array making it `pristine` and `untouched`.
68+
69+
| Method | Return type |
70+
| --------- | ------------- |
71+
| `replaceWith(newItems: Array<any>, clearFlags?: boolean)` | `void` |
72+
73+
### resetValue()
74+
75+
Resets the underlying form control, marking it `pristine` and `untouched` and sets the current and initial value to the one provided. If no value argument is provided, sets those values to `control.currentValue`.
76+
77+
| Method | Return type |
78+
| --------- | ------------- |
79+
| `resetValue(value?: any)` | `value: any` |
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
id: extended-form-control
3+
title: ExtendedFormControl
4+
sidebar_label: ExtendedFormControl
5+
---
6+
7+
`ExtendedFormControl` extends `FormControl`. Tracks the value and validation status of an individual form control.
8+
9+
## Constructor
10+
11+
```ts
12+
constructor(
13+
formState?: any,
14+
validator?: ValidatorFn | Array<ValidatorFn>,
15+
asyncValidator?: AsyncValidatorFn | Array<AsyncValidatorFn>,
16+
isRelationship?: boolean,
17+
propertyOptions?: PropertyOptions
18+
)
19+
```
20+
21+
## Properties
22+
23+
### get isChanged
24+
25+
Returns `true` if current value is not equal to initial value, `false` otherwise.
26+
27+
| Property | Return type |
28+
| --------- | ------------- |
29+
| `get isChanged()` | `boolean` |
30+
31+
### get currentValue
32+
33+
Returns the current value of the control.
34+
35+
| Property | Return type |
36+
| --------- | ------------- |
37+
| `get currentValue()` | `any` |
38+
39+
### initialValue
40+
41+
Getter and setter for initial value of the control.
42+
43+
| Property | Return type |
44+
| --------- | ------------- |
45+
| `get initialValue()` | `any` |
46+
| `set initialValue()` | `any` |
47+
48+
## Methods
49+
50+
### resetValue()
51+
52+
Resets the underlying form control, marking it `pristine` and `untouched` and sets the current and initial value to the one provided. If no value argument is provided, sets those values to `control.currentValue`.
53+
54+
| Method | Return type |
55+
| --------- | ------------- |
56+
| `resetValue(value?: any)` | `value: any` |
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
id: form-store
3+
title: FormStore
4+
sidebar_label: FormStore
5+
---
6+
7+
`FormStore` extends `FormGroup`. Tracks the value and validity state of a group of `AbstractControl` instances.
8+
9+
## Constructor
10+
11+
```ts
12+
constructor(
13+
controls: { [key: string]: AbstractControl; },
14+
validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null,
15+
asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null
16+
)
17+
```
18+
19+
## Properties
20+
21+
### get isChanged
22+
23+
Returns `true` if any of `FormStore`'s controls or relationships have changed.
24+
25+
| Property | Return type |
26+
| --------- | ------------- |
27+
| `get isChanged()` | `boolean` |
28+
29+
### formObject
30+
31+
Getter and setter for `FormObject` for this `FormStore`.
32+
33+
| Property | Return type |
34+
| --------- | ------------- |
35+
| `set formObject(formObject: FormObject<T>)` | | Sets the `FormObject` for this `FormStore` |
36+
| `get formObject()` | `FormObject<T>` | Returns the underlying `FormObject` instance |
37+
38+
### get model
39+
40+
| Property | Return type |
41+
| --------- | ------------- |
42+
| `get model()` | `T` |
43+
44+
### get isSubmitted
45+
46+
Returns `true` if `FormStore.save` method was already called, `false` otherwise.
47+
48+
| Property | Return type |
49+
| --------- | ------------- |
50+
| `get isSubmitted()` | `boolean` |
51+
52+
## Methods
53+
54+
### save()
55+
56+
Initiates the saving process. See more about the saving process in [the guide](../../guides/saving-forms.md).
57+
58+
| Method | Return type |
59+
| --------- | ------------- |
60+
| `save()` | `Observable<T>` |
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
id: form-object
3+
title: FormObject
4+
sidebar_label: FormObject
5+
---
6+
`FormObject` provides a way to specify how its relationship controls will be created.
7+
It also provides a way to define specific saving behaviour through its saving hooks. Check [saving forms guide](../guides/saving-forms.md) for more details.
8+
9+
## Constructor
10+
11+
```ts
12+
constructor(model: T, options: FormObjectOptions);
13+
```
14+
15+
## Properties
16+
17+
### attributeProperties
18+
19+
| Property | Return type |
20+
| --------- | ------------- |
21+
| `readonly attributeProperties` | <code>Map&lt;string &#124; symbol, PropertyOptions&gt;</code> |
22+
23+
### attributePropertiesKeys
24+
25+
| Property | Return type |
26+
| --------- | ------------- |
27+
| `readonly attributePropertiesKeys` | <code>Array&lt;string &#124; symbol&gt;</code> |
28+
29+
### belongsToProperties
30+
31+
| Property | Return type |
32+
| --------- | ------------- |
33+
| `readonly belongsToProperties` | <code>Map&lt;string &#124; symbol, PropertyOptions&gt;</code> |
34+
35+
### belongsToPropertiesKeys
36+
37+
| Property | Return type |
38+
| --------- | ------------- |
39+
| `readonly belongsToPropertiesKeys` | <code>Array&lt;string &#124; symbol&gt;</code> |
40+
41+
### formGroupOptions
42+
43+
Used for defining form field group options.
44+
45+
| Property | Return type |
46+
| --------- | ------------- |
47+
| `get formGroupOptions()` | `FormGroupOptions` |
48+
| `set formGroupOptions()` | `FormGroupOptions` |
49+
50+
### formStoreClass
51+
52+
Used for defining class from which `FormStore` will be created.
53+
54+
| Property | Return type |
55+
| --------- | ------------- |
56+
| `get formStoreClass()` | `new () => FormStore<T>` |
57+
| `set formStoreClass()` | `new () => FormStore<T>` |
58+
59+
### hasManyProperties
60+
61+
| Property | Return type |
62+
| --------- | ------------- |
63+
| `readonly hasManyProperties` | <code>Map&lt;string &#124; symbol, PropertyOptions&gt;</code> |
64+
65+
### hasManyPropertiesKeys
66+
67+
| Property | Return type |
68+
| --------- | ------------- |
69+
| `readonly hasManyPropertiesKeys` | <code>Array&lt;string &#124; symbol&gt;</code> |
70+
71+
### get model
72+
73+
| Property | Return type |
74+
| --------- | ------------- |
75+
| `get model()` | `T` |
76+
77+
### get options
78+
79+
| Property | Return type |
80+
| --------- | ------------- |
81+
| `protected get options()` | `FormObjectOptions` |
82+
83+
### validators
84+
85+
Used for defining form field validators. Check [validating forms guide](../guides/validating-forms.md) for more details.
86+
87+
| Property | Return type |
88+
| --------- | ------------- |
89+
| `get validators()` | <code>Record&lt;string, ValidatorFn &#124; Array&lt;ValidatorFn&gt;&gt;</code> |
90+
| `set validators()` | <code>Record&lt;string, ValidatorFn &#124; Array&lt;ValidatorFn&gt;&gt;</code> |
91+
92+
## Methods
93+
94+
### afterSave()
95+
96+
Implement this method to add custom behaviour after the model is saved. [Find out more](../guides/saving-forms.md#aftersave).
97+
98+
| Method | Return type |
99+
| --------- | ------------- |
100+
| `protected afterSave(model?: T, _form?: FormStore<T>)` | `Observable<T>` |
101+
102+
### beforeSave()
103+
104+
Implement this method to add custom behaviour before the actual saving is triggered. [Find out more](../guides/saving-forms.md#beforesave).
105+
106+
| Method | Return type |
107+
| --------- | ------------- |
108+
| `protected beforeSave(store: FormStore<T>)` | `Observable<FormStore<T>>` |
109+
110+
### getModelType()
111+
112+
By default, `getModelType(model)` will return `model.constructor.name`.
113+
114+
| Method | Return type |
115+
| --------- | ------------- |
116+
| `getModelType(model: T)` | `string` |
117+
118+
### getValidators()
119+
120+
Returns defined validators for provided attribute name.
121+
122+
| Method | Return type |
123+
| --------- | ------------- |
124+
| `getValidators(attributeName: string)` | <code>ValidatorFn &#124; Array&lt;ValidatorFn&gt;</code> |
125+
126+
### isFormValid()
127+
128+
Returns `true` if all enabled controls inside form are valid.
129+
130+
| Method | Return type |
131+
| --------- | ------------- |
132+
| `isFormValid(form: FormStore<T>)` | `boolean` |
133+
134+
### reset()
135+
136+
Resets provided `form` value to the `FormObject` `model` value.
137+
138+
| Method | Return type |
139+
| --------- | ------------- |
140+
| `reset(form: FormStore<T>)` | `void` |
141+
142+
### save()
143+
144+
Required method for saving the form. Override this method to persist the model. [Find out more](../guides/saving-forms.md#save).
145+
146+
| Method | Return type |
147+
| --------- | ------------- |
148+
| `protected save(model: T)` | `Observable<T>` |

docusaurus/docs/extended-form-controls.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)