From 0289b0c1a2b9bec66cc5261c3c862a855d01d140 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 27 Apr 2020 10:39:18 +0300 Subject: [PATCH] UI: Get rid of 'multiple directives with 'exportAs' set to ngForm' --- .../components/alias/entity-alias-dialog.component.html | 2 +- .../alias/entity-aliases-dialog.component.html | 2 +- .../add-widget-to-dashboard-dialog.component.html | 2 +- .../attribute/edit-attribute-value-panel.component.html | 3 +-- .../dashboard/select-target-layout-dialog.component.html | 2 +- .../dashboard/select-target-state-dialog.component.html | 2 +- .../modules/home/components/details-panel.component.ts | 8 ++++---- .../components/entity/add-entity-dialog.component.ts | 6 +++--- .../components/entity/entity-details-panel.component.ts | 6 +++--- .../home/components/entity/entity-tabs.component.ts | 4 ++-- .../modules/home/components/entity/entity.component.ts | 2 -- .../import-export/import-dialog.component.html | 2 +- .../components/relation/relation-dialog.component.html | 2 +- .../widget/action/widget-action-dialog.component.html | 2 +- .../widget/data-key-config-dialog.component.html | 4 ++-- .../widget/lib/multiple-input-widget.component.html | 5 ++--- .../widget/lib/multiple-input-widget.component.ts | 9 ++++----- .../add-entities-to-customer-dialog.component.html | 6 +++--- .../dialogs/assign-to-customer-dialog.component.html | 6 +++--- .../home/pages/admin/general-settings.component.html | 4 ++-- .../modules/home/pages/admin/mail-server.component.html | 6 +++--- .../home/pages/admin/security-settings.component.html | 4 ++-- .../app/modules/home/pages/asset/asset.component.html | 2 +- .../modules/home/pages/customer/customer.component.html | 2 +- .../pages/dashboard/add-widget-dialog.component.html | 2 +- .../home/pages/dashboard/dashboard-form.component.html | 2 +- .../home/pages/dashboard/dashboard-page.component.html | 2 +- .../dashboard/dashboard-settings-dialog.component.html | 2 +- .../home/pages/dashboard/edit-widget.component.html | 2 +- .../home/pages/dashboard/edit-widget.component.ts | 2 -- .../manage-dashboard-layouts-dialog.component.html | 2 +- .../manage-dashboard-customers-dialog.component.html | 6 +++--- .../states/dashboard-state-dialog.component.html | 2 +- .../states/manage-dashboard-states-dialog.component.html | 2 +- .../device/device-credentials-dialog.component.html | 6 +++--- .../app/modules/home/pages/device/device.component.html | 2 +- .../home/pages/entity-view/entity-view.component.html | 2 +- .../pages/profile/change-password-dialog.component.html | 4 ++-- .../modules/home/pages/profile/profile.component.html | 4 ++-- .../pages/rulechain/add-rule-node-dialog.component.html | 4 ++-- .../rulechain/add-rule-node-link-dialog.component.html | 2 +- .../pages/rulechain/rule-node-details.component.html | 2 +- .../home/pages/rulechain/rule-node-details.component.ts | 2 -- .../home/pages/rulechain/rule-node-link.component.html | 2 +- .../home/pages/rulechain/rule-node-link.component.ts | 2 -- .../home/pages/rulechain/rulechain-page.component.html | 4 ++-- .../home/pages/rulechain/rulechain.component.html | 2 +- .../app/modules/home/pages/tenant/tenant.component.html | 2 +- .../modules/home/pages/user/add-user-dialog.component.ts | 6 +++--- .../src/app/modules/home/pages/user/user.component.html | 2 +- .../widget/save-widget-type-as-dialog.component.html | 6 +++--- .../home/pages/widget/widgets-bundle.component.html | 2 +- .../login/pages/login/create-password.component.html | 2 +- .../app/modules/login/pages/login/login.component.html | 2 +- .../pages/login/reset-password-request.component.html | 2 +- .../login/pages/login/reset-password.component.html | 2 +- .../dialog/node-script-test-dialog.component.html | 2 +- 57 files changed, 86 insertions(+), 97 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.html b/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.html index 0731de4ce2..b7f0ff21fc 100644 --- a/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/alias/entity-alias-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+

{{ (isAdd ? 'alias.add' : 'alias.edit') | translate }}

diff --git a/ui-ngx/src/app/modules/home/components/alias/entity-aliases-dialog.component.html b/ui-ngx/src/app/modules/home/components/alias/entity-aliases-dialog.component.html index c0f22872eb..f817762f95 100644 --- a/ui-ngx/src/app/modules/home/components/alias/entity-aliases-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/alias/entity-aliases-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ title | translate }}

diff --git a/ui-ngx/src/app/modules/home/components/attribute/add-widget-to-dashboard-dialog.component.html b/ui-ngx/src/app/modules/home/components/attribute/add-widget-to-dashboard-dialog.component.html index ad85a91923..60fe5e30d7 100644 --- a/ui-ngx/src/app/modules/home/components/attribute/add-widget-to-dashboard-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/attribute/add-widget-to-dashboard-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

attribute.add-widget-to-dashboard

diff --git a/ui-ngx/src/app/modules/home/components/attribute/edit-attribute-value-panel.component.html b/ui-ngx/src/app/modules/home/components/attribute/edit-attribute-value-panel.component.html index a3547cd486..8e2264fae1 100644 --- a/ui-ngx/src/app/modules/home/components/attribute/edit-attribute-value-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/attribute/edit-attribute-value-panel.component.html @@ -15,8 +15,7 @@ limitations under the License. --> -
- +

layout.select

diff --git a/ui-ngx/src/app/modules/home/components/dashboard/select-target-state-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard/select-target-state-dialog.component.html index 16d82ab9b2..41ba893e57 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/select-target-state-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard/select-target-state-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

dashboard.select-state

diff --git a/ui-ngx/src/app/modules/home/components/details-panel.component.ts b/ui-ngx/src/app/modules/home/components/details-panel.component.ts index 66a9f3dc82..1e1ecb8a97 100644 --- a/ui-ngx/src/app/modules/home/components/details-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/details-panel.component.ts @@ -18,7 +18,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; -import { NgForm } from '@angular/forms'; +import { FormGroup, NgForm } from '@angular/forms'; @Component({ selector: 'tb-details-panel', @@ -33,14 +33,14 @@ export class DetailsPanelComponent extends PageComponent { @Input() isReadOnly = false; @Input() isAlwaysEdit = false; - theFormValue: NgForm; + theFormValue: FormGroup; @Input() - set theForm(value: NgForm) { + set theForm(value: FormGroup) { this.theFormValue = value; } - get theForm(): NgForm { + get theForm(): FormGroup { return this.theFormValue; } diff --git a/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts b/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts index 2a39250872..871242c954 100644 --- a/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/add-entity-dialog.component.ts @@ -19,7 +19,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; -import { FormControl, FormGroupDirective, NgForm } from '@angular/forms'; +import { FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms'; import { EntityTypeResource, EntityTypeTranslation } from '@shared/models/entity-type.models'; import { BaseData, HasId } from '@shared/models/base-data'; import { EntityId } from '@shared/models/id/entity-id'; @@ -40,7 +40,7 @@ export class AddEntityDialogComponent extends DialogComponent> implements OnInit, ErrorStateMatcher { entityComponent: EntityComponent>; - detailsForm: NgForm; + detailsForm: FormGroup; entitiesTableConfig: EntityTableConfig>; translations: EntityTypeTranslation; @@ -87,7 +87,7 @@ export class AddEntityDialogComponent extends const componentRef = viewContainerRef.createComponent(componentFactory, 0, injector); this.entityComponent = componentRef.instance; this.entityComponent.isEdit = true; - this.detailsForm = this.entityComponent.entityNgForm; + this.detailsForm = this.entityComponent.entityForm; } helpLinkId(): string { diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts index 37f63ecebc..af70020946 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-details-panel.component.ts @@ -37,7 +37,7 @@ import { AppState } from '@core/core.state'; import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { BaseData, HasId } from '@shared/models/base-data'; import { EntityType, EntityTypeResource, EntityTypeTranslation } from '@shared/models/entity-type.models'; -import { NgForm } from '@angular/forms'; +import { FormGroup, NgForm } from '@angular/forms'; import { EntityComponent } from './entity.component'; import { TbAnchorComponent } from '@shared/components/tb-anchor.component'; import { EntityAction } from '@home/models/entity/entity-component.models'; @@ -68,7 +68,7 @@ export class EntityDetailsPanelComponent extends PageComponent implements OnInit entityTabsComponentRef: ComponentRef>>; entityTabsComponent: EntityTabsComponent>; - detailsForm: NgForm; + detailsForm: FormGroup; entitiesTableConfigValue: EntityTableConfig>; isEditValue = false; @@ -189,7 +189,7 @@ export class EntityDetailsPanelComponent extends PageComponent implements OnInit this.entityComponentRef = viewContainerRef.createComponent(componentFactory, 0, injector); this.entityComponent = this.entityComponentRef.instance; this.entityComponent.isEdit = this.isEdit; - this.detailsForm = this.entityComponent.entityNgForm; + this.detailsForm = this.entityComponent.entityForm; this.subscriptions.push(this.entityComponent.entityAction.subscribe((action) => { this.entityAction.emit(action); })); diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-tabs.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-tabs.component.ts index 41ba7420dc..ef81cef161 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-tabs.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-tabs.component.ts @@ -30,7 +30,7 @@ import { AuditLogMode } from '@shared/models/audit-log.models'; import { DebugEventType, EventType } from '@shared/models/event.models'; import { AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models'; import { NULL_UUID } from '@shared/models/id/has-uuid'; -import { NgForm } from '@angular/forms'; +import { FormGroup, NgForm } from '@angular/forms'; import { PageLink } from '@shared/models/page/page-link'; @Directive() @@ -94,7 +94,7 @@ export abstract class EntityTabsComponent, } @Input() - detailsForm: NgForm; + detailsForm: FormGroup; private entityTabsSubject = new BehaviorSubject>(null); diff --git a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts index d98bcd3adf..b98f5a3b44 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts @@ -35,8 +35,6 @@ export abstract class EntityComponent, entityForm: FormGroup; - @ViewChild('entityNgForm', {static: true}) entityNgForm: NgForm; - isEditValue: boolean; @Input() diff --git a/ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.html b/ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.html index 3e35485b9b..e53ff360ca 100644 --- a/ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/import-export/import-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ importTitle }}

diff --git a/ui-ngx/src/app/modules/home/components/relation/relation-dialog.component.html b/ui-ngx/src/app/modules/home/components/relation/relation-dialog.component.html index 85f0ae64c5..2d637c4066 100644 --- a/ui-ngx/src/app/modules/home/components/relation/relation-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/relation/relation-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ (isAdd ? 'relation.add' : 'relation.edit' ) | translate }}

diff --git a/ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html index b3d56b9774..7bf068a4d0 100644 --- a/ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ (isAdd ? 'widget-config.add-action' : 'widget-config.edit-action' ) | translate }}

diff --git a/ui-ngx/src/app/modules/home/components/widget/data-key-config-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/data-key-config-dialog.component.html index 4b6908bc6f..f05c97f3d5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/data-key-config-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/data-key-config-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ 'datakey.configuration' | translate }}

@@ -39,7 +39,7 @@
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/multiple-input-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/multiple-input-widget.component.ts index d3912e0a76..01adeacdce 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/multiple-input-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/multiple-input-widget.component.ts @@ -27,7 +27,7 @@ import { IWidgetSubscription } from '@core/api/widget-api.models'; import { isDefined, isEqual, isUndefined } from '@core/utils'; import { EntityType } from '@shared/models/entity-type.models'; import * as _moment from 'moment'; -import { FormBuilder, FormGroup, NgForm, ValidatorFn, Validators } from '@angular/forms'; +import { FormBuilder, FormGroup, ValidatorFn, Validators } from '@angular/forms'; import { RequestConfig } from '@core/http/http-utils'; import { AttributeService } from '@core/http/attribute.service'; import { AttributeData, AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models'; @@ -90,7 +90,6 @@ interface MultipleInputWidgetSource { export class MultipleInputWidgetComponent extends PageComponent implements OnInit, OnDestroy { @ViewChild('formContainer', {static: true}) formContainerRef: ElementRef; - @ViewChild('multipleInputForm', {static: true}) multipleInputForm: NgForm; @Input() ctx: WidgetContext; @@ -453,7 +452,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni if (tasks.length) { forkJoin(tasks).subscribe( () => { - this.multipleInputForm.resetForm(); + this.multipleInputFormGroup.reset(undefined, {emitEvent: false}); this.multipleInputFormGroup.markAsPristine(); if (this.settings.showResultMessage) { this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'), @@ -467,13 +466,13 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni } }); } else { - this.multipleInputForm.resetForm(); + this.multipleInputFormGroup.reset(undefined, {emitEvent: false}); this.multipleInputFormGroup.markAsPristine(); } } public discardAll() { - this.multipleInputForm.resetForm(); + this.multipleInputFormGroup.reset(undefined, {emitEvent: false}); this.sources.forEach((source) => { for (const key of this.visibleKeys(source)) { this.multipleInputFormGroup.get(key.formId).patchValue(key.value, {emitEvent: false}); diff --git a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-customer-dialog.component.html b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-customer-dialog.component.html index 9368219816..0b33828bc4 100644 --- a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-customer-dialog.component.html +++ b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-customer-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ assignToCustomerTitle | translate }}

@@ -42,8 +42,8 @@
diff --git a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html index e87ccd3159..f2972687f5 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html @@ -28,7 +28,7 @@
- +
admin.mail-from @@ -97,10 +97,10 @@
-
diff --git a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html index b0b8b52dd7..df2184967d 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html +++ b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html @@ -28,7 +28,7 @@
- +
@@ -140,7 +140,7 @@
-
diff --git a/ui-ngx/src/app/modules/home/pages/asset/asset.component.html b/ui-ngx/src/app/modules/home/pages/asset/asset.component.html index 7a9b65d82e..a78d55ef93 100644 --- a/ui-ngx/src/app/modules/home/pages/asset/asset.component.html +++ b/ui-ngx/src/app/modules/home/pages/asset/asset.component.html @@ -62,7 +62,7 @@ [fxShow]="!isEdit && entity?.customerIsPublic && (assetScope === 'customer' || assetScope === 'tenant')"> {{ 'asset.asset-public' | translate }} - +
asset.name diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html index a30e0acdd5..bb75d81fbd 100644 --- a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html +++ b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html @@ -58,7 +58,7 @@
- +
customer.title diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html index 1b148c64ea..65f6900035 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

widget.add

diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html index 6589e4f81c..4c8376e218 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html @@ -90,7 +90,7 @@
- +
dashboard.title diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html index 76a59242a9..1c35a09282 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html @@ -216,7 +216,7 @@ (closeDetails)="onEditWidgetClosed()" (toggleDetailsEditMode)="onRevertWidgetEdit()" (applyDetails)="saveWidget()" - [theForm]="tbEditWidget.widgetForm"> + [theForm]="tbEditWidget.widgetFormGroup">
diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-settings-dialog.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-settings-dialog.component.html index 0227668842..41a3151d13 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-settings-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-settings-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{settings ? 'dashboard.settings' : 'layout.settings'}}

diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/edit-widget.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/edit-widget.component.html index 110fec0b3f..6dba30e6f2 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/edit-widget.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/edit-widget.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +
- +

layout.manage

diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/manage-dashboard-customers-dialog.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/manage-dashboard-customers-dialog.component.html index 45072cda33..1e6c21cb7c 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/manage-dashboard-customers-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/manage-dashboard-customers-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -

{{ titleText | translate }}

@@ -43,8 +43,8 @@ diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/add-rule-node-dialog.component.html b/ui-ngx/src/app/modules/home/pages/rulechain/add-rule-node-dialog.component.html index 563dc43354..edd35ba06e 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/add-rule-node-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/rulechain/add-rule-node-dialog.component.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

rulenode.add

@@ -42,7 +42,7 @@