Merge pull request #9117 from kalutkaz/relationTypeLabel
Update label logic for relation-type-autocomplete
This commit is contained in:
commit
a0f80e487c
@ -26,7 +26,7 @@
|
|||||||
<div class="tb-form-table-row"
|
<div class="tb-form-table-row"
|
||||||
*ngFor="let relationFilterControl of relationFiltersFormArray.controls; let $index = index">
|
*ngFor="let relationFilterControl of relationFiltersFormArray.controls; let $index = index">
|
||||||
<tb-relation-type-autocomplete subscriptSizing="dynamic"
|
<tb-relation-type-autocomplete subscriptSizing="dynamic"
|
||||||
class="flex-50"
|
class="flex-50" showLabel="false"
|
||||||
[additionalClasses]="['tb-inline-field']"
|
[additionalClasses]="['tb-inline-field']"
|
||||||
appearance="outline"
|
appearance="outline"
|
||||||
[formControl]="relationFilterControl.get('relationType')">
|
[formControl]="relationFilterControl.get('relationType')">
|
||||||
|
|||||||
@ -15,9 +15,9 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<mat-form-field [formGroup]="relationTypeFormGroup" [appearance]="appearance" [floatLabel]="floatLabel"
|
<mat-form-field [formGroup]="relationTypeFormGroup" [appearance]="appearance" [floatLabel]="required ? 'auto' : 'always'"
|
||||||
class="mat-block" [class]="additionalClasses" subscriptSizing="{{ subscriptSizing }}">
|
class="mat-block" [class]="additionalClasses" subscriptSizing="{{ subscriptSizing }}">
|
||||||
<mat-label *ngIf="label">{{ label }}</mat-label>
|
<mat-label *ngIf="showLabel">{{ 'relation.relation-type' | translate }}</mat-label>
|
||||||
<input matInput type="text"
|
<input matInput type="text"
|
||||||
#relationTypeInput
|
#relationTypeInput
|
||||||
formControlName="relationType"
|
formControlName="relationType"
|
||||||
|
|||||||
@ -15,16 +15,15 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import { AfterViewInit, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
|
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { map, mergeMap, tap } from 'rxjs/operators';
|
import { map, mergeMap, tap } from 'rxjs/operators';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@app/core/core.state';
|
import { AppState } from '@app/core/core.state';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { BroadcastService } from '@app/core/services/broadcast.service';
|
import { BroadcastService } from '@app/core/services/broadcast.service';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
||||||
import { RelationTypes } from '@app/shared/models/relation.models';
|
import { RelationTypes } from '@app/shared/models/relation.models';
|
||||||
import { FloatLabelType, MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field';
|
import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field';
|
||||||
import { coerceArray, coerceBoolean } from '@shared/decorators/coercion';
|
import { coerceArray, coerceBoolean } from '@shared/decorators/coercion';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -39,12 +38,13 @@ import { coerceArray, coerceBoolean } from '@shared/decorators/coercion';
|
|||||||
})
|
})
|
||||||
export class RelationTypeAutocompleteComponent implements ControlValueAccessor, OnInit, AfterViewInit, OnDestroy {
|
export class RelationTypeAutocompleteComponent implements ControlValueAccessor, OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
relationTypeFormGroup: UntypedFormGroup;
|
relationTypeFormGroup: FormGroup;
|
||||||
|
|
||||||
modelValue: string | null;
|
modelValue: string | null;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
label: string;
|
@coerceBoolean()
|
||||||
|
showLabel = true;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
@coerceArray()
|
@coerceArray()
|
||||||
@ -53,9 +53,6 @@ export class RelationTypeAutocompleteComponent implements ControlValueAccessor,
|
|||||||
@Input()
|
@Input()
|
||||||
appearance: MatFormFieldAppearance = 'fill';
|
appearance: MatFormFieldAppearance = 'fill';
|
||||||
|
|
||||||
@Input()
|
|
||||||
floatLabel: FloatLabelType = 'auto';
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
@coerceBoolean()
|
@coerceBoolean()
|
||||||
required: boolean;
|
required: boolean;
|
||||||
@ -79,7 +76,7 @@ export class RelationTypeAutocompleteComponent implements ControlValueAccessor,
|
|||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
private broadcast: BroadcastService,
|
private broadcast: BroadcastService,
|
||||||
public translate: TranslateService,
|
public translate: TranslateService,
|
||||||
private fb: UntypedFormBuilder) {
|
private fb: FormBuilder) {
|
||||||
this.relationTypeFormGroup = this.fb.group({
|
this.relationTypeFormGroup = this.fb.group({
|
||||||
relationType: [null, this.required ? [Validators.required, Validators.maxLength(255)] : [Validators.maxLength(255)]]
|
relationType: [null, this.required ? [Validators.required, Validators.maxLength(255)] : [Validators.maxLength(255)]]
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user