Skip to content

Commit

Permalink
Configurable export options, JSON export fix, remove counter from lis…
Browse files Browse the repository at this point in the history
…t of user fields, render subject names and virutal fields in CSV export, add select/deselect all button for export fields, add new/refine search links, allow export field list ordering to be defined, fix IE bug with showing reports.
  • Loading branch information
wfyson committed Mar 1, 2019
1 parent 997b467 commit 9285ca3
Show file tree
Hide file tree
Showing 9 changed files with 1,454 additions and 1,031 deletions.
9 changes: 5 additions & 4 deletions cfg/cfg.d/z_reports.pl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
datestamp
)];

#set order of export plugins
$c->{eprint_report}->{export_plugins} = [ qw( Export::Report::CSV Export::Report::HTML Export::Report::JSON )];

#set config for default user report
$c->{datasets}->{user}->{search}->{user_report} = $c->{search}->{user}; #use the default user search form

Expand All @@ -91,27 +94,25 @@
dept
org
address
counter
usertype
email
)],
};


$c->{user_report}->{exportfield_defaults} = [ qw(
name
username
userid
dept
org
address
counter
usertype
email
)];

#set order of export plugins
$c->{user_report}->{export_plugins} = [ qw( Export::Report::CSV Export::Report::HTML Export::Report::JSON )];

push @{$c->{user_roles}->{admin}}, qw{
+report
};

4 changes: 4 additions & 0 deletions lib/lang/en/phrases/reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

<epp:phrase id="report:no_grouping">No Grouping</epp:phrase>

<epp:phrase id="report_select">Select/Deselect All</epp:phrase>

<epp:phrase id="Report:search_links"><div class="ep_view_group_by"><epc:pin name="links" /></div></epp:phrase>

<!-- the Example reports -->
<epp:phrase id="Plugin/Screen/Report/Example:title">Example</epp:phrase>
<epp:phrase id="Plugin/Screen/Report/Example/Articles:title">Articles</epp:phrase>
Expand Down
23 changes: 19 additions & 4 deletions lib/plugins/EPrints/Plugin/Export/Grid2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ sub dataobj_to_rows
{
if( scalar @{$sub_dataobj_values} > 0 )
{
$_rows = $self->value_to_rows($field, $sub_dataobj_values);
$_rows = $self->value_to_rows($field, $sub_dataobj_values, $dataobj);
}
else #there's no results, but we still need to add an empty cell to the spreadsheet
{
Expand All @@ -224,7 +224,7 @@ sub dataobj_to_rows
{
$value = $field->get_value( $dataobj );
}
$_rows = $self->value_to_rows($field, $value);
$_rows = $self->value_to_rows($field, $value, $dataobj);
}
}

Expand Down Expand Up @@ -262,14 +262,14 @@ sub dataobj_to_rows

sub value_to_rows
{
my ($self, $field, $value) = @_;
my ($self, $field, $value, $dataobj) = @_;

my @rows;

if (ref($value) eq "ARRAY")
{
$value = [$field->empty_value] if !@$value;
@rows = map { $self->value_to_rows($field, $_)->[0] } @$value;
@rows = map { $self->value_to_rows($field, $_, $dataobj)->[0] } @$value;
}
elsif ($field->isa("EPrints::MetaField::Multipart"))
{
Expand All @@ -296,6 +296,21 @@ sub value_to_rows
}
push @rows, \@sub_values;
}
elsif( $field->isa("EPrints::MetaField::Subject"))
{
if( $value ne "" )
{
push @rows, [$field->render_single_value( $field->repository, $value )];
}
else
{
push @rows, [$value];
}
}
elsif( !$field->isa("EPrints::MetaField::Subobject") && $field->is_virtual )
{
push @rows, [$dataobj->render_value( $field->name )];
}
else
{
push @rows, [$value];
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/EPrints/Plugin/Export/Report/JSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ sub _epdata_to_json
next if !$field->get_property( "export_as_xml" );
next if defined $field->{sub_name};
my $value = $field->get_value( $epdata );
if( exists $repo->config( $self->{report}->{export_conf}, "custom_export" )->{$field->get_name} )
if( defined $repo->config( $self->{report}->{export_conf}, "custom_export" ) &&
exists $repo->config( $self->{report}->{export_conf}, "custom_export" )->{$field->get_name} )
{
$value = $repo->config( $self->{report}->{export_conf}, "custom_export" )->{$field->get_name}->( $epdata, $self->{report} );
}
Expand Down
Loading

0 comments on commit 9285ca3

Please sign in to comment.