|
108 | 108 | textarea.value = JSON.stringify(items, null, 2); |
109 | 109 | } |
110 | 110 |
|
111 | | - function buildArrayValueEditor(rowBody, item, option, onChange) { |
| 111 | + function buildArrayValueEditor(rowBody, item, option, onSync) { |
112 | 112 | var wrapper = createElement("div", "x509-extensions-choice-list"), |
113 | 113 | valueSchema = getValueSchema(option); |
114 | 114 |
|
|
124 | 124 | .map(function (element) { |
125 | 125 | return element.value; |
126 | 126 | }); |
127 | | - onChange(); |
| 127 | + onSync(); |
128 | 128 | }); |
129 | 129 | label.appendChild(checkbox); |
130 | 130 | label.appendChild(document.createTextNode(" " + choice)); |
|
134 | 134 | rowBody.appendChild(wrapper); |
135 | 135 | } |
136 | 136 |
|
137 | | - function buildStringValueEditor(rowBody, item, option, onChange) { |
| 137 | + function buildStringValueEditor(rowBody, item, option, onSync) { |
138 | 138 | var input = createElement("input", "vTextField x509-extensions-input"), |
139 | 139 | valueSchema = getValueSchema(option); |
140 | 140 |
|
|
145 | 145 | } |
146 | 146 | input.addEventListener("input", function () { |
147 | 147 | item.value = input.value; |
148 | | - onChange(); |
| 148 | + onSync(); |
149 | 149 | }); |
150 | 150 | rowBody.appendChild(input); |
151 | 151 | } |
152 | 152 |
|
153 | | - function renderRow(editor, items, options, optionMap, index, onChange, labels) { |
| 153 | + function renderRow( |
| 154 | + editor, |
| 155 | + items, |
| 156 | + options, |
| 157 | + optionMap, |
| 158 | + index, |
| 159 | + onSync, |
| 160 | + onStructureChange, |
| 161 | + labels, |
| 162 | + ) { |
154 | 163 | var item = items[index], |
155 | 164 | option = optionMap[item.name], |
156 | 165 | valueSchema = getValueSchema(option), |
157 | 166 | row = createElement("div", "x509-extensions-row"), |
158 | 167 | header = createElement("div", "x509-extensions-row__header"), |
159 | | - selectWrap = createElement("label", "x509-extensions-row__field"), |
| 168 | + selectWrap = createElement( |
| 169 | + "label", |
| 170 | + "x509-extensions-row__field x509-extensions-row__field--select", |
| 171 | + ), |
160 | 172 | selectLabel = createElement("span", "x509-extensions-row__label", "Extension"), |
161 | 173 | select = createElement("select", "x509-extensions-select"), |
162 | | - criticalWrap = createElement("label", "x509-extensions-row__field"), |
| 174 | + criticalWrap = createElement("label", "x509-extensions-row__toggle"), |
| 175 | + criticalLabel = createElement("span", "", "Critical"), |
163 | 176 | critical = createElement("input"), |
164 | 177 | removeButton = createElement( |
165 | 178 | "button", |
|
185 | 198 | var nextOption = optionMap[select.value]; |
186 | 199 | item.name = nextOption.name; |
187 | 200 | item.value = getDefaultValue(getValueSchema(nextOption)); |
188 | | - onChange(); |
| 201 | + onStructureChange(); |
189 | 202 | }); |
190 | 203 |
|
191 | 204 | critical.type = "checkbox"; |
192 | 205 | critical.checked = item.critical; |
193 | 206 | critical.addEventListener("change", function () { |
194 | 207 | item.critical = critical.checked; |
195 | | - onChange(); |
| 208 | + onSync(); |
196 | 209 | }); |
197 | 210 |
|
198 | 211 | removeButton.type = "button"; |
199 | 212 | removeButton.addEventListener("click", function () { |
200 | 213 | items.splice(index, 1); |
201 | | - onChange(); |
| 214 | + onStructureChange(); |
202 | 215 | }); |
203 | 216 |
|
204 | 217 | selectWrap.appendChild(selectLabel); |
205 | 218 | selectWrap.appendChild(select); |
206 | | - criticalWrap.appendChild(document.createTextNode("Critical ")); |
| 219 | + criticalWrap.appendChild(criticalLabel); |
207 | 220 | criticalWrap.appendChild(critical); |
208 | 221 | header.appendChild(selectWrap); |
209 | 222 | header.appendChild(criticalWrap); |
|
218 | 231 |
|
219 | 232 | rowBody.appendChild(valueLabel); |
220 | 233 | if (valueSchema.type === "array") { |
221 | | - buildArrayValueEditor(rowBody, item, option, onChange); |
| 234 | + buildArrayValueEditor(rowBody, item, option, onSync); |
222 | 235 | } else { |
223 | | - buildStringValueEditor(rowBody, item, option, onChange); |
| 236 | + buildStringValueEditor(rowBody, item, option, onSync); |
224 | 237 | } |
225 | 238 | row.appendChild(rowBody); |
226 | 239 | editor.appendChild(row); |
|
236 | 249 | options, |
237 | 250 | optionMap, |
238 | 251 | index, |
| 252 | + function () { |
| 253 | + syncTextarea(textarea, items); |
| 254 | + }, |
239 | 255 | function () { |
240 | 256 | syncTextarea(textarea, items); |
241 | 257 | renderEditor(widget, textarea, editor, items, options, optionMap, labels); |
|
0 commit comments