File Coverage

blib/lib/RapidApp/CoreSchema/Result/NavtreeNode.pm
Criterion Covered Total %
statement 18 22 81.8
branch 0 2 0.0
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 25 32 78.1


line stmt bran cond sub pod time code
1             package RapidApp::CoreSchema::Result::NavtreeNode;
2              
3 1     1   632 use strict;
  1         3  
  1         29  
4 1     1   5 use warnings;
  1         2  
  1         29  
5              
6 1     1   5 use Moose;
  1         2  
  1         9  
7 1     1   6023 use MooseX::NonMoose;
  1         3  
  1         8  
8 1     1   4702 use namespace::autoclean;
  1         2  
  1         11  
9             extends 'DBIx::Class::Core';
10              
11             __PACKAGE__->table("navtree_node");
12              
13             __PACKAGE__->add_columns(
14             "id",
15             {
16             data_type => "integer",
17             extra => { unsigned => 1 },
18             is_auto_increment => 1,
19             is_nullable => 0,
20             },
21             "pid",
22             {
23             data_type => "integer",
24             default_value => 0,
25             extra => { unsigned => 1 },
26             is_foreign_key => 1,
27             is_nullable => 1,
28             },
29             "text",
30             { data_type => "varchar", is_nullable => 0, size => 255 },
31             "iconcls",
32             { data_type => "varchar", is_nullable => 1, size => 255 },
33             "expanded",
34             { data_type => "tinyint", is_nullable => 1 },
35             "ordering",
36             { data_type => "integer", default_value => 500000, is_nullable => 0 },
37             );
38             __PACKAGE__->set_primary_key("id");
39              
40              
41             __PACKAGE__->belongs_to(
42             "pid",
43             "RapidApp::CoreSchema::Result::NavtreeNode",
44             { id => "pid" },
45             {
46             is_deferrable => 1,
47             join_type => "LEFT",
48             on_delete => "CASCADE",
49             on_update => "CASCADE",
50             },
51             );
52              
53              
54             __PACKAGE__->has_many(
55             "navtree_nodes",
56             "RapidApp::CoreSchema::Result::NavtreeNode",
57             { "foreign.pid" => "self.id" },
58             { cascade_copy => 0, cascade_delete => 0 },
59             );
60              
61              
62             __PACKAGE__->has_many(
63             "navtree_node_to_roles",
64             "RapidApp::CoreSchema::Result::NavtreeNodeToRole",
65             { "foreign.node_id" => "self.id" },
66             { cascade_copy => 0, cascade_delete => 0 },
67             );
68              
69              
70             __PACKAGE__->has_many(
71             "saved_states",
72             "RapidApp::CoreSchema::Result::SavedState",
73             { "foreign.node_id" => "self.id" },
74             { cascade_copy => 0, cascade_delete => 0 },
75             );
76              
77 1     1   209 use RapidApp::Util qw(:all);
  1         3  
  1         735  
78              
79             sub update {
80 0     0 1   my $self = shift;
81              
82             # Fail-safe: prevent changes to the 'DUMMY ROOT NODE' (id 0)
83 0 0         if ($self->get_column('id') == 0) {
84             #warn RED.BOLD "Tried to call update() on the DUMMY ROOT NODE." . CLEAR;
85             # Updated: The 'Organize Tree' section is known to try to update the dummy root
86             # node which is a harmless side-effect which we are just silently ignoring.
87             # TODO: investigate the real reason and fix properly
88 0           return undef;
89             }
90              
91 0           return $self->next::method(@_);
92             }
93              
94              
95             __PACKAGE__->load_components('+RapidApp::DBIC::Component::TableSpec');
96             __PACKAGE__->TableSpec_m2m( roles => 'navtree_node_to_roles', 'role' );
97             __PACKAGE__->apply_TableSpec;
98              
99             __PACKAGE__->TableSpec_set_conf(
100             title => 'Navtree Node',
101             title_multi => 'Navtree Nodes',
102             iconCls => 'ra-icon-folder',
103             multiIconCls => 'ra-icon-folders',
104             display_column => 'text'
105             );
106              
107              
108             __PACKAGE__->TableSpec_set_conf('column_properties_ordered',
109              
110             pid => { no_column => \1, no_multifilter => \1, no_quick_search => \1 },
111             navtree_node_to_roles => { no_column => \1, no_multifilter => \1, no_quick_search => \1 },
112            
113             id => {
114             header => 'Id',
115             width => 55,
116             allow_edit => \0,
117             allow_add => \0
118             },
119              
120             text => {
121             header => 'Text',
122             width => 200,
123             allow_edit => \0
124             },
125            
126             iconcls => {
127             header => 'Icon Cls',
128             width => 150,
129             #allow_edit => \0,
130             hidden => \1,
131             editor => { xtype => 'ra-all-icon-assets-combo', }
132             },
133            
134             expanded => {
135             header => 'Expanded',
136             width => 70,
137             allow_edit => \0,
138             hidden => \1
139             },
140            
141             ordering => {
142             header => 'Ordering',
143             width => 80,
144             },
145            
146             navtree_nodes => {
147             header => 'Child Nodes',
148             width => 120
149             },
150            
151             saved_states => {
152             header => 'Searches',
153             width => 140
154             },
155            
156             roles => {
157             header => 'Limit Roles',
158             width => 200
159             }
160            
161             );
162              
163              
164              
165             # You can replace this text with custom code or comments, and it will be preserved on regeneration
166             __PACKAGE__->meta->make_immutable;
167             1;