f85526515745eca82bf3962da786c85cd3235511
[sdc.git] / catalog-ui / src / app / ng2 / components / logic / properties-table / dynamic-property / dynamic-property.component.html
1 <!--
2   ~ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  * 
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  * 
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  -->
15  
16  
17 <div *ngIf="!property.hidden" class="dynamic-property-row nested-level-{{nestedLevel}}" [@fadeIn]
18     [ngClass]="{'selected': selectedPropertyId && selectedPropertyId === property.propertiesName, 'readonly':  property.isDisabled || property.isDeclared || property.isToscaFunction()}"
19     [class.with-top-border]="property.isChildOfListOrMap"
20     (click)="onClickPropertyRow(property, $event)">
21     <!-- LEFT CELL -->
22     <ng-container *ngIf="!isPropertyFEModel">
23         <div class="table-cell" *ngIf="canBeDeclared" [ngClass]="{'filtered':property.name === propertyNameSearchText}" [class.round-checkbox]="property.isDeclared"> <!-- simple children of complex type [@checkEffect]="property.isDeclared"-->
24             <checkbox *ngIf="hasDeclareOption" [(checked)]="property.isSelected" [disabled]="property.isDisabled || property.isDeclared || readonly || property.isToscaFunction()" (checkedChange)="checkProperty.emit(property.propertiesName)" ></checkbox>
25             <div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
26         </div>
27         <div class="table-cell" *ngIf="!canBeDeclared && !property.isChildOfListOrMap">
28             <div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
29         </div> <!-- simple children of complex type within map or list -->
30         <div class="table-cell map-entry" *ngIf="property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && !property.mapInlist"><!-- map left cell -->
31             <dynamic-element #mapKeyInput
32                 class="value-input"
33                 pattern="validationUtils.getValidationPattern(string)"
34                 [value]="property.mapKey"
35                 type="string"
36                 [name]="property.name"
37                 (elementChanged)="mapKeyChanged.emit($event.value)"
38                 [readonly]="readonly"
39                 [testId]="'prop-key-' + propertyTestsId"
40             ></dynamic-element>
41         </div>
42     </ng-container>
43     <!-- RIGHT CELL OR FULL WIDTH CELL-->
44     <ng-container *ngIf="propType == derivedPropertyTypes.SIMPLE || property.isDeclared || property.isToscaFunction() || (property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && property.schema.property.isSimpleType)">
45         <div class="table-cell">
46             <dynamic-element class="value-input"
47                 pattern="validationUtils.getValidationPattern(property.type)"
48                 [value]="property.isDeclared || property.isToscaFunction() ? property.value : property.valueObj"
49                 [type]="property.isDeclared || property.isToscaFunction() ? 'string' : property.type"
50                 [name]="property.name"
51                 [path]="property.propertiesName"
52                 (elementChanged)="onElementChanged($event)"
53                 [readonly]="readonly || property.isDeclared || property.isDisabled || property.isToscaFunction()"
54                 [testId]="'prop-' + propertyTestsId"
55                 [declared] = "property.isDeclared"
56                 [constraints] = "constraints"
57             ></dynamic-element>
58         </div>
59     </ng-container>
60     <ng-container *ngIf="!isPropertyFEModel && propType != derivedPropertyTypes.SIMPLE && !property.isDeclared && !property.isToscaFunction()"> <!-- right cell for complex elements, or list complex -->
61         <div class="table-cell" *ngIf="propType == derivedPropertyTypes.COMPLEX">{{property.type | contentAfterLastDot }}</div>
62         <div class="table-cell" *ngIf="propType == derivedPropertyTypes.MAP && !property.schema.property.isSimpleType">{{property.schema.property.type | contentAfterLastDot }}</div>
63     </ng-container>
64     <ng-container *ngIf="isPropertyFEModel && (propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && !property.isDeclared && !property.isToscaFunction()"><!-- empty, full-width table cell - for PropertyFEModel of type list or map -->
65         <div class="table-cell empty"></div>
66     </ng-container>
67     <!-- ICONS: add, delete, and expand -->
68     <ng-container *ngIf="!property.isDeclared && !property.isToscaFunction()">
69             <a *ngIf="(propType == derivedPropertyTypes.LIST) && (!property.isChildOfListOrMap || property.mapInlist)" class="property-icon add-item" (click)="createNewChildProperty();" [ngClass]="{'disabled':readonly || preventInsertItem(property)}" [attr.data-tests-id]="'add-to-list-' + propertyTestsId">Add value to list</a>
70             <a *ngIf="(propType == derivedPropertyTypes.MAP) && (!property.isChildOfListOrMap || property.mapInlist)" class="property-icon add-item" (click)="createNewChildProperty();" [ngClass]="{'disabled':readonly || preventInsertItem(property)}" [attr.data-tests-id]="'add-to-list-' + propertyTestsId">Add value to map</a>
71             <span *ngIf="property.isChildOfListOrMap" (click)="deleteItem.emit(property);" class="property-icon sprite-new delete-item-icon" [ngClass]="{'disabled':readonly}" [attr.data-tests-id]="'delete-from-list-' + propertyTestsId"></span>
72             <span *ngIf="!isPropertyFEModel && (propType == derivedPropertyTypes.COMPLEX || ((propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && hasChildren))" (click)="expandChildById(propPath)" class="property-icon sprite-new round-expand-icon" [class.open]="expandedChildId.indexOf(propPath) == 0" [attr.data-tests-id]="'expand-' + propertyTestsId" ></span>
73     </ng-container>
74
75 </div>
76 <!-- FLAT CHILDREN -->
77 <div class="flat-children-container" *ngIf="isPropertyFEModel && !property.isDeclared && !property.isToscaFunction()">
78     <ng-container *ngFor="let prop of property.flattenedChildren | filterChildProperties: expandedChildId; trackBy:prop?.propertiesName">
79         <dynamic-property
80             [selectedPropertyId]="selectedPropertyId"
81             [hasDeclareOption]="hasDeclareOption"
82             [canBeDeclared]="hasDeclareOption && prop.canBeDeclared"
83             [property]="prop"
84             [rootProperty]="rootProperty || property"
85             [expandedChildId]="expandedChildId"
86             [propertyNameSearchText]="propertyNameSearchText"
87             [readonly]="readonly"
88             [hasChildren]="getHasChildren(prop)"
89             (propertyChanged)="childValueChanged(prop)"
90             (mapKeyChanged)="updateChildKeyInParent(prop, $event)"
91             (expandChild)="expandChildById($event)"
92             (deleteItem)="deleteListOrMapItem($event)"
93             (clickOnPropertyRow)="onClickPropertyRow($event)"
94             (checkProperty)="checkedChange($event)"
95             (addChildPropsToParent)="addChildProps($event, prop.propertiesName)"
96             >
97         </dynamic-property>
98     </ng-container>
99 </div>