line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::RapidApp::RapidDbic::TableBase; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2663
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
121
|
|
4
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
123
|
|
5
|
4
|
|
|
4
|
|
21
|
use Moose; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
extends 'RapidApp::Module::DbicGrid'; |
7
|
|
|
|
|
|
|
with |
8
|
|
|
|
|
|
|
'RapidApp::Module::Grid::Role::ExcelExport', |
9
|
|
|
|
|
|
|
# This is a bit of overlap/entaglement needed for 'NavCore' to be able to |
10
|
|
|
|
|
|
|
# work. However, NavCore is not always enabled, and this role only |
11
|
|
|
|
|
|
|
# enables itself if it is (i.e. Plugin::NavCore is present) |
12
|
|
|
|
|
|
|
'Catalyst::Plugin::RapidApp::NavCore::GridRole' |
13
|
|
|
|
|
|
|
; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#use RapidApp::Module::DbicPropPage; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
23745
|
use RapidApp::Util qw(:all); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
4276
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'page_class', is => 'ro', isa => 'Str', default => 'RapidApp::Module::DbicPropPage'; |
20
|
|
|
|
|
|
|
has 'page_params', is => 'ro', isa => 'HashRef', default => sub {{}}; |
21
|
|
|
|
|
|
|
has 'no_page', is => 'ro', isa => 'Bool', default => 0; |
22
|
|
|
|
|
|
|
has 'source_model', is => 'ro', isa => 'Maybe[Str]', default => undef; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# This is an option of RapidApp::Module::Grid that will allow double-click to open Rows: |
25
|
|
|
|
|
|
|
has '+open_record_class', lazy => 1, default => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
return undef if ($self->no_page); |
28
|
|
|
|
|
|
|
return { |
29
|
|
|
|
|
|
|
class => $self->page_class, |
30
|
|
|
|
|
|
|
params => { |
31
|
|
|
|
|
|
|
ResultSource => $self->ResultSource, |
32
|
|
|
|
|
|
|
get_ResultSet => $self->get_ResultSet, |
33
|
|
|
|
|
|
|
#TableSpec => $self->TableSpec, |
34
|
|
|
|
|
|
|
include_colspec => clone( $self->include_colspec ), |
35
|
|
|
|
|
|
|
updatable_colspec => clone( $self->updatable_colspec ), |
36
|
|
|
|
|
|
|
persist_all_immediately => $self->persist_all_immediately, |
37
|
|
|
|
|
|
|
persist_immediately => $self->persist_immediately, |
38
|
|
|
|
|
|
|
%{ clone( $self->page_params ) } |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has '+include_colspec', default => sub{[qw(*)]}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# default to read-only: |
46
|
|
|
|
|
|
|
has '+updatable_colspec', default => undef; |
47
|
|
|
|
|
|
|
has '+creatable_colspec', default => undef; |
48
|
|
|
|
|
|
|
has '+destroyable_relspec', default => undef; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Note: setting the default individually instead of setting |
51
|
|
|
|
|
|
|
# persist_all_immediately because the latter takes priority |
52
|
|
|
|
|
|
|
# and we want our consumers to be able to set these without |
53
|
|
|
|
|
|
|
# having to also set 'persist_all_immediately => 0' |
54
|
|
|
|
|
|
|
has '+persist_immediately', default => sub {{ |
55
|
|
|
|
|
|
|
create => 1, |
56
|
|
|
|
|
|
|
update => 1, |
57
|
|
|
|
|
|
|
destroy => 1 |
58
|
|
|
|
|
|
|
}}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has '+use_add_form', default => sub { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
# Default to tab unless 'create' is not set to persist_immediately |
63
|
|
|
|
|
|
|
return ( |
64
|
|
|
|
|
|
|
$self->persist_all_immediately || |
65
|
|
|
|
|
|
|
jstrue( $self->persist_immediately->{create} ) |
66
|
|
|
|
|
|
|
) ? 'tab' : undef; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has '+use_edit_form', default => 'window'; |
70
|
|
|
|
|
|
|
has '+use_column_summaries', default => 1; |
71
|
|
|
|
|
|
|
has '+use_autosize_columns', default => 1; |
72
|
|
|
|
|
|
|
has '+auto_autosize_columns', default => 0; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has 'extra_extconfig', is => 'ro', isa => 'HashRef', default => sub {{}}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# This is highly specific to the RapidDbic and NavCore plugins: |
77
|
|
|
|
|
|
|
has '_rapiddbic_default_views_model_name', is => 'ro', isa => 'Maybe[Str]', lazy => 1, default => sub { |
78
|
|
|
|
|
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
my $c = $self->app; |
80
|
|
|
|
|
|
|
my $config = $c->config->{'Plugin::RapidApp::RapidDbic'}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return ( |
83
|
|
|
|
|
|
|
$config->{navcore_default_views} && |
84
|
|
|
|
|
|
|
$c->_navcore_enabled |
85
|
|
|
|
|
|
|
) ? 'RapidApp::CoreSchema::DefaultView' : undef; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub BUILD { |
91
|
|
|
|
|
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->add_plugin('grid-column-properties'); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Init joined columns hidden: |
96
|
|
|
|
|
|
|
$self->apply_columns( $_ => { hidden => \1 } ) |
97
|
|
|
|
|
|
|
for (grep { $_ =~ /__/ } @{$self->column_order}); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $extra_cnf = $self->extra_extconfig; |
100
|
|
|
|
|
|
|
$self->apply_extconfig( %$extra_cnf ) if (keys %$extra_cnf > 0); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# This is highly specific to the RapidDbic and NavCore plugins. Manually load |
105
|
|
|
|
|
|
|
# a saved search if a 'DefaultView' has been specified for this Source/Model in |
106
|
|
|
|
|
|
|
# the CoreSchema database |
107
|
|
|
|
|
|
|
before 'load_saved_search' => sub { (shift)->before_load_saved_search }; |
108
|
|
|
|
|
|
|
sub before_load_saved_search { |
109
|
21
|
|
|
21
|
0
|
42
|
my $self = shift; |
110
|
|
|
|
|
|
|
|
111
|
21
|
50
|
|
|
|
714
|
my $model_name = $self->_rapiddbic_default_views_model_name or return; |
112
|
0
|
|
|
|
|
|
my $Rs = $self->c->model($model_name); |
113
|
0
|
0
|
|
|
|
|
my $DefaultView = $Rs->find($self->source_model) or return; |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
my $SavedState = $DefaultView->view or return; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $state_data = $SavedState->get_column('state_data'); |
118
|
0
|
0
|
0
|
|
|
|
return if (!$state_data || $state_data eq '{}'); |
119
|
0
|
0
|
|
|
|
|
my $search_data = $self->json->decode($state_data) or die usererr "Error deserializing grid_state"; |
120
|
0
|
|
|
|
|
|
$self->apply_to_all_columns( hidden => \1 ); |
121
|
0
|
|
|
|
|
|
return $self->batch_apply_opts_existing($search_data); |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|