File Coverage

blib/lib/RapidApp/CoreSchema/Result/SavedState.pm
Criterion Covered Total %
statement 15 21 71.4
branch 0 4 0.0
condition 0 6 0.0
subroutine 5 7 71.4
pod 0 2 0.0
total 20 40 50.0


line stmt bran cond sub pod time code
1             package RapidApp::CoreSchema::Result::SavedState;
2              
3 1     1   588 use strict;
  1         2  
  1         30  
4 1     1   6 use warnings;
  1         3  
  1         30  
5              
6 1     1   5 use Moose;
  1         2  
  1         8  
7 1     1   5909 use MooseX::NonMoose;
  1         2  
  1         9  
8 1     1   4687 use namespace::autoclean;
  1         2  
  1         10  
9             extends 'DBIx::Class::Core';
10              
11             __PACKAGE__->table("saved_state");
12              
13              
14             __PACKAGE__->add_columns(
15             "id",
16             {
17             data_type => "integer",
18             extra => { unsigned => 1 },
19             is_auto_increment => 1,
20             is_nullable => 0,
21             },
22             "title",
23             { data_type => "varchar", is_nullable => 0, size => 255 },
24             "subtitle",
25             { data_type => "varchar", is_nullable => 1, size => 1024 },
26             "node_id",
27             {
28             data_type => "integer",
29             extra => { unsigned => 1 },
30             is_foreign_key => 1,
31             is_nullable => 1,
32             },
33             "user_id" => {
34             data_type => "integer",
35             extra => { unsigned => 1 },
36             is_nullable => 1,
37             },
38             "ordering",
39             { data_type => "integer", default_value => 500001, is_nullable => 0 },
40             "iconcls",
41             { data_type => "varchar", is_nullable => 1, size => 255 },
42             "url",
43             { data_type => "varchar", is_nullable => 0, size => 255 },
44             "params",
45             { data_type => "text", is_nullable => 1 },
46             "state_data",
47             { data_type => "text", is_nullable => 1 },
48             );
49             __PACKAGE__->set_primary_key("id");
50              
51              
52             __PACKAGE__->belongs_to(
53             "node",
54             "RapidApp::CoreSchema::Result::NavtreeNode",
55             { id => "node_id" },
56             {
57             is_deferrable => 1,
58             join_type => "LEFT",
59             on_delete => "CASCADE",
60             on_update => "CASCADE",
61             },
62             );
63              
64             __PACKAGE__->belongs_to(
65             "user",
66             "RapidApp::CoreSchema::Result::User",
67             { id => "user_id" },
68             {
69             is_deferrable => 1,
70             join_type => "LEFT",
71             on_delete => "CASCADE",
72             on_update => "CASCADE",
73             },
74             );
75              
76             sub loadContentCnf {
77 0     0 0   my $self = shift;
78            
79             #my $params = $self->decoded_params;
80             #$params->{search_id} = $self->get_column('id');
81            
82 0           my $url = '/view/' . $self->get_column('id');
83            
84             # New: if there is no state_data or params, use the declared URL outright:
85 0 0 0       $url = $self->url unless($self->params || $self->state_data);
86              
87             return {
88 0           title => $self->title,
89             iconCls => $self->iconcls,
90             autoLoad => {
91             #New REST url:
92             url => $url
93             #url => $self->url,
94             #params => $params,
95             }
96             };
97             }
98              
99              
100             # Called from the tree module to get custom attrs
101             sub customAttrs {
102 0     0 0   my $self = shift;
103            
104             # If there no state_data or params, this this is a 'link' node type, and we return
105             # a packet for 'customAttrs'. See the NavTree grid for additional logic.
106 0 0 0       return $self->params || $self->state_data ? undef : {
107             url => $self->url,
108             iconcls => $self->iconcls
109             }
110             }
111              
112              
113             __PACKAGE__->load_components('+RapidApp::DBIC::Component::TableSpec');
114             __PACKAGE__->apply_TableSpec;
115              
116             __PACKAGE__->TableSpec_set_conf(
117             title => 'Saved View',
118             title_multi => 'Saved Views',
119             iconCls => 'ra-icon-data-view',
120             multiIconCls => 'ra-icon-data-views',
121             display_column => 'title',
122             auto_editor_type => 'grid'
123             );
124              
125             __PACKAGE__->TableSpec_set_conf('column_properties_ordered',
126              
127             id => { no_column => \1, no_multifilter => \1, no_quick_search => \1 },
128             node_id => { no_column => \1, no_multifilter => \1, no_quick_search => \1 },
129             user_id => { no_column => \1, no_multifilter => \1, no_quick_search => \1 },
130            
131             title => {
132             header => 'View Name/Title',
133             width => 170,
134             },
135            
136             subtitle => {
137             header => 'Subtitle',
138             width => 225,
139             hidden => \1
140             },
141            
142             ordering => {
143             header => 'Order Num',
144             hidden => 1
145             },
146            
147             iconcls => {
148             width => 110,
149             header => 'Icon Class',
150             },
151            
152             url => {
153             width => 150,
154             header => 'Url',
155             allow_edit => \0
156             },
157            
158             params => {
159             width => 250,
160             header => 'Params',
161             renderer => 'Ext.ux.RapidApp.renderJSONjsDump',
162             hidden => \1,
163             allow_edit => \0,
164             allow_view => \1
165             },
166            
167             state_data => {
168             width => 250,
169             header => 'State Data',
170             renderer => 'Ext.ux.RapidApp.renderJSONjsDump',
171             #allow_edit => \0,
172             hidden => \1
173             },
174            
175             node => {
176             width => 175,
177             header => 'Navtree Parent Node',
178             },
179            
180             user => {
181             width => 130,
182             header => 'User',
183             },
184            
185             );
186              
187              
188             # You can replace this text with custom content, and it will be preserved on regeneration
189             __PACKAGE__->meta->make_immutable;
190             1;