line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RapidApp::Module::DbicGrid; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2304
|
use strict; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
122
|
|
4
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
20
|
use Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
extends 'RapidApp::Module::Grid'; |
8
|
|
|
|
|
|
|
with 'RapidApp::Module::StorCmp::Role::DbicLnk'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
25507
|
use RapidApp::Util qw(:all); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
4773
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'show_base_conditions_in_header', is => 'ro', isa => 'Bool', default => 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# This property defines whether or not the 'Cell Editing' toggle button should start |
15
|
|
|
|
|
|
|
# in the 'Off' or 'On' position. This only applies when the grid is initialized with |
16
|
|
|
|
|
|
|
# a top toolbar, so there is a place to render the button, and also when the plugin |
17
|
|
|
|
|
|
|
# grid-toggle-edit-cells is loaded (which it is, by default) |
18
|
|
|
|
|
|
|
has 'toggle_edit_cells_init_off', default => sub { |
19
|
|
|
|
|
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
# By default, we will initialize with 'Cell Editing Off' as long as there |
21
|
|
|
|
|
|
|
# is both an open_record_url and the grid uses the add form. Unless both |
22
|
|
|
|
|
|
|
# of these conditions are true, we initialize with 'Cell Editing On' |
23
|
|
|
|
|
|
|
return $self->use_add_form && $self->open_record_url ? 1 : 0; |
24
|
|
|
|
|
|
|
}, is => 'ro', isa => 'Bool', lazy => 1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Initial state for the total count toggle - See GitHub Issue #168 |
28
|
|
|
|
|
|
|
has 'init_total_count_off', is => 'ro', isa => 'Bool', default => 0, traits => ['ExtProp']; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILD { |
31
|
|
|
|
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ($self->updatable_colspec) { |
34
|
|
|
|
|
|
|
$self->apply_extconfig( |
35
|
|
|
|
|
|
|
xtype => 'appgrid2ed', |
36
|
|
|
|
|
|
|
clicksToEdit => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# allow toggling |
40
|
|
|
|
|
|
|
$self->add_plugin('grid-toggle-edit-cells'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->apply_extconfig( |
44
|
|
|
|
|
|
|
use_multifilters => \1, |
45
|
|
|
|
|
|
|
gridsearch_remote => \1, |
46
|
|
|
|
|
|
|
setup_bbar_store_buttons => \1, |
47
|
|
|
|
|
|
|
toggle_edit_cells_init_off => $self->toggle_edit_cells_init_off ? \1 : \0, |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Sane default for the add button/tab: |
50
|
|
|
|
|
|
|
store_button_cnf => { |
51
|
|
|
|
|
|
|
add => { |
52
|
|
|
|
|
|
|
text => 'Add ' . $self->ResultClass->TableSpec_get_conf('title'), |
53
|
|
|
|
|
|
|
iconCls => 'ra-icon-add' |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->apply_default_tabtitle; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# New AppGrid2 nav feature. Need to always fetch the column to use for grid nav (open) |
61
|
|
|
|
|
|
|
push @{$self->always_fetch_columns}, $self->open_record_rest_key |
62
|
|
|
|
|
|
|
if ($self->open_record_rest_key); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has '+open_record_rest_key', default => sub { |
67
|
|
|
|
|
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
return try{$self->ResultClass->TableSpec_get_conf('rest_key_column')}; |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub apply_default_tabtitle { |
72
|
47
|
|
|
47
|
0
|
106
|
my $self = shift; |
73
|
|
|
|
|
|
|
# ---- apply default tab title and icon: |
74
|
47
|
|
|
|
|
1409
|
my $class = $self->ResultClass; |
75
|
|
|
|
|
|
|
|
76
|
47
|
|
33
|
11
|
|
391
|
my $title = try{$class->TableSpec_get_conf('title_multi')} || try{$class->_table_name_safe}; |
|
11
|
|
|
25
|
|
397
|
|
|
36
|
|
|
|
|
1192
|
|
77
|
|
|
|
|
|
|
|
78
|
47
|
|
|
47
|
|
971
|
my $iconCls = try{$class->TableSpec_get_conf('multiIconCls')}; |
|
47
|
|
|
|
|
1190
|
|
79
|
47
|
50
|
|
|
|
2410
|
$self->apply_extconfig( tabTitle => $title ) if ($title); |
80
|
47
|
50
|
|
|
|
2008
|
$self->apply_extconfig( tabIconCls => $iconCls ) if ($iconCls); |
81
|
|
|
|
|
|
|
# ---- |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Show that a base condition is in effect in the panel header, unless |
85
|
|
|
|
|
|
|
# the panel header is already set. This is to help users to remember |
86
|
|
|
|
|
|
|
# that a given grid was followed from a multi-rel column, for instance |
87
|
|
|
|
|
|
|
# TODO: better styling |
88
|
|
|
|
|
|
|
around 'content' => sub { |
89
|
|
|
|
|
|
|
my $orig = shift; |
90
|
|
|
|
|
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $ret = $self->$orig(@_); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
if($self->show_base_conditions_in_header) { |
95
|
|
|
|
|
|
|
my $bP = try{$ret->{store}->parm->{baseParams}} || {}; |
96
|
|
|
|
|
|
|
if ($bP->{resultset_condition}) { |
97
|
|
|
|
|
|
|
my $cls = 'blue-text'; |
98
|
|
|
|
|
|
|
$ret->{tabTitleCls} = $cls; |
99
|
|
|
|
|
|
|
$ret->{headerCfg} ||= { |
100
|
|
|
|
|
|
|
tag => 'div', |
101
|
|
|
|
|
|
|
cls => 'panel-borders ra-footer', |
102
|
|
|
|
|
|
|
style => 'padding:3px;', |
103
|
|
|
|
|
|
|
html => join('', |
104
|
|
|
|
|
|
|
'<i><span class="',$cls,'">', |
105
|
|
|
|
|
|
|
'<b>Base Condition:</b></span> ', |
106
|
|
|
|
|
|
|
$bP->{resultset_condition},'</i>' |
107
|
|
|
|
|
|
|
) |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
elsif($bP->{rs_path} && $bP->{rs_method}){ |
111
|
|
|
|
|
|
|
my ($pth,$ourPth) = ($bP->{rs_path},$self->module_path); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#http://stackoverflow.com/a/9114752 |
114
|
|
|
|
|
|
|
"$pth\0$ourPth" =~ m/^([^\0]*)(?>[^\0]*)\0\1/s; |
115
|
|
|
|
|
|
|
$pth =~ s/^${1}//; #<-- make the path relative to us for nice display |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $cls = 'blue-text'; |
118
|
|
|
|
|
|
|
$ret->{tabTitleCls} = $cls; |
119
|
|
|
|
|
|
|
$ret->{headerCfg} ||= { |
120
|
|
|
|
|
|
|
tag => 'div', |
121
|
|
|
|
|
|
|
cls => 'panel-borders ra-footer', |
122
|
|
|
|
|
|
|
style => 'padding:3px;', |
123
|
|
|
|
|
|
|
html => join('', |
124
|
|
|
|
|
|
|
'<i><span class="',$cls,'">', |
125
|
|
|
|
|
|
|
'<b>ResultSet:</b></span> [', |
126
|
|
|
|
|
|
|
$pth,']: ',$bP->{rs_method},'</i>' |
127
|
|
|
|
|
|
|
) |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return $ret; |
133
|
|
|
|
|
|
|
}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#### --------------------- #### |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
4
|
|
|
4
|
|
35
|
no Moose; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
28
|
|
143
|
|
|
|
|
|
|
#__PACKAGE__->meta->make_immutable; |
144
|
|
|
|
|
|
|
1; |