WordPress.org

Make WordPress Core

Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#21921 closed task (blessed) (fixed)

Allow JS Attachments models to be searchable and sortable

Reported by: koopersmith Owned by: 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)

comment:1 koopersmith19 months 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.

comment:2 koopersmith19 months 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.