Rose-DBx-Object-Renderer

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        Fixed a bug where the 'time' and 'date' column values cannot be emptied in render_as_form().
        Added the 'searchable => 1' support to render_as_table(), and render_as_menu().
        Improved 'class_prefix' generation for SQLite.
        Fixed a bug in render_as_table() when including non-character based columns from SQLite in keyword searches.
        Updated the column definitions for 'date', 'datetime' to allow editing and searching in YYYY-MM-DD.
        Updated the regular expression validation for file-related columns.
        Updated the 'for_view' method for the 'money' column definition.
        Minor UI updates to render_as_table() and to the default 'table.tt'.
        Relaxed the default validation regular expression in the 'image' column definition.
        Added the 'template_options' option to render_as_form() and allowed global template options in the default config.
        Added the 'cascade' option to 'table' and 'menu' option into the default config.
        Added the alias 'web' to the 'url' column definition.
        Add the 'query' parameter to all rendering methods to specify the CGI query object.
        RENAMED the 'inherit_form_options' option (introduced in 0.68) to 'form_options' in the default config.
        Added the 'preload="none"' HTML5 attribute to the 'audio' and 'video' for view methods.
        Added the ability to remove uploaded files in render_as_form().
        Added the 'remove_files' option to the default config() hash. Added the 'remove' formatting method to file type columns.
        Code refactoring.
        Added tests.
        Updated POD.
0.73    13/07/2010

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
our $VERSION = 0.77;
# 264.65
 
sub _config {
        my $config = {
                db => {name => undef, type => 'mysql', host => '127.0.0.1', port => undef, username => 'root', password => 'root', tables_are_singular => undef, table_prefix => undef, new_or_cached => 1, check_class => undef},
                template => {path => 'templates', url => 'templates', options => undef},
                upload => {path => 'uploads', url => 'uploads', keep_old_files => undef},
                form => {download_message => 'View', remove_message => 'Remove', remove_files => undef, cancel => 'Cancel', delimiter => ',', action => undef},
                table => {search_result_title => 'Search Results for "[% q %]"', empty_message => 'No Record Found.', no_pagination => undef, per_page => 15, pages => 9, or_filter => undef, like_filter => undefdelimiter => ', ', keyword_delimiter => ',', , like...
                menu => {cascade => ['create', 'edit', 'copy', 'delete', 'ajax', 'prepared', 'searchable', 'template_url', 'template_path', 'template_options', 'query', 'renderer_config']},
                misc => {time_zone => 'Australia/Sydney', stringify_delimiter => ' ', doctype => '<!DOCTYPE HTML>', html_head => '<style type="text/css">body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;paddi...
                columns => {
                        'integer' => {validate => 'INT', sortopts => 'NUM'},
                        'numeric' => {validate => 'NUM', sortopts => 'NUM'},
                        'float' => {validate => 'FLOAT', sortopts => 'NUM'},
                        'text' => {type => 'textarea', cols => '55', rows => '10'},
                        'postcode' => {sortopts => 'NUM', validate => '/^\d{3,4}$/', maxlength => 4},
                        'address' => {format => {for_view => sub {_view_address(@_);}}},
                        'date' => {class => 'date', validate => '/^(0?[1-9]|[1-2][0-9]|3[0-1])\/(0?[1-9]|1[0-2])\/[0-9]{4}|([0-9]{4}\-0?[1-9]|1[0-2])\-(0?[1-9]|[1-2][0-9]|3[0-1])$/', format => {for_edit => sub {_edit_date(@_);}, for_update => sub {_update_date(@_);}, for...
                        'datetime' => {validate => '/^(0?[1-9]|[1-2][0-9]|3[0-1])\/(0?[1-9]|1[0-2])\/[0-9]{4}|([0-9]{4}\-0?[1-9]|1[0-2])\-(0?[1-9]|[1-2][0-9]|3[0-1])\s+[0-9]{1,2}:[0-9]{2}$/', format => {for_edit => sub{_edit_datetime(@_);}, for_view => sub{_view_datetime...

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
my $valid_form_actions = {create => undef, edit => undef, copy => undef};
my $action = $query->param($param_list->{action});
 
if (exists $valid_form_actions->{$action} && $args{$action}) {
        $args{$action} = {} if $args{$action} == 1;
        $args{$action}->{output} = 1;
         
        $args{$action}->{no_head} = $args{no_head} if exists $args{no_head} && ! exists $args{$action}->{no_head};
        $args{$action}->{prepared} = $args{prepared} if exists $args{prepared} && ! exists $args{$action}->{prepared};
         
        _cascade($table_config->{cascade}, \%args, $args{$action});
         
        foreach my $option (@{$table_config->{form_options}}) {
                _inherit_form_option($option, $action, \%args);
        }
                                         
        $args{$action}->{order} ||= Clone::clone($args{order}) if $args{order};
        $args{$action}->{template} ||= _template($args{template}, 'form', 1) if $args{template};
         
        @{$args{$action}->{queries}}{keys %{$args{queries}}} = values %{$args{queries}};
        $args{$action}->{queries}->{$param_list->{action}} = $action;

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
                if ($args{template} && ! exists $options->{template}) {
                        if (ref $args{template} eq 'HASH') {
                                $options->{template} = $args{template};
                        }
                        else {
                                $options->{template} = 1;
                        }
                }
                 
                _cascade($menu_config->{cascade}, \%args, $options);
                 
                foreach my $shortcut (@{$menu_config->{shortcuts}}) {
                        $options->{$shortcut} = 1 if $args{$shortcut} && ! exists $options->{$shortcut};
                }
                 
                $options->{no_head} = 1;
                $output->{table} = "$item\::Manager"->render_as_table(%{$options});
                $menu_title ||= $items->{$item}->{label};
        }
}

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
                        return $output;
                }
                else {
                        return $template->process($args{file},$args{data});
                }
        }
}
 
# util
 
sub _cascade {
        my ($cascade, $args, $options) = @_;
        foreach my $option (@{$cascade}) {
                $options->{$option} = $args->{$option} if defined $args->{$option} && ! defined $options->{$option};
        }
        return;
}
 
sub _ui_config {
        my ($ui_type, $renderer_config, $args) = @_;
        my $ui_config;
        foreach my $option (keys %{$renderer_config->{$ui_type}}) {
                if (defined $args->{$option}) {

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
                         # many to many
                        $self->$column(@{$new_foreign_object_id_hash});
                }
        }
        else {
                if ($relationships->{$column}->{type} eq 'one to many') {
                        Rose::DB::Object::Manager->update_objects(object_class => $foreign_class, set => {$foreign_key => $default}, where => [$foreign_key => $self->$primary_key]);
                }
                else {
                        # many to many
                        $self->$column([]); # cascade deletes foreign objects
                }
        }
}
else {
        my $update_method;
        if ($class->can($column . '_for_update')) {
                $update_method = $column . '_for_update';
        }
        elsif ($class->can($column)) {
                $update_method = $column;

lib/Rose/DBx/Object/Renderer.pm  view on Meta::CPAN

2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
      search_result_title => 'Looking for "[% q %]"?',
      empty_message => 'No matching records.',
      per_page => 25,  # number of records per table, defaulted to 15
      pages => 5,  # the amount of page numbers in the table pagination, defaulted to 9
      no_pagination => 1,  # do not display pagination, defaulted to undef
      or_filter => 1,  # column filtering is joined by 'OR', defaulted to undef
      delimiter => '/'# the delimiter for joining foreign objects in relationship columns, defaulted to ', '
      keyword_delimiter => '\s+'# the delimiter for search keywords, defaulted to ','
      like_operator => 'like', # only applicable to Postgres, defaulted to undef, i.e. render_as_table() uses 'ilike' for Postgres by default
      form_options => ['order', 'template'], # options to be shared by other forms, defaulted to ['before', 'order', 'fields', 'template']
      cascade => ['template_data', 'extra'], # options to be cascaded into all forms, defaulted to ['template_url', 'template_path', 'template_options', 'query', 'renderer_config', 'prepared']
    },
  });
 
These options can be also passed to C<render_as_table> directly to affect only the particular instance.
 
=head3 C<menu>
 
The C<menu> option defines the global default behaviours of C<render_as_menu>:
 
  $renderer->config({
    ...
    menu => {
      cascade => ['template_data', 'extra'], # options to be cascaded into all tables, defaulted to ['create', 'edit', 'copy', 'delete', 'ajax', 'prepared', 'searchable', 'template_url', 'template_path', 'template_options', 'query', 'renderer_config'...
    },
  });
 
These options can be also passed to C<render_as_menu> directly to affect only the particular instance.
 
=head3 C<columns>
 
Renderer has a built-in list of column definitions that encapsulate web conventions and behaviours. A column definition is a collection of column options. Column definitions are used by the rendering methods to generate web UIs. The built-in column d...
 
  my $config = $renderer->config();



( run in 0.272 second using v1.01-cache-2.11-cpan-26ccb49234f )