Catalog alignment
[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}"
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" (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"><!-- map left cell -->
31             <!--<input [value]="property.mapKey" [placeholder]="property.name" (input)="mapKeyChanged.emit($event.target.value)" [readonly]="readonly" type="text" [ngClass]="{'disabled':readonly, 'error':property.mapKeyError}" required/>-->
32             <dynamic-element #mapKeyInput
33                 class="value-input"
34                 pattern="validationUtils.getValidationPattern(string)"
35                 [value]="property.mapKey"
36                 type="string"
37                 [name]="property.name"
38                 (elementChanged)="mapKeyChanged.emit($event.value)"
39                 [readonly]="readonly"
40                 [testId]="'prop-key-' + propertyTestsId"
41             ></dynamic-element>
42         </div>
43     </ng-container>
44     <!-- RIGHT CELL OR FULL WIDTH CELL-->
45     <ng-container *ngIf="propType == derivedPropertyTypes.SIMPLE || property.isDeclared || (property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && property.schema.property.isSimpleType)">
46         <div class="table-cell">
47             <dynamic-element class="value-input"
48                 pattern="validationUtils.getValidationPattern(property.type)"
49                 [value]="property.isDeclared ? property.value : property.valueObj"
50                 [type]="property.isDeclared ? 'string' : property.type"
51                 [name]="property.name"
52                 [path]="property.propertiesName"
53                 (elementChanged)="onElementChanged($event)"
54                 [readonly]="readonly || property.isDeclared || property.isDisabled"
55                 [testId]="'prop-' + propertyTestsId"
56                 [declared] = "property.isDeclared"
57                 [constraints] = "constraints"
58             ></dynamic-element>
59         </div>
60     </ng-container>
61     <ng-container *ngIf="!isPropertyFEModel && propType != derivedPropertyTypes.SIMPLE && !property.isDeclared"> <!-- right cell for complex elements, or list complex -->
62         <div class="table-cell" *ngIf="propType == derivedPropertyTypes.COMPLEX">{{property.type | contentAfterLastDot }}</div>
63         <div class="table-cell" *ngIf="propType == derivedPropertyTypes.MAP && !property.schema.property.isSimpleType">{{property.schema.property.type | contentAfterLastDot }}</div>
64     </ng-container>
65     <ng-container *ngIf="isPropertyFEModel && (propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && !property.isDeclared"><!-- empty, full-width table cell - for PropertyFEModel of type list or map -->
66         <div class="table-cell empty"></div>
67     </ng-container>
68     <!-- ICONS: add, delete, and expand -->
69     <ng-container *ngIf="!property.isDeclared">
70             <a *ngIf="(propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && !property.isChildOfListOrMap" 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>
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">
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>