diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index da0b21f8cb2a4e5ecb97d441fee94b6fc653f2d2..428ea40228645825ba6299cc8ea3ca8741b2a70a 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -969,6 +969,10 @@ class TestActivityDescriptionForm(forms.ModelForm): "is_primary": forms.HiddenInput(), } + def __init__(self,*args,**kwargs): + super().__init__(*args,**kwargs) + self.fields["test_type"].widget.attrs["onchange"]="test_type_changed(this);" + def has_changed(self): """ Test if the form has changed, we consider that it has not changed if it is not linked to an actual instance and @@ -984,6 +988,12 @@ class TestActivityDescriptionForm(forms.ModelForm): return False return super().has_changed() + def clean(self): + cleaned_data = super().clean() + if "test_type" in cleaned_data and cleaned_data["test_type"] is not "CELL": + cleaned_data["cell_line_name"] = "" + return cleaned_data + def save(self, commit=True): """ Before an actual save, we set the foreign key that have been created in the meantime from unique identifier diff --git a/ippisite/ippidb/static/js/ActivityDescriptionFormSet.js b/ippisite/ippidb/static/js/ActivityDescriptionFormSet.js new file mode 100644 index 0000000000000000000000000000000000000000..a2a69f9d9af1992865eef9528ca9a3db3a259767 --- /dev/null +++ b/ippisite/ippidb/static/js/ActivityDescriptionFormSet.js @@ -0,0 +1,8 @@ +function test_type_changed(source){ + var cell_line_input = document.getElementById(source.id.replace("test_type","cell_line_name")).parentNode; + if (source.value=="CELL"){ + cell_line_input.style.display = ''; + }else{ + cell_line_input.style.display = 'none'; + } +} \ No newline at end of file diff --git a/ippisite/ippidb/static/js/TestCytotoxDescriptionFormSet.js b/ippisite/ippidb/static/js/TestCytotoxDescriptionFormSet.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ippisite/ippidb/static/js/TestPKDescriptionFormSet.js b/ippisite/ippidb/static/js/TestPKDescriptionFormSet.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ippisite/ippidb/templates/wizard_formset_with_nested_formset.html b/ippisite/ippidb/templates/wizard_formset_with_nested_formset.html index 4628120d735e79f708467314cb9f720f226767e3..e60cec2e45081309adf246beb531b4094553c707 100644 --- a/ippisite/ippidb/templates/wizard_formset_with_nested_formset.html +++ b/ippisite/ippidb/templates/wizard_formset_with_nested_formset.html @@ -6,6 +6,11 @@ {% block extra_js %} {{block.super}} <script src="{% sstatic '/js/wizard_formset_with_nested_formset.js'%}"></script> +{% with wizard.management_form|get_item:"current_step" as current_step %} +{% with "/js/"|add:current_step.value|add:".js" as js_url %} +<script src="{% sstatic js_url %}"></script> +{%endwith%} +{%endwith%} {% endblock extra_js %} diff --git a/ippisite/ippidb/templatetags/customtags.py b/ippisite/ippidb/templatetags/customtags.py index 6a5c0b257743aad107b0ae68adeae4eab527b574..283da0d14c41181ed40eafaf077486e0b8c3e9fe 100644 --- a/ippisite/ippidb/templatetags/customtags.py +++ b/ippisite/ippidb/templatetags/customtags.py @@ -34,6 +34,10 @@ def bootstrap(object): return mark_safe("".join(bootstrap_core(object))) +@register.filter +def get_item(d, key): + return d[key] + def bootstrap_core(object): ret = [] if isinstance(object, forms.BoundField):