Development

#2092 ([Patch] Admin generator option to define a multi-sort list)

You must first sign up to be able to contribute.

Ticket #2092 (new enhancement)

Opened 11 months ago

Last modified 1 month ago

[Patch] Admin generator option to define a multi-sort list

Reported by: Leon.van.der.Ree Assigned to: fabien
Priority: minor Milestone:
Component: generator Version: 1.0.0
Keywords: Cc:
Qualification: Unreviewed

Description

As said by me in Ticket #924, I would further enhance the capabilities of a list by adding the option to make a list a multi-sort list and that is what I will upload in this ticket.

You can now set in your generator.yml file that the list is a multisort list and the result will be a list which can sort on multiple columns (for example first on product-category (which is a foreign-table) than on the product-names, by clicking on the column-headers one by one. Resetting the ordening can be done file the reset button of the filter. Removing one column from the sorting can be done by the X which will appear in the columns on which you sort.

Enabling the multisort is now as simple as setting multisort: true in the generator.yml file. A complete overview of a generator.yml file, with foreign-columns on which you want to sort alfabetically (instead of on id-value) will be:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Product
    theme:            default

    fields:
      productgroupid: { name: Productgroup }

    list:
      title:            Products
      display: 		[=productname, description, productgroup]
      multisort:	true

      fields:
        productgroup: 
          name: Productgroup
          join_fields: [ProductPeer::PRODUCTGROUPID, ProductgroupPeer::PRODUCTGROUPID]
          sort_column: [ProductgroupPeer::TITLE]
      filters:         [productgroupid]

I've changed the following files from the theme: - _list_th_tabular.php

  • added a X to remove the sorting from a column

- action.class.php (this was rewritten for a big part, now arrays are used to keep track of the columns to sort on)

  • processSort() set an array, instead of only one sort-field
  • addSortCriteria() do the sorting on all fields in the array
  • processFilters() to reset the sorting completely

attached you can find the source

Attachments

_list_th_tabular.php (2.0 kB) - added by Leon.van.der.Ree on 08/13/07 02:18:17.
actions.class.php (21.4 kB) - added by Leon.van.der.Ree on 08/13/07 13:29:25.
bug-fix, to properly support default sortorder from generator.yml (for only one column (for now))
actions.class.2.php (21.9 kB) - added by Leon.van.der.Ree on 08/13/07 13:54:07.
fixed default-sort from generator.yml, you can also sort on multipletables

Change History

08/13/07 02:18:17 changed by Leon.van.der.Ree

  • attachment _list_th_tabular.php added.

08/13/07 13:29:25 changed by Leon.van.der.Ree

  • attachment actions.class.php added.

bug-fix, to properly support default sortorder from generator.yml (for only one column (for now))

08/13/07 13:54:07 changed by Leon.van.der.Ree

  • attachment actions.class.2.php added.

fixed default-sort from generator.yml, you can also sort on multipletables

08/13/07 13:57:27 changed by Leon.van.der.Ree

oops, action.class.2.php had to overwrite action.class.

In the generator.yml file you can still set the default sort-order for non-multi-sort lists as follows:

  sort:  productgroup

or

  sort:  [productgroup, desc]

And for multi-sort-lists you can define it as follows:

  sort:  [productgroup, productname]

or

  sort:  [[productgroup, desc], productname]

04/11/08 01:37:55 changed by Dannyrulez

  • qualification set to Unreviewed.
  • milestone set to 1.0.14.

This should be implement... the admin generator need to be better

04/11/08 17:43:19 changed by Dannyrulez

  • milestone changed from 1.0.14 to 1.1.0 beta4.

04/14/08 18:44:46 changed by fabien

  • milestone deleted.