How do I process column values after retrieval, but before display in buglist.cgi?
Matthew Bogosian
mtb19 at columbia.edu
Thu Jan 10 10:22:06 UTC 2013
I did think about using SQL to do value manipulation/combination, and this does solve the problem of simple combinations (like the one I proposed), but it feels wrong. I'm trying to understand the code, and it looks like current implementations do not contemplate post-retrieval value manipulation in perl (e.g., by hook).
I'm debating writing/submitting a patch. Are there good reasons for me not to attempt this? I'm surprised this doesn't exist already, but that may indicate a lack of need.
I am considering implementing something like this:
sub buglist_columns {
my ( $self, $args ) = @_;
my $columns = $args->{columns};
$columns->{'rep_platform_hidden'} = {
name => 'rep_platform',
title => 'Hardware (Hidden)',
# New (optional) attribute indicating whether the
# column value will be displayed in buglist.cgi,
# or whether the column will merely be added to
# the SQL query (alternate name candidates could
# be "hidden", "no_display", etc.)
sql_only => 1,
};
$columns->{'op_sys_hidden'} = {
name => 'op_sys',
title => 'OS (Hidden)',
sql_only => 1,
};
$columns->{'env'} = {
name => 'NULL',
title => 'Env',
};
}
# New hook called for each DB row retrieved in buglist.cgi
sub buglist_process_row {
my ( $self, $args ) = @_;
my $row_hash = $args->{row_hash};
if (exists $row_hash->{env}) {
$row_hash->{env} = sprintf('%s (%s)',
$row_hash->{rep_platform_hidden},
$row_hash->{op_sys_hidden});
}
}
Thoughts?
--Matt
On Jan 6, 2013, at 23:38, Byron Jones wrote:
> Matthew Bogosian wrote:
>>
>> 1. How do I use multiple source columns to create a single output column in buglist.cgi?
>> 2. How do I format values after retrieval but before display in buglist.cgi (ideally using only hooks without modifying default templates)?
> something like this (untested):
>
> sub buglist_columns {
> my ($self, $args) = @_;
> my $columns = $args->{columns};
> $columns->{'env'} = {
> name => "CONCAT(rep_platform, ' (', op_sys, ')')",
> title => 'Env',
> };
> }
>
> you'll also need to add env to template/en/default/hook/global/field-descs-end.none.tmpl:
>
> [% IF in_template_var %]
> [% vars.field_descs.env = "Env" %]
> [% END %]
>
>
> --
> byron - irc:glob - bugzilla.mozilla.org team -
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bugzilla.org/pipermail/developers/attachments/20130110/80e66ce6/attachment.html>
More information about the developers
mailing list