From 55d148d167630fce08f40e6fcf2ab9def0b9699d Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 25 Nov 2014 13:08:29 +0800 Subject: Bug 1103837: Bug Bounty Entry Form no longer edits bounty attachment description --- extensions/BMO/web/js/attachment_bounty_form.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'extensions/BMO/web') diff --git a/extensions/BMO/web/js/attachment_bounty_form.js b/extensions/BMO/web/js/attachment_bounty_form.js index cdec78276..59ffe8479 100644 --- a/extensions/BMO/web/js/attachment_bounty_form.js +++ b/extensions/BMO/web/js/attachment_bounty_form.js @@ -8,11 +8,27 @@ function add_bounty_attachment(bug_id) { var nodes = YAHOO.util.Selector.query('#attachment_table tr.bz_attach_footer td'); if (nodes) { + var existing = document.getElementById('bounty_attachment'); var td = nodes[0]; var a = document.createElement('a'); a.href = 'page.cgi?id=attachment_bounty_form.html&bug_id=' + bug_id; - a.appendChild(document.createTextNode('Add bounty tracking attachment')); + a.appendChild(document.createTextNode(existing + ? 'Edit bounty tracking attachment' + : 'Add bounty tracking attachment')); td.appendChild(document.createElement('br')); td.appendChild(a); + + if (existing) { + var tr = existing.parentNode.parentNode; + if (tr.nodeName != 'TR') + return; + nodes = tr.getElementsByTagName('a'); + for (var i = 0, il = nodes.length; i < il; i++) { + if (nodes[i].href.match(/attachment\.cgi\?id=\d+$/)) { + nodes[i].href = a.href; + return; + } + } + } } } -- cgit v1.2.3-24-g4f1b