Skip to content

Commit 771547c

Browse files
committed
Bug 1223669 - don't scroll to the top of the page when clicking on the resolution buttons
1 parent b4bfae7 commit 771547c

File tree

4 files changed

+100
-66
lines changed

4 files changed

+100
-66
lines changed

extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -436,34 +436,41 @@
436436
label = "Status"
437437
hide_on_view = bug.assigned_to.id != user.id
438438
%]
439-
[% INCLUDE bug_modal/field.html.tmpl
440-
field = bug_fields.bug_status
441-
field_type = constants.FIELD_TYPE_SINGLE_SELECT
442-
editable = bug.choices.bug_status.size > 1
443-
values = bug.choices.bug_status
444-
inline = 1
445-
no_indent = 1
446-
edit_only = 1
447-
%]
448-
[% INCLUDE bug_modal/field.html.tmpl
449-
field = bug_fields.resolution
450-
field_type = constants.FIELD_TYPE_SINGLE_SELECT
451-
editable = bug.choices.resolution.size > (bug.resolution == "" ? 0 : 1)
452-
values = bug.choices.resolution
453-
inline = 1
454-
edit_only = 1
455-
%]
456-
[% IF bug.choices.resolution.only("name", "DUPLICATE").size %]
457-
<div id="duplicate-container">
458-
of
459-
<input id="dup_id" name="dup_id" size="6" value="[% bug.dup_id FILTER html %]">
460-
</div>
461-
<div id="duplicate-actions">
462-
<button type="button" class="minor" id="mark-as-dup-btn">
463-
Mark as Duplicate
464-
</button>
465-
</div>
466-
[% END %]
439+
[% INCLUDE status_block %]
440+
[% END %]
441+
[% END %]
442+
443+
[% BLOCK status_block %]
444+
[% INCLUDE bug_modal/field.html.tmpl
445+
prefix = prefix
446+
field = bug_fields.bug_status
447+
field_type = constants.FIELD_TYPE_SINGLE_SELECT
448+
editable = bug.choices.bug_status.size > 1
449+
values = bug.choices.bug_status
450+
inline = 1
451+
no_indent = 1
452+
edit_only = 1
453+
%]
454+
[% INCLUDE bug_modal/field.html.tmpl
455+
prefix = prefix
456+
field = bug_fields.resolution
457+
field_type = constants.FIELD_TYPE_SINGLE_SELECT
458+
editable = bug.choices.resolution.size > (bug.resolution == "" ? 0 : 1)
459+
values = bug.choices.resolution
460+
inline = 1
461+
edit_only = 1
462+
%]
463+
[% IF bug.choices.resolution.only("name", "DUPLICATE").size %]
464+
<div id="[% prefix FILTER none %]duplicate-container">
465+
of
466+
<input id="[% prefix FILTER none %]dup_id" name="[% prefix FILTER none %]dup_id"
467+
size="6" value="[% bug.dup_id FILTER html %]">
468+
</div>
469+
<div id="[% prefix FILTER none %]duplicate-actions">
470+
<button type="button" class="minor" id="[% prefix FILTER none %]mark-as-dup-btn">
471+
Mark as Duplicate
472+
</button>
473+
</div>
467474
[% END %]
468475
[% END %]
469476

@@ -1096,21 +1103,31 @@
10961103
[% IF user.id %]
10971104
<div id="new-comment-actions">
10981105
<button type="submit" class="save-btn major" id="bottom-save-btn">Save Changes</button>
1099-
[%
1100-
IF bug.resolution == "";
1101-
seen_header = 0;
1102-
FOREACH resolution IN ["FIXED", "INVALID", "DUPLICATE"];
1103-
NEXT UNLESS bug.choices.resolution.only("name", resolution).size;
1104-
IF NOT seen_header;
1105-
seen_header = 1;
1106-
" Resolve as ";
1106+
<div id="resolve-as">
1107+
[%
1108+
IF bug.resolution == "";
1109+
seen_header = 0;
1110+
FOREACH resolution IN ["FIXED", "INVALID", "DUPLICATE"];
1111+
NEXT UNLESS bug.choices.resolution.only("name", resolution).size;
1112+
IF NOT seen_header;
1113+
seen_header = 1;
1114+
" Resolve as ";
1115+
END;
1116+
%] <button type="button" class="minor resolution-btn">[% resolution FILTER html %]</button> [%
1117+
END;
1118+
ELSE;
1119+
IF bug.choices.bug_status.only("name", "VERIFIED").size && bug.bug_status != "VERIFIED";
1120+
%] <button type="button" class="minor status-btn" data-status="VERIFIED">VERIFY</button> [%
1121+
END;
1122+
IF bug.choices.bug_status.only("name", "REOPENED").size;
1123+
%] <button type="button" class="minor status-btn" data-status="REOPENED">REOPEN</button> [%
11071124
END;
1108-
%] <button type="button" class="minor resolution-btn">[% resolution FILTER html %]</button> [%
11091125
END;
1110-
ELSIF bug.choices.bug_status.only("name", "REOPENED").size;
1111-
%] <button type="button" class="minor status-btn" data-status="REOPENED">REOPEN</button> [%
1112-
END;
1113-
%]
1126+
%]
1127+
</div>
1128+
<div id="bottom-status" style="display:none">
1129+
[% INCLUDE status_block prefix="bottom-" %]
1130+
</div>
11141131
</div>
11151132
[% END %]
11161133
[% END %]

extensions/BugModal/template/en/default/bug_modal/field.html.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# view_only: (boolean) don't allow editing (default: determined from bug.check_can_change_field)
1515
# edit_only: (boolean) always render the edit ui
1616
# container: (boolean) output just a label and the content (eg. for multiple fields next to one label)
17+
# name: (string) field name (default: field.name)
18+
# prefix: (string) string to prepend to 'name' and 'id' attributes (default: empty)
1719
# value: (string) visible value (default: bug.$name)
1820
# values: (array of string) list of value objects (FIELD_TYPE_SINGLE_SELECT and _BUG_URLS only) (default: lazy-load on edit)
1921
# inline: (boolean) output field as a table-cell instead of as a stand-alone div (default: false)
@@ -64,6 +66,9 @@ END;
6466
IF field_type == "";
6567
field_type = -1;
6668
END;
69+
IF prefix.defined;
70+
name = prefix _ name;
71+
END;
6772
# date picker fields should always be short
6873
IF field_type == constants.FIELD_TYPE_DATE
6974
|| field_type == constants.FIELD_TYPE_DATETIME;

extensions/BugModal/web/bug_modal.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ input[type="number"] {
255255
display: inline;
256256
}
257257

258-
#duplicate-container, #duplicate-actions {
258+
#duplicate-container, #duplicate-actions,
259+
#bottom-duplicate-container, #bottom-duplicate-actions {
259260
display: table-cell;
260261
vertical-align: top;
261262
padding-left: 8px;
@@ -265,8 +266,8 @@ input[type="number"] {
265266
margin-left: 4px;
266267
}
267268

268-
#duplicate-container #dup_up {
269-
padding-left: 5px;
269+
#resolve-as, #bottom-status {
270+
display: inline;
270271
}
271272

272273
#after-comment-commit-button {

extensions/BugModal/web/bug_modal.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -678,38 +678,52 @@ $(function() {
678678
});
679679

680680
// knob
681-
$('#bug_status')
681+
$('#bug_status, #bottom-bug_status')
682682
.change(function(event) {
683-
if (event.target.value == "RESOLVED" || event.target.value == "VERIFIED") {
684-
$('#resolution').change().show();
683+
var that = $(this);
684+
var val = that.val();
685+
var other = $(that.attr('id') == 'bug_status' ? '#bottom-bug_status' : '#bug_status');
686+
other.val(val);
687+
if (val == "RESOLVED" || val == "VERIFIED") {
688+
$('#resolution, #bottom-resolution').change().show();
685689
}
686690
else {
687-
$('#resolution').hide();
688-
$('#duplicate-container').hide();
689-
$('#mark-as-dup-btn').show();
691+
$('#resolution, #bottom-resolution').hide();
692+
$('#duplicate-container, #bottom-duplicate-container').hide();
693+
$('#mark-as-dup-btn, #bottom-mark-as-dup-btn').show();
690694
}
691695
})
692696
.change();
693-
$('#resolution')
697+
$('#resolution, #bottom-resolution')
694698
.change(function(event) {
699+
var that = $(this);
700+
var val = that.val();
701+
var other = $(that.attr('id') == 'resolution' ? '#bottom-resolution' : '#resolution');
702+
other.val(val);
695703
var bug_status = $('#bug_status').val();
696-
if ((bug_status == "RESOLVED" || bug_status == "VERIFIED") && event.target.value == "DUPLICATE") {
697-
$('#duplicate-container').show();
698-
$('#mark-as-dup-btn').hide();
699-
$('#dup_id').focus();
704+
if ((bug_status == "RESOLVED" || bug_status == "VERIFIED") && val == "DUPLICATE") {
705+
$('#duplicate-container, #bottom-duplicate-container').show();
706+
$('#mark-as-dup-btn, #bottom-mark-as-dup-btn').hide();
707+
$(that.attr('id') == 'resolution' ? '#dup_id' : '#bottom-dup_id').focus();
700708
}
701709
else {
702-
$('#duplicate-container').hide();
703-
$('#mark-as-dup-btn').show();
710+
$('#duplicate-container, #bottom-duplicate-container').hide();
711+
$('#mark-as-dup-btn, #bottom-mark-as-dup-btn').show();
704712
}
705713
})
706714
.change();
707-
$('#mark-as-dup-btn')
715+
$('#mark-as-dup-btn, #bottom-mark-as-dup-btn')
708716
.click(function(event) {
709717
event.preventDefault();
710718
$('#bug_status').val('RESOLVED').change();
711719
$('#resolution').val('DUPLICATE').change();
712-
$('#dup_id').focus();
720+
$($(this).attr('id') == 'mark-as-dup-btn' ? '#dup_id' : '#bottom-dup_id').focus();
721+
});
722+
$('#dup_id, #bottom-dup_id')
723+
.change(function(event) {
724+
var that = $(this);
725+
var other = $(that.attr('id') == 'dup_id' ? '#bottom-dup_id' : '#dup_id');
726+
other.val(that.val());
713727
});
714728

715729
// add see-also button
@@ -825,12 +839,8 @@ $(function() {
825839
$('#bug_status').val('RESOLVED').change();
826840
$('#resolution').val($(event.target).text()).change();
827841
$('#top-save-btn').show();
828-
if ($(event.target).text() == "DUPLICATE") {
829-
$.scrollTo($('body'));
830-
}
831-
else {
832-
$.scrollTo($('body'), function() { $('#resolution').focus(); });
833-
}
842+
$('#resolve-as').hide();
843+
$('#bottom-status').show();
834844
});
835845
$('.status-btn')
836846
.click(function(event) {
@@ -839,7 +849,8 @@ $(function() {
839849
$('#field-status-edit').show();
840850
$('#bug_status').val($(event.target).data('status')).change();
841851
$('#top-save-btn').show();
842-
$.scrollTo($('body'), function() { $('#bug_status').focus(); });
852+
$('#resolve-as').hide();
853+
$('#bottom-status').show();
843854
});
844855

845856
// vote button

0 commit comments

Comments
 (0)