This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nameAlreadyExists: boolean = false; | |
private notifyParentComponentWhenNameChanges(): void { | |
this.form | |
?.get('name') | |
?.valueChanges.pipe( | |
takeUntilDestroyed(this.destroyRef), | |
debounceTime(300), // debounce user input | |
distinctUntilChanged() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-ecs-field', | |
templateUrl: './ecs-field.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class EcsFieldComponent implements OnInit, OnChanges { | |
private storeService = inject(EcsFieldsStoreService); | |
nameAlreadyExists: boolean = false; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-ecs-field', | |
templateUrl: './ecs-field.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class EcsFieldComponent { | |
formBuilder = inject(FormBuilder); | |
@Input() entity: EcsField; | |
@Input() nameAlreadyExists: boolean | null = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-ecs-fieldset', | |
templateUrl: './ecs-fieldset.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class EcsFieldsetComponent { | |
formBuilder = inject(FormBuilder); | |
@Input() entity: EcsFieldset; | |
@Input() nameAlreadyExists: boolean | null = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ng-container *ngIf="isCreateMode"> | |
<div class="mt-0"> | |
<app-create-custom-field | |
[ecsFieldset]="entity.id!" | |
[nameAlreadyExists]="nameAlreadyExists" | |
(checkIfNameExists)="checkIfNameExists.emit($event)" | |
(cancelEdit)="cancelEdit.emit()" | |
(save)="createCustomField.emit($event)" | |
> | |
</app-create-custom-field> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-ecs-fieldset | |
[entity]="ecsFieldset" | |
[fields]="(ecsFields$ | async) || []" | |
[nameAlreadyExists]="nameAlreadyExists$ | async" | |
(checkIfNameExists)="checkIfNameExists($event)" | |
(cancelEdit)="onCancelEdit()" | |
> | |
</app-ecs-fieldset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-create-custom-field', | |
templateUrl: './create-custom-field.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class CreateCustomFieldComponent implements OnInit { | |
private readonly destroyRef = inject(DestroyRef); | |
@Input() nameAlreadyExists: boolean | null = false; | |
@Output() checkIfNameExists = new EventEmitter<string>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-ecs-fieldsets-with-details', | |
templateUrl: './ecs-fieldsets-with-details.component.html', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
}) | |
export class EcsFieldsetsWithDetailsComponent implements OnChanges { | |
private storeService = inject(EcsFieldsStoreService); | |
nameAlreadyExists$ = new BehaviorSubject<boolean>(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Show warning: Name already exists --> | |
<ng-container *ngIf="nameAlreadyExists"> | |
<div class="mb-4 text-red-600"> | |
{{ "WARNING.DUPLICATE_NAME" | transloco }} | |
</div> | |
</ng-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes: Routes = [ | |
{ path: "dashboard", component: DashboardComponent }, | |
{ | |
path: "profiles", | |
redirectTo: ({ queryParams }) => { | |
const errorHandler = inject(ErrorHandler); | |
const userId = queryParams['userId']; | |
if (userId) { | |
// return the appropriate redirect path based on the userId query-parameter | |
return `/profiles/${userId}`; |
NewerOlder