6a5bd5a00766acf49a3f074c2a76f50b7fa75d95
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / interface-operatons / operation-creator / input-list / input-list-item / input-list-item.component.html
1 <!--
2   ~ -
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
9   ~
10   ~       http://www.apache.org/licenses/LICENSE-2.0
11   ~
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.
17   ~
18   ~  SPDX-License-Identifier: Apache-2.0
19   ~  ============LICENSE_END=========================================================
20   -->
21
22 <li [class.root]="isRoot()">
23   <span class="input-info">
24     <em class="sprite-new round-expand-icon" [class.open]="isExpanded" (click)="expandAndCollapse()"></em>
25     <label class="input-label">{{name}}:</label> <em data-tests-id="input-type">{{resolveType()}}</em>
26     <span class="sprite-new delete-btn" *ngIf="showInputDelete()" (click)="onInputDelete()"></span>
27     <span class="sprite-new delete-btn" *ngIf="showListItemDelete()" (click)="onChildListItemDelete()"></span>
28   </span>
29
30   <ng-container *ngIf="isExpanded && showToscaFunctionOption">
31     <form>
32       <fieldset [disabled]="isViewOnly" >
33         <input type="radio" name="hasGetFunctionValue"
34               [(ngModel)]="isToscaFunction"
35               [value]="false"
36               (change)="onValueTypeChange()"/> Value
37         <input type="radio" name="hasGetFunctionValue"
38               [(ngModel)]="isToscaFunction"
39               [value]="true"/> {{'TOSCA_FUNCTION_LABEL' | translate}}
40       </fieldset>
41     </form>
42     <div *ngIf="isToscaFunction">
43       <ul>
44         <li>
45           <div *ngIf="componentInstanceMap">
46             <tosca-function
47                             [property]="property"
48                             [allowClear]="false"
49                             [componentInstanceMap]="componentInstanceMap"
50                             (onValidityChange)="onToscaFunctionValidityChange($event)">
51             </tosca-function>
52           </div>
53           <div *ngIf="!componentInstanceMap">
54             <tosca-function
55                             [property]="property"
56                             [allowClear]="false"
57                             (onValidityChange)="onToscaFunctionValidityChange($event)">
58             </tosca-function>
59           </div>
60         </li>
61       </ul>
62     </div>
63   </ng-container>
64
65   <div *ngIf="!isToscaFunction">
66     <ng-container *ngIf="isTypeSimple(type.name)">
67       <ul *ngIf="isExpanded">
68         <li class="input-value">
69           <ng-container *ngIf="isViewOnly">
70             {{valueObjRef}}<em class="empty-value" *ngIf="valueObjRef !== false && !valueObjRef">{{'GENERAL_LABEL_EMPTY' | translate | lowercase}}</em>
71           </ng-container>
72           <input *ngIf="!isViewOnly && isTypeLiteral(type.name)" type="text" name="value"
73                  [(ngModel)]="valueObjRef" (ngModelChange)="onValueChange($event)"/>
74           <input *ngIf="!isViewOnly && isTypeNumber(type.name)" type="number"
75                  [(ngModel)]="valueObjRef" (ngModelChange)="onValueChange($event)"/>
76           <select *ngIf="!isViewOnly && isTypeBoolean(type.name)" [(ngModel)]="valueObjRef" (ngModelChange)="onValueChange($event)">
77             <option [value]="true">{{'GENERAL_LABEL_TRUE' | translate}}</option>
78             <option [value]="false">{{'GENERAL_LABEL_FALSE' | translate}}</option>
79           </select>
80         </li>
81       </ul>
82     </ng-container>
83     <ng-container *ngIf="isTypeRange(type.name)">
84         <ul *ngIf="isExpanded">
85             <ng-container *ngFor="let value1 of [0, 1]; index as i">
86                 <li class="input-value">
87                     <ng-container *ngIf="isViewOnly">
88                         {{valueObjRef[i]}}
89                     </ng-container>
90                     <input type="text" *ngIf="!isViewOnly"
91                     [(ngModel)]="valueObjRef[i]" (ngModelChange)="onListValueChange()" />
92                 </li>
93             </ng-container>
94         </ul>
95     </ng-container>
96     <ng-container *ngIf="isTypeComplex(type.name)" >
97         <ul *ngIf="isExpanded">
98           <ng-container *ngFor="let property of this.type.properties">
99             <app-input-list-item
100                 [name]="property.name"
101                 [type]="getDataType(property.type)"
102                 [dataTypeMap]="dataTypeMap"
103                 [valueObjRef]="valueObjRef[property.name]"
104                 [schema]="property.schema"
105                 [nestingLevel]="nestingLevel + 1"
106                 [isViewOnly]="isViewOnly"
107                 [showToscaFunctionOption]="showToscaFunctionOption"
108                 [allowDeletion]="allowDeletion"
109                 (onValueChange)="onPropertyValueChange($event)">
110             </app-input-list-item>
111           </ng-container>
112         </ul>
113     </ng-container>
114     <ng-container *ngIf="isTypeList(type.name)">
115       <ul *ngIf="isExpanded">
116         <ng-container *ngFor="let value1 of valueObjRef; index as i; trackBy: trackByIndex">
117           <li class="input-value" *ngIf="isTypeSimple(schema.property.type)">
118             <ng-container *ngIf="isViewOnly">
119               {{valueObjRef[i]}}
120             </ng-container>
121             <input type="text" *ngIf="!isViewOnly"
122                   [(ngModel)]="valueObjRef[i]" (ngModelChange)="onListValueChange()" />
123             <span class="sprite-new delete-btn" *ngIf="!isViewOnly" (click)="onListItemDelete(i)"></span>
124           </li>
125           <app-input-list-item *ngIf="!isTypeSimple(schema.property.type)"
126               [name]="i+''"
127               [type]="getDataType(schema.property.type)"
128               [dataTypeMap]="dataTypeMap"
129               [valueObjRef]="valueObjRef[i]"
130               [schema]="buildSchemaGroupProperty()"
131               [nestingLevel]="nestingLevel + 1"
132               [listIndex]="i"
133               [isListChild]="true"
134               [isViewOnly]="isViewOnly"
135               [allowDeletion]="allowDeletion"
136               (onValueChange)="onPropertyValueChange($event)"
137               (onChildListItemDelete)="onListItemDelete($event)">
138           </app-input-list-item>
139         </ng-container>
140         <li class="input-value" *ngIf="!isViewOnly">
141           <a class="add-btn" (click)="addListElement()">{{'INPUT_LIST_ADD_LIST_ENTRY' | translate}}</a>
142         </li>
143       </ul>
144     </ng-container>
145     <ng-container *ngIf="isTypeMap(type.name)">
146       <ul *ngIf="isExpanded">
147         <ng-container *ngFor="let key of getObjectEntries(valueObjRef); index as i">
148           <li class="input-value" *ngIf="isTypeSimple(schema.property.type)">
149             <label class="input-label">{{key}}:</label>
150             <ng-container *ngIf="isViewOnly">
151               {{valueObjRef[key]}}
152             </ng-container>
153             <input type="text" *ngIf="!isViewOnly" [(ngModel)]="valueObjRef[key]" (ngModelChange)="onMapValueChange()"/>
154             <span class="sprite-new delete-btn" *ngIf="!isViewOnly" (click)="onMapKeyDelete(key)"></span>
155           </li>
156           <app-input-list-item
157               *ngIf="!isTypeSimple(schema.property.type)"
158               [name]="key"
159               [type]="getDataType(schema.property.type)"
160               [dataTypeMap]="dataTypeMap"
161               [valueObjRef]="valueObjRef[key]"
162               [schema]="buildSchemaGroupProperty()"
163               [isMapChild]="true"
164               [nestingLevel]="nestingLevel + 1"
165               [isViewOnly]="isViewOnly"
166               [allowDeletion]="allowDeletion"
167               (onValueChange)="onPropertyValueChange($event)"
168               (onDelete)="onMapKeyDelete($event)">
169           </app-input-list-item>
170         </ng-container>
171         <li class="input-value" *ngIf="!isViewOnly">
172           <input type="text" [(ngModel)]="mapEntryName" placeholder="{{ 'INPUT_LIST_MAP_KEY_PLACEHOLDER' | translate }}"/>
173           <a class="add-btn" (click)="addMapEntry()">{{ 'INPUT_LIST_ADD_MAP_ENTRY' | translate }}</a>
174         </li>
175       </ul>
176     </ng-container>
177   </div>
178 </li>