3 ~ ============LICENSE_START=======================================================
4 ~ Copyright (C) 2022 Nordix Foundation.
5 ~ ================================================================================
6 ~ Licensed under the Apache License, Version 2.0 (the "License");
7 ~ you may not use this file except in compliance with the License.
8 ~ You may obtain a copy of the License at
10 ~ http://www.apache.org/licenses/LICENSE-2.0
12 ~ Unless required by applicable law or agreed to in writing, software
13 ~ distributed under the License is distributed on an "AS IS" BASIS,
14 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ~ See the License for the specific language governing permissions and
16 ~ limitations under the License.
18 ~ SPDX-License-Identifier: Apache-2.0
19 ~ ============LICENSE_END=========================================================
22 <div class="app-constraints">
23 <form novalidate class="w-sdc-form two-columns" [formGroup]="constraintForm">
24 <div *ngFor="let constraint of constraintsArray.controls; let constraintIndex = index; trackBy:trackByFn">
26 <div formArrayName="constraint">
27 <div class="w-sdc-form-columns-wrapper" [formGroupName]="constraintIndex">
28 <div class="w-sdc-form-column-small">
29 <select class="i-sdc-form-select"
30 data-tests-id="constraints"
31 formControlName="type"
32 [value]="constraintsArray.at(constraintIndex).get('type').value"
33 (change)="onChangeConstraintType(constraintIndex, $event.target.value)">
34 <option *ngIf="constraint" [value]="constraint.value.type"
36 {{ConstraintTypesMapping[constraint.value.type]}}
38 <option *ngFor="let constraintType of constraintTypes"
39 [value]="constraintType"
40 [disabled]="disableConstraint(constraintType, constraint.value.type)">
41 {{ConstraintTypesMapping[constraintType]}}
45 <div class="validation-errors">
46 <ng-container *ngFor="let validation of validationMessages.type">
47 <div class="input-error" *ngIf="constraintsArray.at(constraintIndex).get('type').hasError(validation.type);">
48 {{ validation.message }}
55 <div class="w-sdc-form-columns-wrapper">
57 <div class="w-sdc-form-column">
58 <div class="w-sdc-form-columns-wrapper" *ngIf="constraint.value.type == 'inRange'">
59 <div class="w-sdc-form-column">
60 <input type="text" class="i-sdc-form-input myClass" required
61 (input)="onChangeConstrainValueIndex(constraintIndex, $event.target.value, 0)"
62 [value]="getInRangeValue(constraintIndex, 0)"/>
64 <ng-container *ngFor="let validation of validationMessages.constraint">
65 <div class="input-error" *ngIf="constraintValuesArray(constraintIndex).controls[0].hasError(validation.type);">
66 {{ validation.message }}
70 <div class="w-sdc-form-column">
71 <input type="text" class="i-sdc-form-input myClass" required
72 (input)="onChangeConstrainValueIndex(constraintIndex, $event.target.value, 1)"
73 [value]="getInRangeValue(constraintIndex, 1)"/>
75 <ng-container *ngFor="let validation of validationMessages.constraint">
76 <div class="input-error" *ngIf="constraintValuesArray(constraintIndex).controls[1].hasError(validation.type);">
77 {{ validation.message }}
83 <div *ngIf="constraint.value.type == 'validValues'">
84 <div class="w-sdc-form-columns-wrapper-block">
85 <div class="add-btn add-list-item w-sdc-form-column-block"
86 [ngClass]="{'disabled': isViewOnly}"
87 (click)="addToList(constraintIndex)">Add to List</div>
89 <div class="w-sdc-form-columns-wrapper" *ngFor="let value of constraintValuesArray(constraintIndex).controls; let valueIndex = index; trackBy:trackByFn">
90 <div class="w-sdc-form-column">
91 <input type="text" class="i-sdc-form-input" required
93 (input)="onChangeConstrainValueIndex(constraintIndex, $event.target.value, valueIndex)"/>
96 <ng-container *ngFor="let validation of validationMessages.constraint">
97 <div class="input-error" *ngIf="constraintValuesArray(constraintIndex).controls[valueIndex].hasError(validation.type);">
98 {{ validation.message }}
102 <div class="w-sdc-form-column">
103 <span class="sprite-new delete-btn" [ngClass]="{'disabled': isViewOnly}" (click)="removeFromList(constraintIndex, valueIndex)"></span>
108 <div *ngIf="constraint.get('type').value != 'inRange' && constraint.get('type').value != 'validValues'">
109 <input type="text" class="i-sdc-form-input myClass required" required
110 formControlName="value"
111 [value]="constraintsArray.at(constraintIndex).get('value').value"
112 (input)="onChangeConstraintValue(constraintIndex, $event.target.value)"/>
114 <div class="validation-errors">
115 <ng-container *ngFor="let validation of validationMessages.constraint">
116 <div class="input-error" *ngIf="constraintsArray.at(constraintIndex).get('value').hasError(validation.type);">
117 {{ validation.message }}
124 <div class="w-sdc-form-column-vsmall" *ngIf="!isViewOnly">
125 <span class="sprite-new delete-btn" [ngClass]="{'disabled': isViewOnly}" (click)="removeConstraint(constraintIndex)"></span>
132 <div class="w-sdc-form-columns-wrapper-small" *ngIf="!isViewOnly">
133 <div class="add-btn add-list-item w-sdc-form-column-small" *ngIf="!isViewOnly" [ngClass]="{'disabled': isViewOnly}"
134 (click)="addConstraint()"> Add Constraint </div>