|
Lines 1-4
Link Here
|
| 1 |
package Koha::Template::Plugin::ColumnsSettings; |
1 |
package Koha::Template::Plugin::TablesSettings; |
| 2 |
|
2 |
|
| 3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
| 4 |
# |
4 |
# |
|
Lines 19-46
package Koha::Template::Plugin::ColumnsSettings;
Link Here
|
| 19 |
|
19 |
|
| 20 |
=head1 NAME |
20 |
=head1 NAME |
| 21 |
|
21 |
|
| 22 |
Koha::Template::Plugin::ColumnsSettings |
22 |
Koha::Template::Plugin::TablesSettings |
| 23 |
|
23 |
|
| 24 |
=head2 SYNOPSYS |
24 |
=head2 SYNOPSYS |
| 25 |
|
25 |
|
| 26 |
[% USE ColumnsSettings %] |
26 |
[% USE TablesSettings %] |
| 27 |
|
27 |
|
| 28 |
. . . |
28 |
. . . |
| 29 |
|
29 |
|
| 30 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
30 |
[% UNLESS TablesSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
| 31 |
<th id="column" data-colname="column">Column title</th> |
31 |
<th id="column" data-colname="column">Column title</th> |
| 32 |
[% END %] |
32 |
[% END %] |
| 33 |
|
33 |
|
| 34 |
. . . |
34 |
. . . |
| 35 |
|
35 |
|
| 36 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
36 |
[% UNLESS TablesSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
| 37 |
<td>[% row.column %]</td> |
37 |
<td>[% row.column %]</td> |
| 38 |
[% END %] |
38 |
[% END %] |
| 39 |
|
39 |
|
| 40 |
. . . |
40 |
. . . |
| 41 |
|
41 |
|
| 42 |
<script> |
42 |
<script> |
| 43 |
var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
43 |
var columns_settings = [% TablesSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
| 44 |
var table = KohaTable("id", { "bAutoWidth": false }, columns_settings ); |
44 |
var table = KohaTable("id", { "bAutoWidth": false }, columns_settings ); |
| 45 |
</script> |
45 |
</script> |
| 46 |
|
46 |
|
|
Lines 58-72
use YAML qw( LoadFile );
Link Here
|
| 58 |
use JSON qw( to_json ); |
58 |
use JSON qw( to_json ); |
| 59 |
|
59 |
|
| 60 |
use C4::Context qw( config ); |
60 |
use C4::Context qw( config ); |
| 61 |
use C4::Utils::DataTables::ColumnsSettings; |
61 |
use C4::Utils::DataTables::TablesSettings; |
| 62 |
|
62 |
|
| 63 |
=head1 FUNCTIONS |
63 |
=head1 FUNCTIONS |
| 64 |
|
64 |
|
| 65 |
=head2 GetColumns |
65 |
=head2 GetColumns |
| 66 |
|
66 |
|
| 67 |
<script> |
67 |
<script> |
| 68 |
var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
68 |
var tables_settings = [% TablesSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
| 69 |
var table = KohaTable("id", { "bAutoWidth": false }, columns_settings ); |
69 |
var table = KohaTable("id", { "bAutoWidth": false }, tables_settings ); |
| 70 |
</script> |
70 |
</script> |
| 71 |
|
71 |
|
| 72 |
Used to get the full column settings configuration for datatables, usually requires a format of 'json' to pass into |
72 |
Used to get the full column settings configuration for datatables, usually requires a format of 'json' to pass into |
|
Lines 78-84
sub GetColumns {
Link Here
|
| 78 |
my ( $self, $module, $page, $table, $format ) = @_; |
78 |
my ( $self, $module, $page, $table, $format ) = @_; |
| 79 |
$format //= q{}; |
79 |
$format //= q{}; |
| 80 |
|
80 |
|
| 81 |
my $columns = C4::Utils::DataTables::ColumnsSettings::get_columns( $module, $page, $table ); |
81 |
my $columns = C4::Utils::DataTables::TablesSettings::get_columns( $module, $page, $table ); |
| 82 |
|
82 |
|
| 83 |
return $format eq 'json' |
83 |
return $format eq 'json' |
| 84 |
? to_json( $columns ) |
84 |
? to_json( $columns ) |
|
Lines 87-93
sub GetColumns {
Link Here
|
| 87 |
|
87 |
|
| 88 |
=head2 is_hidden |
88 |
=head2 is_hidden |
| 89 |
|
89 |
|
| 90 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
90 |
[% UNLESS TablesSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
| 91 |
<th id="column" data-colname="column">Column title</th> |
91 |
<th id="column" data-colname="column">Column title</th> |
| 92 |
[% END %] |
92 |
[% END %] |
| 93 |
|
93 |
|
|
Lines 98-104
it may contain confidential information and should be fully hidden rather than j
Link Here
|
| 98 |
|
98 |
|
| 99 |
sub is_hidden { |
99 |
sub is_hidden { |
| 100 |
my ( $self, $module, $page, $table, $column_name ) = @_; |
100 |
my ( $self, $module, $page, $table, $column_name ) = @_; |
| 101 |
my $columns = C4::Utils::DataTables::ColumnsSettings::get_columns( $module, $page, $table ); |
101 |
my $columns = C4::Utils::DataTables::TablesSettings::get_columns( $module, $page, $table ); |
| 102 |
foreach my $keys(@$columns){ |
102 |
foreach my $keys(@$columns){ |
| 103 |
if($keys->{'columnname'} eq $column_name){ |
103 |
if($keys->{'columnname'} eq $column_name){ |
| 104 |
return $keys->{'is_hidden'}; |
104 |
return $keys->{'is_hidden'}; |