Support complex types in interface operation inputs
[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   <ng-container *ngIf="isTypeSimple(type.name)">
30     <ul *ngIf="isExpanded">
31       <li class="input-value">
32         <ng-container *ngIf="isViewOnly">
33           {{valueObjRef}}<em class="empty-value" *ngIf="!valueObjRef">empty</em>
34         </ng-container>
35         <input *ngIf="!isViewOnly" [type]="getSimpleValueInputType()" name="value"
36                [(ngModel)]="valueObjRef"
37                (ngModelChange)="onValueChange($event)"
38         />
39       </li>
40     </ul>
41   </ng-container>
42   <ng-container *ngIf="isTypeComplex(type.name)" >
43       <ul *ngIf="isExpanded">
44         <ng-container *ngFor="let property of this.type.properties">
45           <app-input-list-item
46               [name]="property.name"
47               [type]="getDataType(property.type)"
48               [dataTypeMap]="dataTypeMap"
49               [valueObjRef]="valueObjRef[property.name]"
50               [schema]="property.schema"
51               [nestingLevel]="nestingLevel + 1"
52               [isViewOnly]="isViewOnly"
53               (onValueChange)="onPropertyValueChange($event)">
54           </app-input-list-item>
55         </ng-container>
56       </ul>
57   </ng-container>
58   <ng-container *ngIf="isTypeList(type.name)">
59     <ul *ngIf="isExpanded">
60       <ng-container *ngFor="let value1 of valueObjRef; index as i; trackBy: trackByIndex">
61         <li class="input-value" *ngIf="isTypeSimple(schema.property.type)">
62           <ng-container *ngIf="isViewOnly">
63             {{valueObjRef[i]}}
64           </ng-container>
65           <input type="text" *ngIf="!isViewOnly"
66                  [(ngModel)]="valueObjRef[i]" (ngModelChange)="onListValueChange()" />
67           <span class="sprite-new delete-btn" *ngIf="!isViewOnly" (click)="onListItemDelete(i)"></span>
68         </li>
69         <app-input-list-item *ngIf="!isTypeSimple(schema.property.type)"
70             [name]="i+''"
71             [type]="getDataType(schema.property.type)"
72             [dataTypeMap]="dataTypeMap"
73             [valueObjRef]="valueObjRef[i]"
74             [schema]="schema"
75             [nestingLevel]="nestingLevel + 1"
76             [listIndex]="i"
77             [isListChild]="true"
78             [isViewOnly]="isViewOnly"
79             (onValueChange)="onPropertyValueChange($event)"
80             (onChildListItemDelete)="onListItemDelete($event)">
81         </app-input-list-item>
82       </ng-container>
83       <li class="input-value" *ngIf="!isViewOnly">
84         <a class="add-btn" (click)="addListElement()">{{'INPUT_LIST_ADD_LIST_ENTRY' | translate}}</a>
85       </li>
86     </ul>
87   </ng-container>
88   <ng-container *ngIf="isTypeMap(type.name)">
89     <ul *ngIf="isExpanded">
90       <ng-container *ngFor="let key of getObjectEntries(valueObjRef); index as i">
91         <li class="input-value" *ngIf="isTypeSimple(schema.property.type)">
92           <label class="input-label">{{key}}:</label>
93           <ng-container *ngIf="isViewOnly">
94             {{valueObjRef[key]}}
95           </ng-container>
96           <input type="text" *ngIf="!isViewOnly" [(ngModel)]="valueObjRef[key]" (ngModelChange)="onMapValueChange()"/>
97           <span class="sprite-new delete-btn" *ngIf="!isViewOnly" (click)="onMapKeyDelete(key)"></span>
98         </li>
99         <app-input-list-item
100             *ngIf="!isTypeSimple(schema.property.type)"
101             [name]="key"
102             [type]="getDataType(schema.property.type)"
103             [dataTypeMap]="dataTypeMap"
104             [valueObjRef]="valueObjRef[key]"
105             [schema]="schema"
106             [isMapChild]="true"
107             [nestingLevel]="nestingLevel + 1"
108             [isViewOnly]="isViewOnly"
109             (onValueChange)="onPropertyValueChange($event)"
110             (onDelete)="onMapKeyDelete($event)">
111         </app-input-list-item>
112       </ng-container>
113       <li class="input-value" *ngIf="!isViewOnly">
114         <input type="text" [(ngModel)]="mapEntryName" placeholder="{{ 'INPUT_LIST_MAP_KEY_PLACEHOLDER' | translate }}"/>
115         <a class="add-btn" (click)="addMapEntry()">{{ 'INPUT_LIST_ADD_MAP_ENTRY' | translate }}</a>
116       </li>
117     </ul>
118   </ng-container>
119 </li>