|
123 | 123 | ] |
124 | 124 | }); |
125 | 125 |
|
| 126 | + // Don't create form here - it will be created when the container is shown |
| 127 | +
|
| 128 | + }); |
| 129 | +
|
| 130 | + function createForm() |
| 131 | + { |
| 132 | + if (form) |
| 133 | + { |
| 134 | + return; // Form already exists |
| 135 | + } |
| 136 | +
|
126 | 137 | // syncMargin is the negative margin-left of the syncX and syncY fields. If the filters are not being displayed |
127 | 138 | // the sync fields slide under the width/height fields. |
128 | 139 | var syncMargin; |
|
141 | 152 | name: 'chromForm', |
142 | 153 | border: false, frame: false, |
143 | 154 | width:550, |
144 | | - height: 160, |
| 155 | + autoHeight: true, // Don't set a fixed height. Use autoHeight to allow the ExtJS form to automatically size itself to fit all content |
145 | 156 | defaults: { |
146 | 157 | labelWidth: 150, |
147 | 158 | labelHeight: 23, |
|
277 | 288 | ], |
278 | 289 | }); |
279 | 290 |
|
| 291 | + // Initialize form after creation |
| 292 | + setupFormHandlers(); |
| 293 | + setInitialValues(); |
| 294 | + hideFieldsNotNeeded(); |
| 295 | + } |
| 296 | +
|
| 297 | + function setupFormHandlers() |
| 298 | + { |
280 | 299 | document.getElementById("clear-rep")['onclick'] = clearReplicates; |
281 | 300 | document.getElementById("clear-annot")['onclick'] = clearAnnotations; |
| 301 | + } |
282 | 302 |
|
| 303 | + function setInitialValues() |
| 304 | + { |
283 | 305 | // This has to happen after form is rendered. |
284 | 306 | form.getForm().findField("annotationsFilter").setValue(selectedAnnotationsFilterList); |
285 | 307 | for(var i = 0; i < selectedAnnotationsFilterList.length; i++) |
|
309 | 331 | } |
310 | 332 | } |
311 | 333 | manageFilterListVisibility(); |
| 334 | + } |
312 | 335 |
|
| 336 | + function hideFieldsNotNeeded() |
| 337 | + { |
313 | 338 | // Hides multi-select combo boxes if there is only one or zero values in its value store. |
314 | 339 | <%if(replicatesList.size() <= 1){%> |
315 | 340 | form.getForm().findField("replicatesFilter").hide(); |
|
321 | 346 | form.getForm().findField("hideAnnotations").hide(); |
322 | 347 | hiddenFields++; |
323 | 348 | <%}%> |
| 349 | + } |
324 | 350 |
|
325 | | - // appendFilterItem adds a filter table row & column to the appropriate parent filter box. |
326 | | - function appendFilterItem(element, displayValue, parentTable, id) { |
327 | | - if(displayValue != null) { |
328 | | - let deleteIconId = 'delete-' + id; |
329 | | - let newRowContent = "<tr id=\""+LABKEY.Utils.encodeHtml(id)+"\"><td class=\"item\"><img id=\""+LABKEY.Utils.encodeHtml(deleteIconId)+"\" src='<%=getWebappURL("_images/delete.png")%>' style='width:10px; height:10px; margin-right:3px;'>"+LABKEY.Utils.encodeHtml(displayValue)+"</td></tr>"; |
330 | | - element.append(newRowContent); |
| 351 | + // appendFilterItem adds a filter table row & column to the appropriate parent filter box. |
| 352 | + function appendFilterItem(element, displayValue, parentTable, id) { |
| 353 | + if(displayValue != null) { |
| 354 | + let deleteIconId = 'delete-' + id; |
| 355 | + let newRowContent = "<tr id=\""+LABKEY.Utils.encodeHtml(id)+"\"><td class=\"item\"><img id=\""+LABKEY.Utils.encodeHtml(deleteIconId)+"\" src='<%=getWebappURL("_images/delete.png")%>' style='width:10px; height:10px; margin-right:3px;'>"+LABKEY.Utils.encodeHtml(displayValue)+"</td></tr>"; |
| 356 | + element.append(newRowContent); |
331 | 357 |
|
332 | | - document.getElementById(deleteIconId).addEventListener('click', function() { |
333 | | - deleteFilter(this, parentTable); |
334 | | - }); |
335 | | - } |
| 358 | + document.getElementById(deleteIconId).addEventListener('click', function() { |
| 359 | + deleteFilter(this, parentTable); |
| 360 | + }); |
336 | 361 | } |
| 362 | + } |
337 | 363 |
|
338 | | - // modifyFilter is triggered when user modifies selection through the combobox and will add/remove items from the list based on a newValue and an oldValue. |
339 | | - function modifyFilter(newValues, oldValues, parentId) |
| 364 | + // modifyFilter is triggered when user modifies selection through the combobox and will add/remove items from the list based on a newValue and an oldValue. |
| 365 | + function modifyFilter(newValues, oldValues, parentId) |
| 366 | + { |
| 367 | + if(newValues !=null && oldValues !=null) |
340 | 368 | { |
341 | | - if(newValues !=null && oldValues !=null) |
| 369 | + if(newValues.length >= oldValues.length) |
342 | 370 | { |
343 | | - if(newValues.length >= oldValues.length) |
| 371 | + for (var i = 0; i < newValues.length; i++) |
344 | 372 | { |
345 | | - for (var i = 0; i < newValues.length; i++) |
| 373 | + if(oldValues.indexOf(newValues[i]) === -1) |
346 | 374 | { |
347 | | - if(oldValues.indexOf(newValues[i]) === -1) |
| 375 | + var val; |
| 376 | + var id; |
| 377 | + if(parentId === "replicateFilters") |
348 | 378 | { |
349 | | - var val; |
350 | | - var id; |
351 | | - if(parentId === "replicateFilters") |
| 379 | + for(var a = 0; a < replicateStore.getCount(); a++) |
352 | 380 | { |
353 | | - for(var a = 0; a < replicateStore.getCount(); a++) |
| 381 | + if(replicateStore.data.items[a].data.replicateId === newValues[i]) |
354 | 382 | { |
355 | | - if(replicateStore.data.items[a].data.replicateId === newValues[i]) |
356 | | - { |
357 | | - val = replicateStore.data.items[a].data.replicateName; |
358 | | - id = replicateStore.data.items[a].data.replicateId; |
359 | | - } |
| 383 | + val = replicateStore.data.items[a].data.replicateName; |
| 384 | + id = replicateStore.data.items[a].data.replicateId; |
360 | 385 | } |
361 | 386 | } |
362 | | - else |
363 | | - { |
364 | | - val = newValues[i]; |
365 | | - id = newValues[i]; |
366 | | - } |
367 | | - appendFilterItem($('#'+parentId+''), val, parentId, id); |
368 | 387 | } |
| 388 | + else |
| 389 | + { |
| 390 | + val = newValues[i]; |
| 391 | + id = newValues[i]; |
| 392 | + } |
| 393 | + appendFilterItem($('#'+parentId+''), val, parentId, id); |
369 | 394 | } |
370 | 395 | } |
371 | | - else if(newValues.length < oldValues.length) |
372 | | - { |
373 | | - for (var j = 0; j < oldValues.length; j++) { |
374 | | - if(newValues.indexOf(oldValues[j]) === -1) |
| 396 | + } |
| 397 | + else if(newValues.length < oldValues.length) |
| 398 | + { |
| 399 | + for (var j = 0; j < oldValues.length; j++) { |
| 400 | + if(newValues.indexOf(oldValues[j]) === -1) |
| 401 | + { |
| 402 | + var textValue = oldValues[j]; |
| 403 | + if(parentId === "replicateFilters") |
375 | 404 | { |
376 | | - var textValue = oldValues[j]; |
377 | | - if(parentId === "replicateFilters") |
| 405 | + for(var a = 0; a < replicateStore.getCount(); a++) |
378 | 406 | { |
379 | | - for(var a = 0; a < replicateStore.getCount(); a++) |
| 407 | + if(replicateStore.data.items[a].data.replicateId === oldValues[j]) |
380 | 408 | { |
381 | | - if(replicateStore.data.items[a].data.replicateId === oldValues[j]) |
382 | | - { |
383 | | - textValue = replicateStore.data.items[a].data.replicateName; |
384 | | - } |
| 409 | + textValue = replicateStore.data.items[a].data.replicateName; |
385 | 410 | } |
386 | 411 | } |
387 | | - var el = findByText(document.getElementById("allFilters"), textValue); |
388 | | - var $el = $(el); |
389 | | - if(null != el) |
390 | | - { |
| 412 | + } |
| 413 | + var el = findByText(document.getElementById("allFilters"), textValue); |
| 414 | + var $el = $(el); |
| 415 | + if(null != el) |
| 416 | + { |
391 | 417 | $el.closest('tr').remove(); |
392 | | - } |
393 | 418 | } |
394 | 419 | } |
395 | 420 | } |
396 | 421 | } |
397 | | - manageFilterListVisibility(); |
398 | 422 | } |
399 | | - }); |
| 423 | + manageFilterListVisibility(); |
| 424 | + } |
400 | 425 |
|
401 | 426 | // Finds element that contains text value. Searches all children of node. |
402 | 427 | function findByText(node, text) { |
|
485 | 510 | $('#showGraphImg').attr('src', <%= q(getWebappURL("/_images/minus.gif")) %>); |
486 | 511 | $('#formContainer').show(); |
487 | 512 | $('#allFilters').show(); |
| 513 | +
|
| 514 | + // Create the form after the container is visible |
| 515 | + createForm(); |
488 | 516 | } |
489 | 517 | else |
490 | 518 | { |
|
498 | 526 | <div id="headContainer"> |
499 | 527 | <% addHandler("showChartHeadContainer", "click", "showChart()"); %> |
500 | 528 | <div id="showChartHeadContainer" style="margin-bottom: 10px;"><img id="showGraphImg" src="<%=getWebappURL("_images/plus.gif")%>"> <strong>Display Chart Settings</strong></div> |
501 | | - <div id="formContainer" style="float:left; width:550px; height: 160px; padding-bottom: 25px; display: none;"></div> |
| 529 | + <div id="formContainer" style="float:left; width:550px; padding-bottom: 25px; display: none;"></div> |
502 | 530 | <div id="allFilters" style="float:left; display: none;"> |
503 | 531 |
|
504 | 532 | <div style="float:left;" class="chrom_title_box" id="reptitle" > |
|
0 commit comments