Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4417 closed (duplicate)

Add media descriptions to newforms widgets

Reported by: russellm Owned by: adrian
Component: Forms Version: master
Severity: Keywords: media css javascript
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
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 (0)

Change History (2)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Something went wonky during submission. This was duplicated as [4418].

comment:2 Changed 7 years ago by Brian Rosner <brosner@…>

I believe Russell meant to say #4418 the ticket and not the changeset ;)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.