Merge pull request #8931 from ArtemDzhereleiko/AD/imp/add-asset-dialog
Improvement for Add asset dialog
This commit is contained in:
commit
bff3297c56
@ -43,6 +43,11 @@
|
|||||||
(click)="editAssetProfile($event)">
|
(click)="editAssetProfile($event)">
|
||||||
<mat-icon class="material-icons">edit</mat-icon>
|
<mat-icon class="material-icons">edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-button color="primary" matSuffix
|
||||||
|
(click)="createAssetProfile($event, '')"
|
||||||
|
*ngIf="!selectAssetProfileFormGroup.get('assetProfile').value && !disabled && addNewProfile">
|
||||||
|
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
|
||||||
|
</button>
|
||||||
<mat-autocomplete
|
<mat-autocomplete
|
||||||
class="tb-autocomplete"
|
class="tb-autocomplete"
|
||||||
(closed)="onPanelClosed()"
|
(closed)="onPanelClosed()"
|
||||||
|
|||||||
@ -19,3 +19,9 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host ::ng-deep {
|
||||||
|
.mat-mdc-form-field-icon-suffix {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import { AssetProfile, AssetProfileInfo } from '@shared/models/asset.models';
|
|||||||
import { AssetProfileService } from '@core/http/asset-profile.service';
|
import { AssetProfileService } from '@core/http/asset-profile.service';
|
||||||
import { AssetProfileDialogComponent, AssetProfileDialogData } from './asset-profile-dialog.component';
|
import { AssetProfileDialogComponent, AssetProfileDialogData } from './asset-profile-dialog.component';
|
||||||
import { SubscriptSizing } from '@angular/material/form-field';
|
import { SubscriptSizing } from '@angular/material/form-field';
|
||||||
|
import { coerceBoolean } from '@shared/decorators/coercion';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-asset-profile-autocomplete',
|
selector: 'tb-asset-profile-autocomplete',
|
||||||
@ -84,14 +85,9 @@ export class AssetProfileAutocompleteComponent implements ControlValueAccessor,
|
|||||||
@Input()
|
@Input()
|
||||||
showDetailsPageLink = false;
|
showDetailsPageLink = false;
|
||||||
|
|
||||||
private requiredValue: boolean;
|
|
||||||
get required(): boolean {
|
|
||||||
return this.requiredValue;
|
|
||||||
}
|
|
||||||
@Input()
|
@Input()
|
||||||
set required(value: boolean) {
|
@coerceBoolean()
|
||||||
this.requiredValue = coerceBooleanProperty(value);
|
required = false;
|
||||||
}
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button mat-button color="primary" matSuffix
|
<button mat-button color="primary" matSuffix
|
||||||
(click)="createDeviceProfile($event, '')"
|
(click)="createDeviceProfile($event, '')"
|
||||||
*ngIf="!selectDeviceProfileFormGroup.get('deviceProfile').value && !disabled && addNewProfile && showCreateNewButton">
|
*ngIf="!selectDeviceProfileFormGroup.get('deviceProfile').value && !disabled && addNewProfile">
|
||||||
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
|
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
<mat-autocomplete
|
<mat-autocomplete
|
||||||
|
|||||||
@ -88,10 +88,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
|
|||||||
@coerceBoolean()
|
@coerceBoolean()
|
||||||
addNewProfile = true;
|
addNewProfile = true;
|
||||||
|
|
||||||
@Input()
|
|
||||||
@coerceBoolean()
|
|
||||||
showCreateNewButton = false;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showDetailsPageLink = false;
|
showDetailsPageLink = false;
|
||||||
|
|
||||||
|
|||||||
@ -146,11 +146,8 @@ export class DeviceWizardDialogComponent extends DialogComponent<DeviceWizardDia
|
|||||||
overwriteActivityTime: this.deviceWizardFormGroup.get('overwriteActivityTime').value,
|
overwriteActivityTime: this.deviceWizardFormGroup.get('overwriteActivityTime').value,
|
||||||
description: this.deviceWizardFormGroup.get('description').value
|
description: this.deviceWizardFormGroup.get('description').value
|
||||||
},
|
},
|
||||||
customerId: null
|
customerId: this.deviceWizardFormGroup.get('customerId').value
|
||||||
};
|
};
|
||||||
if (this.deviceWizardFormGroup.get('customerId').value) {
|
|
||||||
device.customerId = new CustomerId(this.deviceWizardFormGroup.get('customerId').value);
|
|
||||||
}
|
|
||||||
if (this.addDeviceWizardStepper.steps.last.completed || this.addDeviceWizardStepper.selectedIndex > 0) {
|
if (this.addDeviceWizardStepper.steps.last.completed || this.addDeviceWizardStepper.selectedIndex > 0) {
|
||||||
return this.deviceService.saveDeviceWithCredentials(deepTrim(device), deepTrim(this.credentialsFormGroup.value.credential)).pipe(
|
return this.deviceService.saveDeviceWithCredentials(deepTrim(device), deepTrim(this.credentialsFormGroup.value.credential)).pipe(
|
||||||
catchError((e: HttpErrorResponse) => {
|
catchError((e: HttpErrorResponse) => {
|
||||||
|
|||||||
@ -86,13 +86,6 @@
|
|||||||
{{ 'asset.name-max-length' | translate }}
|
{{ 'asset.name-max-length' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<tb-asset-profile-autocomplete
|
|
||||||
[selectDefaultProfile]="isAdd"
|
|
||||||
required
|
|
||||||
formControlName="assetProfileId"
|
|
||||||
[showDetailsPageLink]="true"
|
|
||||||
(assetProfileUpdated)="onAssetProfileUpdated()">
|
|
||||||
</tb-asset-profile-autocomplete>
|
|
||||||
<mat-form-field class="mat-block">
|
<mat-form-field class="mat-block">
|
||||||
<mat-label translate>asset.label</mat-label>
|
<mat-label translate>asset.label</mat-label>
|
||||||
<input matInput formControlName="label">
|
<input matInput formControlName="label">
|
||||||
@ -100,6 +93,20 @@
|
|||||||
{{ 'asset.label-max-length' | translate }}
|
{{ 'asset.label-max-length' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<tb-asset-profile-autocomplete
|
||||||
|
[selectDefaultProfile]="isAdd"
|
||||||
|
required
|
||||||
|
formControlName="assetProfileId"
|
||||||
|
[showDetailsPageLink]="true"
|
||||||
|
(assetProfileUpdated)="onAssetProfileUpdated()">
|
||||||
|
</tb-asset-profile-autocomplete>
|
||||||
|
<tb-entity-autocomplete
|
||||||
|
*ngIf="isAdd"
|
||||||
|
useFullEntityId
|
||||||
|
formControlName="customerId"
|
||||||
|
labelText="asset.assign-to-customer"
|
||||||
|
[entityType]="entityType.CUSTOMER">
|
||||||
|
</tb-entity-autocomplete>
|
||||||
<div formGroupName="additionalInfo">
|
<div formGroupName="additionalInfo">
|
||||||
<mat-form-field class="mat-block">
|
<mat-form-field class="mat-block">
|
||||||
<mat-label translate>asset.description</mat-label>
|
<mat-label translate>asset.description</mat-label>
|
||||||
|
|||||||
@ -69,6 +69,7 @@ export class AssetComponent extends EntityComponent<AssetInfo> {
|
|||||||
name: [entity ? entity.name : '', [Validators.required, Validators.maxLength(255)]],
|
name: [entity ? entity.name : '', [Validators.required, Validators.maxLength(255)]],
|
||||||
assetProfileId: [entity ? entity.assetProfileId : null, [Validators.required]],
|
assetProfileId: [entity ? entity.assetProfileId : null, [Validators.required]],
|
||||||
label: [entity ? entity.label : '', Validators.maxLength(255)],
|
label: [entity ? entity.label : '', Validators.maxLength(255)],
|
||||||
|
customerId: [entity ? entity.customerId : ''],
|
||||||
additionalInfo: this.fb.group(
|
additionalInfo: this.fb.group(
|
||||||
{
|
{
|
||||||
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
|
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
|
||||||
@ -82,6 +83,7 @@ export class AssetComponent extends EntityComponent<AssetInfo> {
|
|||||||
this.entityForm.patchValue({name: entity.name});
|
this.entityForm.patchValue({name: entity.name});
|
||||||
this.entityForm.patchValue({assetProfileId: entity.assetProfileId});
|
this.entityForm.patchValue({assetProfileId: entity.assetProfileId});
|
||||||
this.entityForm.patchValue({label: entity.label});
|
this.entityForm.patchValue({label: entity.label});
|
||||||
|
this.entityForm.patchValue({customerId: entity.customerId});
|
||||||
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
|
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user