Commit 7cb9bcb1 authored by Diogo Santos's avatar Diogo Santos
Browse files

Include valueFrom, valueTo and rangeInterval in characteristics sent to the TMF API

parent 12e6043f
Loading
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ export class EditServiceSpecCharacteristicsComponent implements OnInit {


  updateFormArrayItem(CharValue: ServiceSpecCharacteristicValue): UntypedFormGroup {
    const rangeInterval = CharValue.valueFrom != null || CharValue.valueTo != null ? "closed" : null
    return new UntypedFormGroup({
      value: new UntypedFormGroup({
        alias: new UntypedFormControl(CharValue.value.alias),
@@ -127,7 +128,10 @@ export class EditServiceSpecCharacteristicsComponent implements OnInit {
      }),
      unitOfMeasure: new UntypedFormControl(CharValue.unitOfMeasure),
      isDefault: new UntypedFormControl({value: (CharValue.isDefault || this.data.specToBeUpdated.valueType === 'ARRAY'), disabled: this.data.specToBeUpdated.valueType === 'ARRAY'}),
      valueType: new UntypedFormControl(CharValue.valueType)
      valueType: new UntypedFormControl(CharValue.valueType),
      valueFrom: new UntypedFormControl(CharValue.valueFrom),
      valueTo: new UntypedFormControl(CharValue.valueTo),
      rangeInterval: new UntypedFormControl(rangeInterval)
    })
  }

@@ -151,9 +155,13 @@ export class EditServiceSpecCharacteristicsComponent implements OnInit {
        }),
        unitOfMeasure: new UntypedFormControl(),
        isDefault: new UntypedFormControl({value: this.editFormCharacteristic.get('valueType').value === 'ARRAY', disabled: this.editFormCharacteristic.get('valueType').value === 'ARRAY'}),
        valueType: new UntypedFormControl(subType)
        valueType: new UntypedFormControl(subType),
        valueFrom: new UntypedFormControl(),
        valueTo: new UntypedFormControl(),
        rangeInterval: new UntypedFormControl()
      })
    )

    this.isCharValueBlockExpanded.push(false)
  }

@@ -184,7 +192,15 @@ export class EditServiceSpecCharacteristicsComponent implements OnInit {
  submitDialog() {
    
    if (this.newSpec) {
      this.data.serviceSpec.serviceSpecCharacteristic.push(this.editFormCharacteristic.getRawValue())
      const specChar = this.editFormCharacteristic.getRawValue();
      // rangeInterval defaults to closed for INTEGER characteristics in order to be validated by the API. 
      // Without this code rangeInterval would be null and therefore no validation would be done.
      specChar.serviceSpecCharacteristicValue.forEach(value => {
        if (value.valueFrom != null || value.valueTo != null) {
          value.rangeInterval = 'closed';
        }
      });
      this.data.serviceSpec.serviceSpecCharacteristic.push(specChar);
    } else {
      const updateCharacteristIndex = this.data.serviceSpec.serviceSpecCharacteristic.findIndex(char => char.id === this.data.specToBeUpdated.id)
      this.data.serviceSpec.serviceSpecCharacteristic[updateCharacteristIndex] = this.editFormCharacteristic.getRawValue()