« blib/lib/Mojolicious/Command/generate/callbackery_app/lib/App/GuiPlugin/SongForm.pm
↑ Summary
lib/CallBackery/Database.pm »
| 1 | package CallBackery::GuiPlugin::AbstractTable; | ||||||||||||||
| 2 | 1 | ▶ | use Carp qw(carp croak); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1 | ▶ | use CallBackery::Translate qw(trm); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | =head1 NAME | ||||||||||||||
| 6 | |||||||||||||||
| 7 | CallBackery::GuiPlugin::AbstractTable - Base Class for a table plugin | ||||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||
| 10 | |||||||||||||||
| 11 | use Mojo::Base 'CallBackery::GuiPlugin::AbstractTable'; | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||
| 14 | |||||||||||||||
| 15 | The base class for reporter reporters. | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =cut | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 1 | ▶ | use Mojo::Base 'CallBackery::GuiPlugin::AbstractForm'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | =head1 ATTRIBUTES | ||||||||||||||
| 22 | |||||||||||||||
| 23 | The attributes of the L<CallBackery::GuiPlugin::AbstractForm> class and these: | ||||||||||||||
| 24 | |||||||||||||||
| 25 | =cut | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 0 | ▶ | has screenCfg => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||
| 29 | 0 | my $screen = $self->SUPER::screenCfg; | |||||||||||||
| 30 | 0 | $screen->{table} = $self->tableCfg; | |||||||||||||
| 31 | 0 | $screen->{type} = 'table'; | |||||||||||||
| 32 | 0 | return $screen; | |||||||||||||
| 33 | 1 | }; | |||||||||||||
| 34 | |||||||||||||||
| 35 | =head2 tableCfg | ||||||||||||||
| 36 | |||||||||||||||
| 37 | a table configuration | ||||||||||||||
| 38 | |||||||||||||||
| 39 | return [ | ||||||||||||||
| 40 | { | ||||||||||||||
| 41 | label => trm('Id'), | ||||||||||||||
| 42 | type => 'number', | ||||||||||||||
| 43 | flex => 1, | ||||||||||||||
| 44 | key => 'id', | ||||||||||||||
| 45 | sortable => true, | ||||||||||||||
| 46 | }, | ||||||||||||||
| 47 | { | ||||||||||||||
| 48 | label => trm('Date'), | ||||||||||||||
| 49 | type => 'str', | ||||||||||||||
| 50 | flex => 2 | ||||||||||||||
| 51 | key => 'date' | ||||||||||||||
| 52 | }, | ||||||||||||||
| 53 | { | ||||||||||||||
| 54 | label => trm('Content'), | ||||||||||||||
| 55 | type => 'str', | ||||||||||||||
| 56 | flex => 8, | ||||||||||||||
| 57 | key => 'date' | ||||||||||||||
| 58 | }, | ||||||||||||||
| 59 | ] | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =cut | ||||||||||||||
| 62 | |||||||||||||||
| 63 | 0 | ▶ | has tableCfg => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 64 | 0 | croak "the plugin must define its tableCfg property"; | |||||||||||||
| 65 | 1 | }; | |||||||||||||
| 66 | |||||||||||||||
| 67 | =head1 METHODS | ||||||||||||||
| 68 | |||||||||||||||
| 69 | All the methods of L<CallBackery::GuiPlugin::AbstractForm> plus: | ||||||||||||||
| 70 | |||||||||||||||
| 71 | =cut | ||||||||||||||
| 72 | |||||||||||||||
| 73 | |||||||||||||||
| 74 | =head2 getData ('tableData|tableRowCount',tableDataRequest); | ||||||||||||||
| 75 | |||||||||||||||
| 76 | Return the requested table data and pass other types of request on to the upper levels. | ||||||||||||||
| 77 | |||||||||||||||
| 78 | =cut | ||||||||||||||
| 79 | |||||||||||||||
| 80 | 0 | ▶ | sub getData { | ||||||||||||
|
Subroutine
getData: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||
| 82 | 0 | ▶ | my $type = shift // ''; | ||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||
| 83 | 0 | ▶ | if ($type eq 'tableData'){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 84 | 0 | return $self->getTableData(@_); | |||||||||||||
| 85 | } | ||||||||||||||
| 86 | elsif ($type eq 'tableRowCount'){ | ||||||||||||||
| 87 | 0 | return $self->getTableRowCount(@_); | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | else { | ||||||||||||||
| 90 | 0 | return $self->SUPER::getData($type,@_); | |||||||||||||
| 91 | } | ||||||||||||||
| 92 | } | ||||||||||||||
| 93 | |||||||||||||||
| 94 | =head2 getTableData({formData=>{},firstRow=>{},lastRow=>{},sortColumn=>'key',sortDesc=>true) | ||||||||||||||
| 95 | |||||||||||||||
| 96 | return data appropriate for the remote table widget | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =cut | ||||||||||||||
| 99 | |||||||||||||||
| 100 | 0 | ▶ | sub getTableData { | ||||||||||||
|
Subroutine
getTableData: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 101 | 0 | return [{}]; | |||||||||||||
| 102 | } | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =head2 getTableRowCount({formData=>{}}) | ||||||||||||||
| 105 | |||||||||||||||
| 106 | return the number of rows matching the given formData | ||||||||||||||
| 107 | |||||||||||||||
| 108 | =cut | ||||||||||||||
| 109 | |||||||||||||||
| 110 | 0 | ▶ | sub getTableRowCount { | ||||||||||||
|
Subroutine
getTableRowCount: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 111 | 0 | return 0; | |||||||||||||
| 112 | } | ||||||||||||||
| 113 | |||||||||||||||
| 114 | 1 | 1; | |||||||||||||
| 115 | __END__ | ||||||||||||||