diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index 43322b75d0db67d511f0779a555d408a051fa6f0..12fcd876234448ac6bd5cd2cf38e317c4622eefd 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -42,47 +42,27 @@ class ProteinForm(ModelForm): ProteinFormSet = modelformset_factory(Protein, exclude=('recommended_name_long', 'short_name'), extra=0) - -ARCHI_TYPE = ( - ('inhibited', 'Inhibited'), - ('stabilized', 'Stabilized'), - ) - -INHIBITED_CHOICES = ( - ('Hetero2merAB','Hetero 2-mer AB'), - ('Homo2merA2','Homo 2-mer A2'), - ('custom', 'Custom your own'), - ) - -STABILIZED_CHOICES = ( - ('Hetero2merAB','Hetero 2-mer AB'), - ('Homo2merA2','Homo 2-mer A2'), - ('HomoLike2mer','Homo-Like 2-mer A2'), - ('Homo3merA3','Homo 3-mer A3'), - ('Homo3merA2','Homo 3-mer A3 inhibited A2-dimer'), - ('Homo4merA4','Homo 4-mer A4'), - ('RingHomo3mer','Ring-Like 3-mer A3'), - ('RingHomo5mer','Ring-Like 5-mer A5'), - ('custom', 'Custom your own'), +TYPE_CHOICES = ( + ('Hetero2merAB','Inhib_Hetero 2-mer AB'), + ('Homo2merA2','Inhib_Homo 2-mer A2'), + ('custom', 'Inhib_Custom your own'), + ('Hetero2merAB','Stab_Hetero 2-mer AB'), + ('Homo2merA2','Stab_Homo 2-mer A2'), + ('HomoLike2mer','Stab_Homo-Like 2-mer A2'), + ('Homo3merA3','Stab_Homo 3-mer A3'), + ('Homo3merA2','Stab_Homo 3-mer A3 inhibited A2-dimer'), + ('Homo4merA4','Stab_Homo 4-mer A4'), + ('RingHomo3mer','Stab_Ring-Like 3-mer A3'), + ('RingHomo5mer','Stab_Ring-Like 5-mer A5'), + ('custom', 'Stab_Custom your own'), ) class ProteinDomainComplexTypeForm(forms.Form): - archi = forms.CharField( - label="PPI Architecture Type", - widget=forms.Select( - choices=ARCHI_TYPE, - ) - ) - inhibited = forms.ChoiceField( + complexType = forms.ChoiceField( widget=forms.RadioSelect, - choices=INHIBITED_CHOICES, + choices=TYPE_CHOICES, ) - stabilized = forms.ChoiceField( - widget=forms.RadioSelect, - choices=STABILIZED_CHOICES, - ) - class ProteinDomainComplexForm(ModelForm): class Meta: model = ProteinDomainComplex diff --git a/ippisite/ippidb/static/css/ippidb.css b/ippisite/ippidb/static/css/ippidb.css index 022b5e443e27b5be5a8baa98ddc7d42b4f84eb2a..27a7af1c7c9171ba51cc9e8d9dfc95691925eafa 100644 --- a/ippisite/ippidb/static/css/ippidb.css +++ b/ippisite/ippidb/static/css/ippidb.css @@ -873,9 +873,6 @@ body { } /* Stabilized */ -#stabilized{ - display:none; -} #id_ProteinDomainComplexTypeForm-stabilized { overflow: hidden; @@ -1382,13 +1379,13 @@ button, input, select, textarea { } -.type_style { +#type_style { background-color: rgb(227, 233, 235); padding: 10px; margin: 10px; } -.type_title h1{ +#type_title h1{ text-align: left; color: #414144; font-size: 42px; diff --git a/ippisite/ippidb/static/js/ippidb.js b/ippisite/ippidb/static/js/ippidb.js index 4072273c28279a7e8873719dfe1d26a51d2cabf7..efc8ebb3b7e08f9507aac461a9fdaaa45994b393 100644 --- a/ippisite/ippidb/static/js/ippidb.js +++ b/ippisite/ippidb/static/js/ippidb.js @@ -19,18 +19,17 @@ $(document).ready(function() { $(document).ready(function(){ - $('#id_ProteinDomainComplexTypeForm-archi').on('change', function() { - if ( this.value === "inhibited") - { - $("#inhibited").show(); - $("#stabilized").hide(); - } - else - { - $("#inhibited").hide(); - $("#stabilized").show(); - } +$("select").change(function(){ + $(this).find("option:selected").each(function(){ + if($(this).attr("value")=="inhibited"){ + $(".box").not(".inhibited").hide(); + $(".inhibited").show(); + }else if($(this).attr("value")=="stabilized"){ + $(".box").not(".stabilized").hide(); + $(".stabilized").show(); + }else{ + $(".box").hide(); + } }); -}); - - +}).change(); +}); \ No newline at end of file diff --git a/ippisite/ippidb/templates/PDBForm.html b/ippisite/ippidb/templates/PDBForm.html index a146e696219ff5fb2bfa91a7d563d332eabe98df..bfac10f460cbc25b5d61db9dfb7d70341ac3001f 100644 --- a/ippisite/ippidb/templates/PDBForm.html +++ b/ippisite/ippidb/templates/PDBForm.html @@ -20,7 +20,6 @@ {% csrf_token %} <table> {{ wizard.management_form }} - {{ wizard.form.errors}} {{ wizard.form.non_field_errors}} {% block custom_form %}{% endblock %} diff --git a/ippisite/ippidb/templates/ProteinDomainComplexForm.html b/ippisite/ippidb/templates/ProteinDomainComplexForm.html index 4c00a21d633c22fcc29a8757645ef99838316c16..6401c925104d04f4f83584d03fbdbfbab3bb6368 100644 --- a/ippisite/ippidb/templates/ProteinDomainComplexForm.html +++ b/ippisite/ippidb/templates/ProteinDomainComplexForm.html @@ -34,8 +34,6 @@ If your PPI complex is not among them, please select « Create you Own »</p> <div class="inline_field"> {{ form.ppc_copy_nb }}</div> </div> {% endfor %} - {% else %} - {{ wizard.form }} {% endif %} <input type="submit" value="{% trans "Next step" %}"/> </form> diff --git a/ippisite/ippidb/templates/ProteinDomainComplexTypeForm.html b/ippisite/ippidb/templates/ProteinDomainComplexTypeForm.html index db177f898dc34c4344f4c6c99b60254ab5f31118..1f42e708090c49ac01a901fb74cc98c93271f60c 100644 --- a/ippisite/ippidb/templates/ProteinDomainComplexTypeForm.html +++ b/ippisite/ippidb/templates/ProteinDomainComplexTypeForm.html @@ -21,43 +21,66 @@ If your PPI complex is not among them, please select « Create you Own »</p> {% csrf_token %} <table> {{ wizard.management_form }} - {{ wizard.form.errors}} {{ wizard.form.non_field_errors}} {% block custom_form %}{% endblock %} {% if wizard.form.forms %} {{ wizard.form.management_form }} {% for form in wizard.form.forms %} + {% endfor %} {% else %} - {{ wizard.form.archi }} - <div id='inhibited' name='inhibited' class="type_style"> - <div class="type_title"> + <div id="id_ProteinDomainComplexTypeForm-stabilized"> + PPI Complex Type: + <select> + <option value="inhibited">Inhibited</option> + <option value="stabilized">Stabilized</option> + </select> + </div> + <div id="type_style" class="inhibited box"> + <div id="type_title"> <h1>Inhibited</h1> </div> <div id="id_ProteinDomainComplexTypeForm-inhibited"> - {% for radio in wizard.form.inhibited %} - <div class="imageBack_Inhib_{{radio.choice_label|cut:" "}}"> - {{ radio.tag }} - <label for="{{ radio.id_for_label }}"> - <span>{{ radio.choice_label}}</span> - </label> - </div> + {% for radio in wizard.form.complexType %} + <!-- I'm sorry for this bad/ugly code but I couldn't figure how to do it in a proper way - If you have a better idea feel free to let me know rachel.torchet@pasteur.fr --> + {% if "Inhib_" in radio.choice_label%} + <!-- If the label of the radio button start with Inhib (I had to put a prefix to seperate Inhibitor and Stabilizator) --> + {% with LabelName=radio.choice_label|cut:"Inhib_" %} + <!-- Then cut this prefix to create a better label --> + {% with InhibClass=LabelName|cut:" " %} + <!-- Then discard the blank spaces to get a tag for the corresponding CSS Class --> + <div class="imageBack_Inhib_{{InhibClass}}"> + <!-- For each radio option there is a separate CSS class --> + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"> + <span>{{InhibClass}}</span> + </label> + </div> + {% endwith %} + {% endwith %} + {% endif %} {% endfor %} </div> </div> - <div id="stabilized" class="type_style"> - <div class="type_title"> + <div id="type_style" class="stabilized box"> + <div id="type_title"> <h1>Stabilized</h1> </div> <div id="id_ProteinDomainComplexTypeForm-stabilized"> - {% for radio in wizard.form.stabilized %} - <div class="imageBack_Stab_{{radio.choice_label|cut:" "}}"> - {{ radio.tag }} - <label for="{{ radio.id_for_label }}"> - <span>{{ radio.choice_label}}</span> - </label> - </div> + {% for radio in wizard.form.complexType %} + {% if "Stab_" in radio.choice_label%} + {% with LabelName=radio.choice_label|cut:"Stab_" %} + {% with StabClass=LabelName|cut:" " %} + <div class="imageBack_Stab_{{StabClass}}"> + {{ radio.tag }} + <label for="{{ radio.id_for_label }}"> + <span>{{ StabClass}}</span> + </label> + </div> + {% endwith %} + {% endwith %} + {% endif %} {% endfor %} </div> </div> diff --git a/ippisite/ippidb/templates/ProteinForm.html b/ippisite/ippidb/templates/ProteinForm.html index 9eb42be3b1712f02f96a58050c4ef4dabc29b7de..fab383c8dcb87f201173c036a74a97d5b5ba0fc1 100644 --- a/ippisite/ippidb/templates/ProteinForm.html +++ b/ippisite/ippidb/templates/ProteinForm.html @@ -19,7 +19,6 @@ <form class="proteins_form" action="" method="post"> {% csrf_token %} {{ wizard.management_form }} - {{ wizard.form.errors}} {{ wizard.form.non_field_errors}} {% block custom_form %}{% endblock %}