DataTables/SSP/Params.pm

filter: Statementstmt 50.0% 13 / 26 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 1 / 3 Podpod 0.0% 0 / 2 totaltotal 40.0% 14 / 35 CC 5 SCAR 23.4
CC
5
Cov
43%
db_columns
12.0
db_order
12.0
BEGIN
1.0
CRAP 10.4
« DataTables.pm ↑ Summary DataTables/SSP/Results.pm »
1 package Mojolicious::Plugin::DataTables::SSP::Params;
2  
3 2 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '2.01';
6  
7 2 has 'columns';
8 2 has 'draw';
9 2 has 'length';
10 2 has 'order';
11 2 has 'search';
12 2 has 'columns';
13 2 has 'timestamp';
14 2 has 'start';
15  
16 0 ▶sub db_columns {
Subroutine db_columns: not called CC=3 SCAR=24.8
Pod undocumented
17  
18 0 my ($self) = @_;
19  
20 0 my @columns;
21  
22 0 foreach ( @{ $self->columns } ) {
23 0 ▶ push @columns, $_->database if ( $_->database );
Branch: 1 branch
BranchTrueFalseTotal
if $_->database 0 0 0
24 }
25  
26 0 return @columns;
27  
28 }
29  
30 0 ▶sub db_order {
Subroutine db_order: not called CC=3 SCAR=24.8
Pod undocumented
31  
32 0 my ($self) = @_;
33  
34 0 my $order = {};
35  
36 0 foreach ( @{ $self->order } ) {
37 0 ▶ if ( $_->{column}->{database} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"column"}{"database"}) 0 0 0
38 0 $order->{ $_->{column}->{database} } = $_->{dir};
39 }
40 }
41  
42 0 return $order;
43  
44 }
45  
46 2 1;
47  
48 =encoding utf8
49  
50 =head1 NAME
51  
52 Mojolicious::Plugin::DataTables::SSP::Params - DataTables SSP Params Helper
53  
54 =head1 SYNOPSIS
55  
56 # Mojolicious
57 $self->plugin('DataTables');
58  
59 # Mojolicious::Lite
60 plugin 'DataTables';
61  
62 [...]
63  
64 my $dt_params = $c->datatable->ssp_params(
65 [
66 {
67 label => 'UID',
68 db => 'uid',
69 dt => 0,
70 formatter => sub {
71 my ($value, $column) = @_;
72 return '<a href="/user/' . $value . '">' . $value . '</a>';
73 }
74 },
75 {
76 label => 'e-Mail',
77 db => 'mail',
78 dt => 1,
79 },
80 {
81 label => 'Status',
82 db => 'status',
83 dt => 2,
84 },
85 ]
86 ));
87  
88 =head1 DESCRIPTION
89  
90 L<Mojolicious::Plugin::DataTables::SSP::Params> is a L<Mojolicious> plugin to add DataTables SSP (Server-Side Protocol) support in your Mojolicious application.
91  
92  
93 =head1 CONTRUCTOR
94  
95 =head2 Mojolicious::Plugin::DataTables::SSP::Params->new ( @options )
96  
97 Create a new instance of L<Mojolicious::Plugin::DataTables::SSP::Params> class.
98  
99 Options:
100  
101 =over 4
102  
103 =item C<label>: Column label
104  
105 =item C<db>: Database column name
106  
107 =item C<dt>: DataTable column ID
108  
109 =item C<formatter>: Formatter sub
110  
111 =back
112  
113  
114 =head1 METHODS
115  
116 L<Mojolicious::Plugin::DataTables::SSP::Params> implements the following methods.
117  
118 =head2 columns
119  
120 =head2 draw
121  
122 =head2 length
123  
124 =head2 order
125  
126 =head2 search
127  
128 =head2 columns
129  
130 =head2 timestamp
131  
132 =head2 start
133  
134  
135  
136 =head1 SEE ALSO
137  
138 L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>, L<Mojolicious::Plugin::DataTables>, L<Mojolicious::Plugin::DataTables::SSP::Results>.
139  
140  
141 =head1 SUPPORT
142  
143 =head2 Bugs / Feature Requests
144  
145 Please report any bugs or feature requests through the issue tracker
146 at L<https://github.com/giterlizzi/perl-Mojolicious-Plugin-DataTables/issues>.
147 You will be notified automatically of any progress on your issue.
148  
149 =head2 Source Code
150  
151 This is open source software. The code repository is available for
152 public review and contribution under the terms of the license.
153  
154 L<https://github.com/giterlizzi/perl-Mojolicious-Plugin-DataTables>
155  
156 git clone https://github.com/giterlizzi/perl-Mojolicious-Plugin-DataTables.git
157  
158  
159 =head1 AUTHOR
160  
161 =over 4
162  
163 =item * Giuseppe Di Terlizzi <gdt@cpan.org>
164  
165 =back
166  
167  
168 =head1 LICENSE AND COPYRIGHT
169  
170 This software is copyright (c) 2020-2021 by Giuseppe Di Terlizzi.
171  
172 This is free software; you can redistribute it and/or modify it under
173 the same terms as the Perl 5 programming language system itself.
174  
175 =cut
176  
« DataTables.pm ↑ Summary DataTables/SSP/Results.pm »