This is a subissue of #1391216: Views integration for the 6.x-2.x and 7.x-1.x version.

Problem/Motivation

As an alternative to Fields (in Views), Ubercart Addresses should provide an "Address" row style. This way a View can be created with addresses themed the same as on the address book page.
This feature is a requirement for #1433034: Redesign the address book page using Views.

Proposed resolution

Implement a Views row style plugin. Theme the list of addresses with "uc_addresses_list_address".
The address book API should be responsible for loading the addresses from the database. Views should only load the address ID (aid) and user ID (uid) from the uc_addresses table and then pass this values to the address book API which will care for loading full UcAddressesAddress objects. To increase performance, the address book API should be informed to load all addresses for one user at once. This can be done by setting the performance hint to UcAddressesAddressBook::PERF_HINT_LOAD_ALL.

Additionaly, the theme function "uc_addresses_list_address" should be adjusted to support an option to show the default labels for an address, for example it should be able to show "Default billing address" for a single address. Currently, this label is only printed in the template "uc-addresses-address-book.tpl.php".

The solution should be implemented for both 7.x-1.x and 6.x-2.x versions. Previously, it was planned to be only implemented for the 6.x-2.x version, because I thought the row style "Rendered Entity" would replace the need for this feature in the 7.x-1.x version. I didn't find a way to provide additional display options for this row style (other than implementing View modes, which Ubercart Addresses 7.x-1.x doesn't support, see #1831424: Turn Ubercart Addresses address into an entity), so that's why I decided the row style should be implemented for both versions.

Remaining tasks

  • Implement a Views row style plugin.
  • Adjust the theme function "uc_addresses_list_address" (add option for default labels).
  • Refine contents of template_preprocess_uc_addresses_list_address().

User interface changes

Some of the Ubercart Addresses templates will be adjusted and template_preprocess_uc_addresses_list_address() will be refined.

API changes

The theme function "uc_addresses_list_address" will get additional variables/options.

I'm working on it.

Comments

megachriz’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new16.74 KB

First patch. This implement the Views row style plugin, adjusts the theme function "uc_addresses_list_address" and refines the contents of template_preprocess_uc_addresses_list_address(). Additionally, a function called uc_addresses_render_link() is defined in uc_addresses.pages.inc. I'm not sure yet if that function should be moved to uc_addresses.module.

This could use an automated test as well to ensure the views plugin works as expected.

megachriz’s picture

Issue tags: -Needs tests
StatusFileSize
new25.33 KB

Now with automated tests. No other changes were made.

megachriz’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed #2 with one small difference in uc_addresses_render_link(): the code still putted CSS classes into a string, while in Drupal 7 CSS classes should always be defined in an array.

Moving to 6.x-2.x.

megachriz’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new25 KB

Patch for the 6.x-2.x version.

megachriz’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

Committed #4.

Setting issue version back to the one it was originally reported for and mark it as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.