Skip to content

Commit e201dac

Browse files
committed
Update _ambiguous_type_genome.html.erb
1 parent 7253788 commit e201dac

1 file changed

Lines changed: 39 additions & 10 deletions

File tree

app/views/registers/curation_genomics/_ambiguous_type_genome.html.erb

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
c_class = r[1].to_f > 95.0 ? 'text-danger' :
88
r[1].to_f > 60.0 ? '' : 'text-muted'
99
content_tag(:div,
10-
opts.merge(class: c_class, type: :aai, value: r[1])
10+
opts.merge(class: c_class, data: { type: :aai, value: r[1] })
1111
) do
1212
content_tag(:span, "#{r[1]}% - ") +
1313
if r[0] =~ /^genome_(\d+)$/
@@ -51,10 +51,13 @@
5151
<td>
5252
<% name.qc_warnings.each do |warn| %>
5353
<% if warn.type.to_s =~ /^discrepant_/ %>
54-
<%= render(
55-
partial: 'checks/check',
56-
locals: { warn: warn, no_message: true, no_action: true }
57-
) %>
54+
<div data-type="qc-warning" data-name="<%= name.id %>"
55+
data-kind="<%= warn.type %>">
56+
<%= render(
57+
partial: 'checks/check',
58+
locals: { warn: warn, no_message: true, no_action: true }
59+
) %>
60+
</div>
5861
<% end %>
5962
<% end %>
6063
</td>
@@ -97,22 +100,48 @@
97100
var skip = $(this);
98101
var name_id = skip.find("a[data-do=skip]").data("name");
99102
if (name_id) {
103+
var name_fail = 0;
104+
100105
// The name is in the list, now check if any of the AAI values are too
101106
// high and should be manually checked
102-
var aai_high = $(`[data-type=aai][data-name=${name_id}][data-value]`)
103-
107+
var aai = $(`[data-type=aai][data-name=${name_id}][data-value]`);
108+
var max_aai = Math.max.apply(
109+
null, aai.map(function(){ reuturn $(this).data("value"); })
110+
);
111+
if (max_aai >= 90.0) {
112+
aai.parents("td").addClass("bg-warning");
113+
name_fail += 1;
114+
}
115+
116+
// Check if the MiGA classification matches the reported one
104117
var miga = $(`#tax-${name_id}-miga [data-kind=taxonomy]`).last();
105118
var same = $(
106119
`#tax-${name_id}-reported ` +
107120
`[data-kind=taxonomy][data-rank=${miga.data("rank")}]` +
108121
`[data-value=${miga.data("value")}]`
109122
)
110-
if (same.length > 0) {
111-
// MiGA and Reported taxonomy coincide at the lowest MiGA rank
112-
123+
if (same.length == 0) {
124+
miga.parents("td").addClass("bg-warning");
125+
$(`#tax-${name_id}-reported`).parents("td").addClass("bg-warning");
126+
name_fail += 1;
127+
}
128+
129+
// And check if there are any other discrepancies detected
130+
var warn = $(`[data-type=qc-warning][data-name=${name_id}][data-kind]`);
131+
if (warn.length > 0) {
132+
warn.parents("td").addClass("bg-warning");
133+
name_fail += 1;
134+
}
135+
136+
// If all is good, auto-check the button, but only if it's currently
137+
// in "skip" status (i.e., not yet passed or failed)
138+
if (name_fail == 0) {
139+
$(`.check-skip .check-links [data-name=${name_id}][data-do=pass]`)
140+
.click();
113141
}
114142
}
115143
});
144+
return false;
116145
});
117146
</script>
118147

0 commit comments

Comments
 (0)