Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#21921 closed task (blessed) (fixed)

Allow JS Attachments models to be searchable and sortable

Reported by: koopersmith's profile koopersmith Owned by: koopersmith's profile koopersmith
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords:
Focuses: Cc:

Description

Currently sorting and searching can only be performed on media Query models. However, it's preferable to shift this functionality to the base Attachments model, as we may want to sort sets of Attachments that are independent of a server-side representation, such as galleries or selections.

This will chiefly benefit #21809. See #21390 for the umbrella ticket.

Change History (2)

#1 @koopersmith
12 years ago

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

In [21898]:

Allow JS Attachments models to be searchable and sortable.

Moves wp.media.model.Query sorting and searching to the parent wp.media.model.Attachments.

Query parameters are stored in attachments.props, which is a Backbone.Model, and supports order ('ASC' or 'DESC'), orderby (any Attachment model property name), search (a search term), and query (a boolean value that ties the Attachments collection to the server).

wp.media.query( args ) now returns an Attachments set that is mapped to a Query collection instead of the Query collection itself. This allows you to change the query arguments by updating attachments.props instead of fetching the mirrored arguments, changing them, and passing them to wp.media.query() again.

fixes #21921, see #21390, #21809.

#2 @koopersmith
12 years ago

In [21900]:

Ensure the Attachments model properties are correctly set for Query collections.

After shifting sorting and searching logic from the Query collection in [21898], it became apparent that Query collections should also have an accurate props model, as the model controls the aforementioned searching and sorting.

see #21921, #21809, and #21390.

Note: See TracTickets for help on using tickets.