Skip to content

Commit 742bf4b

Browse files
committed
Auto-select the next reviewer when choosing to assign a reviewer to an
unassigned request on the manage review requests page - Legacy-Id: 11837
1 parent 6e253f0 commit 742bf4b

2 files changed

Lines changed: 47 additions & 5 deletions

File tree

ietf/static/ietf/js/manage-review-requests.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@ $(document).ready(function () {
33

44
form.find(".reviewer-action").on("click", function () {
55
var row = $(this).closest("tr");
6+
7+
var select = row.find(".reviewer-controls [name$=\"-reviewer\"]");
8+
if (!select.val()) {
9+
// collect reviewers already assigned in this session
10+
var reviewerAssigned = {};
11+
select.find("option").each(function () {
12+
if (this.value)
13+
reviewerAssigned[this.value] = 0;
14+
});
15+
16+
form.find("[name$=\"-action\"][value=\"assign\"]").each(function () {
17+
var v = $(this).closest("tr").find("[name$=\"-reviewer\"]").val();
18+
if (v)
19+
reviewerAssigned[v] += 1;
20+
});
21+
22+
// by default, the select box contains a sorted list, so
23+
// we should be able to select the first, unless that
24+
// person has already been assigned to review in this
25+
// session
26+
var found = null;
27+
var options = select.find("option").get();
28+
for (var round = 0; round < 100 && !found; ++round) {
29+
for (var i = 0; i < options.length && !found; ++i) {
30+
var v = options[i].value;
31+
if (!v)
32+
continue;
33+
34+
if (reviewerAssigned[v] == round)
35+
found = v;
36+
}
37+
}
38+
39+
if (found)
40+
select.val(found);
41+
}
42+
643
row.find(".close-controls .undo").click();
744
row.find("[name$=\"-action\"]").val("assign");
845
row.find(".reviewer-action").hide();
@@ -14,6 +51,7 @@ $(document).ready(function () {
1451
row.find(".reviewer-controls").hide();
1552
row.find(".reviewer-action").show();
1653
row.find("[name$=\"-action\"]").val("");
54+
row.find("[name$=\"-reviewer\"]").val($(this).data("initial"));
1755
});
1856

1957
form.find(".close-action").on("click", function () {
@@ -38,9 +76,13 @@ $(document).ready(function () {
3876

3977
var row = $(this).closest("tr");
4078

41-
if (v == "assign")
42-
row.find(".reviewer-action").click();
43-
else if (v == "close")
44-
row.find(".close-action").click();
79+
if (v == "assign") {
80+
row.find(".reviewer-action").hide();
81+
row.find(".reviewer-controls").show();
82+
}
83+
else if (v == "close") {
84+
row.find(".close-action").hide();
85+
row.find(".close-controls").show();
86+
}
4587
});
4688
});

ietf/templates/group/manage_review_requests.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ <h1>Manage open review requests for {{ group.acronym }}</h1>
9494
<span class="reviewer-controls form-inline">
9595
{% spaceless %}
9696
{{ r.form.reviewer }}
97-
<button type="button" class="btn btn-default btn-sm undo fa fa-times" title="Undo assignment"></button>
97+
<button type="button" class="btn btn-default btn-sm undo fa fa-times" title="Undo assignment" data-initial="{{ r.form.fields.reviewer.initial|default:"" }}"></button>
9898
{% if r.form.reviewer.errors %}
9999
<div class="alert alert-danger">
100100
{% for e in r.form.reviewer.errors %}

0 commit comments

Comments
 (0)