From 29c02cccaf44012de79f9c4ff8fadd979ddc9354 Mon Sep 17 00:00:00 2001 From: August Andersen Date: Mon, 14 Mar 2022 10:49:09 +0100 Subject: [PATCH 1/2] functions and supportedunits are sorted alphabetically --- .../device-model-edit/device-model-edit.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/device-model/device-model-edit/device-model-edit.component.ts b/src/app/device-model/device-model-edit/device-model-edit.component.ts index a1e23526..ea5a12e8 100644 --- a/src/app/device-model/device-model-edit/device-model-edit.component.ts +++ b/src/app/device-model/device-model-edit/device-model-edit.component.ts @@ -31,7 +31,7 @@ export class DeviceModelEditComponent implements OnInit { controlledPropperties = []; categories = []; supportedUnits = new SupportedUnit(); - deviceFunctions = []; + deviceFunctions: string[] = []; energyLimitationClass = new EnergyLimitationClass(); supportedProtocol = []; @@ -55,12 +55,14 @@ export class DeviceModelEditComponent implements OnInit { if (deviceModelId) { this.getDeviceModel(deviceModelId); } + this.supportedUnits.units.sort((a,b) => a.name.localeCompare(b.name)); } mapEnumsToArray() { this.controlledPropperties = Object.values(ControlledPropperty); this.categories = Object.values(DeviceCategory); this.deviceFunctions = Object.values(DeviceFunction); + this.deviceFunctions.sort((a: string, b: string) => a.localeCompare(b)); this.supportedProtocol = Object.values(SupportedProtocol); } From 97853fa52edf8501ac562b23ce01b9923ae5ba27 Mon Sep 17 00:00:00 2001 From: Aram Al-Sabti Date: Wed, 16 Mar 2022 15:31:56 +0100 Subject: [PATCH 2/2] Improve device model edit typing --- .../device-model-edit.component.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/device-model/device-model-edit/device-model-edit.component.ts b/src/app/device-model/device-model-edit/device-model-edit.component.ts index ea5a12e8..ce0d3b0c 100644 --- a/src/app/device-model/device-model-edit/device-model-edit.component.ts +++ b/src/app/device-model/device-model-edit/device-model-edit.component.ts @@ -22,18 +22,18 @@ import { SupportedUnit } from '../supported-unit.model'; }) export class DeviceModelEditComponent implements OnInit { - public errorMessages: any; + public errorMessages: string[]; public errorFields: string[]; public deviceModel: DeviceModel = new DeviceModel(); public backButton: BackButton = { label: '', routerLink: '/device-model' }; public title = ''; public formFailedSubmit = false; - controlledPropperties = []; - categories = []; + controlledPropperties: ControlledPropperty[] = []; + categories: DeviceCategory[] = []; supportedUnits = new SupportedUnit(); - deviceFunctions: string[] = []; + deviceFunctions: DeviceFunction[] = []; energyLimitationClass = new EnergyLimitationClass(); - supportedProtocol = []; + supportedProtocol: SupportedProtocol[] = []; constructor( private translate: TranslateService, @@ -55,14 +55,14 @@ export class DeviceModelEditComponent implements OnInit { if (deviceModelId) { this.getDeviceModel(deviceModelId); } - this.supportedUnits.units.sort((a,b) => a.name.localeCompare(b.name)); + this.supportedUnits.units.sort((a, b) => a.name.localeCompare(b.name)); + this.deviceFunctions.sort((a, b) => a.localeCompare(b)); } mapEnumsToArray() { this.controlledPropperties = Object.values(ControlledPropperty); this.categories = Object.values(DeviceCategory); this.deviceFunctions = Object.values(DeviceFunction); - this.deviceFunctions.sort((a: string, b: string) => a.localeCompare(b)); this.supportedProtocol = Object.values(SupportedProtocol); }