Django

Code

Ticket #4418 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Add media descriptions to newforms widgets

Reported by: russellm Assigned to: russellm
Milestone: Component: Forms
Version: SVN Keywords: media css javascript
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 0 Patch needs improvement: 0

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

media.diff (9.8 kB) - added by russellm on 05/29/07 09:32:53.
Adds a Media descriptor to newforms widgets
media2.diff (10.7 kB) - added by russellm on 05/30/07 08:36:13.
Revised media patch, to address inheritance issues.
media3.diff (16.3 kB) - added by russellm on 07/09/07 10:27:58.
Media descriptors for newforms, v3; against [5636]
newforms-admin-media.diff (27.2 kB) - added by russellm on 07/09/07 10:30:18.
Media descriptors for newforms-admin; against [5636]
newforms-admin-media.5651.diff (43.1 kB) - added by russellm on 07/11/07 23:48:14.
Improved media descriptors for newforms-admin; against [5651]

Change History

05/29/07 09:32:53 changed by russellm

  • attachment media.diff added.

Adds a Media descriptor to newforms widgets

05/29/07 09:35:53 changed by russellm

  • owner changed from adrian to russellm.
  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

05/29/07 09:38:55 changed by russellm

  • needs_docs set to 1.
  • has_patch set to 1.

05/30/07 08:36:13 changed by russellm

  • attachment media2.diff added.

Revised media patch, to address inheritance issues.

07/09/07 10:27:58 changed by russellm

  • attachment media3.diff added.

Media descriptors for newforms, v3; against [5636]

07/09/07 10:30:18 changed by russellm

  • attachment newforms-admin-media.diff added.

Media descriptors for newforms-admin; against [5636]

07/11/07 23:48:14 changed by russellm

  • attachment newforms-admin-media.5651.diff added.

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

08/18/07 00:42:57 changed by russellm

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

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


Add/Change #4418 (Add media descriptions to newforms widgets)




Change Properties
Action