Skip to content
Snippets Groups Projects
Commit 9179cf76 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add sorting options to compounds list table headers

as requested in #48


Former-commit-id: 2002ce71cfd5a26f73bd99286b58362f025a01c8
parent 2094daa2
No related branches found
No related tags found
No related merge requests found
{% if col_id in fields %}
{% with '-'|add:col_id as col_id_desc %}
<th scope="col">
{% if col_id == sort_by %}
<i class="fa fa-arrow-up" title="sorted by ascending {{ col_name }}"></i>
<a onclick="modifyUrl('sort_by','{{ col_id_desc }}')" title="click to sort descending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
{% elif col_id_desc == sort_by %}
<i class="fa fa-arrow-down" title="sorted by descending {{ col_name }}"></i>
<a onclick="modifyUrl('sort_by','{{ col_id }}')" title="click to sort ascending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
{% elif col_id in sort_by_options %}
<a onclick="modifyUrl('sort_by','{{ col_id }}')" title="click to sort ascending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
{% else %}
{{ col_name | capfirst }}
{% endif %}
</th>
{% endwith %}
{% endif %}
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
{% if "common_name" in fields %}
<th scope="col">Common name</th>
{% endif %}
{% if "molecular_weight" in fields %}
<th scope="col">Molecular weight</th>
{% endif %}
{% if "a_log_p" in fields %}
<th scope="col">AlogP</th>
{% endif %}
{% if "compound_action_pdb_ids" in fields %}
<th scope="col">PDB ligand</th>
{% endif %}
{% if "mddr_phase" in fields %}
<th scope="col">MDDR phase</th>
{% endif %}
{% if "available_tests" in fields %}
<th scope="col">Available tests</th>
{% endif %}
{% if "biblio_refs" in fields %}
<th scope="col">Available publications
</th>
{% endif %}
{% if "nb_acceptor_h" in fields %}
<th scope="col">Number of hydrogen bond acceptors
</th>
{% endif %}
{% if "nb_donor_h" in fields %}
<th scope="col">Number of hydrogen bond donors
</th>
{% endif %}
{% if "tpsa" in fields %}
<th scope="col">Topological Polar Surface Area (TPSA)
</th>
{% endif %}
{% if "nb_rotatable_bonds" in fields %}
<th scope="col">Number of rotatable bonds
</th>
{% endif %}
{% if "nb_aromatic_sssr" in fields %}
<th scope="col">Number of aromatic Smallest Set of System Rings (SSSR)
</th>
{% endif %}
{% include "compound_t_colhead.html" with col_id="id" col_name="#" %}
{% include "compound_t_colhead.html" with col_id="common_name" col_name="common name" %}
{% include "compound_t_colhead.html" with col_id="molecular_weight" col_name="molecular weight" %}
{% include "compound_t_colhead.html" with col_id="a_log_p" col_name="AlogP" %}
{% include "compound_t_colhead.html" with col_id="compound_action_pdb_ids" col_name="PDB ligand(s)" %}
{% include "compound_t_colhead.html" with col_id="mddr_phase" col_name="MDDR phase" %}
{% include "compound_t_colhead.html" with col_id="available_tests" col_name="available tests" %}
{% include "compound_t_colhead.html" with col_id="biblio_refs" col_name="available publications" %}
{% include "compound_t_colhead.html" with col_id="nb_acceptor_h" col_name="number of hydrogen bond acceptors" %}
{% include "compound_t_colhead.html" with col_id="nb_donor_h" col_name="number of hydrogen bond donors" %}
{% include "compound_t_colhead.html" with col_id="tpsa" col_name="TPSA" %}
{% include "compound_t_colhead.html" with col_id="nb_rotatable_bonds" col_name="number of rotatable bonds" %}
{% include "compound_t_colhead.html" with col_id="nb_aromatic_sssr" col_name="number of aromatic SSSR" %}
<button type="button" class="btn btn-primary float-right" style="width: inherit!important" data-toggle="modal" data-target="#selectColumns">
<i class="fa fa-columns" title="customize columns"></i>
</button>
......
......@@ -224,6 +224,8 @@ def compound_list(request):
sort_by_options[sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'ascending', 'id': sort_by_option_id}
sort_by_options['-'+sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'descending', 'id': sort_by_option_id}
fields = request.GET.getlist('fields',['id', 'common_name', 'molecular_weight', 'a_log_p', 'compound_action_pdb_ids', 'biblio_refs'])
if 'id' not in fields:
fields.append('id')
return render(request, 'compound_list.html', {'compounds': compounds,
'count': count,
'selected_ppis': selected_ppis,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment