| 1 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # lib/JPList/Request.pm - JPList Request parser module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2017 Exceleron Software, LLC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package JPList::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | with 'JPList::Controls::Filter'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | with 'JPList::Controls::Sort'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | JPList::Request - JPList Request parser module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | Version 0.05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | use JPList::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | my $jplist_req = JPList::Request->new(request_params => $self->request_params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | The JPList::Request module allows you to decode the request params with all the controls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | =head2 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | has 'request_params' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | isa => 'Str' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | has 'request_data' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | builder => '_decode_request_params', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | clearer => 'clear_request_data' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | has 'filter_attrs' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | isa => 'HashRef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | has 'filter_data' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => 'ArrayRef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | has 'sort_data' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | isa => 'ArrayRef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | has 'pagination_data' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | isa => 'HashRef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | has 'is_download' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =head2 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | =item C<decode_data> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | Params : $statuses_request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Returns: NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | Desc : decode the request params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub decode_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_data: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | ▶ | if (ref($self->request_data) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 8 | $self->_store_status_list($self->request_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =item C<_decode_request_params> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | Params : $self->request_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | Returns: Data structure of formatted request data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | Desc : decode params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub _decode_request_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_request_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 8 | return decode_json(uri_unescape($self->request_params)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =item C<_store_status_list> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Params : Request Data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | Returns: NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Desc : parses the list of unique actions and computes filter, sort and pagination data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | sub _store_status_list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store_status_list: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 8 | my ($self, $statuses_request) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | foreach my $status_req (@$statuses_request) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 71 | my $action = $status_req->{'action'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 71 | push(@{$self->{'status_list'}->{$action}}, $status_req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | $self->_get_filter_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 8 | $self->_get_sort_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | $self->_get_pagination_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ## Clear unwanted attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 8 | $self->clear_request_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | delete($self->{'status_list'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =item C<_get_filter_data> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | Params : NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | Returns: NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | Desc : private function to parse filter data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | sub _get_filter_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_filter_data: called CC=20 SCAR=46.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | my @filter_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # This is used to store the values of filter by column name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # Eg: $jplist->jplist_request->filter_attrs->{'ServiceType'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my %filter_attrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | foreach my $filter_vals (@{$self->{'status_list'}->{'filter'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 40 | ▶ | if ($filter_vals->{'type'} eq 'textbox') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 19 | my $filter_result = $self->textbox($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 19 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | $filter_attrs{$filter_result->{'column'}} = $filter_result->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | elsif ($filter_vals->{'type'} eq 'filter-drop-down') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | my $filter_result = $self->filterdropdown($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $filter_attrs{$filter_result->{'column'}} = $filter_result->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | elsif ($filter_vals->{'type'} eq 'filter-select') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $filter_result = $self->filterselect($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $filter_attrs{$filter_result->{'column'}} = $filter_result->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ($filter_vals->{'type'} eq 'date-picker-range-filter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $filter_result = $self->filterdaterange($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $filter_attrs{$filter_result->{'column'}} = $filter_result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | elsif ($filter_vals->{'type'} eq 'date-picker-filter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $filter_result = $self->filterdatepicker($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $filter_attrs{$filter_result->{'column'}} = $filter_result->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | elsif ($filter_vals->{'type'} eq 'checkbox-group-filter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 14 | my $filter_result = $self->checkboxgroup($filter_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 14 | ▶ | if (defined $filter_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | push(@filter_data, $filter_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $filter_attrs{$filter_result->{'column'}} = $filter_result->{'values'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ▶ | elsif ($filter_vals->{'type'} eq 'button-filter' and $filter_vals->{'name'} eq 'download') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$filter_vals->{"type"} eq "button-filter" and $filter_vals->{"name"} eq "download"
MC/DC0%0/2
$filter_vals->{"type"} eq "button-filter" and $filter_vals->{"name"} eq "download"
$filter_vals->{"type"} eq "button-filter"
$filter_vals->{"name"} eq "download"
Truth table0%0/3
A and B
A= $filter_vals->{"type"} eq "button-filter"B= $filter_vals->{"name"} eq "download"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | print STDERR "[jplist info] download request filter called\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $data = $filter_vals->{'data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ( exists($data->{'filterType'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $data->{"filterType"} and $data->{"filterType"} eq "path" and exists $data->{"path"} and $data->{"path"} eq ".download"
exists $data->{"filterType"} and $data->{"filterType"} eq "path" and exists $data->{"path"}
exists $data->{"filterType"} and $data->{"filterType"} eq "path"
MC/DC0%0/4
exists $data->{"filterType"} and $data->{"filterType"} eq "path" and exists $data->{"path"} and $data->{"path"} eq ".download"
exists $data->{"filterType"}
$data->{"filterType"} eq "path"
exists $data->{"path"}
$data->{"path"} eq ".download"
Truth table0%0/5
A and B and C and D
A= exists $data->{"filterType"}B= $data->{"filterType"} eq "path"C= exists $data->{"path"}D= $data->{"path"} eq ".download"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | and ($data->{'filterType'} eq 'path') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | and exists($data->{'path'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | and ($data->{'path'} eq '.download')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->is_download(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 8 | $self->filter_data(\@filter_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 8 | $self->filter_attrs(\%filter_attrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | =item C<_get_sort_data> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | Params : NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | Returns: NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | Desc : private functiont to parse sort data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | sub _get_sort_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_sort_data: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | my @sort_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | foreach my $sort_vals (@{$self->{'status_list'}->{'sort'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | ▶ | if ($sort_vals->{'type'} eq 'sort-drop-down') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 7 | my $sort_result = $self->sortdropdown($sort_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 7 | push(@sort_data, $sort_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | elsif ($sort_vals->{'type'} eq 'sort-select') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | my $sort_result = $self->sortselect($sort_vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | push(@sort_data, $sort_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 8 | $self->sort_data(\@sort_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # ========================================================================== # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | =item C<_get_pagination_data> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | Params : NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | Returns: NONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | Desc : private functiont to parse pagination data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub _get_pagination_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pagination_data: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | my $pagination_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | foreach my $paging_vals (@{$self->{'status_list'}->{'paging'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 16 | my $data = $paging_vals->{'data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 16 | ▶ | if ($data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 16 | ▶ | if ($data->{'currentPage'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | $pagination_data->{'currentPage'} = $data->{'currentPage'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 16 | ▶ | if ($data->{'number'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 8 | $pagination_data->{'number'} = $data->{'number'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | $self->pagination_data($pagination_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||