From e1c3aa104b37cd4715c7e283bf475c467ed0a408 Mon Sep 17 00:00:00 2001 From: Rachel TORCHET <racheltorchet@users.noreply.github.com> Date: Mon, 11 Jun 2018 14:11:38 +0200 Subject: [PATCH] update CompoundForm and TestsForm + JS files Former-commit-id: a8921957bdc969b1e7e9a4bf7e61bb28f4384e38 --- ippisite/ippidb/forms.py | 38 ++++++++++---------- ippisite/ippidb/static/css/admin-session.css | 6 +++- ippisite/ippidb/static/js/ippidb.js | 19 +++++----- ippisite/ippidb/templates/CompoundForm.html | 5 +-- ippisite/ippidb/templates/TestsForm.html | 20 ++++------- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index f5eb96eb..097c57b6 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -169,7 +169,7 @@ formset = CompoundFormSet() """ Step 8 : TestsForm """ class TestsForm(forms.Form): - activityDesc_test_name=forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) + desc_test_name=forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) activityDesc_cell_line=forms.ModelChoiceField(queryset=CellLine.objects.all(), empty_label=None, widget=forms.Select(attrs={'class':'form-control'})) activityDesc_nb_active_compound=forms.IntegerField(initial=1) activityDesc_type=forms.ModelChoiceField(widget=forms.RadioSelect(attrs={'class':'form-control'}),queryset=TestActivityDescription.objects.values_list('test_type', flat=True).distinct(), empty_label=None) @@ -178,22 +178,20 @@ class TestsForm(forms.Form): activityRes_test_modulation_type=forms.ModelChoiceField(queryset=CompoundActivityResult.objects.values_list('modulation_type', flat=True).distinct(), empty_label=None, widget=forms.Select(attrs={'class':'form-control'})) activityRes_activity_type=forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) activityRes_activity=forms.IntegerField(forms.NumberInput(attrs={'class':'form-control'})) - cytotoxDesc_test_name=forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) - cytotoxDesc_cell_line=forms.ModelChoiceField(queryset=CellLine.objects.all(), empty_label=None, widget=forms.Select(attrs={'class':'form-control'})) - cytotoxDesc_compound_concentration=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Compound concentration'})) - cytotoxRes_compound=forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'})) - cytotoxRes_toxicity=forms.ModelChoiceField(queryset=CompoundCytotoxicityResult.objects.all()) - pkDesc_test_name=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'PK test name'})) - pkDesc_organism=forms.ModelChoiceField(queryset=Taxonomy.objects.all(), empty_label="Choose a corresponding organism") - pkDesc_administration_mode=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Admnistration mode'})) - pkDesc_dose=forms.IntegerField(initial=1) - pkDesc_dose_interval=forms.IntegerField(initial=1) - pkRes_compound = forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'})) - pkRes_tolerated = forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'})) - pkRes_auc = forms.IntegerField(initial=1) - pkRes_clearance = forms.DecimalField() - pkRes_cmax = forms.DecimalField() - pkRes_oral_bioavailability = forms.IntegerField(initial=1) - pkRes_t_demi = forms.IntegerField(initial=1) - pkRes_t_max = forms.IntegerField(initial=1) - pkRes_voldistribution = forms.DecimalField() \ No newline at end of file + cytotoxDesc_cell_line=forms.ModelChoiceField(queryset=CellLine.objects.all(), empty_label=None, widget=forms.Select(attrs={'class':'form-control'}),required=False) + cytotoxDesc_compound_concentration=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Compound concentration'}),required=False) + cytotoxRes_compound=forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'}),required=False) + cytotoxRes_toxicity=forms.ModelChoiceField(queryset=CompoundCytotoxicityResult.objects.all(),required=False) + pkDesc_organism=forms.ModelChoiceField(queryset=Taxonomy.objects.all(), empty_label="Choose a corresponding organism",required=False) + pkDesc_administration_mode=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Admnistration mode'}),required=False) + pkDesc_dose=forms.IntegerField(initial=1,required=False) + pkDesc_dose_interval=forms.IntegerField(initial=1,required=False) + pkRes_compound = forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'}),required=False) + pkRes_tolerated = forms.ChoiceField(widget=forms.TextInput(attrs={'class': 'form-control'}),required=False) + pkRes_auc = forms.IntegerField(initial=1,required=False) + pkRes_clearance = forms.DecimalField(required=False) + pkRes_cmax = forms.DecimalField(required=False) + pkRes_oral_bioavailability = forms.IntegerField(initial=1,required=False) + pkRes_t_demi = forms.IntegerField(initial=1,required=False) + pkRes_t_max = forms.IntegerField(initial=1,required=False) + pkRes_voldistribution = forms.DecimalField(required=False) \ No newline at end of file diff --git a/ippisite/ippidb/static/css/admin-session.css b/ippisite/ippidb/static/css/admin-session.css index ab6e4a57..b06b1009 100644 --- a/ippisite/ippidb/static/css/admin-session.css +++ b/ippisite/ippidb/static/css/admin-session.css @@ -1066,6 +1066,10 @@ Description: IPPI-DB Theme margin-right: auto; } +.test_name { + padding: 12px 12px 0px 12px; +} + #ck-button-half { width:100%; display: inline-flex; @@ -1158,7 +1162,7 @@ Description: IPPI-DB Theme /* Style the tab content */ .tabcontent { display: none; - padding: 12px 12px; + padding: 0px 12px 12px 12px; border-top: none; background-color: #E3E9EB; } diff --git a/ippisite/ippidb/static/js/ippidb.js b/ippisite/ippidb/static/js/ippidb.js index c88592a2..9a2ea522 100644 --- a/ippisite/ippidb/static/js/ippidb.js +++ b/ippisite/ippidb/static/js/ippidb.js @@ -19,18 +19,19 @@ $("select").change(function(){ }).change(); }); -// CompoundForm - Update compound name in div -function AnEventHasOccurred(id) { - console.log("Compound "+ document.getElementById(id).value); -document.getElementById("Name_"+id).innerHTML = "Compound "+ document.getElementById(id).value; -} // Function to add/remove form in CoumpoundFormSet function addComp(id){ - var div = document.getElementById("compound_"+id); - clone = div.cloneNode(true); - console.log(id); - document.getElementById("compound_"+id).appendChild(clone); + var first = id.split("-")[0]; + var val = id.split("-")[1]; + var val2 = ++val; + var last = id.split("-")[2]; + var newId = first+"-"+val2+"-"+last; + console.log(newId); + var div = document.getElementById("compound_"+id).cloneNode(true); + div.name= "compound_"+newId; + console.log(div); + document.getElementById("compound_"+id).appendChild(div); } diff --git a/ippisite/ippidb/templates/CompoundForm.html b/ippisite/ippidb/templates/CompoundForm.html index 274d1619..57d74efa 100644 --- a/ippisite/ippidb/templates/CompoundForm.html +++ b/ippisite/ippidb/templates/CompoundForm.html @@ -65,11 +65,12 @@ <div id="ck-button-long"> <label>{{ form.is_macrocycle}}<span>{{ form.is_macrocycle.label }}</span></label> </div> - <input type="button" id="ck-button-long" class="add_button" onclick="addComp();" value="Add Compound"> - </input> </div> + <input type="button" id="ck-button-long" class="add_button" onclick="addComp('{{ form.compound_name.id_for_label }}');" value="Add Compound"> + </input> {% endfor %} </div> + <!--<div class="add_form"> <div id="{{ form.compound_name.id_for_label }}" onclick="">Add compound<div> </div>--> diff --git a/ippisite/ippidb/templates/TestsForm.html b/ippisite/ippidb/templates/TestsForm.html index ef8dd9cb..5672b7e4 100644 --- a/ippisite/ippidb/templates/TestsForm.html +++ b/ippisite/ippidb/templates/TestsForm.html @@ -44,15 +44,16 @@ <button class="tablinks" onclick="openTests(event, 'Cytotoxicity')">Cytotoxicity</button> <button class="tablinks" onclick="openTests(event, 'PK')">PK</button> </div> - + <div class="test_activity test_name"> + <h2>Describe your test</h2> + <div class="test_input form-group "> + {{ wizard.form.desc_test_name }} + <label class="form-control-placeholder" for="id_TestsForm-activityDesc_test_name">Test name</label> + </div> + </div> <!-- Tab content --> <div id="Activity" class="tabcontent" style="display: block;"> <div class="test_activity"> - <h2>Describe your activity test</h2> - <div class="test_input form-group"> - {{ wizard.form.activityDesc_test_name }} - <label class="form-control-placeholder" for="id_TestsForm-activityDesc_test_name">Activity test name</label> - </div> <div id="ck-button-half"> {% for radio in wizard.form.activityDesc_type %} <label> @@ -94,11 +95,6 @@ </div> <div id="Cytotoxicity" class="tabcontent"> <div class="test_activity"> - <h2>Describe your cytotoxicity test</h2> - <div class="test_input form-group"> - {{ wizard.form.cytotoxDesc_test_name }} - <label class="form-control-placeholder" for="id_TestsForm-id_TestsForm-cytotoxDesc_test_name">Cytotoxicity test name</label> - </div> <div class="test_input">{{ wizard.form.cytotoxDesc_cell_line }}</div> <div class="test_input">{{ wizard.form.cytotoxDesc_compound_concentration }}</div> <h2>Results</h2> @@ -112,8 +108,6 @@ <div id="PK" class="tabcontent"> <div class="test_activity"> - <h2>Describe your PK test</h2> - <div class="test_input">{{ wizard.form.pkDesc_test_name }}</div> <div class="test_input">{{ wizard.form.pkDesc_organism }}</div> <div class="test_input">{{ wizard.form.pkDesc_administration_mode }}</div> <div class="test_input">{{ wizard.form.pkDesc_dose }}</div> -- GitLab