dc26d1f6a3ce35912a2f9e70f14778fc34933071
[sdc.git] / catalog-ui / src / app / view-models / forms / property-forms / component-property-form / property-form-view.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 <ng1-modal modal="modalInstanceProperty" type="classic" class="sdc-edit-property-container" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true" data-tests-id="sdc-edit-property-container">
17     <loader data-display="isLoading" relative="false" size="medium"></loader>
18     <div class="sdc-modal-top-bar" data-ng-if="!isNew">
19         <div class="sdc-modal-top-bar-buttons">
20             <span ng-click="delete(editPropertyModel.property)" data-ng-class="{'disabled' : isPropertyValueOwner || editPropertyModel.property.readonly || propertyOwnerType == 'group' || propertyOwnerType == 'policy'}" class="sprite-new delete-btn" data-tests-id="delete_property"  sdc-smart-tooltip="">Delete</span>
21             <span class="delimiter"></span>
22             <span data-ng-click="getPrev()" data-ng-class="{'disabled' : !currentPropertyIndex }" class="sprite-new left-arrow" data-tests-id="get-prev" sdc-smart-tooltip="">Previous</span>
23             <span data-ng-click="getNext()" data-ng-class="{'disabled' : isLastProperty }" class="sprite-new right-arrow" data-tests-id="get-next" sdc-smart-tooltip="">Next</span>
24         </div>
25     </div>
26
27     <div class="sdc-edit-property-form-container" >
28         <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container">
29             <form novalidate class="w-sdc-form two-columns" name="forms.editForm" >
30
31                 <div class="w-sdc-form-columns-wrapper">
32
33                     <div class="w-sdc-form-column">
34
35                         <!-- Name -->
36                         <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid)}">
37                             <label class="i-sdc-form-label" ng-class="{'required': !componentMetadata.isService}">Name</label>
38                             <input class="i-sdc-form-input"
39                                    data-tests-id="propertyName"
40                                    data-ng-maxlength="nameMaxLength"
41                                    data-ng-disabled="!isNew || editPropertyModel.property.readonly"
42                                    maxlength="{{nameMaxLength}}"
43                                    data-ng-model="editPropertyModel.property.name"
44                                    type="text"
45                                    name="propertyName"
46                                    data-ng-pattern="propertyNameValidationPattern"
47                                    data-required
48                                    data-ng-model-options="{ debounce: 200 }"
49                                    autofocus />
50
51                             <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid">
52                                 <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span>
53                                 <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{nameMaxLength}}' }"></span>
54                                 <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
55                             </div>
56                         </div>
57                     </div>
58
59                     <div class="w-sdc-form-column">
60                         <div class="w-sdc-form-columns-wrapper">
61                             <div class="w-sdc-form-column">
62                                 <!-- Type -->
63                                 <div class="i-sdc-form-item"  data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}">
64                                     <label class="i-sdc-form-label" ng-class="{'required': !componentMetadata.isService}">Type</label>
65                                     <select class="i-sdc-form-select"
66                                             data-tests-id="propertyType"
67                                             data-required
68                                             data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
69                                             name="type"
70                                             data-ng-change="onTypeChange()"
71                                             data-ng-model="editPropertyModel.property.type">
72                                         <option value="">Choose Type</option>
73                                         <option data-ng-repeat="type in editPropertyModel.types"
74                                                 value="{{type}}">{{type}}</option>
75                                         <option data-ng-repeat="type in nonPrimitiveTypes"
76                                                 value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
77                                     </select>
78
79                                     <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid">
80                                         <span ng-show="forms.editForm.type.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Type' }"></span>
81                                     </div>
82                                 </div>
83                             </div>
84                             <div class="w-sdc-form-column" data-ng-if="showSchema()">
85                                 <!-- Entry Schema -->
86                                 <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid)}">
87                                     <label class="i-sdc-form-label required">{{'PROPERTY_ENTRY_SCHEMA' | translate}}</label>
88                                     <select class="i-sdc-form-select"
89                                             data-required
90                                             data-tests-id="schema-type"
91                                             data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
92                                             name="schemaType"
93                                             data-ng-change="onSchemaTypeChange()"
94                                             data-ng-model="editPropertyModel.property.schema.property.type">
95                                         <option value="">{{'PROPERTY_ENTRY_SCHEMA_CHOOSE_OPTION' | translate}}</option>
96                                         <option data-ng-repeat="type in editPropertyModel.types"
97                                                 value="{{type}}">{{type}}</option>
98                                         <option data-ng-repeat="type in nonPrimitiveTypes"
99                                                 value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
100                                     </select>
101
102                                     <div class="input-error" data-ng-show="forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid">
103                                         <span ng-show="forms.editForm.schemaType.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Entry schema' }"></span>
104                                     </div>
105                                 </div>
106                             </div>
107                         </div>
108
109                         <!-- Constraints by type -->
110                         <div class="i-sdc-form-item" data-ng-if="false">
111                             <label class="i-sdc-form-label required">Constraints by type</label>
112                             <div>
113                                 Should be constraints by type(TBD)
114                             </div>
115                         </div>
116
117                     </div>
118
119                 </div>
120                 <!-- Description -->
121                 <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}">
122                     <label class="i-sdc-form-label">Description</label>
123                             <textarea  class="i-sdc-form-textarea"
124                                        data-ng-maxlength="400"
125                                        data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
126                                        maxlength="400"
127                                        data-ng-pattern="commentValidationPattern"
128                                        name="description"
129                                        data-ng-model="editPropertyModel.property.description"
130                                        data-ng-model-options="{ debounce: 200 }"
131                                        data-tests-id="description"
132                             ></textarea>
133
134                     <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid">
135                         <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span>
136                         <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
137                         <span ng-show="forms.editForm.description.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Description' }"></span>
138                     </div>
139                 </div>
140                 <!-- Default value -->
141
142                 <div class="default-value-section i-sdc-form-item">
143                     <label class="i-sdc-form-label">Default Value</label>
144                     <ng-container ng-if="!componentMetadata.isVfc">
145                         <input type="hidden" ng-model="editPropertyModel.isGetFunctionValid" required="required"/>
146                         <input type="radio" name="hasGetFunctionValue"
147                                ng-model="editPropertyModel.hasGetFunctionValue"
148                                ng-value="false"
149                                ng-change="onValueTypeChange()"/> {{(editPropertyModel.property.type == 'map' || editPropertyModel.property.type == 'list') ? 'Entries' : 'Value'}}
150                         <input type="radio" name="hasGetFunctionValue"
151                                ng-model="editPropertyModel.hasGetFunctionValue"
152                                ng-value="true"
153                                ng-change="onValueTypeChange()"/> {{'TOSCA_FUNCTION_LABEL' | translate}}
154                         <div data-ng-if="editPropertyModel.hasGetFunctionValue">
155                             <tosca-function [property]="editPropertyModel.property"
156                                             [component-instance-map]="componentInstanceMap"
157                                             [allow-clear]="false"
158                                             (on-valid-function)="onGetFunctionValidFunction($event)"
159                                             (on-validity-change)="onToscaFunctionValidityChange($event)"
160                             >
161                             </tosca-function>
162                         </div>
163                     </ng-container>
164                     <div data-ng-if="!editPropertyModel.hasGetFunctionValue">
165                         <div data-ng-if="isTypeDataType">
166                             <fields-structure value-obj-ref="myValue"
167                                               type-name="editPropertyModel.property.type"
168                                               parent-form-obj="forms.editForm"
169                                               fields-prefix-name="currentPropertyIndex"
170                                               read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
171                                               default-value="{{getDefaultValue()}}"
172                                               types="dataTypes"
173                                               expand-by-default="true"></fields-structure>
174
175                         </div>
176                         <div data-ng-if="!isTypeDataType" ng-switch="editPropertyModel.property.type">
177                             <div ng-switch-when="map">
178                                 <type-map value-obj-ref="myValue"
179                                           schema-property="editPropertyModel.property.schema.property"
180                                           parent-property="editPropertyModel.property"
181                                           component-instance-map="componentInstanceMap"
182                                           parent-form-obj="forms.editForm"
183                                           fields-prefix-name="currentPropertyIndex"
184                                           read-only="(editPropertyModel.property.readonly && !isPropertyValueOwner) || isVnfConfiguration"
185                                           default-value="{{getDefaultValue()}}"
186                                           max-length="maxLength"
187                                           types="dataTypes"
188                                           constraints="editPropertyModel.property.constraints && editPropertyModel.property.constraints[0].validValues">
189                                 </type-map>
190                             </div>
191
192                             <div ng-switch-when="list">
193                                 <type-list value-obj-ref="myValue"
194                                            schema-property="editPropertyModel.property.schema.property"
195                                            parent-property="editPropertyModel.property"
196                                            component-instance-map="componentInstanceMap"
197                                            parent-form-obj="forms.editForm"
198                                            fields-prefix-name="currentPropertyIndex"
199                                            read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
200                                            default-value="{{getDefaultValue()}}"
201                                            max-length="maxLength"
202                                            types="dataTypes"
203                                            constraints="editPropertyModel.property.constraints && editPropertyModel.property.constraints[0].validValues"></type-list>
204                             </div>
205
206                             <div ng-switch-default>
207                                 <div class="i-sdc-form-item"
208                                      data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid), 'input-group' : editPropertyModel.property.addOn}">
209                                     <span ng-if="editPropertyModel.property.addOn"
210                                           class="input-group-addon">{{editPropertyModel.property.addOn}}</span>
211
212                                     <!-- Constraints any NOT Boolean -->
213                                     <input class="i-sdc-form-input"
214                                            data-tests-id="defaultvalue"
215                                            ng-if="!((editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean')"
216                                            data-ng-maxlength="maxLength"
217                                            data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner"
218                                            maxlength="{{maxLength}}"
219                                            data-ng-model="editPropertyModel.property.value"
220                                            type="text"
221                                            name="value"
222                                            data-ng-pattern="getValidationPattern((editPropertyModel.property.simpleType||editPropertyModel.property.type))"
223                                            data-ng-model-options="{ debounce: 200 }"
224                                            data-ng-change="('json'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateJson(editPropertyModel.property.value)))
225                                                         ||(!forms.editForm.value.$error.pattern && ('integer'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editPropertyModel.property.value)) || onValueChange()))"
226                                            autofocus/>
227                                     <!-- Boolean -->
228                                     <select class="i-sdc-form-select"
229                                             data-tests-id="booleantype"
230                                             ng-if="(editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean'"
231                                             data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner"
232                                             name="value"
233                                             data-ng-change="onValueChange()"
234                                             data-ng-model="editPropertyModel.property.value">
235                                         <option value="true">true</option>
236                                         <option value="false">false</option>
237                                     </select>
238
239                                     <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid">
240                                         <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED"
241                                               translate-values="{'field': 'Property' }"></span>
242                                         <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH"
243                                               translate-values="{'max': '{{maxLength}}' }"></span>
244                                         <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
245                                     </div>
246                                 </div>
247                             </div>
248                         </div>
249                     </div>
250                 </div>
251                 <div class="constraints-section i-sdc-form-item" data-ng-if="editPropertyModel.property.constraints || !(isViewOnly || componentMetadata.isService)">
252                     <label class="i-sdc-form-label">Constraints</label>
253                     <ng-container>
254                         <app-constraints [property-constraints]="editPropertyModel.property.constraints"
255                                          [is-view-only]="isViewOnly || componentMetadata.isService"
256                                          [property-type]="editPropertyModel.property.type"
257                                          (on-constraint-change)="onConstraintChange($event)">
258                         </app-constraints>
259                     </ng-container>
260                 </div>
261                 <span  class="w-sdc-form-note"  data-ng-show="forms.editForm.$invalid && false" translate="LABEL_ALL_FIELDS_ARE_MANDATORY"></span>
262             </form>
263         </perfect-scrollbar>
264     </div>
265
266 </ng1-modal>