[Jifty-commit] r6242 - in jifty/trunk: lib/Jifty/View/Declare
Jifty commits
jifty-commit at lists.jifty.org
Wed Jan 14 15:09:17 EST 2009
Author: alexmv
Date: Wed Jan 14 15:09:16 2009
New Revision: 6242
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
Log:
r40948 at kohr-ah: chmrr | 2009-01-14 14:48:26 -0500
* Perltidy, small additional POD
Modified: jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/CRUD.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/CRUD.pm Wed Jan 14 15:09:16 2009
@@ -244,30 +244,41 @@
return $record;
}
-=head2 display_columns
+=head2 display_columns ACTION
-Returns a list of all the columns that this REST view should display
+Returns a list of all the column names that this REST view should
+display. Defaults to all argument names for the provided C<ACTION>.
=cut
sub display_columns {
my $self = shift;
my $action = shift;
- return $action->argument_names;
- #return grep { !( m/_confirm/ || $action->arguments->{$_}{unreadable} ) } $action->argument_names;
+ return $action->argument_names;
}
+=head2 edit_columns ACTION
+
+Returns a list of all the columns that this REST view should display
+for update. Defaults to the L</display_columns>, without C<id>.
+
+=cut
sub edit_columns {
my $self = shift;
return grep { $_ ne 'id' } $self->display_columns(@_);
}
+=head2 create_columns ACTION
+
+Returns a list of all of the columns that this REST view should
+displat for create. Defaults to L</edit_columns>.
+
+=cut
+
sub create_columns {
my $self = shift;
return $self->edit_columns(@_);
-
-
}
@@ -286,7 +297,8 @@
form {
render_region(
name => $self->object_type.'-list',
- path => $self->fragment_base_path.'/list');
+ path => $self->fragment_base_path.'/list'
+ );
}
};
@@ -341,7 +353,7 @@
div {
{ class is 'crud read item inline' };
my @fields = $self->display_columns($update);
- foreach my $field (@fields) {
+ for my $field (@fields) {
div { { class is 'view-argument-'.$field};
render_param( $update => $field, render_mode => 'read' );
};
@@ -420,39 +432,38 @@
my $delete = $record->as_delete_action(
moniker => 'delete-' . Jifty->web->serial,
);
- div {
- { class is 'crud editlink' };
- hyperlink(
- label => _("Save"),
- onclick => [
- { submit => $update },
- { replace_with => $self->fragment_for('view'),
- args => { object_type => $object_type, id => $id }
- }
- ]
- );
- hyperlink(
- label => _("Cancel"),
+ div {
+ { class is 'crud editlink' };
+ hyperlink(
+ label => _("Save"),
+ onclick => [
+ { submit => $update },
+ { replace_with => $self->fragment_for('view'),
+ args => { object_type => $object_type, id => $id }
+ }
+ ]
+ );
+ hyperlink(
+ label => _("Cancel"),
+ onclick => {
+ replace_with => $self->fragment_for('view'),
+ args => { object_type => $object_type, id => $id }
+ },
+ as_button => 1,
+ class => 'cancel'
+ );
+ if ( $record->current_user_can('delete') ) {
+ $delete->button(
+ label => _('Delete'),
onclick => {
- replace_with => $self->fragment_for('view'),
- args => { object_type => $object_type, id => $id }
+ submit => $delete,
+ confirm => _('Really delete?'),
+ refresh => Jifty->web->current_region->parent,
},
- as_button => 1,
- class => 'cancel'
+ class => 'delete'
);
- if ( $record->current_user_can('delete') ) {
- $delete->button(
- label => _('Delete'),
- onclick => {
- submit => $delete,
- confirm => _('Really delete?'),
- refresh => Jifty->web->current_region->parent,
- },
- class => 'delete'
- );
- }
- };
-
+ }
+ };
};
=head2 list
@@ -469,14 +480,14 @@
my $sort_by = get ('sort_by') || '';
my $order = get ('order') || '';
my $collection = $self->_current_collection();
- div { {class is 'crud-'.$self->object_type};
-
- show('./search_region');
- show( './paging_top', $collection, $page );
- show( './sort_header', $item_path, $sort_by, $order );
- show( './list_items', $collection, $item_path );
- show( './paging_bottom', $collection, $page );
- show( './new_item_region');
+ div {
+ {class is 'crud-'.$self->object_type };
+ show('./search_region');
+ show( './paging_top', $collection, $page );
+ show( './sort_header', $item_path, $sort_by, $order );
+ show( './list_items', $collection, $item_path );
+ show( './paging_bottom', $collection, $page );
+ show( './new_item_region');
};
};
@@ -534,29 +545,34 @@
my $record_class = $self->record_class;
my $create = $record_class->as_create_action;
- div { { class is "jifty_admin_header"};
- foreach my $argument ($create->argument_names) {
- next if $create->arguments->{$argument}{unreadable};
- my $css_class = ($sort_by && !$order && $sort_by eq $argument)?'up_select':'up';
- span { {class is $css_class };
- hyperlink(
- label => _("asc"),
- onclick =>
- { args => { sort_by => $argument, order => undef } }
- )
- };
- $css_class = ($sort_by && $order && $sort_by eq $argument)?'down_select':'down' ;
- span { {class is $css_class };
- hyperlink(
- label => _("desc"),
- onclick =>
- { args => { sort_by => $argument, order => 'D' } }
- )
- };
- span{ {class is "field"};
- outs $create->arguments->{$argument}{label} || $argument; };
- };
- hr {};
+ div {
+ { class is "jifty_admin_header" };
+ for my $argument ($self->display_columns($create)) {
+ next if $create->arguments->{$argument}{unreadable};
+ my $css_class = ($sort_by && !$order && $sort_by eq $argument)?'up_select':'up';
+ span {
+ { class is $css_class };
+ hyperlink(
+ label => _("asc"),
+ onclick =>
+ { args => { sort_by => $argument, order => undef } },
+ );
+ };
+ $css_class = ($sort_by && $order && $sort_by eq $argument)?'down_select':'down' ;
+ span {
+ { class is $css_class };
+ hyperlink(
+ label => _("desc"),
+ onclick =>
+ { args => { sort_by => $argument, order => 'D' } },
+ );
+ };
+ span{
+ {class is "field"};
+ outs $create->arguments->{$argument}{label} || $argument;
+ };
+ };
+ hr {};
};
};
@@ -774,11 +790,12 @@
private template 'create_item' => sub {
my $self = shift;
my $action = shift;
- foreach my $field ($self->create_columns($action)) {
- div { { class is 'create-argument-'.$field}
- render_param($action, $field) ;
+ for my $field ($self->create_columns($action)) {
+ div {
+ { class is 'create-argument-'.$field};
+ render_param($action, $field);
}
- }
+ }
};
=head2 edit_item $action
@@ -790,11 +807,12 @@
private template 'edit_item' => sub {
my $self = shift;
my $action = shift;
- foreach my $field ($self->edit_columns($action)) {
- div { { class is 'update-argument-'.$field}
- render_param($action, $field) ;
+ for my $field ($self->edit_columns($action)) {
+ div {
+ { class is 'update-argument-'.$field};
+ render_param($action, $field);
}
- }
+ }
};
=head1 new_item
@@ -818,27 +836,27 @@
};
private template 'new_item_controls' => sub {
- my $self = shift;
- my $create = shift;
+ my $self = shift;
+ my $create = shift;
my ( $object_type ) = ( $self->object_type);
- outs(
- Jifty->web->form->submit(
- label => _('Create'),
- onclick => [
- { submit => $create },
- { refresh_self => 1 },
- { element => Jifty->web->current_region->parent->get_element( 'div.list'),
- append => $self->fragment_for('view'),
- args => {
- object_type => $object_type,
- id => { result_of => $create, name => 'id' },
- },
+ outs(
+ Jifty->web->form->submit(
+ label => _('Create'),
+ onclick => [
+ { submit => $create },
+ { refresh_self => 1 },
+ { element => Jifty->web->current_region->parent->get_element( 'div.list'),
+ append => $self->fragment_for('view'),
+ args => {
+ object_type => $object_type,
+ id => { result_of => $create, name => 'id' },
},
- ]
- )
+ },
+ ]
)
- };
+ )
+};
More information about the Jifty-commit
mailing list