I would like to be able to create a calendar view from the date fields in uc_orders.
I believe the addition of this code would let it happen. Simliar code could be used for the other date fields in the other ubercart submodules to provide same functionality.
Thanks,
Alex
/**
* Implements hook_date_views_fields().
*
* All modules that create custom fields that use the
* 'views_handler_field_date' handler can provide
* additional information here about the type of
* date they create so the date can be used by
* the Date API views date argument and date filter.
*/
function uc_order_date_views_fields($field) {
$values = array(
// The type of date: DATE_UNIX, DATE_ISO, DATE_DATETIME.
'sql_type' => DATE_UNIX,
// Timezone handling options: 'none', 'site', 'date', 'utc' .
'tz_handling' => 'site',
// Needed only for dates that use 'date' tz_handling.
'timezone_field' => '',
// Needed only for dates that use 'date' tz_handling.
'offset_field' => '',
// Array of "table.field" values for related fields that should be
// loaded automatically in the Views SQL.
'related_fields' => array(),
// Granularity of this date field's db data.
'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
);
switch ($field) {
case 'uc_orders.created':
case 'uc_orders.modified':
return $values;
}
}
Comments
Comment #1
longwaveI think we need an extra hook and also to set 'is date' in the Views data hook to fully integrate with Date here. Please test the attached patch and let me know if this works for you.
Comment #2
alex.neblett commentedThe patch is definately pushing things in the right direction. Thanks:)
I can now import:
But, I get
I believe this is related to the other problem:
If I try to build a view via add new view, when I get to Add contextual filters, uc_orders.created is not there (uc_orders.order_id is there so we know the problem is related to the field and not the table).
I think you almost have it.
Thanks again,
Alex
Comment #3
alex.neblett commentedI forgot to mention that prior to your patch I was unable to import the view due to the contextual filter and that the second issue was present.
Thanks,
Alex
Comment #4
longwaveThe order date fields are not currently implemented as contextual filters (arguments), so that's why they don't show up. That should just need a few lines adding to uc_order.views.inc I think.
Comment #5
longwaveComment #6
alex.neblett commentedI just updated to the latest commit versions of Calendar and Date API. Karen S. has been busy:) I like the updated views from templates function - very cool - I can now create my view from a template.
My created date order now appears. But I am getting a new message:
It comes down to the line
It looks like between you and Karen S. things are moving forward rapidly.
Thanks again,
Alex
Comment #7
alex.neblett commentedKaren S. informs me that the error is coming from this bit of code:
She goes on to say that "Entities are supposed to provide either a 'label' or a 'label callback' (this is the equivalent of the node title). It looks like the uc entity has done neither, so the code can't figure out what to do. This information would be in ubercarts hook_entity_info()."
Hopefully, adding this to your patch completes the task.
Thanks again,
Alex
Comment #8
alex.neblett commentedMore progress:)
It turns out that 'entity keys' was missing 'lablel' in uc_order/uc_orders.module so I added them in resulting in:
This leads to a new error message:
This comes from 'uri callback' => 'uc_order_uri' above so now I am off to trace this down.
Thanks,
Alex
Comment #9
alex.neblett commentedI have resolved the issue by adding the missing function to uc_order/uc_orders.module
I am now able to render calendars:) But, I am still not doing one or more thing right. Above the calendar, the below message repeats once per item listed on the calendar.
This comes back to:
letting me know that my hack for the ['entity keys']['label'] may have gotten me a calendar, but is not right.
If we fix this, the issue is wrapped up and Ubercart 3 is just that much better.
Thanks,
Alex
Comment #10
alex.neblett commentedAttached is a diff against the latest git.
It works for me aside from the below warning:
Thanks,
Alex
Comment #11
longwaveThanks for the updated patch.
This doesn't make sense; this should probably use the 'admin/store/orders/' prefix, but I wonder if we can/should do any permission checking here.
Comment #12
alex.neblett commentedYeah. I was wondering what to put in there... and was not even sure it was used...
On another note, I took in the latest updates to ubercart, calendar, date and views and now the warning message is gone:)
Thanks,
Alex
Comment #13
alex.neblett commentedHere is the revised version of the patch.
Please consider commiting it. I have been working with it for a few weeks now without issue.
Thanks again,
Alex
Comment #14
longwaveThanks for working on this! Committed #13 with some fixes to uc_order_uri().