From dac9873a61b108133ee00bda5b1862404712dd63 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 30 Apr 2015 14:06:06 +0800 Subject: Bug 1151745: add ui to minimise steps required to move bugs between products --- extensions/BugModal/web/bug_modal.js | 163 ++++++++++++++++++++++++++++++++--- 1 file changed, 150 insertions(+), 13 deletions(-) (limited to 'extensions/BugModal/web/bug_modal.js') diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index c96267e14..dba3abc85 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -52,8 +52,9 @@ $(function() { .click(function(event) { event.preventDefault(); var btn = $(event.target); + var modules; if (btn.data('expanded-modules')) { - var modules = btn.data('expanded-modules'); + modules = btn.data('expanded-modules'); btn.data('expanded-modules', false); modules.each(function() { slide_module($(this).parent('.module')); @@ -61,7 +62,7 @@ $(function() { btn.text('Expand All'); } else { - var modules = $('.module-content:hidden'); + modules = $('.module-content:hidden'); btn.data('expanded-modules', modules); modules.each(function() { slide_module($(this).parent('.module')); @@ -134,7 +135,7 @@ $(function() { }); // use non-native tooltips for relative times and bug summaries - $('.rel-time, .rel-time-title, .bz_bug_link').tooltip({ + $('.rel-time, .rel-time-title, .bz_bug_link, .tt').tooltip({ position: { my: "left top+8", at: "left bottom", collision: "flipfit" }, show: { effect: 'none' }, hide: { effect: 'none' } @@ -146,7 +147,7 @@ $(function() { $('.ui-helper-hidden-accessible').remove(); // product/component info - $('.spin-toggle') + $('.spin-toggle, #product-latch, #component-latch') .click(function(event) { event.preventDefault(); var latch = $($(event.target).data('latch')); @@ -222,8 +223,8 @@ $(function() { $(document).on( 'copy', function(event) { var selection = document.getSelection().toString().trim(); - var match = selection.match(/^(Bug \d+)\s*\n(.+)$/) - || selection.match(/^(Bug \d+)\s+\([^\)]+\)\s*\n(.+)$/); + var match = selection.match(/^(Bug \d+)\s*\n(.+)$/) || + selection.match(/^(Bug \d+)\s+\([^\)]+\)\s*\n(.+)$/); if (match) { var content = match[1] + ' - ' + match[2].trim(); if (event.originalEvent.clipboardData) { @@ -352,6 +353,15 @@ $(function() { }); $('#mode-btn').prop('disabled', false); + // disable the save buttons while posting + $('.save-btn') + .click(function(event) { + if (document.changeform.checkValidity && !document.changeform.checkValidity()) + return; + $('.save-btn').attr('disabled', true); + }) + .attr('disabled', false); + // cc toggle (follow/stop following) $('#cc-btn') .click(function(event) { @@ -724,10 +734,6 @@ $(function() { var cb = $(event.target); var input = $('#' + cb.data('for')); input.attr('disabled', cb.prop('checked')); - if (!cb.prop('checked')) { - input.focus(); - input.select(); - } }) .change(); @@ -740,7 +746,7 @@ $(function() { if (document.activeElement.nodeNode == 'INPUT' || document.activeElement.nodeName == 'TEXTAREA') return; if (String.fromCharCode(event.which).toLowerCase() == 'e') { - if ($('#cancel-btn:visible').length == 0) { + if ($('#cancel-btn:visible').length === 0) { event.preventDefault(); $('#mode-btn').click(); } @@ -756,6 +762,136 @@ $(function() { $('#top-save-btn').show(); $('#add-cc').focus(); }); + + + // product change --> load components, versions, milestones, groups + $('#product').data('default', $('#product').val()); + $('#component, #version, #target_milestone').each(function() { + $(this).data('default', $(this).val()); + }); + $('#product') + .change(function(event) { + $('#product-throbber').show(); + $('#component, #version, #target_milestone').attr('disabled', true); + + slide_module($('#module-tracking'), 'show'); + + $.each($('input[name=groups]'), function() { + if (this.checked) { + slide_module($('#module-security'), 'show'); + return false; + } + }); + + bugzilla_ajax( + { + url: 'rest/bug_modal/new_product/' + BUGZILLA.bug_id + '?product=' + encodeURIComponent($('#product').val()) + }, + function(data) { + $('#product-throbber').hide(); + $('#component, #version, #target_milestone').attr('disabled', false); + var is_default = $('#product').val() == $('#product').data('default'); + + // populate selects + $.each(data, function(key, value) { + if (key == 'groups') return; + var el = $('#' + key); + if (!el) return; + el.empty(); + var selected = el.data('preselect'); + $(value).each(function(i, v) { + el.append($('