Django

Code

Ticket #12508 (closed: fixed)

Opened 2 months ago

Last modified 3 weeks ago

Feature: Dynamically adding inlines

Reported by: zain Assigned to: jezdez
Milestone: 1.2 Component: django.contrib.admin
Version: soc2009/admin-ui Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

This patch adds the ability to add extra inlines dynamically with a "Add new <model>" link at the bottom of the inline. When Javascript is enabled, extra forms for inlines are hidden on load and the "add new <model>" link is unhidden.

Attachments

adminui-newinlines.diff (72.1 kB) - added by zain on 01/05/10 15:28:42.
Fixed a bug related to spaces in verbose_name
inlines_patch.diff (0.8 kB) - added by andraz on 02/22/10 00:56:52.
hope this time the patch gets uploaded
field_numbering_off_by_one.diff (4.1 kB) - added by stefanfoulis on 03/02/10 07:46:31.
Fixes faulty field numbering for ForeigKeys? (add link and field. and potentially others)
field_numbering_off_by_one.2.diff (3.9 kB) - added by stefanfoulis on 03/02/10 07:49:30.
Fixes faulty field numbering for ForeigKeys? (add link and field. and potentially others)

Change History

01/05/10 15:28:42 changed by zain

  • attachment adminui-newinlines.diff added.

Fixed a bug related to spaces in verbose_name

01/19/10 17:40:15 changed by jezdez

  • owner changed from zain to jezdez.
  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

FYI, my current status can be found here: http://github.com/jezdez/django/tree/admin-ui-combined

("combined" with the select-across feature of #12282 which I've ported to jQuery, as well)

01/26/10 09:02:54 changed by jezdez

  • status changed from new to closed.
  • resolution set to fixed.

(In [12297]) Fixed #12508 - Added ability to dynamically add inlines in the admin app.

Refs #13. Also introduces an empty_form attribute on formsets to make it easier to implement dynamic forms.

Many thanks to Zain Memon for the initial patch from his Summer of Code 2009 project, Stanislaus Madueke for his django-dynamic-formset app and all the other people helping out.

02/22/10 00:56:32 changed by andraz

  • status changed from closed to reopened.
  • resolution deleted.

there's a bug with current implementation, when using ManyToManyField? and raw_id_admin, the ids of the fields are off-by-one and thus when popup closes the value is entered in a row after the one that the user clicked on to change.

Since ticketing system thinks my patch is a spam, here's a simple patch to make it work:

--- inlines.js (revision 12486) +++ inlines.js (working copy) @@ -56,8 +56,8 @@

var template = $("#" + options.prefix + "-empty"); var row = template.clone(true).get(0); $(row).removeClass(options.emptyCssClass).removeAttr("id").insertBefore($(template));

- $(row).html($(row).html().replace(/prefix/g, nextIndex)); - $(row).addClass(options.formCssClass).attr("id", options.prefix + nextIndex); + $(row).html($(row).html().replace(/prefix/g, totalForms.val())); + $(row).addClass(options.formCssClass).attr("id", options.prefix + totalForms.val());

if ($(row).is("TR")) {

// If the forms are laid out in table rows, insert // the remove button into the last table cell:

02/22/10 00:56:52 changed by andraz

  • attachment inlines_patch.diff added.

hope this time the patch gets uploaded

02/23/10 16:56:37 changed by Alex

  • status changed from reopened to closed.
  • resolution set to fixed.

This was fixed, if there's a new bug please file it.

03/02/10 07:46:31 changed by stefanfoulis

  • attachment field_numbering_off_by_one.diff added.

Fixes faulty field numbering for ForeigKeys? (add link and field. and potentially others)

03/02/10 07:49:30 changed by stefanfoulis

  • attachment field_numbering_off_by_one.2.diff added.

Fixes faulty field numbering for ForeigKeys? (add link and field. and potentially others)


Add/Change #12508 (Feature: Dynamically adding inlines)




Change Properties
Action