Commit 005a0573 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

DELETE checkbox of formset handled, prevent from skipping step in wizard

parent 04f105c0
......@@ -235,7 +235,7 @@ class RefCompoundBiblioForm(ModelForm):
exclude = ['compound', 'bibliography']
CompoundFormSet = formset_factory(CompoundForm, can_delete=True)
CompoundFormSet = formset_factory(CompoundForm, can_delete=True, extra=1)
""" Step 8 : TestsForm """
......@@ -461,5 +461,5 @@ ADMINISTRATION_MODE = [
]
# TestsFormSet = formset_factory(TestsForm, formset=BaseTestsFormSet, can_delete=True, can_order=True)
TestsFormSet = formset_factory(TestsForm, can_delete=False, can_order=False, extra=0)
TestsFormSet = formset_factory(TestsForm, can_delete=True, can_order=False, extra=1)
# formset = TestsFormSet()
......@@ -30,6 +30,10 @@ Description: IPPI-DB Theme
padding-left: 5px;
}
.step_nav li a:not([href]), .step_nav li a:not([href]):hover {
color:#AAA;
}
.step_nav li a, .step_nav li a:hover, .step_nav li a:focus {
width: 100%;
background-color: #E3E9EB;
......@@ -130,7 +134,7 @@ Description: IPPI-DB Theme
background-color: #E8E0E0;
color: #8D8888;
text-align: center;
}
}
#id_IdForm-source input {
display:none;
......@@ -264,6 +268,16 @@ Description: IPPI-DB Theme
opacity: 1.0;
}
.formset-item .formset-item-delete-host{
font-size:initial;
}
.formset-item.delete-checked{
opacity:0.3;
overflow: hidden;
max-height: 5em;
}
.small_icon {
width:30%;
}
......
......@@ -610,7 +610,11 @@ font-size: 42px;
.form_div {
font-family: "BrandonGrotesqueReg";
margin: 10px auto;
width: 43%
width: 43%;
}
.form_div-fluid {
width: 100%;
padding:1em;
}
#Form{
......
......@@ -168,9 +168,17 @@ function add_form_to_formset(source){
empty_form_as_str = $(source).closest(".formset-encloser").find(".empty_form").prop('innerHTML');
empty_form_as_str = empty_form_as_str.replace(
/__prefix__/g,
$(source).closest(".formset-encloser").find('.div_test').length
$(source).closest(".formset-encloser").find('.formset-item').length
);
empty_form=$(empty_form_as_str ).removeClass("empty_form");
empty_form.insertBefore($(source).parent());
empty_form.find("select.test-selector").change(change_test_selector);
}
function formsetItemDelete(src){
var fi = $(src).closest('.formset-item');
fi.toggleClass('delete-checked');
fi.find('input:not([type=\'checkbox\'])').prop('disabled', function(i, v) { return !v; });
fi.find('select').prop('disabled', function(i, v) { return !v; });
}
\ No newline at end of file
......@@ -4,6 +4,14 @@
{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %}
{% block extra_js %}
<script type="text/javascript">
window.onload = function() {
$(".formset-item-delete:checked").each(function(i,o){formsetItemDelete(o);});
};
</script>
{% endblock extra_js %}
{% block content%}
<div class="inner-wrap">
<nav class="breadcrumb breadNav" role="navigation">
......@@ -43,12 +51,19 @@
<div class="step_nav">
<ul>
{%for step in wizard.steps.all %}
<li><a {% if step == wizard.steps.current %}class="active" {%endif%}
href="{% url 'ippidb_step' step=step %}">
{% with step|add:"_tab_title" as step_title %}
{% trans step_title %}
{% endwith %}
</a></li>
<li>
<a
{% if step == wizard.steps.current %}
class="active"
{%endif%}
{% if forloop.counter0 <= wizard.steps.step0 %}
href="{% url 'ippidb_step' step=step %}"
{%endif%}
>
{% with step|add:"_tab_title" as step_title %}
{% trans step_title %}
{% endwith%}
</a></li>
{%endfor%}
</ul>
</div>
......
{% load i18n %}
{% load customtags %}
<div class="compound">
<div class="compound_name">
<div class="compound_title">
<h1>Compound</h1>
<h2>Name your compound</h2>
</div>
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{{ form.common_name|bootstrap }}
{{ form.compound_name|bootstrap }}
<div class="type_title">
<h2 class="{%if form.molecule.errors%} is-invalid{%endif%}">Choose a format to import your molecule</h2>
</div>
<div class="input_field form-group">
<div class="compound_mol form-control{%if form.molecule.errors%} is-invalid{%endif%}">
{% for radio in form.molecule %}
<div class="compound_radio_{{ radio.choice_label }}">
{{ radio.tag }}
<label for="{{ radio.id_for_label }}" id="{{ radio.id_for_label }}">
<span>{{ radio.choice_label }}</span>
</label>
</div>
{% endfor %}
<div class="compound formset-item">
<div class="compound_name">
<div class="compound_title">
<h2>Compound
<span class="float-right">{{ form.DELETE|bootstrap }}</span>
</h2>
<h3>Name your compound</h3>
</div>
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{{ form.common_name|bootstrap }}
{{ form.compound_name|bootstrap }}
<div class="type_title">
<h3 class="{%if form.molecule.errors%} is-invalid{%endif%}">Choose a format to import your molecule</h3>
</div>
<div class="input_field form-group">
<div class="compound_mol form-control{%if form.molecule.errors%} is-invalid{%endif%}">
{% for radio in form.molecule %}
<div class="compound_radio_{{ radio.choice_label }}">
{{ radio.tag }}
<label for="{{ radio.id_for_label }}">
<span>{{ radio.choice_label }}</span>
</label>
</div>
{% endfor %}
</div>
{% for e in form.molecule.errors %}
......
......@@ -4,6 +4,7 @@
{% block title %}compounds list{% endblock %}
{% block extra_js %}
{{block.super}}
<script src="/static/marvinjs-18/js/util.js"></script>
<script src="/static/marvinjs-18/js/marvinjslauncher.js"></script>
<script src="/static/marvinjs-18/gui/lib/promise-1.0.0.min.js"></script>
......
......@@ -3,7 +3,7 @@
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div class="div_test_activity">
<div class="div_test_activity formset-item">
<div class="div_test_activity_desc">
<h4>Activity test descrition</h4>
<div class="test_inline_box_complex_long">
......@@ -26,7 +26,7 @@
</div>
</div>
</div>
<div class="div_test_cytotoxicity" style="display:none;">
<div class="div_test_cytotoxicity formset-item" style="display:none;">
<div class="div_test_cytotoxicity_desc">
<h4>Cytotoxicity test descrition</h4>
<div class="test_inline_box_complex_long">
......@@ -49,7 +49,7 @@
</div>
</div>
</div>
<div class="div_test_pk" style="display:none;">
<div class="div_test_pk formset-item" style="display:none;">
<div class="div_test_pk_desc">
<h4>PK test descrition</h4>
<div class="test_inline_box_complex_long">
......
......@@ -26,7 +26,6 @@ def bootstrap(object):
css_classes.add("is-invalid")
if field.field.required:
attrs['required'] = 'required'
print(type(field.field.widget))
if isinstance(field.field.widget, widgets.CheckboxInput):
wrapping_classes = "form-check"
label_classes = "form-check-label"
......@@ -35,6 +34,10 @@ def bootstrap(object):
wrapping_classes = "input_field form-group"
label_classes = "form-control-placeholder"
css_classes.add("form-control")
if field.name == "DELETE":
attrs["onchange"] = "formsetItemDelete(this);"
wrapping_classes += " formset-item-delete-host"
css_classes.add("formset-item-delete")
attrs["class"] = " ".join(css_classes)
ret.append('<div class="%s">' % wrapping_classes)
ret.append(field.as_widget(attrs=attrs))
......
Supports Markdown
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