aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html
blob: aa03cecb17baaa7c7a70a746dd9507ebcccf2e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!--
  ~ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
 
 
<div>
    <div data-ng-repeat="i in getNumber(mapKeys.length) track by $index" class="map-item" data-ng-class="{'primitive-value-map':!isSchemaTypeDataType}">
        <div class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapKey'+fieldsPrefixName+$index].$dirty && parentFormObj['mapKey'+fieldsPrefixName+$index].$invalid)}">
            <label class="i-sdc-form-label required">Key</label>
            <input class="i-sdc-form-input"
                   data-tests-id="mapKey{{fieldsPrefixName}}{{$index}}"
                   data-ng-model="mapKeys[$index]"
                   type="text"
                   data-ng-maxlength="50"
                   maxlength="50"
                   name="mapKey{{fieldsPrefixName}}{{$index}}"
                   data-ng-pattern="MapKeyValidationPattern"
                   data-ng-model-options="{ debounce: 200 }"
                   data-ng-change="changeKeyOfMap(mapKeys[$index], $index,'mapKey'+fieldsPrefixName+$index);$event.stopPropagation();"
                   data-ng-readonly="readOnly"
                   data-required
                   autofocus/>
            <div class="input-error" data-ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$dirty && parentFormObj['mapKey'+fieldsPrefixName+$index].$invalid">
                <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.keyExist" translate="PROPERTY_EDIT_MAP_UNIQUE_KEYS"></span>
                <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Key' }"></span>
                <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span>
                <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
            </div>
        </div>
        <div data-ng-if="!isSchemaTypeDataType" class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapValue'+fieldsPrefixName+$index].$dirty && parentFormObj['mapValue'+fieldsPrefixName+$index].$invalid)}">
            <label class="i-sdc-form-label required">Value</label>
            <input class="i-sdc-form-input"
                   ng-if="!((schemaProperty.simpleType||schemaProperty.type) == 'boolean')"
                   data-ng-readonly="readOnly"
                   data-ng-model="valueObjRef[mapKeys[$index]]"
                   type="text"
                   name="mapValue{{fieldsPrefixName}}{{$index}}"
                   data-tests-id="mapValue{{fieldsPrefixName}}{{$index}}"
                   data-ng-pattern="getValidationPattern((schemaProperty.simpleType||schemaProperty.type))"
                   data-ng-change="!parentFormObj['mapValue'+fieldsPrefixName+$index].$error.pattern && parseToCorrectType(valueObjRef, key, (schemaProperty.simpleType||schemaProperty.type))"
                   data-ng-model-options="{ debounce: 200 }"
                   data-ng-maxlength="maxLength"
                   maxlength="{{maxLength}}"
                   data-required
                   autofocus />
            <select class="i-sdc-form-select"
                    data-tests-id="mapValue{{fieldsPrefixName}}{{$index}}"
                    ng-if="(schemaProperty.simpleType||schemaProperty.type) == 'boolean'"
                    data-ng-disabled="readOnly"
                    name="mapValue{{fieldsPrefixName}}{{$index}}"
                    data-ng-model="valueObjRef[mapKeys[$index]]"
                    data-required>
                <option value="true">true</option>
                <option value="false">false</option>
            </select>
            <div class="input-error" data-ng-show="parentFormObj['mapValue'+fieldsPrefixName+$index].$dirty && parentFormObj['mapValue'+fieldsPrefixName+$index].$invalid">
                <span ng-show="parentFormObj['mapValue'+fieldsPrefixName+$index].$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value' }"></span>
                <span ng-show="parentFormObj['mapValue'+fieldsPrefixName+$index].$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
                <span ng-show="parentFormObj['mapValue'+fieldsPrefixName+$index].$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span>
            </div>
        </div>
        <div data-ng-if="isSchemaTypeDataType" class="i-sdc-form-item map-item-field">
            <label class="i-sdc-form-label">Value</label>
            <fields-structure value-obj-ref="valueObjRef[mapKeysStatic[$index]]"
                              type-name="schemaProperty.type"
                              parent-form-obj="parentFormObj"
                              fields-prefix-name="'mapValue'+fieldsPrefixName+''+$index"
                              read-only="readOnly"
            ></fields-structure>
        </div>
        <span ng-click="deleteMapItem($index)" class="delete-map-item" data-tests-id="delete-map-item{{fieldsPrefixName}}{{$index}}" data-ng-class="{'disabled': readOnly}"></span>
    </div>
    <div class="add-map-item" data-ng-class="{'schema-data-type':isSchemaTypeDataType}">
        <div class="add-btn" data-tests-id="add-map-item"
             data-ng-class="{'disabled': readOnly || !schemaProperty.type || mapKeys.indexOf('')>-1 || !isMapKeysUnique}" data-ng-click="addMapItemFields()">Add</div>
    </div>
</div>