-
Notifications
You must be signed in to change notification settings - Fork 230
/
key-value-editor.html
243 lines (231 loc) · 10.3 KB
/
key-value-editor.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<ng-form name="forms.keyValueEditor" novalidate ng-if="entries" ng-class="{ 'has-sort' : (!cannotSort) && (entries.length > 1)}">
<div ng-if="showHeader" class="row form-row-has-controls input-labels">
<div class="col-xs-6">
<label class="input-label">
{{keyPlaceholder}}
</label>
</div>
<div class="col-xs-6">
<label class="input-label">
{{valuePlaceholder}}
</label>
</div>
</div>
<div ng-model="entries" class="key-value-editor" as-sortable="dragControlListeners">
<div
class="key-value-editor-entry row form-row-has-controls"
ng-class-odd="'odd'"
ng-class-even="'even'"
ng-repeat="entry in entries"
as-sortable-item>
<!-- The name/key block -->
<div
class="form-group col-xs-6 key-value-editor-input"
ng-class="{ 'has-error' : (forms.keyValueEditor[uniqueForKey(unique, $index)].$invalid && forms.keyValueEditor[uniqueForKey(unique, $index)].$touched) }">
<label for="uniqueForKey(unique, $index)" class="sr-only">{{keyPlaceholder}}</label>
<input
type="text"
class="form-control"
ng-class="{ '{{setFocusKeyClass}}' : $last }"
id="{{uniqueForKey(unique, $index)}}"
name="{{uniqueForKey(unique, $index)}}"
ng-attr-placeholder="{{ (!isReadonlyAny) && keyPlaceholder || ''}}"
ng-minlength="{{keyMinlength}}"
maxlength="{{keyMaxlength}}"
ng-model="entry.name"
ng-readonly="isReadonlyAny || isReadonlySome(entry.name) || entry.isReadonlyKey || entry.isReadonly"
ng-pattern="validation.key"
ng-value
ng-required="!allowEmptyKeys && (entry.value || entry.valueFrom)"
ng-attr-key-value-editor-focus="{{grabFocus && $last}}"
autocorrect="off"
autocapitalize="none"
spellcheck="false">
<!-- name/key help block -->
<span ng-show="(forms.keyValueEditor[uniqueForKey(unique, $index)].$touched)">
<span
class="help-block key-validation-error"
ng-show="(forms.keyValueEditor[uniqueForKey(unique, $index)].$error.pattern)">
<span class="validation-text">{{ entry.keyValidatorError || keyValidatorError }}</span>
<span ng-if="entry.keyValidatorErrorTooltip || keyValidatorErrorTooltip" class="help action-inline">
<a
aria-hidden="true"
data-toggle="tooltip"
data-placement="top"
data-original-title="{{entry.keyValidatorErrorTooltip || keyValidatorErrorTooltip}}">
<i class="{{entry.keyValidatorErrorTooltipIcon || keyValidatorErrorTooltipIcon}}"></i>
</a>
</span>
</span>
<span
class="help-block key-min-length"
ng-show="(forms.keyValueEditor[uniqueForKey(unique, $index)].$error.minlength)">
<span class="validation-text">Minimum character count is {{keyMinlength}}</span>
</span>
<span
class="help-block key-validation-error"
ng-show="(forms.keyValueEditor[uniqueForKey(unique, $index)].$error.required)">
<span class="validation-text">{{keyRequiredError}}</span>
</span>
</span>
</div>
<!-- the value block -->
<div
class="form-group col-xs-6 key-value-editor-input"
ng-class="{ 'has-error': (forms.keyValueEditor[uniqueForValue(unique, $index)].$invalid && forms.keyValueEditor[uniqueForValue(unique, $index)].$touched) }">
<label for="uniqueForValue(unique, $index)" class="sr-only">{{valuePlaceholder}}</label>
<div ng-if="(!entry.valueFrom)">
<input
type="text"
class="form-control"
ng-class="{ '{{setFocusValClass}}' : $last }"
id="{{uniqueForValue(unique, $index)}}"
name="{{uniqueForValue(unique, $index)}}"
ng-attr-placeholder="{{ (!isReadonlyAny) && valuePlaceholder || ''}}"
ng-minlength="{{valueMinlength}}"
maxlength="{{valueMaxlength}}"
ng-model="entry.value"
ng-readonly="isReadonlyAny || isReadonlySome(entry.name) || entry.isReadonly"
ng-pattern="validation.val"
ng-required="!allowEmptyKeys && entry.value"
autocorrect="off"
autocapitalize="none"
spellcheck="false">
</div>
<div ng-if="entry.valueFrom">
<div ng-if="isValueFromReadonly(entry)" class="faux-input-group">
<span
class="faux-form-control-addon {{entry.valueIcon}}"
aria-hidden="true"
data-toggle="tooltip"
data-placement="top"
data-original-title="{{entry.valueIconTooltip || valueIconTooltip}}"></span>
<div
class="faux-form-control readonly">
<span ng-switch="entry.refType">
<span ng-switch-when="configMapKeyRef">
Set to the key {{entry.valueFrom.configMapKeyRef.key}} in config map
<span
ng-if="!(configMapVersion | canI : 'get')">
{{entry.valueFrom.configMapKeyRef.name}}
</span>
<a
ng-if="configMapVersion | canI : 'get'"
ng-href="{{entry.apiObj | navigateResourceURL}}">
{{entry.valueFrom.configMapKeyRef.name}}
</a>
</span>
<span ng-switch-when="secretKeyRef">
Set to the key {{entry.valueFrom.secretKeyRef.key}} in secret
<span
ng-if="!(secretsVersion | canI : 'get')">
{{entry.valueFrom.secretKeyRef.name}}
</span>
<a
ng-if="secretsVersion | canI : 'get'"
ng-href="{{entry.apiObj | navigateResourceURL}}">
{{entry.valueFrom.secretKeyRef.name}}
</a>
</span>
<span ng-switch-when="fieldRef">
{{entry.valueAlt}}
</span>
<span ng-switch-default>
{{entry.valueAlt}}
</span>
</span>
</div>
</div>
<div ng-if="!isValueFromReadonly(entry)">
<div class="ui-select key-value-editor-select">
<ui-select ng-model="entry.selectedValueFrom" ng-required="true" on-select="valueFromObjectSelected(entry, $select.selected)">
<ui-select-match placeholder="Select a resource">
<span>
{{$select.selected.metadata.name}}
<small class="text-muted">– {{$select.selected.kind | humanizeKind : true}}</small>
</span>
</ui-select-match>
<ui-select-choices
repeat="source in valueFromSelectorOptions | filter : { metadata: { name: $select.search } } track by (source | uid)"
group-by="groupByKind">
<span ng-bind-html="source.metadata.name | highlight : $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<div class="ui-select key-value-editor-select">
<ui-select ng-model="entry.selectedValueFromKey" ng-required="true" on-select="valueFromKeySelected(entry, $select.selected)">
<ui-select-match placeholder="Select key">
{{$select.selected}}
</ui-select-match>
<ui-select-choices repeat="key in entry.selectedValueFrom.data | keys">
<span ng-bind-html="key | highlight : $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</div>
</div>
<!-- value help block -->
<span ng-show="(forms.keyValueEditor[uniqueForValue(unique, $index)].$touched)">
<span
class="help-block value-validation-error"
ng-show="(forms.keyValueEditor[uniqueForValue(unique, $index)].$error.pattern)">
<span class="validation-text">{{ entry.valueValidatorError || valueValidatorError}}</span>
<span ng-if="entry.valueValidatorErrorTooltip || valueValidatorErrorTooltip" class="help action-inline">
<a
aria-hidden="true"
data-toggle="tooltip"
data-placement="top"
data-original-title="{{entry.valueValidatorErrorTooltip || valueValidatorErrorTooltip}}">
<i class="{{entry.valueValidatorErrorTooltipIcon || valueValidatorErrorTooltipIcon}}"></i>
</a>
</span>
</span>
<span
class="help-block value-min-length"
ng-show="(forms.keyValueEditor[uniqueForValue(unique, $index)].$error.minlength)">
<span class="validation-text">Minimum character count is {{valueMinlength}}</span>
</span>
</span>
</div>
<div class="key-value-editor-buttons form-row-controls">
<button ng-if="(!cannotSort) && (entries.length > 1)"
class="sort-row"
type="button"
aria-hidden="true"
aria-grabbed="false"
as-sortable-item-handle>
<span class="fa fa-bars"></span>
<span class="sr-only">Move row</span>
</button>
<button
class="btn-remove close delete-row as-sortable-item-delete"
type="button"
aria-hidden="true"
ng-hide="cannotDeleteAny || cannotDeleteSome(entry.name) || entry.cannotDelete"
ng-click="deleteEntry($index, 1)">
<span class="pficon pficon-close" aria-hidden="true"></span>
<span class="sr-only">Delete row</span>
</button>
</div>
</div>
<div
class="key-value-editor-entry form-group"
ng-if="(!cannotAdd)">
<a
href=""
class="add-row-link"
role="button"
ng-click="onAddRow()">{{ addRowLink }}</a>
<span ng-if="valueFromSelectorOptions.length">
<span
class="action-divider"
aria-hidden="true">|</span>
<a
href=""
class="add-row-link"
role="button"
ng-click="onAddRowWithSelectors()">{{ addRowWithSelectorsLink }}</a>
</span>
</div>
</div>
</ng-form>