Replaced some list comprehension with generators, javascript in templates to create click event.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
<h3><u>Reagents:</u></h3>
|
||||
<p>{% for item in sub['reagents'] %}
|
||||
<b>{{ item['role'] }}</b>: <a class="data-link" id="{{ item['lot'] }}">{{ item['lot'] }} (EXP: {{ item['expiry'] }})</a><br>
|
||||
<b>{{ item['role'] }}</b>: <a class="data-link reagent" id="{{ item['lot'] }}">{{ item['lot'] }} (EXP: {{ item['expiry'] }})</a><br>
|
||||
{% endfor %}</p>
|
||||
|
||||
{% if sub['equipment'] %}
|
||||
@@ -38,7 +38,7 @@
|
||||
{% if sub['samples'] %}
|
||||
<h3><u>Samples:</u></h3>
|
||||
<p>{% for item in sub['samples'] %}
|
||||
<b>{{ item['well'] }}:</b><a class="data-link" id="{{ item['submitter_id'] }}_alpha">{% if item['organism'] %} {{ item['name'] }} - ({{ item['organism']|replace('\n\t', '<br> ') }}){% else %} {{ item['name']|replace('\n\t', '<br> ') }}{% endif %}</a><br>
|
||||
<b>{{ item['well'] }}:</b><a class="data-link sample" id="{{ item['submitter_id'] }}">{% if item['organism'] %} {{ item['name'] }} - ({{ item['organism']|replace('\n\t', '<br> ') }}){% else %} {{ item['name']|replace('\n\t', '<br> ') }}{% endif %}</a><br>
|
||||
{% endfor %}</p>
|
||||
{% endif %}
|
||||
|
||||
@@ -83,22 +83,25 @@
|
||||
<script>
|
||||
{% block script %}
|
||||
{{ super() }}
|
||||
{% for sample in sub['samples'] %}
|
||||
document.getElementById("{{ sample['submitter_id'] }}").addEventListener("click", function(){
|
||||
backend.sample_details("{{ sample['submitter_id'] }}");
|
||||
});
|
||||
document.getElementById("{{ sample['submitter_id'] }}_alpha").addEventListener("click", function(){
|
||||
backend.sample_details("{{ sample['submitter_id'] }}");
|
||||
});
|
||||
{% endfor %}
|
||||
{% for reagent in sub['reagents'] %}
|
||||
document.getElementById("{{ reagent['lot'] }}").addEventListener("click", function(){
|
||||
backend.reagent_details("{{ reagent['lot'] }}", "{{ sub['extraction_kit'] }}");
|
||||
});
|
||||
{% endfor %}
|
||||
|
||||
document.getElementById("sign_btn").addEventListener("click", function(){
|
||||
backend.sign_off("{{ sub['plate_number'] }}");
|
||||
});
|
||||
var sampleSelection = document.getElementsByClassName('sample');
|
||||
|
||||
for(let i = 0; i < sampleSelection.length; i++) {
|
||||
sampleSelection[i].addEventListener("click", function() {
|
||||
backend.sample_details(sampleSelection[i].id);
|
||||
})
|
||||
}
|
||||
|
||||
var reagentSelection = document.getElementsByClassName('reagent');
|
||||
|
||||
for(let i = 0; i < reagentSelection.length; i++) {
|
||||
reagentSelection[i].addEventListener("click", function() {
|
||||
backend.reagent_details(reagentSelection[i].id, "{{ sub['extraction_kit'] }}");
|
||||
})
|
||||
}
|
||||
|
||||
{% endblock %}
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="gallery" style="display: grid;grid-template-columns: repeat({{ PLATE_COLUMNS }}, 7.5vw);grid-template-rows: repeat({{ PLATE_ROWS }}, 7.5vw);grid-gap: 2px;">
|
||||
{% for sample in samples %}
|
||||
<div class="well data-link" id="{{sample['submitter_id']}}" style="background-color: {{sample['background_color']}};
|
||||
<div class="well data-link sample" id="{{sample['submitter_id']}}" style="background-color: {{sample['background_color']}};
|
||||
border: 1px solid #000;
|
||||
padding: 20px;
|
||||
grid-column-start: {{sample['column']}};
|
||||
|
||||
Reference in New Issue
Block a user