File Coverage

blib/lib/JPList/Controls/Sort.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 6 66.6
condition 2 6 33.3
subroutine 3 3 100.0
pod 2 2 100.0
total 26 32 81.2


line stmt bran cond sub pod time code
1             # ========================================================================== #
2             # lib/JPList/Controls/Sort.pm - JPList Sort controls
3             # Copyright (C) 2017 Exceleron Software, LLC
4             # ========================================================================== #
5              
6             package JPList::Controls::Sort;
7              
8 2     2   1399 use Moose::Role;
  2         6  
  2         20  
9              
10             # ========================================================================== #
11              
12             =head1 NAME
13              
14             JPList::Controls::Sort - JPList Sort controls
15              
16             =head1 VERSION
17              
18             Version 0.04
19              
20             =cut
21              
22             our $VERSION = '0.04';
23              
24             =head1 SYNOPSIS
25              
26             with 'JPList::Controls::Sort'
27              
28             =head1 DESCRIPTION
29              
30             The Sort module allows you get the values sort controls
31              
32             =head2 METHODS
33              
34             =over 4
35              
36             =cut
37              
38             # ========================================================================== #
39              
40             =item C<sortdropdown>
41              
42             Params : sort_vals
43              
44             {
45             'type' => 'sort-drop-down',
46             'inStorage' => $VAR1->[0]{'inDeepLinking'},
47             'inAnimation' => $VAR1->[0]{'inDeepLinking'},
48             'name' => 'sort',
49             'data' => {
50             'order' => '',
51             'type' => '',
52             'dateTimeFormat' => '',
53             'path' => 'default',
54             'ignore' => ''
55             },
56             'initialIndex' => 1,
57             'inDeepLinking' => $VAR1->[0]{'inDeepLinking'},
58             'action' => 'sort',
59             'isAnimateToTop' => $VAR1->[0]{'isAnimateToTop'}
60             }
61              
62             Returns: Returns the column and value for order
63              
64             Desc : Returns the column and value for order
65              
66             =cut
67              
68             sub sortdropdown
69             {
70 8     8 1 32 my ($self, $sort_vals) = @_;
71              
72 8         26 my $data = $sort_vals->{'data'};
73 8         18 my $result;
74 8         24 my $order = "asc";
75              
76 8 50 33     76 if ($data && exists($data->{'path'}) && $data->{'path'}) {
      33        
77              
78 8         40 $result->{'column'} = $data->{'path'};
79 8         40 $result->{'column'} =~ s/\.//;
80              
81 8 50       40 if (exists($data->{'order'})) {
82 8         29 $order = lc($data->{'order'});
83             }
84              
85 8 100       43 $result->{'order'} = ($order eq "desc") ? "desc" : "asc";
86             }
87              
88 8         32 return $result;
89             }
90              
91             # ========================================================================== #
92              
93             =item C<sortselect>
94              
95             Params : sort_vals
96              
97             {
98             'type' => 'sort-select',
99             'action' => 'sort',
100             'inStorage' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),
101             'data' => {
102             'order' => '',
103             'type' => '',
104             'dateTimeFormat' => '{month}/{day}/{year}',
105             'path' => 'default',
106             'ignore' => ''
107             },
108             'isAnimateToTop' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ),
109             'inDeepLinking' => $VAR1->[0]{'inStorage'},
110             'name' => 'sort',
111             'inAnimation' => $VAR1->[0]{'inStorage'}
112             }
113              
114             Returns: Returns the column and value for order
115              
116             Desc : Returns the column and value for order
117              
118             =cut
119              
120             sub sortselect
121             {
122 1     1 1 8 shift->sortdropdown(@_);
123             }
124              
125             1;
126              
127             __END__
128              
129             =back
130            
131             =head1 AUTHORS
132              
133             Sheeju Alex, <sheeju@exceleron.com>
134              
135             =head1 BUGS
136              
137             https://github.com/sheeju/JPList/issues
138              
139             =head1 SUPPORT
140              
141             You can find documentation for this module with the perldoc command.
142              
143             perldoc JPList
144              
145              
146             You can also look for information at:
147              
148             =over 4
149              
150             =item * RT: CPAN's request tracker (report bugs here)
151              
152             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=JPList>
153              
154             =item * AnnoCPAN: Annotated CPAN documentation
155              
156             L<http://annocpan.org/dist/JPList>
157              
158             =item * CPAN Ratings
159              
160             L<http://cpanratings.perl.org/d/JPList>
161              
162             =item * Search CPAN
163              
164             L<http://search.cpan.org/dist/JPList/>
165              
166             =back
167              
168             =head1 ACKNOWLEDGEMENTS
169              
170             Development time supported by Exceleron L<www.exceleron.com|http://www.exceleron.com>.
171              
172             =head1 LICENSE AND COPYRIGHT
173              
174             Copyright (C) 2017 Exceleron Software, LLC
175              
176             This program is free software; you can redistribute it and/or modify it
177             under the terms of the the Artistic License (2.0). You may obtain a
178             copy of the full license at:
179              
180             L<http://www.perlfoundation.org/artistic_license_2_0>
181              
182             Any use, modification, and distribution of the Standard or Modified
183             Versions is governed by this Artistic License. By using, modifying or
184             distributing the Package, you accept this license. Do not use, modify,
185             or distribute the Package, if you do not accept this license.
186              
187             If your Modified Version has been derived from a Modified Version made
188             by someone other than you, you are nevertheless required to ensure that
189             your Modified Version complies with the requirements of this license.
190              
191             This license does not grant you the right to use any trademark, service
192             mark, tradename, or logo of the Copyright Holder.
193              
194             This license includes the non-exclusive, worldwide, free-of-charge
195             patent license to make, have made, use, offer to sell, sell, import and
196             otherwise transfer the Package with respect to any patent claims
197             licensable by the Copyright Holder that are necessarily infringed by the
198             Package. If you institute patent litigation (including a cross-claim or
199             counterclaim) against any party alleging that the Package constitutes
200             direct or contributory patent infringement, then this Artistic License
201             to you shall terminate on the date that such litigation is filed.
202              
203             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
204             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
205             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
206             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
207             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
208             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
209             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
210             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
211              
212             =cut
213              
214             # vim: ts=4
215             # vim600: fdm=marker fdl=0 fdc=3