|
1 | 1 | <%= pager(@names) %> |
2 | 2 |
|
| 3 | +<div class="text-center mb-4 w-100"> |
| 4 | + <%= link_to('#', class: 'btn btn-primary', id: 'smart-checks') do %> |
| 5 | + <%= fa_icon('robot') %> Smart-check easy cases |
| 6 | + <% end %> |
| 7 | +</div> |
| 8 | + |
3 | 9 | <table class="table table-hover table-responsive"> |
4 | 10 | <thead> |
5 | 11 | <tr> |
|
67 | 73 | </table> |
68 | 74 | <%= render(partial: 'checks/curator_script') %> |
69 | 75 | <%= pager(@names) %> |
| 76 | + |
| 77 | +<script> |
| 78 | + function auto_check_name(name_id) { |
| 79 | + if (!name_id) return false; |
| 80 | + |
| 81 | + // Check if the MiGA classification matches the 16S one |
| 82 | + var miga = $(`#tax-${name_id}-miga [data-kind=taxonomy]`).last(); |
| 83 | + var copies = $(`ul:has(#tax-${name_id}-16s)`).length; |
| 84 | + var same = $( |
| 85 | + `#tax-${name_id}-16s ` + |
| 86 | + `[data-kind=taxonomy][data-rank="${miga.data("rank")}"]` + |
| 87 | + `[data-value="${miga.data("value")}"]` |
| 88 | + ); |
| 89 | + if (same.length != copies) { |
| 90 | + miga.parents("td").addClass("bg-warning"); |
| 91 | + $(`#tax-${name_id}-16s`).parents("ul").addClass("bg-warning"); |
| 92 | + return false; |
| 93 | + } |
| 94 | + |
| 95 | + // If all is good, auto-check the button, but only if it's currently |
| 96 | + // in "skip" status (i.e., not yet passed or failed) |
| 97 | + $(`.check-skip .check-links [data-name=${name_id}][data-do=pass]`).click(); |
| 98 | + return true; |
| 99 | + } |
| 100 | + |
| 101 | + $("#smart-checks").on("click", function() { |
| 102 | + var passed = 0; |
| 103 | + var all = $(".curator-checklist .check-skip").each(function() { |
| 104 | + var skip = $(this); |
| 105 | + var name_id = skip.find("a[data-do=skip]").data("name"); |
| 106 | + if (auto_check_name(name_id)) passed += 1; |
| 107 | + }).length; |
| 108 | + alert(`Auto-passed ${passed} names of ${all} checked`); |
| 109 | + return false; |
| 110 | + }); |
| 111 | +</script> |
| 112 | + |
0 commit comments