Opened 8 years ago

Closed 8 years ago

#4418 closed (fixed)

Add media descriptions to newforms widgets

Reported by: russellm Owned by: russellm
Component: Forms Version: master
Severity: Keywords: media css javascript
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

A newforms widget currently defines the way to render a user interface input element. However, in order to make interesting input elements, you also need other media - i.e., Javascript and CSS. These requirements can be defined on a per-widget basis (a Date field requires a Calendar widget; the calendar widget requires media/calendar.js and media/calendar.css).

At present, there is no easy way to:

  1. identify what media is required to display a form
  2. identify and eliminate any duplicate media requirements, e.g., a base css file required by two different widgets on a form.

newforms-admin has some hand rolled functionality to determine Javascript requirements for a page. This ticket describes a more general solution that could be applied to any widget, and therefore to any form.

It involves adding a meta-class to Widget that processes a 'Media' inner class; this inner class is turned into a 'Media' object. Media objects can be printed (yielding <link> and <script> statements). Media objects can also be added, so media from one widget can be added to another widget, yielding the union of required media.

Forms are also modified; you can interrogate form.media to find out the union of all CSS and JavaScript required by a given form.

Discussed in detail here:
http://groups.google.com/group/django-developers/browse_thread/thread/58fc9cab819c08b9/af54bb9c638fede7#af54bb9c638fede7

Attachments (5)

media.diff (9.8 KB) - added by russellm 8 years ago.
Adds a Media descriptor to newforms widgets
media2.diff (10.7 KB) - added by russellm 8 years ago.
Revised media patch, to address inheritance issues.
media3.diff (16.3 KB) - added by russellm 8 years ago.
Media descriptors for newforms, v3; against [5636]
newforms-admin-media.diff (27.2 KB) - added by russellm 8 years ago.
Media descriptors for newforms-admin; against [5636]
newforms-admin-media.5651.diff (43.1 KB) - added by russellm 8 years ago.
Improved media descriptors for newforms-admin; against [5651]

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by russellm

Adds a Media descriptor to newforms widgets

comment:1 Changed 8 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from adrian to russellm
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 8 years ago by russellm

  • Has patch set
  • Needs documentation set

Changed 8 years ago by russellm

Revised media patch, to address inheritance issues.

Changed 8 years ago by russellm

Media descriptors for newforms, v3; against [5636]

Changed 8 years ago by russellm

Media descriptors for newforms-admin; against [5636]

Changed 8 years ago by russellm

Improved media descriptors for newforms-admin; against [5651]

comment:3 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [5926]) newforms-admin: Fixed #4418 -- Added the ability for widgets, forms, and Admin declarations to have media definitions.

Note: See TracTickets for help on using tickets.
Back to Top