--- lib/Arh/View/Materials.pm 2007/11/30 23:23:14 23 +++ lib/Arh/View/Materials.pm 2007/12/01 00:23:26 25 @@ -52,29 +52,34 @@ template 'view' => sub :CRUDView { my $self = shift; - my $record = $self->_get_record( get('id') ); + my ( $id, $unit ) = get(qw(id unit)); + my $record = $self->_get_record( $id ); - my $update = $record->as_update_action( - moniker => "update-" . Jifty->web->serial, + my $delete = $record->as_delete_action( + moniker => "delete-" . Jifty->web->serial, ); - my $unit = get('unit'); #warn "## unit $unit"; + div { { class is 'form_field' }; - if ( $record->current_user_can('update') && $self->current_user->editing ) { + if ( $record->current_user_can('delete') && $self->current_user->editing ) { hyperlink( - label => _("Edit"), + label => _("Delete"), class => "float-crud-button", onclick => { - replace_with => $self->fragment_for('update'), - args => { id => $record->id } + submit => $delete, + confirm => _('Really delete?'), + replace_with => '/__jifty/empty', + refresh_self => 1, + args => { id => $id }, }, as_button => 1, ); - } - render_param( $update => 'material', render_mode => 'read' ); + }; + label { { class is 'label' } _("Material") }; + span { $record->material->name }; }; }; @@ -83,7 +88,7 @@ my $self = shift; return unless $self->current_user->editing; - my ( $object_type, $id, $unit ) = ( $self->object_type, get('id'), get('unit') ); + my ( $id, $unit ) = get(qw(id unit)); my $record_class = $self->record_class; my $create = $record_class->as_create_action( moniker => "create-" . Jifty->web->serial, @@ -111,8 +116,9 @@ element => $attach_to, append => $self->fragment_for('view'), args => { - object_type => $object_type, + object_type => $self->object_type, id => { result_of => $create, name => 'id' }, + unit => $unit, }, }, ],