src/app/core/entity/entity-field-edit/dynamic-edit/dynamic-edit.component.ts
| changeDetection | ChangeDetectionStrategy.OnPush |
| providers |
DynamicEditComponent
|
| selector | app-dynamic-edit |
| imports |
DynamicComponentDirective
ReactiveFormsModule
|
| templateUrl | ./dynamic-edit.component.html |
| styleUrl | ./dynamic-edit.component.scss |
Properties |
|
Methods |
Inputs |
Outputs |
Accessors |
| entity | |
Type : Entity
|
|
| formFieldConfig | |
Type : FormFieldConfig
|
|
| aria-describedby | |
Type : string
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:98
|
|
| disabled | |
Type : boolean
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:155
|
|
| ngControl | |
Type : any
|
|
Default value : inject(NgControl, { optional: true, self: true })
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:91
|
|
| placeholder | |
Type : string
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:99
|
|
| required | |
Type : boolean
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:102
|
|
| value | |
Type : T
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:164
|
|
| valueChange | |
Type : EventEmitter
|
|
|
Inherited from
CustomFormControlDirective
|
|
|
Defined in
CustomFormControlDirective:172
|
|
| blur |
blur()
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:201
|
|
Returns :
void
|
| focus |
focus()
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:196
|
|
Returns :
void
|
| onContainerClick | ||||||
onContainerClick(event: MouseEvent)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Defined in
CustomFormControlDirective:218
|
||||||
|
Parameters :
Returns :
void
|
| registerOnChange | ||||||
registerOnChange(fn: any)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Defined in
CustomFormControlDirective:237
|
||||||
|
Parameters :
Returns :
void
|
| registerOnTouched | ||||||
registerOnTouched(fn: any)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Defined in
CustomFormControlDirective:241
|
||||||
|
Parameters :
Returns :
void
|
| setDescribedByIds | ||||||
setDescribedByIds(ids: string[])
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Defined in
CustomFormControlDirective:211
|
||||||
|
Parameters :
Returns :
void
|
| setDisabledState | ||||||
setDisabledState(isDisabled: boolean)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Defined in
CustomFormControlDirective:245
|
||||||
|
Parameters :
Returns :
void
|
| writeValue | |||||||||||||||
writeValue(value: T, notifyFormControl: unknown)
|
|||||||||||||||
|
Inherited from
CustomFormControlDirective
|
|||||||||||||||
|
Defined in
CustomFormControlDirective:226
|
|||||||||||||||
|
Implementation for Angular ControlValueAccessor interface that links the form control value to the component value
Parameters :
Returns :
void
|
| controlType |
Type : string
|
Default value : "custom-control"
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:114
|
| elementRef |
Type : unknown
|
Default value : inject<ElementRef<HTMLElement>>(ElementRef)
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:87
|
| Readonly enabled |
Type : Signal<boolean>
|
Default value : computed(() => !this._disabled())
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:80
|
|
Whether the control is currently enabled, as a signal (tracks disabled). |
| errorStateMatcher |
Type : unknown
|
Default value : inject(ErrorStateMatcher)
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:88
|
| id |
Type : unknown
|
Default value : `custom-form-control-${CustomFormControlDirective.nextId++}`
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:96
|
| Static nextId |
Type : number
|
Default value : 0
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:95
|
| onChange |
Type : unknown
|
Default value : () => {...}
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:115
|
| onTouched |
Type : unknown
|
Default value : () => {...}
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:116
|
| parentForm |
Type : unknown
|
Default value : inject(NgForm, { optional: true })
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:92
|
| parentFormGroup |
Type : unknown
|
Default value : inject(FormGroupDirective, { optional: true })
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:93
|
| stateChanges |
Type : unknown
|
Default value : new Subject<void>()
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:113
|
| Readonly valueSignal |
Type : Signal<T>
|
Default value : computed(() => this._value())
|
|
Inherited from
CustomFormControlDirective
|
|
Defined in
CustomFormControlDirective:77
|
|
The current value of the control as a signal.
Authoritative in both modes: it reflects the bound |
| disabled | ||||||
getdisabled()
|
||||||
setdisabled(value: boolean)
|
||||||
|
Parameters :
Returns :
void
|
import { FormFieldConfig } from "#src/app/core/common-components/entity-form/FormConfig";
import { DynamicComponentDirective } from "#src/app/core/config/dynamic-components/dynamic-component.directive";
import { Entity } from "#src/app/core/entity/model/entity";
import { Component, ChangeDetectionStrategy, input } from "@angular/core";
import { ReactiveFormsModule } from "@angular/forms";
import { MatFormFieldControl } from "@angular/material/form-field";
import { CustomFormControlDirective } from "../../../common-components/basic-autocomplete/custom-form-control.directive";
import { EditComponent } from "./edit-component.interface";
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: "app-dynamic-edit",
imports: [DynamicComponentDirective, ReactiveFormsModule],
templateUrl: "./dynamic-edit.component.html",
styleUrl: "./dynamic-edit.component.scss",
providers: [
{ provide: MatFormFieldControl, useExisting: DynamicEditComponent },
],
})
export class DynamicEditComponent
extends CustomFormControlDirective<any>
implements EditComponent
{
private static readonly TODO_COMPLETION_EDIT_COMPONENT = "EditTodoCompletion";
formFieldConfig = input<FormFieldConfig>();
entity = input<Entity>();
override get disabled(): boolean {
const control = this.ngControl?.control;
if (
this.formFieldConfig()?.editComponent ===
DynamicEditComponent.TODO_COMPLETION_EDIT_COMPONENT &&
control?.disabled &&
!control.value
) {
return false;
}
return super.disabled;
}
override set disabled(value: boolean) {
super.disabled = value;
}
}
<ng-container
[appDynamicComponent]="{
component: formFieldConfig()?.editComponent,
config: {
ngControl: ngControl,
formFieldConfig: formFieldConfig(),
entity: entity(),
},
}"
>
</ng-container>