src/app/core/basic-datatypes/string/edit-email/edit-email.component.ts
CustomFormControlDirective<string>
| changeDetection | ChangeDetectionStrategy.OnPush |
| providers |
EditEmailComponent
|
| selector | app-edit-email |
| standalone | true |
| imports |
MatInputModule
MatButtonModule
MatTooltipModule
FontAwesomeModule
|
| styleUrls | ./edit-email.component.scss, |
| templateUrl | ./edit-email.component.html |
No results matching.
MatInputModule
ReactiveFormsModule
MatButtonModule
MatTooltipModule
FontAwesomeModule
CustomFormControlDirective<string>
EditComponent
Properties |
|
Methods |
Inputs |
Outputs |
| entity | |
Type : Entity
|
|
| formFieldConfig | |
Type : FormFieldConfig
|
|
| aria-describedby | |
Type : string
|
|
|
Inherited from
CustomFormControlDirective
|
|
| disabled | |
Type : boolean
|
|
|
Inherited from
CustomFormControlDirective
|
|
| ngControl | |
Type : any
|
|
Default value : inject(NgControl, { optional: true, self: true })
|
|
|
Inherited from
CustomFormControlDirective
|
|
| placeholder | |
Type : string
|
|
|
Inherited from
CustomFormControlDirective
|
|
| required | |
Type : boolean
|
|
|
Inherited from
CustomFormControlDirective
|
|
| value | |
Type : T
|
|
|
Inherited from
CustomFormControlDirective
|
|
| valueChange | |
Type : EventEmitter
|
|
|
Inherited from
CustomFormControlDirective
|
|
| openEmailDialog | ||||||
openEmailDialog(event: Event)
|
||||||
|
Parameters :
Returns :
void
|
| blur |
blur()
|
|
Inherited from
CustomFormControlDirective
|
|
Returns :
void
|
| focus |
focus()
|
|
Inherited from
CustomFormControlDirective
|
|
Returns :
void
|
| onContainerClick | ||||||
onContainerClick(event: MouseEvent)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Parameters :
Returns :
void
|
| registerOnChange | ||||||
registerOnChange(fn: any)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Parameters :
Returns :
void
|
| registerOnTouched | ||||||
registerOnTouched(fn: any)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Parameters :
Returns :
void
|
| setDescribedByIds | ||||||
setDescribedByIds(ids: string[])
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Parameters :
Returns :
void
|
| setDisabledState | ||||||
setDisabledState(isDisabled: boolean)
|
||||||
|
Inherited from
CustomFormControlDirective
|
||||||
|
Parameters :
Returns :
void
|
| writeValue | |||||||||||||||
writeValue(value: T, notifyFormControl: unknown)
|
|||||||||||||||
|
Inherited from
CustomFormControlDirective
|
|||||||||||||||
|
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
|
| elementRef |
Type : unknown
|
Default value : inject<ElementRef<HTMLElement>>(ElementRef)
|
|
Inherited from
CustomFormControlDirective
|
| Readonly enabled |
Type : Signal<boolean>
|
Default value : computed(() => !this._disabled())
|
|
Inherited from
CustomFormControlDirective
|
|
Whether the control is currently enabled, as a signal (tracks disabled). |
| errorStateMatcher |
Type : unknown
|
Default value : inject(ErrorStateMatcher)
|
|
Inherited from
CustomFormControlDirective
|
| id |
Type : unknown
|
Default value : `custom-form-control-${CustomFormControlDirective.nextId++}`
|
|
Inherited from
CustomFormControlDirective
|
| Static nextId |
Type : number
|
Default value : 0
|
|
Inherited from
CustomFormControlDirective
|
| onChange |
Type : unknown
|
Default value : () => {...}
|
|
Inherited from
CustomFormControlDirective
|
| onTouched |
Type : unknown
|
Default value : () => {...}
|
|
Inherited from
CustomFormControlDirective
|
| parentForm |
Type : unknown
|
Default value : inject(NgForm, { optional: true })
|
|
Inherited from
CustomFormControlDirective
|
| parentFormGroup |
Type : unknown
|
Default value : inject(FormGroupDirective, { optional: true })
|
|
Inherited from
CustomFormControlDirective
|
| stateChanges |
Type : unknown
|
Default value : new Subject<void>()
|
|
Inherited from
CustomFormControlDirective
|
| Readonly valueSignal |
Type : Signal<T>
|
Default value : computed(() => this._value())
|
|
Inherited from
CustomFormControlDirective
|
|
The current value of the control as a signal.
Authoritative in both modes: it reflects the bound |
import { CustomFormControlDirective } from "#src/app/core/common-components/basic-autocomplete/custom-form-control.directive";
import { Entity } from "#src/app/core/entity/model/entity";
import { EmailClientService } from "#src/app/features/email-client/email-client.service";
import {
ChangeDetectionStrategy,
Component,
inject,
input,
} from "@angular/core";
import { ReactiveFormsModule } from "@angular/forms";
import { MatButtonModule } from "@angular/material/button";
import { MatFormFieldControl } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input";
import { MatTooltipModule } from "@angular/material/tooltip";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { FormFieldConfig } from "../../../common-components/entity-form/FormConfig";
import { DynamicComponent } from "../../../config/dynamic-components/dynamic-component.decorator";
import { EditComponent } from "../../../entity/entity-field-edit/dynamic-edit/edit-component.interface";
@DynamicComponent("EditEmail")
@Component({
selector: "app-edit-email",
templateUrl: "./edit-email.component.html",
styleUrls: [
"./edit-email.component.scss",
"../../../entity/entity-field-edit/dynamic-edit/dynamic-edit.component.scss",
],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
MatInputModule,
ReactiveFormsModule,
MatButtonModule,
MatTooltipModule,
FontAwesomeModule,
],
providers: [
{ provide: MatFormFieldControl, useExisting: EditEmailComponent },
],
})
export class EditEmailComponent
extends CustomFormControlDirective<string>
implements EditComponent
{
formFieldConfig = input<FormFieldConfig>();
entity = input<Entity>();
private readonly emailClientService = inject(EmailClientService);
openEmailDialog(event: Event) {
event.stopPropagation();
const entity = this.entity();
if (!entity) {
return;
}
// use the current (possibly not yet saved) input value, not the field's last saved state
const fieldId = this.formFieldConfig()?.id;
const entityWithCurrentValue = fieldId
? Object.assign(entity.copy(), { [fieldId]: this.valueSignal() })
: entity;
this.emailClientService.executeMailto(entityWithCurrentValue, fieldId);
}
}
<div class="flex-row align-center gap-small">
<input
[formControl]="formControl"
matInput
type="email"
class="flex-grow"
dir="ltr"
/>
@if (valueSignal() && entity()) {
<button
mat-icon-button
type="button"
class="input-action-button"
i18n-aria-label
aria-label="Send email"
i18n-matTooltip
matTooltip="Send an email"
(click)="openEmailDialog($event)"
>
<fa-icon icon="envelope"></fa-icon>
</button>
}
</div>
./edit-email.component.scss
../../../entity/entity-field-edit/dynamic-edit/dynamic-edit.component.scss
@use "variables/colors";
.input-action-button {
margin: -12px;
color: colors.$muted;
}