Mercurial > bugzilla-dashboard
comparison js/modules/app.js @ 73:1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 18:53:27 -0700 |
parents | 0eab9a3ff12f |
children | 1a0a3abbba93 |
comparison
equal
deleted
inserted
replaced
72:0eab9a3ff12f | 73:1cd66cabe153 |
---|---|
418 const PRETTY_DATE_UPDATE_INTERVAL = 1000 * 60; | 418 const PRETTY_DATE_UPDATE_INTERVAL = 1000 * 60; |
419 | 419 |
420 window.setInterval(function() { updatePrettyDates($("#reports")); }, | 420 window.setInterval(function() { updatePrettyDates($("#reports")); }, |
421 PRETTY_DATE_UPDATE_INTERVAL); | 421 PRETTY_DATE_UPDATE_INTERVAL); |
422 | 422 |
423 const BUGS_TO_SHOW = 10; | |
424 | |
423 function showBugs(query, bugs) { | 425 function showBugs(query, bugs) { |
424 var table = $("#templates .bugs").clone(); | 426 var table = $("#templates .bugs").clone(); |
425 var rowTemplate = table.find(".bug-row").remove(); | 427 var rowTemplate = table.find(".bug-row").remove(); |
428 | |
429 function appendRowForBug(bug) { | |
430 var row = rowTemplate.clone(); | |
431 row.attr("id", "bug-id-" + bug.id); | |
432 row.find(".summary").text(bug.summary); | |
433 row.addClass("status-" + bug.status); | |
434 if (bug.priority != "--") { | |
435 row.addClass(bug.priority); | |
436 row.addClass(bug.severity); | |
437 } | |
438 row.find(".last-changed").attr("data-last-change", | |
439 bug.last_change_time); | |
440 | |
441 row.click( | |
442 function onClick() { | |
443 window.open(bugzilla.getShowBugURL(bug.id)); | |
444 }); | |
445 | |
446 row.hover( | |
447 function onIn() { | |
448 var tooltip = $("#templates .bug-tooltip").clone(); | |
449 tooltip.find(".priority").text(bug.priority); | |
450 // TODO: Show more information in tooltip. | |
451 $(this).append(tooltip); | |
452 }, | |
453 function onOut() { | |
454 $(this).find(".bug-tooltip").remove(); | |
455 }); | |
456 | |
457 table.append(row); | |
458 } | |
459 | |
426 sortByLastChanged(bugs); | 460 sortByLastChanged(bugs); |
427 bugs.reverse(); | 461 bugs.reverse(); |
428 bugs.forEach( | 462 |
429 function(bug) { | 463 var extraBugs = bugs.slice(BUGS_TO_SHOW); |
430 var row = rowTemplate.clone(); | 464 bugs = bugs.slice(0, BUGS_TO_SHOW); |
431 row.attr("id", "bug-id-" + bug.id); | 465 |
432 row.find(".summary").text(bug.summary); | 466 bugs.forEach(appendRowForBug); |
433 row.addClass("status-" + bug.status); | 467 |
434 if (bug.priority != "--") { | |
435 row.addClass(bug.priority); | |
436 row.addClass(bug.severity); | |
437 } | |
438 row.find(".last-changed").attr("data-last-change", | |
439 bug.last_change_time); | |
440 | |
441 row.click( | |
442 function onClick() { | |
443 window.open(bugzilla.getShowBugURL(bug.id)); | |
444 }); | |
445 | |
446 row.hover( | |
447 function onIn() { | |
448 var tooltip = $("#templates .bug-tooltip").clone(); | |
449 tooltip.find(".priority").text(bug.priority); | |
450 // TODO: Show more information in tooltip. | |
451 $(this).append(tooltip); | |
452 }, | |
453 function onOut() { | |
454 $(this).find(".bug-tooltip").remove(); | |
455 }); | |
456 | |
457 table.append(row); | |
458 }); | |
459 updatePrettyDates(table); | 468 updatePrettyDates(table); |
460 query.find(".bugs").remove(); | 469 query.find(".bugs").remove(); |
470 query.find(".more-link").remove(); | |
461 query.append(table); | 471 query.append(table); |
472 | |
473 if (extraBugs.length) { | |
474 var moreLink = $("#templates .more-link").clone(); | |
475 moreLink.click( | |
476 function() { | |
477 moreLink.remove(); | |
478 extraBugs.forEach(appendRowForBug); | |
479 updatePrettyDates(table); | |
480 removeDuplicateBugs(); | |
481 }); | |
482 query.append(moreLink); | |
483 } | |
484 | |
462 table.hide(); | 485 table.hide(); |
463 removeDuplicateBugs(); | 486 removeDuplicateBugs(); |
464 table.fadeIn(); | 487 table.fadeIn(); |
465 } | 488 } |
466 | 489 |