Lines 17-22
package Koha::Template::Plugin::ColumnsSettings;
Link Here
|
17 |
# You should have received a copy of the GNU General Public License |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
|
|
20 |
=head1 NAME |
21 |
|
22 |
Koha::Template::Plugin::ColumnsSettings |
23 |
|
24 |
=head2 SYNOPSYS |
25 |
|
26 |
[% USE ColumnsSettings %] |
27 |
|
28 |
. . . |
29 |
|
30 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
31 |
<th id="column" data-colname="column">Column title</th> |
32 |
[% END %] |
33 |
|
34 |
. . . |
35 |
|
36 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
37 |
<td>[% row.column %]</td> |
38 |
[% END %] |
39 |
|
40 |
. . . |
41 |
|
42 |
<script> |
43 |
var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
44 |
var table = KohaTable("id", { "bAutoWidth": false }, columns_settings ); |
45 |
</script> |
46 |
|
47 |
This plugin allows to get the column configuration for a table. It should be used both in table markup |
48 |
and as the input for datatables visibility settings to take full effect. |
49 |
|
50 |
=cut |
51 |
|
20 |
use Modern::Perl; |
52 |
use Modern::Perl; |
21 |
|
53 |
|
22 |
use Template::Plugin; |
54 |
use Template::Plugin; |
Lines 28-43
use JSON qw( to_json );
Link Here
|
28 |
use C4::Context qw( config ); |
60 |
use C4::Context qw( config ); |
29 |
use C4::Utils::DataTables::ColumnsSettings; |
61 |
use C4::Utils::DataTables::ColumnsSettings; |
30 |
|
62 |
|
31 |
=pod |
63 |
=head1 FUNCTIONS |
32 |
|
64 |
|
33 |
This plugin allows to get the column configuration for a table. |
65 |
=head2 GetColumns |
34 |
|
66 |
|
35 |
First, include the line '[% USE Tables %]' at the top |
67 |
<script> |
36 |
of the template to enable the plugin. |
68 |
var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %]; |
|
|
69 |
var table = KohaTable("id", { "bAutoWidth": false }, columns_settings ); |
70 |
</script> |
37 |
|
71 |
|
38 |
To use, call ColumnsSettings.GetColumns with the module, the page and the table where the template is called. |
72 |
Used to get the full column settings configuration for datatables, usually requires a format of 'json' to pass into |
39 |
|
73 |
datatables instantiator. |
40 |
For example: [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'holdst' ) %] |
|
|
41 |
|
74 |
|
42 |
=cut |
75 |
=cut |
43 |
|
76 |
|
Lines 52-57
sub GetColumns {
Link Here
|
52 |
: $columns |
85 |
: $columns |
53 |
} |
86 |
} |
54 |
|
87 |
|
|
|
88 |
=head2 is_hidden |
89 |
|
90 |
[% UNLESS ColumnsSettings.is_hidden( 'module', 'page', 'table', 'column') %] |
91 |
<th id="column" data-colname="column">Column title</th> |
92 |
[% END %] |
93 |
|
94 |
Used to fetch an individual columns display status so we can fully hide a column in the markup for cases where |
95 |
it may contain confidential information and should be fully hidden rather than just hidden from display. |
96 |
|
97 |
=cut |
98 |
|
55 |
sub is_hidden { |
99 |
sub is_hidden { |
56 |
my ( $self, $module, $page, $table, $column_name ) = @_; |
100 |
my ( $self, $module, $page, $table, $column_name ) = @_; |
57 |
my $columns = C4::Utils::DataTables::ColumnsSettings::get_columns( $module, $page, $table ); |
101 |
my $columns = C4::Utils::DataTables::ColumnsSettings::get_columns( $module, $page, $table ); |
58 |
- |
|
|