Auto-select the next reviewer when choosing to assign a reviewer to an

unassigned request on the manage review requests page
 - Legacy-Id: 11837
This commit is contained in:
Ole Laursen 2016-08-22 14:28:56 +00:00
parent 6e253f0407
commit 742bf4b233
2 changed files with 47 additions and 5 deletions

View file

@ -3,6 +3,43 @@ $(document).ready(function () {
form.find(".reviewer-action").on("click", function () {
var row = $(this).closest("tr");
var select = row.find(".reviewer-controls [name$=\"-reviewer\"]");
if (!select.val()) {
// collect reviewers already assigned in this session
var reviewerAssigned = {};
select.find("option").each(function () {
if (this.value)
reviewerAssigned[this.value] = 0;
});
form.find("[name$=\"-action\"][value=\"assign\"]").each(function () {
var v = $(this).closest("tr").find("[name$=\"-reviewer\"]").val();
if (v)
reviewerAssigned[v] += 1;
});
// by default, the select box contains a sorted list, so
// we should be able to select the first, unless that
// person has already been assigned to review in this
// session
var found = null;
var options = select.find("option").get();
for (var round = 0; round < 100 && !found; ++round) {
for (var i = 0; i < options.length && !found; ++i) {
var v = options[i].value;
if (!v)
continue;
if (reviewerAssigned[v] == round)
found = v;
}
}
if (found)
select.val(found);
}
row.find(".close-controls .undo").click();
row.find("[name$=\"-action\"]").val("assign");
row.find(".reviewer-action").hide();
@ -14,6 +51,7 @@ $(document).ready(function () {
row.find(".reviewer-controls").hide();
row.find(".reviewer-action").show();
row.find("[name$=\"-action\"]").val("");
row.find("[name$=\"-reviewer\"]").val($(this).data("initial"));
});
form.find(".close-action").on("click", function () {
@ -38,9 +76,13 @@ $(document).ready(function () {
var row = $(this).closest("tr");
if (v == "assign")
row.find(".reviewer-action").click();
else if (v == "close")
row.find(".close-action").click();
if (v == "assign") {
row.find(".reviewer-action").hide();
row.find(".reviewer-controls").show();
}
else if (v == "close") {
row.find(".close-action").hide();
row.find(".close-controls").show();
}
});
});

View file

@ -94,7 +94,7 @@
<span class="reviewer-controls form-inline">
{% spaceless %}
{{ r.form.reviewer }}
<button type="button" class="btn btn-default btn-sm undo fa fa-times" title="Undo assignment"></button>
<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>
{% if r.form.reviewer.errors %}
<div class="alert alert-danger">
{% for e in r.form.reviewer.errors %}