mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49: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.management_form }}
|
||||
{% for maintainerform in maintainerformset %}
|
||||
<div class="maintainerform" id="maintainerform-{{forloop.counter0}}">
|
||||
<h4>Maintainer {{forloop.counter}}</h4>
|
||||
{% for hidden in maintainerform.hidden_fields %}
|
||||
{{ hidden }}
|
||||
|
@ -86,9 +87,11 @@
|
|||
{{ field.help_text }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p><a href="#" class="btn" id="addanothermaintainer">Add another maintainer</a><p>
|
||||
{% block submitbuttons %}
|
||||
<input type="submit" value="Save" class='btn' />
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
{% endblock %}
|
||||
</form>
|
||||
|
||||
|
@ -165,14 +168,32 @@
|
|||
}
|
||||
}
|
||||
|
||||
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] = ""
|
||||
expand_maintainer = function() {
|
||||
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
||||
maintbox = $('#maintainerform-' + i)
|
||||
if( maintbox.is(':hidden') ) {
|
||||
maintbox.slideToggle();
|
||||
if( i == {{maintainerformset.total_form_count}} - 1 )
|
||||
$('#addanothermaintainer').hide()
|
||||
break
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$(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)
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -41,7 +41,7 @@ class BaseLayerMaintainerFormSet(forms.models.BaseInlineFormSet):
|
|||
f.required = True
|
||||
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):
|
||||
# Additional form fields
|
||||
|
|
|
@ -25,5 +25,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block submitbuttons %}
|
||||
<input type="submit" value="Submit" class='btn' />
|
||||
<input type="submit" value="Submit" class="btn btn-primary" />
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user