diff --git a/ietf/ipr/views.py b/ietf/ipr/views.py index d587eaecd20..2450e531375 100644 --- a/ietf/ipr/views.py +++ b/ietf/ipr/views.py @@ -296,7 +296,7 @@ def edit(request, id, updates=None): ipr = get_object_or_404(IprDisclosureBase, id=id).get_child() type = class_to_type[ipr.__class__.__name__] - DraftFormset = inlineformset_factory(IprDisclosureBase, IprDocRel, form=DraftForm, can_delete=True, extra=1) + DraftFormset = inlineformset_factory(IprDisclosureBase, IprDocRel, form=DraftForm, can_delete=True, extra=0) if request.method == 'POST': form = ipr_form_mapping[ipr.__class__.__name__](request.POST,instance=ipr) @@ -316,7 +316,7 @@ def edit(request, id, updates=None): else: valid_formsets = True - if form.is_valid() and valid_formsets: + if form.is_valid() and valid_formsets: updates = form.cleaned_data.get('updates') disclosure = form.save(commit=False) disclosure.save() diff --git a/ietf/static/js/ipr-edit.js b/ietf/static/js/ipr-edit.js index 40ca4e352f7..9af5b03591a 100644 --- a/ietf/static/js/ipr-edit.js +++ b/ietf/static/js/ipr-edit.js @@ -18,7 +18,7 @@ $(document) ["for", "id", "name"].forEach(function (at) { var val = x.attr(at); if (val && val.match("iprdocrel")) { - x.attr(at, val.replace('-1-', '-' + total + '-')); + x.attr(at, val.replace('__prefix__', total.toString())); } }); }); @@ -27,6 +27,8 @@ $(document) totalField.val(total); template.before(el); + + el.find('.select2-field').each((index, element) => setupSelect2Field($(element))); }); function updateRevisions() { diff --git a/ietf/templates/ipr/details_edit.html b/ietf/templates/ipr/details_edit.html index 2dc51bc7edc..7caf28f1a7d 100644 --- a/ietf/templates/ipr/details_edit.html +++ b/ietf/templates/ipr/details_edit.html @@ -131,37 +131,13 @@

{% cycle section %}. IETF document or other contribution to whi

{{ draft_formset.management_form }} {% for draft_form in draft_formset %} -
- -
- {{ draft_form.id }} - {{ draft_form.document }} - {% if draft_form.document.errors %}
{{ draft_form.document.errors }}
{% endif %} -
-
- {% bootstrap_field draft_form.revisions class="form-control" placeholder="Revisions, e.g., 04-07" show_help=False show_label=False %} - -
-
- {% bootstrap_field draft_form.sections class="form-control" placeholder="Sections" show_help=False show_label=False %} - -
+
+ {% include "ipr/details_edit_draft.html" with draft_form=draft_form only %}
{% endfor %} - {% comment %} - {% for draft_form in draft_formset %} -
-
{% bootstrap_label draft_form.document.label %}
-
{% bootstrap_field draft_form.document label_class="d-none" show_help=False %}
-
- {% bootstrap_field draft_form.revisions placeholder="Revisions, e.g., 04-07" label_class="d-none" show_help=False %} -
-
- {% bootstrap_field draft_form.sections placeholder="Sections" label_class="d-none" show_help=False %} -
-
- {% endfor %} - {% endcomment %} +
+ {% include "ipr/details_edit_draft.html" with draft_form=draft_formset.empty_form only %} +
diff --git a/ietf/templates/ipr/details_edit_draft.html b/ietf/templates/ipr/details_edit_draft.html new file mode 100644 index 00000000000..64e5afe60a1 --- /dev/null +++ b/ietf/templates/ipr/details_edit_draft.html @@ -0,0 +1,14 @@ +{% load django_bootstrap5 %} +
+ {{ draft_form.id }} + {{ draft_form.document }} + {% if draft_form.document.errors %}
{{ draft_form.document.errors }}
{% endif %} +
+
+ {% bootstrap_field draft_form.revisions class="form-control" placeholder="Revisions, e.g., 04-07" show_help=False show_label=False %} + +
+
+ {% bootstrap_field draft_form.sections class="form-control" placeholder="Sections" show_help=False show_label=False %} + +