blib/lib/CallBackery/GuiPlugin/AbstractCardlist.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 72 CC 4 SCAR 15.9
CC
4
Cov
0%
getData
12.0
getAllCardData
6.0
allCardData
2.0
CRAP 4.9
1 package CallBackery::GuiPlugin::AbstractCardlist;
2 use Carp qw(carp croak);
3 use CallBackery::Translate qw(trm);
4 use CallBackery::Exception qw(mkerror);
5 use Mojo::JSON qw(true false);
6 use POSIX qw(strftime);
7  
8 =head1 NAME
9  
10 CallBackery::GuiPlugin::AbstractCardlist - Base class for a cardlist plugin
11  
12 =head1 SYNOPSIS
13  
14 use Mojo::Base 'CallBackery::GuiPlugin::AbstractCardlist';
15  
16 =head1 DESCRIPTION
17  
18 The base class for cardlist plugins, derived from CallBackery::GuiPlugin::AbstractTable
19  
20 =cut
21  
22 use Mojo::Base 'CallBackery::GuiPlugin::AbstractTable';
23  
24 =head1 ATTRIBUTES
25  
26 The attributes of the L<CallBackery::GuiPlugin::AbstractTable> class and these:
27  
28 =cut
29  
30 has screenCfg => sub {
31 my $self = shift;
32 my $screen = $self->SUPER::screenCfg;
33 $screen->{type} = 'cardlist';
34 $screen->{updateAction} = 'updateCard';
35 $screen->{cardCfg} = $self->cardCfg;
36 return $screen;
37 };
38  
39 =head2 cardCfg
40  
41 Configuration of the card list cards
42  
43 return [
44 layout => {
45 class => 'qx.ui.layout.Grid',
46 setFunctions => {
47 setColumnFlex => [
48 [ 0, 1 ],
49 [ 5, 1 ],
50 ],
51 setColumnWidth => [
52 [ 5, 200 ],
53 ],
54 setColumnAlign => [
55 [ 5, 'right', 'bottom' ],
56 ],
57 setSpacingX => [ [20], ],
58 setSpacingY => [ [3], ],
59 },
60 },
61 form => [
62 {
63 label => {
64 addSet => { row => 0, column => 0, },
65 set => {
66 value => trm('Type'),
67 },
68 },
69 field => {
70 addSet => { row => 1, column => 0, },
71 class => 'qx.ui.form.TextField',
72 key => 'oatkg_label',
73 set => { width => 100, readOnly => true },
74 },
75 },
76 ],
77 ];
78  
79 =cut
80  
81 has cardCfg => sub {
82 die mkerror(3456, trm("cardCfg must be defined in child plugin class"));
83 };
84  
85 =head2 tableCfg
86  
87 is not used for card plugins, use cardCfg instead.
88  
89 =cut
90  
91 has 'tableCfg';
92  
93 =head1 METHODS
94  
95 All the methods of L<CallBackery::GuiPlugin::AbstractTable> plus:
96  
97 =cut
98  
99 =head2 getData ('allCardData');
100  
101 Return the requested card data and pass other types of request on to the upper levels.
102  
103 allCardData() can either return an array ref of card data or a hash ref
104  
105 {
106 data => [], # card data
107 info => {}, # Qooxdoo qx.ui.basic.Label properties
108 }
109  
110 in which case a label is shown between the action toolbar and the card list.
111 Sending an undefined info entry removes the label.
112  
113 =cut
114  
115 sub getData {
116 my $self = shift;
117 my $call = shift // '';
118  
119 if ($call eq 'getAllCardData') {
120 my $parentFormData = shift;
121 return $self->getAllCardData($parentFormData, @_);
122 }
123 elsif ($call eq 'allCardData') {
124 # backward compatibility with previously broken CardList.js implementation
125 $self->log->warn("allCardData() is deprecated, use getAllCardData() instead");
126 return $self->allCardData(@_);
127 }
128 else {
129 return $self->SUPER::getData($call, @_);
130 }
131 }
132  
133  
134 =head2 getAllCardData(parentFormData, { currentFormData => data }, @_)
135  
136 return data appropriate for the card list widget
137  
138 =cut
139  
140 sub getAllCardData {
141 my $self = shift;
142 state $warned = 0;
143 if (not $warned) {
144 $self->log->warn("getAllCardData() must be overridden");
145 $self->log->warn("Calling deprecated method allCardData(), you should use getAllCardData() instead.");
146 $warned = 1;
147 }
148 return $self->allCardData(@_);
149 }
150  
151  
152 =head2 allCardData()
153  
154 deprecated, return data appropriate for the card list widget
155  
156 =cut
157  
158 sub allCardData {
159 my $self = shift;
160 $self->log->warn("allCardData() is deprecated, use getAllCardData() instead");
161 return [{}];
162 }
163  
164  
165 =head2 makeExportAction(type => 'XLSX', filename => 'export-"now"', label => 'Export')
166  
167 Create export button. Not yet implemented for card plugins.
168  
169 =cut
170  
171 sub makeExportAction {
172 die mkerror(999, "makeExportAction() not yet implemented for card plugins");
173 }
174  
175 1;
176 __END__