mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
Hide extra maintainer forms and show each one on request
Hide all empty maintainer forms and have a button to "add" another maintainer which just uses jQuery to show the next hidden form. Up to 10 maintainers can be added which should be more than enough. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
9a3bfac320
commit
0e14cf17d8
|
@ -73,6 +73,7 @@
|
||||||
{{ maintainerformset.non_form_errors }}
|
{{ maintainerformset.non_form_errors }}
|
||||||
{{ maintainerformset.management_form }}
|
{{ maintainerformset.management_form }}
|
||||||
{% for maintainerform in maintainerformset %}
|
{% for maintainerform in maintainerformset %}
|
||||||
|
<div class="maintainerform" id="maintainerform-{{forloop.counter0}}">
|
||||||
<h4>Maintainer {{forloop.counter}}</h4>
|
<h4>Maintainer {{forloop.counter}}</h4>
|
||||||
{% for hidden in maintainerform.hidden_fields %}
|
{% for hidden in maintainerform.hidden_fields %}
|
||||||
{{ hidden }}
|
{{ hidden }}
|
||||||
|
@ -86,9 +87,11 @@
|
||||||
{{ field.help_text }}
|
{{ field.help_text }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<p><a href="#" class="btn" id="addanothermaintainer">Add another maintainer</a><p>
|
||||||
{% block submitbuttons %}
|
{% block submitbuttons %}
|
||||||
<input type="submit" value="Save" class='btn' />
|
<input type="submit" value="Save" class="btn btn-primary" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -165,14 +168,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
expand_maintainer = function() {
|
||||||
name_input = $('#id_layermaintainer_set-' + i + '-name')
|
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
||||||
name_input.change(split_email)
|
maintbox = $('#maintainerform-' + i)
|
||||||
resp_id = 'id_layermaintainer_set-' + i + '-responsibility'
|
if( maintbox.is(':hidden') ) {
|
||||||
window['last_' + resp_id] = ""
|
maintbox.slideToggle();
|
||||||
|
if( i == {{maintainerformset.total_form_count}} - 1 )
|
||||||
|
$('#addanothermaintainer').hide()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('.maintainerform').hide()
|
||||||
|
|
||||||
|
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
||||||
|
name_input = $('#id_layermaintainer_set-' + i + '-name')
|
||||||
|
name_input.change(split_email)
|
||||||
|
resp_id = 'id_layermaintainer_set-' + i + '-responsibility'
|
||||||
|
window['last_' + resp_id] = ""
|
||||||
|
if( i==0 || name_input.val() )
|
||||||
|
$('#maintainerform-' + i).show()
|
||||||
|
}
|
||||||
|
$('#addanothermaintainer').click(expand_maintainer)
|
||||||
|
|
||||||
$('#id_vcs_url').change(auto_web_fields)
|
$('#id_vcs_url').change(auto_web_fields)
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -41,7 +41,7 @@ class BaseLayerMaintainerFormSet(forms.models.BaseInlineFormSet):
|
||||||
f.required = True
|
f.required = True
|
||||||
return f
|
return f
|
||||||
|
|
||||||
LayerMaintainerFormSet = inlineformset_factory(LayerItem, LayerMaintainer, form=LayerMaintainerForm, formset=BaseLayerMaintainerFormSet, can_delete=False)
|
LayerMaintainerFormSet = inlineformset_factory(LayerItem, LayerMaintainer, form=LayerMaintainerForm, formset=BaseLayerMaintainerFormSet, can_delete=False, extra=10, max_num=10)
|
||||||
|
|
||||||
class SubmitLayerForm(forms.ModelForm):
|
class SubmitLayerForm(forms.ModelForm):
|
||||||
# Additional form fields
|
# Additional form fields
|
||||||
|
|
|
@ -25,5 +25,5 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block submitbuttons %}
|
{% block submitbuttons %}
|
||||||
<input type="submit" value="Submit" class='btn' />
|
<input type="submit" value="Submit" class="btn btn-primary" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user