diff options
author | Byron Jones <glob@mozilla.com> | 2014-07-22 09:23:21 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-07-22 09:23:21 +0200 |
commit | bff9f8e135cdf6e72228d7502cf160b3bdd9bde4 (patch) | |
tree | da82f0b3b2b4e3d44b4c4bf00be9f07854f15717 /extensions/TrackingFlags/web/js | |
parent | 235190a76c418d89f808f48d174bdcde5add4073 (diff) | |
download | bugzilla-bff9f8e135cdf6e72228d7502cf160b3bdd9bde4.tar.gz bugzilla-bff9f8e135cdf6e72228d7502cf160b3bdd9bde4.tar.xz |
Bug 713307: Please add FlagTypeComments for tracking/approval flags
Diffstat (limited to 'extensions/TrackingFlags/web/js')
-rw-r--r-- | extensions/TrackingFlags/web/js/admin.js | 42 | ||||
-rw-r--r-- | extensions/TrackingFlags/web/js/tracking_flags.js | 85 |
2 files changed, 88 insertions, 39 deletions
diff --git a/extensions/TrackingFlags/web/js/admin.js b/extensions/TrackingFlags/web/js/admin.js index e3eb81714..58bdd294f 100644 --- a/extensions/TrackingFlags/web/js/admin.js +++ b/extensions/TrackingFlags/web/js/admin.js @@ -80,7 +80,7 @@ function update_flag_values() { for (var i = 0, l = flag_values.length; i < l; i++) { var value = flag_values[i]; - var row = tbl.insertRow(2 + i); + var row = tbl.insertRow(2 + (i * 2)); var cell; // value @@ -157,10 +157,31 @@ function update_flag_values() { ? '<span class="txt_icon"> - </span>' : '<a class="txt_icon" href="#" onclick="value_move_down(' + i + ');return false"> ∇ </a>' ); - if (value.value != '---') - html += '| <a href="#" onclick="remove_value(' + i + ');return false">Remove</a>'; - html += ']'; + if (value.value != '---') { + var lbl = value.comment == '' ? 'Set Comment' : 'Edit Comment'; + html += + '|<a href="#" onclick="remove_value(' + i + ');return false">Remove</a>' + + '|<a href="#" onclick="toggle_value_comment(this, ' + i + ');return false">' + lbl + '</a>' + + } + html += ' ]'; cell.innerHTML = html; + + row = tbl.insertRow(3 + (i * 2)); + row.className = 'bz_default_hidden'; + row.id = 'comment_row_' + i; + cell = row.insertCell(0); + cell = row.insertCell(1); + cell.colSpan = 3; + var ta = document.createElement('textarea'); + ta.className = 'value_comment'; + ta.id = 'value_comment_' + i; + ta.rows = 5; + ta.value = value.comment; + cell.appendChild(ta); + Event.addListener(ta, 'blur', function(e, idx) { + flag_values[idx].comment = e.target.value; + }, i); } tag_invalid_values(); @@ -229,6 +250,19 @@ function update_value(e, o) { flag_values[i].value = o.value; } +function toggle_value_comment(btn, idx) { + var row = Dom.get('comment_row_' + idx); + if (Dom.hasClass(row, 'bz_default_hidden')) { + Dom.removeClass(row, 'bz_default_hidden'); + btn.innerHTML = 'Hide Comment'; + Dom.get('value_comment_' + idx).select(); + Dom.get('value_comment_' + idx).focus(); + } else { + Dom.addClass(row, 'bz_default_hidden'); + btn.innerHTML = flag_values[idx].comment == '' ? 'Set Comment' : 'Edit Comment'; + } +} + // visibility function update_flag_visibility() { diff --git a/extensions/TrackingFlags/web/js/tracking_flags.js b/extensions/TrackingFlags/web/js/tracking_flags.js index 135b93dba..17513ffe4 100644 --- a/extensions/TrackingFlags/web/js/tracking_flags.js +++ b/extensions/TrackingFlags/web/js/tracking_flags.js @@ -8,49 +8,64 @@ var Dom = YAHOO.util.Dom; -var TrackingFlags = { - flags: {}, - types: [] -}; - function hide_tracking_flags() { - for (var i = 0, l = TrackingFlags.types.length; i < l; i++) { - var flag_type = TrackingFlags.types[i]; - for (var field in TrackingFlags.flags[flag_type]) { - var el = Dom.get(field); - var value = el ? el.value : TrackingFlags.flags[flag_type][field]; - if (el && (value != TrackingFlags.flags[flag_type][field])) { - show_tracking_flags(flag_type); - return; - } - if (value == '---') { - Dom.addClass('row_' + field, 'bz_default_hidden'); - } else { - Dom.addClass(field, 'bz_default_hidden'); - Dom.removeClass('ro_' + field, 'bz_default_hidden'); - } + for (var i = 0, l = TrackingFlags.types.length; i < l; i++) { + var flag_type = TrackingFlags.types[i]; + for (var field in TrackingFlags.flags[flag_type]) { + var el = Dom.get(field); + var value = el ? el.value : TrackingFlags.flags[flag_type][field]; + if (el && (value != TrackingFlags.flags[flag_type][field])) { + show_tracking_flags(flag_type); + return; + } + if (value == '---') { + Dom.addClass('row_' + field, 'bz_default_hidden'); + } else { + Dom.addClass(field, 'bz_default_hidden'); + Dom.removeClass('ro_' + field, 'bz_default_hidden'); + } + } } - } } function show_tracking_flags(flag_type) { - Dom.addClass('edit_' + flag_type + '_flags_action', 'bz_default_hidden'); - for (var field in TrackingFlags.flags[flag_type]) { - if (Dom.get(field).value == '---') { - Dom.removeClass('row_' + field, 'bz_default_hidden'); + Dom.addClass('edit_' + flag_type + '_flags_action', 'bz_default_hidden'); + for (var field in TrackingFlags.flags[flag_type]) { + if (Dom.get(field).value == '---') { + Dom.removeClass('row_' + field, 'bz_default_hidden'); + } else { + Dom.removeClass(field, 'bz_default_hidden'); + Dom.addClass('ro_' + field, 'bz_default_hidden'); + } + } +} + +function tracking_flag_change(e) { + var value = e.value; + if (!TrackingFlags.comments[e.name]) + return; + var prefill = TrackingFlags.comments[e.name][e.value]; + if (!prefill) + return; + var commentEl = document.getElementById('comment'); + if (!commentEl) + return; + var value = commentEl.value; + if (value == prefill) + return; + if (value == '') { + commentEl.value = prefill; } else { - Dom.removeClass(field, 'bz_default_hidden'); - Dom.addClass('ro_' + field, 'bz_default_hidden'); + commentEl.value = prefill + "\n\n" + value; } - } } YAHOO.util.Event.onDOMReady(function() { - var edit_tracking_links = Dom.getElementsByClassName('edit_tracking_flags_link'); - for (var i = 0, l = edit_tracking_links.length; i < l; i++) { - YAHOO.util.Event.addListener(edit_tracking_links[i], 'click', function(e) { - e.preventDefault(); - show_tracking_flags(this.name); - }); - } + var edit_tracking_links = Dom.getElementsByClassName('edit_tracking_flags_link'); + for (var i = 0, l = edit_tracking_links.length; i < l; i++) { + YAHOO.util.Event.addListener(edit_tracking_links[i], 'click', function(e) { + e.preventDefault(); + show_tracking_flags(this.name); + }); + } }); |