/[Arh]/lib/Arh/View/Units.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Arh/View/Units.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by dpavlin, Wed Apr 9 12:28:16 2008 UTC revision 82 by dpavlin, Sat Apr 19 23:18:06 2008 UTC
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11  sub object_type { 'Unit' };  sub object_type { 'Unit' };
12    
13  sub per_page {  sub per_page {
14          my $per_page = get('per_page') || 5;          my $per_page = get('per_page') || 3;
15          warn "## Units per_page = $per_page\n";          warn "## Units per_page = $per_page\n";
16          return $per_page;          return $per_page;
17  };  };
# Line 104  template 'list' => sub { Line 104  template 'list' => sub {
104    
105  =cut  =cut
106    
107    =head2 single
108    
109    display singe unit on page, using C<id> or C<unit> for unit id
110    
111    =cut
112    
113    template 'single' => page {
114            my $self = shift;
115    
116            my $id = get('unit') || get('id') || warn "no unit or id?";
117    
118            my $item = Arh::Model::Unit->new;
119            $item->load( $id );
120            die _("Can't find item %1", $id) unless $item->id;
121    
122            title is $item->name;
123    
124            render_region(
125                    name => 'item-' . $item->id,
126                    path => $self->fragment_for('view'),
127                    defaults => { id => $item->id, object_type => $self->object_type }
128            );
129    
130    };
131    
132  private template 'paging_top' => sub {  private template 'paging_top' => sub {
133          my $self           = shift;          my $self           = shift;
134          my $collection = shift;          my $collection = shift;
# Line 129  private template 'paging_top' => sub { Line 154  private template 'paging_top' => sub {
154  private template paging_bottom => sub {  private template paging_bottom => sub {
155          my $self           = shift;          my $self           = shift;
156          my $collection = shift;          my $collection = shift;
157          my $page           = shift;          my $page           = shift || 0;
158          div {          div {
159                  { class is 'paging' };                  { class is 'paging' };
160                  if ( $collection->pager->previous_page ) {                  if ( $collection->pager->previous_page ) {
# Line 143  private template paging_bottom => sub { Line 168  private template paging_bottom => sub {
168                          }                          }
169                  }                  }
170    
171                  foreach my $p ( $collection->pager->first_page .. $collection->pager->last_page ) {                  my ( $f_p, $t_p ) = ( '...', '...' );
172    
173                    my $from = $page - 15;
174                    if ( $from < 0 ) {
175                            $from = $collection->pager->first_page;
176                            $f_p = '';
177                    }
178                    my $to = $page + 15;
179                    if ( $to > $collection->pager->last_page ) {
180                            $to = $collection->pager->last_page;
181                            $t_p = '';
182                    }
183    
184                    outs $f_p;
185    
186                    foreach my $p ( $from .. $to ) {
187                          if ( $p == $page ) {                          if ( $p == $page ) {
188                                  b { $p }                                  b { $p }
189                          } else {                          } else {
# Line 156  private template paging_bottom => sub { Line 196  private template paging_bottom => sub {
196                                  }                                  }
197                          }                          }
198                  }                  }
199                            
200                    outs $t_p;
201    
202                  if ( $collection->pager->next_page ) {                  if ( $collection->pager->next_page ) {
203                          span {                          span {
# Line 191  template 'view' => sub :CRUDView { Line 232  template 'view' => sub :CRUDView {
232          div { { class is 'unit' }          div { { class is 'unit' }
233    
234                  if ( $editing ) {                  if ( $editing ) {
235                          outs_raw($delete->button(                          form {
236                                  label => _('Delete unit'),                                  outs_raw($delete->button(
237                                  class => 'float-crud-button button-delete',                                          label => _('Delete unit'),
238                                  onclick => {                                          class => 'float-crud-button button-delete',
239                                          submit => $delete,                                          onclick => {
240                                          confirm => _('Really delete?'),                                                  submit => $delete,
241  #                                       region => Jifty->web->current_region,                                                  confirm => _('Really delete?'),
242                                          replace_with => '/__jifty/empty',          #                                       region => Jifty->web->current_region,
243                                          refresh_self => 1,                                                  replace_with => '/__jifty/empty',
244                                          args => { id => $id },                                                  refresh_self => 1,
245                                  },                                                  args => { id => $id },
246                          ));                                          },
247                                    ));
248                            }
249                  };                  };
250    
251                  foreach my $f ( $self->display_columns ) {                  foreach my $f ( $self->display_columns ) {

Legend:
Removed from v.70  
changed lines
  Added in v.82

  ViewVC Help
Powered by ViewVC 1.1.26