Catalog alignment
[sdc.git] / catalog-ui / src / app / directives / property-types / type-list / type-list-directive.html
1 <!--
2   ~ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
3   ~
4   ~ Licensed under the Apache License, Version 2.0 (the "License");
5   ~ you may not use this file except in compliance with the License.
6   ~ You may obtain a copy of the License at
7   ~
8   ~      http://www.apache.org/licenses/LICENSE-2.0
9   ~
10   ~ Unless required by applicable law or agreed to in writing, software
11   ~ distributed under the License is distributed on an "AS IS" BASIS,
12   ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   ~ See the License for the specific language governing permissions and
14   ~ limitations under the License.
15   -->
16  
17  
18 <div>
19     <div data-ng-if="!isSchemaTypeDataType">
20         <div class="i-sdc-form-item list-new-item" data-ng-class="{error:(parentFormObj['listNewItem'+fieldsPrefixName].$dirty && parentFormObj['listNewItem'+fieldsPrefixName].$invalid)}">
21             <input class="i-sdc-form-input"
22                    data-tests-id="listNewItem{{fieldsPrefixName}}"
23                    ng-if="!constraints && !((schemaProperty.simpleType||schemaProperty.type) == 'boolean')"
24                    data-ng-disabled="readOnly"
25                    data-ng-model="listNewItem.value"
26                    type="text"
27                    name="listNewItem{{fieldsPrefixName}}"
28                    data-ng-pattern="getValidationPattern((schemaProperty.simpleType||schemaProperty.type))"
29                    data-ng-model-options="{ debounce: 200 }"
30                    placeholder="Type a value and then click ADD"
31                    data-ng-maxlength="maxLength"
32                    maxlength="{{maxLength}}"
33                    sdc-keyboard-events="" key-enter="schemaProperty.type && !parentFormObj['listNewItem'+fieldsPrefixName].$invalid && listNewItem.value && addListItem"
34                    autofocus />
35             <select class="i-sdc-form-select"
36                     data-tests-id="listNewItem{{fieldsPrefixName}}"
37                     ng-if="!constraints && (schemaProperty.simpleType||schemaProperty.type) == 'boolean'"
38                     data-ng-disabled="readOnly"
39                     name="listNewItem{{fieldsPrefixName}}"
40                     data-ng-model="listNewItem.value">
41                 <option value="true">true</option>
42                 <option value="false">false</option>
43             </select>
44
45
46             <select class="i-sdc-form-select"
47                 data-tests-id="constraints"
48                 ng-if="constraints"
49                 data-ng-disabled="readOnly"
50                 data-ng-model="listNewItem.value">
51                 <!-- Get the default value in case exist -->
52                 <option value = "{{listNewItem.value}" name = "{{listNewItem.value}}" hidden selected>
53                         {{listNewItem.value}}
54                 </option> 
55                 <!-- add all constratint to Select list -->
56                 <option ng-repeat='value in constraints' value="{{value}}" name="{{value}}">
57                     {{value}}
58                 </option>
59                 
60                 
61             </select>
62
63             <div class="input-error" data-ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$dirty && parentFormObj['listNewItem'+fieldsPrefixName].$invalid">
64                 <span ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
65                 <span ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span>
66             </div>
67         </div>
68         <div class="add-btn add-list-item" data-tests-id="add-list-item{{fieldsPrefixName}}"
69              data-ng-class="{'disabled': readOnly || !schemaProperty.type || parentFormObj['listNewItem'+fieldsPrefixName].$invalid || !listNewItem.value}" data-ng-click="addListItem()">Add</div>
70         <div class="list-value-items">
71                                     <span class="list-value-item" data-ng-repeat="value in valueObjRef track by $index">
72                                         {{value}}
73                                         <span ng-if="!readOnly" class="delete-list-item sprite-new small-x-button" data-ng-click="deleteListItem($index)"></span>
74                                     </span>
75         </div>
76     </div>
77     <div data-ng-if="isSchemaTypeDataType">
78         <div class="dt-list">
79             <div data-ng-repeat="value in valueObjRef track by $index" class="dt-list-item">
80                 <span class="delete-dt-list-item" data-ng-click="deleteListItem($index)"></span>
81                 <fields-structure value-obj-ref="valueObjRef[$index]"
82                                   type-name="schemaProperty.type"
83                                   parent-form-obj="parentFormObj"
84                                   fields-prefix-name="fieldsPrefixName+''+$index"
85                                   read-only="readOnly"></fields-structure>
86             </div>
87             <div class="add-btn add-list-item" data-tests-id="add-list-item"
88                        data-ng-class="{'disabled': readOnly}" data-ng-click="listNewItem.value='{}';addListItem();">Add</div>
89         </div>
90
91     </div>
92 </div>