Rose-DBx-Object-Renderer
view release on metacpan or search on metacpan
303132333435363738394041424344454647484950
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
26272829303132333435363738394041424344454647our
$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
=>
undef
,
delimiter
=>
', '
,
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
105210531054105510561057105810591060106110621063106410651066106710681069107010711072my
$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
152515261527152815291530153115321533153415351536153715381539154015411542154315441545
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
17801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
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
192419251926192719281929193019311932193319341935193619371938193919401941194219431944
# 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
2740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773
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 )