|
175 | 175 | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
176 | 176 | <input type="text" id="node-input-name" placeholder="Name">
|
177 | 177 | </div>
|
178 |
| - |
179 |
| - <script> |
180 |
| - $("#node-input-search").change(function() { |
181 |
| - var searchType = $("#node-input-search option:selected").val(); |
182 |
| - if (searchType == "_id_") $("#node-search-index-form").hide(); |
183 |
| - else $("#node-search-index-form").show(); |
184 |
| - }); |
185 |
| - </script> |
186 | 178 | </script>
|
187 | 179 |
|
188 | 180 | <script type="text/javascript">
|
|
217 | 209 | name : { value: "" },
|
218 | 210 | database: { value: "", required: true },
|
219 | 211 | search : { value: "_id_", required: true },
|
220 |
| - design : { value: "", required: true }, |
221 |
| - index : { value: "", required: true } |
| 212 | + design : { value: "" }, |
| 213 | + index : { value: "" } |
222 | 214 | },
|
223 | 215 | inputs : 1,
|
224 | 216 | outputs: 1,
|
|
231 | 223 | });
|
232 | 224 |
|
233 | 225 | function oneditprepare() {
|
234 |
| - var select = $('#node-input-service'); |
235 | 226 | var node = this;
|
236 | 227 |
|
| 228 | + var serviceSelect = $('#node-input-service'); |
| 229 | + var searchBySelect = $('#node-input-search'); |
| 230 | + var searchForm = $('#node-search-index-form'); |
| 231 | + |
237 | 232 | $.getJSON('cloudant/vcap/',function(data) {
|
238 |
| - var last = select.children().last(); |
| 233 | + var last = serviceSelect.children().last(); |
239 | 234 | var opts = [];
|
240 | 235 |
|
241 | 236 | for (var i=0; i < data.length; i++) {
|
|
249 | 244 |
|
250 | 245 | if (opts.length == 0) {
|
251 | 246 | node.service = "_ext_";
|
252 |
| - select.find("option").filter(function() { |
| 247 | + serviceSelect.find("option").filter(function() { |
253 | 248 | return $(this).val() == node.service;
|
254 | 249 | }).attr('selected', true);
|
255 | 250 | } else {
|
256 | 251 | last.before(opts.join(""));
|
257 | 252 | }
|
258 | 253 |
|
259 |
| - select.change(); |
| 254 | + serviceSelect.change(); |
260 | 255 | });
|
261 | 256 |
|
262 |
| - select.change(function() { |
263 |
| - var service = select.val(); |
| 257 | + serviceSelect.change(function() { |
| 258 | + var service = serviceSelect.val(); |
264 | 259 | if (service == "_ext_") {
|
265 | 260 | $("#node-input-external-details").show();
|
266 | 261 | } else {
|
267 | 262 | $("#node-input-external-details").hide();
|
268 | 263 | }
|
269 | 264 | });
|
| 265 | + |
| 266 | + searchBySelect.change(function() { |
| 267 | + var searchBy = searchBySelect.val(); |
| 268 | + |
| 269 | + if (searchBy === "_idx_") { |
| 270 | + node._def.defaults.design.required = true; |
| 271 | + node._def.defaults.index.required = true; |
| 272 | + searchForm.show(); |
| 273 | + } else { |
| 274 | + node._def.defaults.design.required = false; |
| 275 | + node._def.defaults.index.required = false; |
| 276 | + searchForm.hide(); |
| 277 | + } |
| 278 | + }); |
270 | 279 | }
|
271 | 280 |
|
272 | 281 | function label() {
|
|
0 commit comments