Commit 0289b0c1a2b9bec66cc5261c3c862a855d01d140

Authored by Igor Kulikov
1 parent 3d71a5ba

UI: Get rid of 'multiple directives with 'exportAs' set to ngForm'

Showing 57 changed files with 86 additions and 97 deletions
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #entityAliasForm="ngForm" [formGroup]="entityAliasFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
  18 +<form [formGroup]="entityAliasFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ (isAdd ? 'alias.add' : 'alias.edit') | translate }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #entityAliasesForm="ngForm" [formGroup]="entityAliasesFormGroup" (ngSubmit)="save()" style="width: 700px;">
  18 +<form [formGroup]="entityAliasesFormGroup" (ngSubmit)="save()" style="width: 700px;">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ title | translate }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #addWidgetForm="ngForm" [formGroup]="addWidgetFormGroup" (ngSubmit)="add()" style="min-width: 400px;">
  18 +<form [formGroup]="addWidgetFormGroup" (ngSubmit)="add()" style="min-width: 400px;">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>attribute.add-widget-to-dashboard</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,8 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #attributeForm="ngForm"
19   - class="mat-elevation-z1"
  18 +<form class="mat-elevation-z1"
20 19 [formGroup]="attributeFormGroup" (ngSubmit)="update()" style="width: 400px; padding: 5px;">
21 20 <fieldset [disabled]="isLoading$ | async">
22 21 <tb-value-input
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #widgetForm="ngForm">
  18 +<form>
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>layout.select</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #stateForm="ngForm" [formGroup]="stateFormGroup" (ngSubmit)="save()">
  18 +<form [formGroup]="stateFormGroup" (ngSubmit)="save()">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>dashboard.select-state</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -18,7 +18,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
18 18 import { PageComponent } from '@shared/components/page.component';
19 19 import { Store } from '@ngrx/store';
20 20 import { AppState } from '@core/core.state';
21   -import { NgForm } from '@angular/forms';
  21 +import { FormGroup, NgForm } from '@angular/forms';
22 22
23 23 @Component({
24 24 selector: 'tb-details-panel',
... ... @@ -33,14 +33,14 @@ export class DetailsPanelComponent extends PageComponent {
33 33 @Input() isReadOnly = false;
34 34 @Input() isAlwaysEdit = false;
35 35
36   - theFormValue: NgForm;
  36 + theFormValue: FormGroup;
37 37
38 38 @Input()
39   - set theForm(value: NgForm) {
  39 + set theForm(value: FormGroup) {
40 40 this.theFormValue = value;
41 41 }
42 42
43   - get theForm(): NgForm {
  43 + get theForm(): FormGroup {
44 44 return this.theFormValue;
45 45 }
46 46
... ...
... ... @@ -19,7 +19,7 @@ import { ErrorStateMatcher } from '@angular/material/core';
19 19 import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
20 20 import { Store } from '@ngrx/store';
21 21 import { AppState } from '@core/core.state';
22   -import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
  22 +import { FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms';
23 23 import { EntityTypeResource, EntityTypeTranslation } from '@shared/models/entity-type.models';
24 24 import { BaseData, HasId } from '@shared/models/base-data';
25 25 import { EntityId } from '@shared/models/id/entity-id';
... ... @@ -40,7 +40,7 @@ export class AddEntityDialogComponent extends
40 40 DialogComponent<AddEntityDialogComponent, BaseData<HasId>> implements OnInit, ErrorStateMatcher {
41 41
42 42 entityComponent: EntityComponent<BaseData<HasId>>;
43   - detailsForm: NgForm;
  43 + detailsForm: FormGroup;
44 44
45 45 entitiesTableConfig: EntityTableConfig<BaseData<HasId>>;
46 46 translations: EntityTypeTranslation;
... ... @@ -87,7 +87,7 @@ export class AddEntityDialogComponent extends
87 87 const componentRef = viewContainerRef.createComponent(componentFactory, 0, injector);
88 88 this.entityComponent = componentRef.instance;
89 89 this.entityComponent.isEdit = true;
90   - this.detailsForm = this.entityComponent.entityNgForm;
  90 + this.detailsForm = this.entityComponent.entityForm;
91 91 }
92 92
93 93 helpLinkId(): string {
... ...
... ... @@ -37,7 +37,7 @@ import { AppState } from '@core/core.state';
37 37 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
38 38 import { BaseData, HasId } from '@shared/models/base-data';
39 39 import { EntityType, EntityTypeResource, EntityTypeTranslation } from '@shared/models/entity-type.models';
40   -import { NgForm } from '@angular/forms';
  40 +import { FormGroup, NgForm } from '@angular/forms';
41 41 import { EntityComponent } from './entity.component';
42 42 import { TbAnchorComponent } from '@shared/components/tb-anchor.component';
43 43 import { EntityAction } from '@home/models/entity/entity-component.models';
... ... @@ -68,7 +68,7 @@ export class EntityDetailsPanelComponent extends PageComponent implements OnInit
68 68
69 69 entityTabsComponentRef: ComponentRef<EntityTabsComponent<BaseData<HasId>>>;
70 70 entityTabsComponent: EntityTabsComponent<BaseData<HasId>>;
71   - detailsForm: NgForm;
  71 + detailsForm: FormGroup;
72 72
73 73 entitiesTableConfigValue: EntityTableConfig<BaseData<HasId>>;
74 74 isEditValue = false;
... ... @@ -189,7 +189,7 @@ export class EntityDetailsPanelComponent extends PageComponent implements OnInit
189 189 this.entityComponentRef = viewContainerRef.createComponent(componentFactory, 0, injector);
190 190 this.entityComponent = this.entityComponentRef.instance;
191 191 this.entityComponent.isEdit = this.isEdit;
192   - this.detailsForm = this.entityComponent.entityNgForm;
  192 + this.detailsForm = this.entityComponent.entityForm;
193 193 this.subscriptions.push(this.entityComponent.entityAction.subscribe((action) => {
194 194 this.entityAction.emit(action);
195 195 }));
... ...
... ... @@ -30,7 +30,7 @@ import { AuditLogMode } from '@shared/models/audit-log.models';
30 30 import { DebugEventType, EventType } from '@shared/models/event.models';
31 31 import { AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
32 32 import { NULL_UUID } from '@shared/models/id/has-uuid';
33   -import { NgForm } from '@angular/forms';
  33 +import { FormGroup, NgForm } from '@angular/forms';
34 34 import { PageLink } from '@shared/models/page/page-link';
35 35
36 36 @Directive()
... ... @@ -94,7 +94,7 @@ export abstract class EntityTabsComponent<T extends BaseData<HasId>,
94 94 }
95 95
96 96 @Input()
97   - detailsForm: NgForm;
  97 + detailsForm: FormGroup;
98 98
99 99 private entityTabsSubject = new BehaviorSubject<Array<MatTab>>(null);
100 100
... ...
... ... @@ -35,8 +35,6 @@ export abstract class EntityComponent<T extends BaseData<HasId>,
35 35
36 36 entityForm: FormGroup;
37 37
38   - @ViewChild('entityNgForm', {static: true}) entityNgForm: NgForm;
39   -
40 38 isEditValue: boolean;
41 39
42 40 @Input()
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #importForm="ngForm" [formGroup]="importFormGroup" (ngSubmit)="importFromJson()">
  18 +<form [formGroup]="importFormGroup" (ngSubmit)="importFromJson()">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>{{ importTitle }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #relationForm="ngForm" [formGroup]="relationFormGroup" (ngSubmit)="save()" style="min-width: 600px;">
  18 +<form [formGroup]="relationFormGroup" (ngSubmit)="save()" style="min-width: 600px;">
19 19 <mat-toolbar fxLayout="row" color="primary">
20 20 <h2>{{ (isAdd ? 'relation.add' : 'relation.edit' ) | translate }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #widgetActionForm="ngForm" [formGroup]="widgetActionFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
  18 +<form [formGroup]="widgetActionFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ (isAdd ? 'widget-config.add-action' : 'widget-config.edit-action' ) | translate }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #dataKeyForm="ngForm" [formGroup]="dataKeyFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
  18 +<form [formGroup]="dataKeyFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ 'datakey.configuration' | translate }}</h2>
21 21 <span fxFlex></span>
... ... @@ -39,7 +39,7 @@
39 39 <div mat-dialog-actions fxLayoutAlign="end center">
40 40 <button mat-raised-button color="primary"
41 41 type="submit"
42   - [disabled]="(isLoading$ | async) || dataKeyForm.invalid || !dataKeyForm.dirty">
  42 + [disabled]="(isLoading$ | async) || dataKeyFormGroup.invalid || !dataKeyFormGroup.dirty">
43 43 {{ 'action.save' | translate }}
44 44 </button>
45 45 <button mat-button color="primary"
... ...
... ... @@ -16,7 +16,6 @@
16 16
17 17 -->
18 18 <form #formContainer class="tb-multiple-input"
19   - #multipleInputForm="ngForm"
20 19 [formGroup]="multipleInputFormGroup"
21 20 tb-toast toastTarget="{{ toastTargetId }}"
22 21 (ngSubmit)="save()" novalidate autocomplete="off">
... ... @@ -103,12 +102,12 @@
103 102 *ngIf="entityDetected && settings.showActionButtons">
104 103 <button mat-button color="primary" type="button"
105 104 (click)="discardAll()" style="max-height: 50px; margin-right:20px;"
106   - [disabled]="!multipleInputForm.dirty">
  105 + [disabled]="!multipleInputFormGroup.dirty">
107 106 {{ 'action.undo' | translate }}
108 107 </button>
109 108 <button mat-button mat-raised-button color="primary" type="submit"
110 109 style="max-height: 50px; margin-right:20px;"
111   - [disabled]="!multipleInputForm.dirty || multipleInputForm.invalid">
  110 + [disabled]="!multipleInputFormGroup.dirty || multipleInputFormGroup.invalid">
112 111 {{ 'action.save' | translate }}
113 112 </button>
114 113 </div>
... ...
... ... @@ -27,7 +27,7 @@ import { IWidgetSubscription } from '@core/api/widget-api.models';
27 27 import { isDefined, isEqual, isUndefined } from '@core/utils';
28 28 import { EntityType } from '@shared/models/entity-type.models';
29 29 import * as _moment from 'moment';
30   -import { FormBuilder, FormGroup, NgForm, ValidatorFn, Validators } from '@angular/forms';
  30 +import { FormBuilder, FormGroup, ValidatorFn, Validators } from '@angular/forms';
31 31 import { RequestConfig } from '@core/http/http-utils';
32 32 import { AttributeService } from '@core/http/attribute.service';
33 33 import { AttributeData, AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
... ... @@ -90,7 +90,6 @@ interface MultipleInputWidgetSource {
90 90 export class MultipleInputWidgetComponent extends PageComponent implements OnInit, OnDestroy {
91 91
92 92 @ViewChild('formContainer', {static: true}) formContainerRef: ElementRef<HTMLElement>;
93   - @ViewChild('multipleInputForm', {static: true}) multipleInputForm: NgForm;
94 93
95 94 @Input()
96 95 ctx: WidgetContext;
... ... @@ -453,7 +452,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
453 452 if (tasks.length) {
454 453 forkJoin(tasks).subscribe(
455 454 () => {
456   - this.multipleInputForm.resetForm();
  455 + this.multipleInputFormGroup.reset(undefined, {emitEvent: false});
457 456 this.multipleInputFormGroup.markAsPristine();
458 457 if (this.settings.showResultMessage) {
459 458 this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'),
... ... @@ -467,13 +466,13 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
467 466 }
468 467 });
469 468 } else {
470   - this.multipleInputForm.resetForm();
  469 + this.multipleInputFormGroup.reset(undefined, {emitEvent: false});
471 470 this.multipleInputFormGroup.markAsPristine();
472 471 }
473 472 }
474 473
475 474 public discardAll() {
476   - this.multipleInputForm.resetForm();
  475 + this.multipleInputFormGroup.reset(undefined, {emitEvent: false});
477 476 this.sources.forEach((source) => {
478 477 for (const key of this.visibleKeys(source)) {
479 478 this.multipleInputFormGroup.get(key.formId).patchValue(key.value, {emitEvent: false});
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #addEntitiesToCustomerForm="ngForm" [formGroup]="addEntitiesToCustomerFormGroup" (ngSubmit)="assign()">
  18 +<form [formGroup]="addEntitiesToCustomerFormGroup" (ngSubmit)="assign()">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ assignToCustomerTitle | translate }}</h2>
21 21 <span fxFlex></span>
... ... @@ -42,8 +42,8 @@
42 42 <div mat-dialog-actions fxLayoutAlign="end center">
43 43 <button mat-raised-button color="primary"
44 44 type="submit"
45   - [disabled]="(isLoading$ | async) || addEntitiesToCustomerForm.invalid
46   - || !addEntitiesToCustomerForm.dirty">
  45 + [disabled]="(isLoading$ | async) || addEntitiesToCustomerFormGroup.invalid
  46 + || !addEntitiesToCustomerFormGroup.dirty">
47 47 {{ 'action.assign' | translate }}
48 48 </button>
49 49 <button mat-button color="primary"
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #assignToCustomerForm="ngForm" [formGroup]="assignToCustomerFormGroup" (ngSubmit)="assign()">
  18 +<form [formGroup]="assignToCustomerFormGroup" (ngSubmit)="assign()">
19 19 <mat-toolbar color="primary">
20 20 <h2>{{ assignToCustomerTitle | translate }}</h2>
21 21 <span fxFlex></span>
... ... @@ -41,8 +41,8 @@
41 41 <div mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
42 42 <button mat-raised-button color="primary"
43 43 type="submit"
44   - [disabled]="(isLoading$ | async) || assignToCustomerForm.invalid
45   - || !assignToCustomerForm.dirty">
  44 + [disabled]="(isLoading$ | async) || assignToCustomerFormGroup.invalid
  45 + || !assignToCustomerFormGroup.dirty">
46 46 {{ 'action.assign' | translate }}
47 47 </button>
48 48 <button mat-button color="primary"
... ...
... ... @@ -26,7 +26,7 @@
26 26 </mat-progress-bar>
27 27 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
28 28 <mat-card-content style="padding-top: 16px;">
29   - <form #generalSettingsForm="ngForm" [formGroup]="generalSettings" (ngSubmit)="save()">
  29 + <form [formGroup]="generalSettings" (ngSubmit)="save()">
30 30 <fieldset [disabled]="isLoading$ | async">
31 31 <mat-form-field class="mat-block">
32 32 <mat-label translate>admin.base-url</mat-label>
... ... @@ -36,7 +36,7 @@
36 36 </mat-error>
37 37 </mat-form-field>
38 38 <div fxLayout="row" fxLayoutAlign="end center" style="width: 100%;" class="layout-wrap">
39   - <button mat-button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || generalSettingsForm.invalid || !generalSettingsForm.dirty"
  39 + <button mat-button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || generalSettings.invalid || !generalSettings.dirty"
40 40 type="submit">{{'action.save' | translate}}
41 41 </button>
42 42 </div>
... ...
... ... @@ -28,7 +28,7 @@
28 28 </mat-progress-bar>
29 29 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
30 30 <mat-card-content style="padding-top: 16px;">
31   - <form #mailSettingsForm="ngForm" [formGroup]="mailSettings" (ngSubmit)="save()">
  31 + <form [formGroup]="mailSettings" (ngSubmit)="save()">
32 32 <fieldset [disabled]="isLoading$ | async">
33 33 <mat-form-field class="mat-block">
34 34 <mat-label translate>admin.mail-from</mat-label>
... ... @@ -97,10 +97,10 @@
97 97 </mat-form-field>
98 98 <div fxLayout="row" fxLayoutAlign="end center" fxLayout.xs="column" fxLayoutAlign.xs="end" fxLayoutGap="16px">
99 99 <button mat-raised-button type="button"
100   - [disabled]="(isLoading$ | async) || mailSettingsForm.invalid" (click)="sendTestMail()">
  100 + [disabled]="(isLoading$ | async) || mailSettings.invalid" (click)="sendTestMail()">
101 101 {{'admin.send-test-mail' | translate}}
102 102 </button>
103   - <button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || mailSettingsForm.invalid || !mailSettingsForm.dirty"
  103 + <button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || mailSettings.invalid || !mailSettings.dirty"
104 104 type="submit">{{'action.save' | translate}}
105 105 </button>
106 106 </div>
... ...
... ... @@ -28,7 +28,7 @@
28 28 </mat-progress-bar>
29 29 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
30 30 <mat-card-content style="padding-top: 16px;">
31   - <form #securitySettingsForm="ngForm" [formGroup]="securitySettingsFormGroup" (ngSubmit)="save()">
  31 + <form [formGroup]="securitySettingsFormGroup" (ngSubmit)="save()">
32 32 <fieldset [disabled]="isLoading$ | async">
33 33 <mat-expansion-panel [expanded]="true">
34 34 <mat-expansion-panel-header>
... ... @@ -140,7 +140,7 @@
140 140 </section>
141 141 </mat-expansion-panel>
142 142 <div fxLayout="row" fxLayoutAlign="end center" style="width: 100%;" class="layout-wrap">
143   - <button mat-button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || securitySettingsForm.invalid || !securitySettingsForm.dirty"
  143 + <button mat-button mat-raised-button color="primary" [disabled]="(isLoading$ | async) || securitySettingsFormGroup.invalid || !securitySettingsFormGroup.dirty"
144 144 type="submit">{{'action.save' | translate}}
145 145 </button>
146 146 </div>
... ...
... ... @@ -62,7 +62,7 @@
62 62 [fxShow]="!isEdit && entity?.customerIsPublic && (assetScope === 'customer' || assetScope === 'tenant')">
63 63 {{ 'asset.asset-public' | translate }}
64 64 </div>
65   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  65 + <form [formGroup]="entityForm">
66 66 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
67 67 <mat-form-field class="mat-block">
68 68 <mat-label translate>asset.name</mat-label>
... ...
... ... @@ -58,7 +58,7 @@
58 58 </div>
59 59 </div>
60 60 <div class="mat-padding" fxLayout="column">
61   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  61 + <form [formGroup]="entityForm">
62 62 <fieldset [fxShow]="!isPublic" [disabled]="(isLoading$ | async) || !isEdit">
63 63 <mat-form-field class="mat-block">
64 64 <mat-label translate>customer.title</mat-label>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #widgetForm="ngForm" [formGroup]="widgetFormGroup" (ngSubmit)="add()" style="width: 900px;">
  18 +<form [formGroup]="widgetFormGroup" (ngSubmit)="add()" style="width: 900px;">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>widget.add</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -90,7 +90,7 @@
90 90 </button>
91 91 </div>
92 92 </div>
93   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  93 + <form [formGroup]="entityForm">
94 94 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
95 95 <mat-form-field class="mat-block">
96 96 <mat-label translate>dashboard.title</mat-label>
... ...
... ... @@ -216,7 +216,7 @@
216 216 (closeDetails)="onEditWidgetClosed()"
217 217 (toggleDetailsEditMode)="onRevertWidgetEdit()"
218 218 (applyDetails)="saveWidget()"
219   - [theForm]="tbEditWidget.widgetForm">
  219 + [theForm]="tbEditWidget.widgetFormGroup">
220 220 <div class="details-buttons">
221 221 <div [tb-help]="helpLinkIdForWidgetType()"></div>
222 222 </div>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #settingsForm="ngForm" (ngSubmit)="save()">
  18 +<form (ngSubmit)="save()">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>{{settings ? 'dashboard.settings' : 'layout.settings'}}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #widgetForm="ngForm" [formGroup]="widgetFormGroup">
  18 +<form [formGroup]="widgetFormGroup">
19 19 <fieldset [disabled]="isLoading$ | async">
20 20 <tb-widget-config
21 21 [aliasController]="aliasController"
... ...
... ... @@ -49,8 +49,6 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan
49 49 @Input()
50 50 widgetLayout: WidgetLayout;
51 51
52   - @ViewChild('widgetForm', {static: true}) widgetForm: NgForm;
53   -
54 52 widgetFormGroup: FormGroup;
55 53
56 54 widgetConfig: WidgetConfigComponentData;
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #widgetForm="ngForm" [formGroup]="layoutsFormGroup" (ngSubmit)="save()">
  18 +<form [formGroup]="layoutsFormGroup" (ngSubmit)="save()">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>layout.manage</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #dashboardCustomersForm="ngForm" style="width: 600px;"
  18 +<form style="width: 600px;"
19 19 [formGroup]="dashboardCustomersFormGroup" (ngSubmit)="submit()">
20 20 <mat-toolbar fxLayout="row" color="primary">
21 21 <h2>{{ titleText | translate }}</h2>
... ... @@ -43,8 +43,8 @@
43 43 <span fxFlex></span>
44 44 <button mat-button mat-raised-button color="primary"
45 45 type="submit"
46   - [disabled]="(isLoading$ | async) || dashboardCustomersForm.invalid
47   - || !dashboardCustomersForm.dirty">
  46 + [disabled]="(isLoading$ | async) || dashboardCustomersFormGroup.invalid
  47 + || !dashboardCustomersFormGroup.dirty">
48 48 {{ actionName | translate }}
49 49 </button>
50 50 <button mat-button color="primary"
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #stateForm="ngForm" [formGroup]="stateFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
  18 +<form [formGroup]="stateFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>{{ isAdd ? 'dashboard.add-state' : 'dashboard.edit-state' }}</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #statesForm="ngForm" [formGroup]="statesFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
  18 +<form [formGroup]="statesFormGroup" (ngSubmit)="save()" style="min-width: 480px;">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>dashboard.manage-states</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #deviceCredentialsForm="ngForm" [formGroup]="deviceCredentialsFormGroup" (ngSubmit)="save()" style="min-width: 350px;">
  18 +<form [formGroup]="deviceCredentialsFormGroup" (ngSubmit)="save()" style="min-width: 350px;">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>device.device-credentials</h2>
21 21 <span fxFlex></span>
... ... @@ -63,8 +63,8 @@
63 63 <div mat-dialog-actions fxLayoutAlign="end center">
64 64 <button *ngIf="!isReadOnly" mat-raised-button color="primary"
65 65 type="submit"
66   - [disabled]="(isLoading$ | async) || deviceCredentialsForm.invalid
67   - || !deviceCredentialsForm.dirty">
  66 + [disabled]="(isLoading$ | async) || deviceCredentialsFormGroup.invalid
  67 + || !deviceCredentialsFormGroup.dirty">
68 68 {{ 'action.save' | translate }}
69 69 </button>
70 70 <button mat-button color="primary"
... ...
... ... @@ -74,7 +74,7 @@
74 74 [fxShow]="!isEdit && entity?.customerIsPublic && (deviceScope === 'customer' || deviceScope === 'tenant')">
75 75 {{ 'device.device-public' | translate }}
76 76 </div>
77   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  77 + <form [formGroup]="entityForm">
78 78 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
79 79 <mat-form-field class="mat-block">
80 80 <mat-label translate>device.name</mat-label>
... ...
... ... @@ -62,7 +62,7 @@
62 62 [fxShow]="!isEdit && entity?.customerIsPublic && (entityViewScope === 'customer' || entityViewScope === 'tenant')">
63 63 {{ 'entity-view.entity-view-public' | translate }}
64 64 </div>
65   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  65 + <form [formGroup]="entityForm">
66 66 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
67 67 <mat-form-field class="mat-block">
68 68 <mat-label translate>entity-view.name</mat-label>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #changePasswordForm="ngForm" [formGroup]="changePassword" (ngSubmit)="onChangePassword()">
  18 +<form [formGroup]="changePassword" (ngSubmit)="onChangePassword()">
19 19 <mat-toolbar fxLayout="row" color="primary">
20 20 <h2 translate>profile.change-password</h2>
21 21 <span fxFlex></span>
... ... @@ -48,7 +48,7 @@
48 48 <div mat-dialog-actions fxLayout="row" fxLayoutAlign="end center">
49 49 <button mat-raised-button color="primary"
50 50 type="submit"
51   - [disabled]="(isLoading$ | async) || changePasswordForm.invalid">
  51 + [disabled]="(isLoading$ | async) || changePassword.invalid">
52 52 {{ 'profile.change-password' | translate }}
53 53 </button>
54 54 <button mat-button color="primary"
... ...
... ... @@ -35,7 +35,7 @@
35 35 </mat-progress-bar>
36 36 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
37 37 <mat-card-content style="padding-top: 16px;">
38   - <form #profileForm="ngForm" [formGroup]="profile" (ngSubmit)="save()">
  38 + <form [formGroup]="profile" (ngSubmit)="save()">
39 39 <fieldset [disabled]="isLoading$ | async">
40 40 <mat-form-field class="mat-block">
41 41 <mat-label translate>user.email</mat-label>
... ... @@ -74,7 +74,7 @@
74 74 <span fxFlex></span>
75 75 <button mat-button mat-raised-button color="primary"
76 76 type="submit"
77   - [disabled]="(isLoading$ | async) || profileForm.invalid || !profileForm.dirty">
  77 + [disabled]="(isLoading$ | async) || profile.invalid || !profile.dirty">
78 78 {{ 'action.save' | translate }}
79 79 </button>
80 80 </div>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #ruleNodeForm="ngForm" (ngSubmit)="add()" style="min-width: 650px;">
  18 +<form (ngSubmit)="add()" style="min-width: 650px;">
19 19 <mat-toolbar fxLayout="row" color="primary">
20 20 <h2 translate>rulenode.add</h2>
21 21 <span fxFlex></span>
... ... @@ -42,7 +42,7 @@
42 42 <span fxFlex></span>
43 43 <button mat-button mat-raised-button color="primary"
44 44 type="submit"
45   - [disabled]="(isLoading$ | async) || tbRuleNode.ruleNodeForm.invalid || !tbRuleNode.ruleNodeForm.dirty">
  45 + [disabled]="(isLoading$ | async) || tbRuleNode.ruleNodeFormGroup.invalid || !tbRuleNode.ruleNodeFormGroup.dirty">
46 46 {{ 'action.add' | translate }}
47 47 </button>
48 48 <button mat-button color="primary"
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #ruleNodeLinkForm="ngForm" [formGroup]="ruleNodeLinkFormGroup" (ngSubmit)="add()" style="width: 900px;">
  18 +<form [formGroup]="ruleNodeLinkFormGroup" (ngSubmit)="add()" style="width: 900px;">
19 19 <mat-toolbar fxLayout="row" color="primary">
20 20 <h2 translate>rulenode.add-link</h2>
21 21 <span fxFlex></span>
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <div class="mat-padding" fxLayout="column">
19   - <form #ruleNodeForm="ngForm" [formGroup]="ruleNodeFormGroup">
  19 + <form [formGroup]="ruleNodeFormGroup">
20 20 <fieldset [disabled]="(isLoading$ | async) || !isEdit || isReadOnly">
21 21 <section *ngIf="ruleNode.component.type !== ruleNodeType.RULE_CHAIN">
22 22 <section fxLayout="column" fxLayout.gt-sm="row">
... ...
... ... @@ -32,8 +32,6 @@ import { RuleNodeConfigComponent } from './rule-node-config.component';
32 32 })
33 33 export class RuleNodeDetailsComponent extends PageComponent implements OnInit, OnChanges {
34 34
35   - @ViewChild('ruleNodeForm', {static: true}) ruleNodeForm: NgForm;
36   -
37 35 @ViewChild('ruleNodeConfigComponent') ruleNodeConfigComponent: RuleNodeConfigComponent;
38 36
39 37 @Input()
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <div class="mat-padding" fxLayout="column">
19   - <form #ruleNodeLinkForm="ngForm" [formGroup]="ruleNodeLinkFormGroup">
  19 + <form [formGroup]="ruleNodeLinkFormGroup">
20 20 <tb-link-labels
21 21 required
22 22 formControlName="labels"
... ...
... ... @@ -33,8 +33,6 @@ import { TranslateService } from '@ngx-translate/core';
33 33 })
34 34 export class RuleNodeLinkComponent implements ControlValueAccessor, OnInit {
35 35
36   - @ViewChild('ruleNodeLinkForm', {static: true}) ruleNodeLinkForm: NgForm;
37   -
38 36 private requiredValue: boolean;
39 37 get required(): boolean {
40 38 return this.requiredValue;
... ...
... ... @@ -107,7 +107,7 @@
107 107 (closeDetails)="onEditRuleNodeClosed()"
108 108 (toggleDetailsEditMode)="onRevertRuleNodeEdit()"
109 109 (applyDetails)="saveRuleNode()"
110   - [theForm]="tbRuleNode.ruleNodeForm">
  110 + [theForm]="tbRuleNode.ruleNodeFormGroup">
111 111 <div class="details-buttons">
112 112 <div [tb-help]="helpLinkIdForRuleNodeType()"></div>
113 113 </div>
... ... @@ -148,7 +148,7 @@
148 148 (closeDetails)="onEditRuleNodeLinkClosed()"
149 149 (toggleDetailsEditMode)="onRevertRuleNodeLinkEdit()"
150 150 (applyDetails)="saveRuleNodeLink()"
151   - [theForm]="tbRuleNodeLink.ruleNodeLinkForm">
  151 + [theForm]="tbRuleNodeLink.ruleNodeLinkFormGroup">
152 152 <div class="details-buttons">
153 153 <div [tb-help]="'ruleEngine'"></div>
154 154 </div>
... ...
... ... @@ -52,7 +52,7 @@
52 52 </div>
53 53 </div>
54 54 <div class="mat-padding" fxLayout="column">
55   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  55 + <form [formGroup]="entityForm">
56 56 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
57 57 <mat-form-field class="mat-block">
58 58 <mat-label translate>rulechain.name</mat-label>
... ...
... ... @@ -40,7 +40,7 @@
40 40 </div>
41 41 </div>
42 42 <div class="mat-padding" fxLayout="column">
43   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  43 + <form [formGroup]="entityForm">
44 44 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
45 45 <mat-form-field class="mat-block">
46 46 <mat-label translate>tenant.title</mat-label>
... ...
... ... @@ -18,7 +18,7 @@ import { Component, Inject, OnInit, ViewChild } from '@angular/core';
18 18 import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
19 19 import { Store } from '@ngrx/store';
20 20 import { AppState } from '@core/core.state';
21   -import { NgForm } from '@angular/forms';
  21 +import { FormGroup, NgForm } from '@angular/forms';
22 22 import { UserComponent } from '@modules/home/pages/user/user.component';
23 23 import { Authority } from '@shared/models/authority.enum';
24 24 import { ActivationMethod, activationMethodTranslations, User } from '@shared/models/user.model';
... ... @@ -46,7 +46,7 @@ export interface AddUserDialogData {
46 46 })
47 47 export class AddUserDialogComponent extends DialogComponent<AddUserDialogComponent, User> implements OnInit {
48 48
49   - detailsForm: NgForm;
  49 + detailsForm: FormGroup;
50 50 user: User;
51 51
52 52 activationMethods = Object.keys(ActivationMethod);
... ... @@ -71,7 +71,7 @@ export class AddUserDialogComponent extends DialogComponent<AddUserDialogCompone
71 71 this.user = {} as User;
72 72 this.userComponent.isEdit = true;
73 73 this.userComponent.entity = this.user;
74   - this.detailsForm = this.userComponent.entityNgForm;
  74 + this.detailsForm = this.userComponent.entityForm;
75 75 }
76 76
77 77 cancel(): void {
... ...
... ... @@ -55,7 +55,7 @@
55 55 </button>
56 56 </div>
57 57 <div class="mat-padding" fxLayout="column">
58   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  58 + <form [formGroup]="entityForm">
59 59 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
60 60 <mat-form-field class="mat-block">
61 61 <mat-label translate>user.email</mat-label>
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<form #saveWidgetTypeAsForm="ngForm" [formGroup]="saveWidgetTypeAsFormGroup" (ngSubmit)="saveAs()">
  18 +<form [formGroup]="saveWidgetTypeAsFormGroup" (ngSubmit)="saveAs()">
19 19 <mat-toolbar color="primary">
20 20 <h2 translate>widget.save-widget-type-as</h2>
21 21 <span fxFlex></span>
... ... @@ -48,8 +48,8 @@
48 48 <div mat-dialog-actions fxLayoutAlign="end center">
49 49 <button mat-raised-button color="primary"
50 50 type="submit"
51   - [disabled]="(isLoading$ | async) || saveWidgetTypeAsForm.invalid
52   - || !saveWidgetTypeAsForm.dirty">
  51 + [disabled]="(isLoading$ | async) || saveWidgetTypeAsFormGroup.invalid
  52 + || !saveWidgetTypeAsFormGroup.dirty">
53 53 {{ 'action.saveAs' | translate }}
54 54 </button>
55 55 <button mat-button color="primary"
... ...
... ... @@ -36,7 +36,7 @@
36 36 </button>
37 37 </div>
38 38 <div class="mat-padding" fxLayout="column">
39   - <form #entityNgForm="ngForm" [formGroup]="entityForm">
  39 + <form [formGroup]="entityForm">
40 40 <fieldset [disabled]="(isLoading$ | async) || !isEdit">
41 41 <mat-form-field class="mat-block">
42 42 <mat-label translate>widgets-bundle.title</mat-label>
... ...
... ... @@ -24,7 +24,7 @@
24 24 </mat-progress-bar>
25 25 <span style="height: 4px;" *ngIf="!(isLoading$ | async)"></span>
26 26 <mat-card-content>
27   - <form #createPasswordForm="ngForm" [formGroup]="createPassword" (ngSubmit)="onCreatePassword()">
  27 + <form [formGroup]="createPassword" (ngSubmit)="onCreatePassword()">
28 28 <fieldset [disabled]="isLoading$ | async">
29 29 <div tb-toast fxLayout="column" class="layout-padding">
30 30 <span style="height: 50px;"></span>
... ...
... ... @@ -18,7 +18,7 @@
18 18 <div class="tb-login-content mat-app-background tb-dark" fxFlex fxLayoutAlign="center center">
19 19 <mat-card style="height: 100%; max-height: 525px; overflow-y: auto;">
20 20 <mat-card-content>
21   - <form #loginForm="ngForm" class="tb-login-form" [formGroup]="loginFormGroup" (ngSubmit)="login()">
  21 + <form class="tb-login-form" [formGroup]="loginFormGroup" (ngSubmit)="login()">
22 22 <fieldset [disabled]="isLoading$ | async" fxLayout="column">
23 23 <div fxLayout="column" fxLayoutAlign="start center" style="padding: 15px 0;">
24 24 <tb-logo class="login-logo"></tb-logo>
... ...
... ... @@ -24,7 +24,7 @@
24 24 </mat-progress-bar>
25 25 <span style="height: 4px;" *ngIf="!(isLoading$ | async)"></span>
26 26 <mat-card-content>
27   - <form #requestPasswordResetForm="ngForm" [formGroup]="requestPasswordRequest" (ngSubmit)="sendResetPasswordLink()">
  27 + <form [formGroup]="requestPasswordRequest" (ngSubmit)="sendResetPasswordLink()">
28 28 <fieldset [disabled]="isLoading$ | async">
29 29 <div tb-toast fxLayout="column" class="layout-padding">
30 30 <span style="height: 50px;"></span>
... ...
... ... @@ -27,7 +27,7 @@
27 27 </mat-progress-bar>
28 28 <span style="height: 4px;" *ngIf="!(isLoading$ | async)"></span>
29 29 <mat-card-content>
30   - <form #resetPasswordForm="ngForm" [formGroup]="resetPassword" (ngSubmit)="onResetPassword()">
  30 + <form [formGroup]="resetPassword" (ngSubmit)="onResetPassword()">
31 31 <fieldset [disabled]="isLoading$ | async">
32 32 <div tb-toast fxLayout="column" class="layout-padding">
33 33 <span style="height: 50px;"></span>
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <form class="tb-node-script-test-dialog"
19   - #nodeScriptTestForm="ngForm" [formGroup]="nodeScriptTestFormGroup" (ngSubmit)="save()">
  19 + [formGroup]="nodeScriptTestFormGroup" (ngSubmit)="save()">
20 20 <mat-toolbar fxLayout="row" color="primary">
21 21 <h2>{{ 'rulenode.test-script-function' | translate }}</h2>
22 22 <span fxFlex></span>
... ...