#28267: Change submit_line implementation to allow easier modification
-------------------------------------------+------------------------
               Reporter:  Karolis Ryselis  |          Owner:  nobody
                   Type:  Uncategorized    |         Status:  new
              Component:  contrib.admin    |        Version:  master
               Severity:  Normal           |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Currently submit_line renders its buttons inside a div element and 5 if
 statements in the template are used to show or hide these buttons. This
 makes it difficult to add more buttons. Whole html template has to be
 overridden because there is no way to place the buttons inside div.submit-
 row element.
 We needed quite a few of those buttons, e.g., save as draft, save and add
 invoice (shortcut button).
 There is no way to change the default button either - `class="default"` is
 hardcoded in Save button.

 Proposed solution:
 define buttons in admin class. `ModelAdmin` could have a method
 `get_submit_line_buttons` which returns a list of buttons. A single item
 of this list could be either a dict or an object of a new Button class.
 Suggested dict keys or object properties:
 `id` - translates to HTML id attribute
 `display_name` - visible text on the button
 `name` - HTML name attribute
 `highlighted` - `bool`, equivalent to current `class="default"` if `True`
 `onclick` - hook to attach JavaScript

 Current buttons could be defined in default
 `ModelAdmin.get_submit_line_buttons` implementation with the same
 conditions as now. Template would consist of a loop that iterates over a
 list of buttons and renders them.

--
Ticket URL: <https://code.djangoproject.com/ticket/28267>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.730ad29fdbb5293f08570d111b027a32%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to