From 0d71c225256de0a0e4f96e33c314efdab032f83f Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 31 Jul 2013 22:08:20 +0800 Subject: Bug 899974: Patch checkbox gets unchecked when picking a patch --- extensions/Review/web/js/review.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'extensions') diff --git a/extensions/Review/web/js/review.js b/extensions/Review/web/js/review.js index 3ba00487d..0dedd2410 100644 --- a/extensions/Review/web/js/review.js +++ b/extensions/Review/web/js/review.js @@ -13,6 +13,8 @@ var REVIEW = { target: false, fields: [], use_error_for: false, + ispatch_override: false, + description_override: false, init_review_flag: function(fid, flag_name) { var idx = this.fields.push({ 'fid': fid, 'flag_name': flag_name, 'component': '' }) - 1; @@ -44,6 +46,8 @@ var REVIEW = { init_create_attachment: function() { Event.addListener('data', 'change', REVIEW.attachment_change); + Event.addListener('description', 'change', REVIEW.description_change); + Event.addListener('ispatch', 'change', REVIEW.ispatch_change); }, component_change: function() { @@ -55,16 +59,26 @@ var REVIEW = { attachment_change: function() { var filename = Dom.get('data').value.split('/').pop().split('\\').pop(); var description = Dom.get('description'); - if (description.value == '') { + if (description.value == '' || !REVIEW.description_override) { description.value = filename; } - Dom.get('ispatch').checked = - REVIEW.endsWith(filename, '.diff') || REVIEW.endsWith(filename, '.patch'); - bz_fireEvent(Dom.get('ispatch'), 'change'); + if (!REVIEW.ispatch_override) { + Dom.get('ispatch').checked = + REVIEW.endsWith(filename, '.diff') || REVIEW.endsWith(filename, '.patch'); + } + setContentTypeDisabledState(this.form); description.select(); description.focus(); }, + description_change: function() { + REVIEW.description_override = true; + }, + + ispatch_change: function() { + REVIEW.ispatch_override = true; + }, + flag_change: function(e, field_idx) { var field = REVIEW.fields[field_idx]; var suggestions_span = Dom.get(field.fid + '_suggestions'); -- cgit v1.2.3-24-g4f1b