diff options
author | Frederick Muriuki Muriithi | 2022-01-03 11:03:21 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-01-28 08:07:27 +0300 |
commit | f06bfa6ce485392a4bba5e66e6472630dcc6683b (patch) | |
tree | e0707e13310e19dccf564f8ab6d25ada4864a0be | |
parent | f130d308b509218b03319deaf491f6a45e9ca9ac (diff) | |
download | genenetwork2-f06bfa6ce485392a4bba5e66e6472630dcc6683b.tar.gz |
Include template to get rid of repetitive template code
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
* The generation of input elements that relate to the traits is very
similar, therefore this commit pulls it out into a separate template
that can be included where needed.
-rw-r--r-- | wqflask/wqflask/templates/partial_correlations.html | 30 | ||||
-rw-r--r-- | wqflask/wqflask/templates/with-trait-items.html | 18 |
2 files changed, 23 insertions, 25 deletions
diff --git a/wqflask/wqflask/templates/partial_correlations.html b/wqflask/wqflask/templates/partial_correlations.html index 800222ba..c565d4bf 100644 --- a/wqflask/wqflask/templates/partial_correlations.html +++ b/wqflask/wqflask/templates/partial_correlations.html @@ -24,18 +24,8 @@ {%if step == "select-primary":%} <p>Please select the primary trait (X)</p> - {%for trait in traits_list:%} - <div class="label-element-combo with-trait"> - <input type="radio" - name="primary_trait" - value="{{trait['name']}}:::{{trait['dataset']}}:::{{trait['symbol']}}:::{{trait['description']}}:::{{trait['data_hmac']}}" - id="trait_{{trait['data_hmac']}}" - class="selector-element" /> - <label for="trait_{{trait['data_hmac']}}" class="label-element"> - {{trait["name"]}} - {{trait["symbol"]}} - {{trait["description"]}} - </label> - </div> - {%endfor%} + {%include "with-trait-items.html" %} + <button type="submit" class="btn btn-primary"> Next: Select Control Traits </button> @@ -46,20 +36,10 @@ {%if step == "select-controls":%} <p>Select a maximum of three (3) control traits (Z)</p> - {%for trait in traits_list:%} - <div class="label-element-combo with-trait"> - <input type="checkbox" - name="control_traits[]" - value="{{trait['name']}}:::{{trait['dataset']}}:::{{trait['symbol']}}:::{{trait['description']}}:::{{trait['data_hmac']}}" - id="trait_{{trait['data_hmac']}}" - class="selector-element" /> - <label for="trait_{{trait['data_hmac']}}" class="label-element"> - {{trait["name"]}} - {{trait["symbol"]}} - {{trait["description"]}} - </label> - </div> - {%endfor%} + {%include "with-trait-items.html" %} + <button type="submit" class="btn btn-primary"> - Next: Select Target Traits + Next: Select Target </button> {%endif%} diff --git a/wqflask/wqflask/templates/with-trait-items.html b/wqflask/wqflask/templates/with-trait-items.html new file mode 100644 index 00000000..66d6fd22 --- /dev/null +++ b/wqflask/wqflask/templates/with-trait-items.html @@ -0,0 +1,18 @@ +{%for trait in traits_list:%} +<div class="with-trait"> + <input type="{%if step=='select-primary':%}radio{%else:%}checkbox{%endif%}" + name="{%if step=='select-primary':%}primary_trait{%else:%}control_traits[]{%endif%}" + value="{{trait['name']}}:::{{trait['dataset']}}:::{{trait['symbol']}}:::{{trait['description']}}:::{{trait['location']}}:::{{trait['mean_expr']}}:::{{trait['max_lrs']}}:::{{trait['data_hmac']}}" + id="trait_{{trait['data_hmac']}}" + class="selector-element" /> + <label for="trait_{{trait['data_hmac']}}" class="label-element"> + <span class="trait-dataset" data-title="dataset">{{trait["dataset"]}}</span> + <span class="trait-name" data-title="name">{{trait["name"]}}</span> + <span class="trait-symbol" data-title="symbol">{{trait["symbol"]}}</span> + <span class="trait-description" data-title="description">{{trait["description"]}}</span> + <span class="trait-locatin" data-title="location">{{trait["location"]}}</span> + <span class="trait-mean-expr" data-title="mean">{{"%0.3f" % trait["mean_expr"]|float}}</span> + <span class="trait-max-lrs" data-title="max LRS">{{trait["max_lrs"]}}</span> + </label> +</div> +{%endfor%} |