/[Arh]/lib/Arh/View/Materials.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/Materials.pm

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

revision 15 by dpavlin, Fri Nov 30 16:46:39 2007 UTC revision 23 by dpavlin, Fri Nov 30 23:23:14 2007 UTC
# Line 9  use Jifty::View::Declare -base; Line 9  use Jifty::View::Declare -base;
9  sub object_type { 'UnitMaterial' };  sub object_type { 'UnitMaterial' };
10    
11  private template search_region => sub {};  private template search_region => sub {};
12    private template 'no_items_found' => sub {};
13    
14  sub display_columns {  sub display_columns {
15          my $self = shift;          my $self = shift;
# Line 17  sub display_columns { Line 18  sub display_columns {
18    
19  sub edit_columns {  sub edit_columns {
20          my $self = shift;          my $self = shift;
21          return ('unit','material');          return ('material');
22  }  }
23    
24    template 'list' => sub {
25        my $self = shift;
26    
27        my ( $page, $unit ) = get(qw(page unit));
28        my $item_path = get('item_path') || $self->fragment_for("view");
29            my $fragment_for_new_item = get('fragment_for_new_item') || $self->fragment_for('new_item');
30        my $collection =  $self->_current_collection();
31            # XXX show just materials from current unit
32            $collection->limit( column => 'unit', value => $unit ) if $unit;
33        div {
34                    { class is 'materials' };
35    
36                    show('./search_region');
37                    show( './paging_top',    $collection, $page );
38                    show( './list_items',    $collection, $item_path );
39                    show( './paging_bottom', $collection, $page );
40    
41                    render_region(
42                            name => 'new_item',
43                            path => $fragment_for_new_item,
44                            defaults => {
45                                    object_type => $self->object_type,
46                                    unit => $unit,
47                            },
48                    );
49            }
50    
51    };
52    
53  template 'view' => sub :CRUDView {  template 'view' => sub :CRUDView {
54          my $self   = shift;          my $self   = shift;
55          my $record = $self->_get_record( get('id') );          my $record = $self->_get_record( get('id') );
# Line 29  template 'view' => sub :CRUDView { Line 59  template 'view' => sub :CRUDView {
59          );          );
60    
61          my $unit = get('unit');          my $unit = get('unit');
62          warn "## new item for unit $unit";          #warn "## unit $unit";
63    
64          div {          div {
65                  { class is 'form_field' };                  { class is 'form_field' };
66                  if ( $record->current_user_can('update') ) {                  if ( $record->current_user_can('update') && $self->current_user->editing ) {
67                          hyperlink(                          hyperlink(
68                                  label   => _("Edit"),                                  label   => _("Edit"),
69                                  class   => "float-crud-button",                                  class   => "float-crud-button",
# Line 51  template 'view' => sub :CRUDView { Line 81  template 'view' => sub :CRUDView {
81    
82  template 'new_item' => sub {  template 'new_item' => sub {
83      my $self = shift;      my $self = shift;
84      my ( $object_type, $id ) = ( $self->object_type, get('id') );          return unless $self->current_user->editing;
85    
86      my $record_class = $self->record_class;          my ( $object_type, $id, $unit ) = ( $self->object_type, get('id'), get('unit') );
87      my $create = $record_class->as_create_action;          my $record_class = $self->record_class;
88          my $unit = get('unit');          my $create = $record_class->as_create_action(
89          warn "## new item for unit $unit";                  moniker => "create-" . Jifty->web->serial,
90            );
91            warn "## unit $unit";
92    
93            my $attach_to =
94                    Jifty->web->current_region->parent ?
95                    Jifty->web->current_region->parent->get_element( 'div.list' ) :
96                    Jifty->web->current_region;
97    
98            warn "## attach_to = $attach_to";
99    
100      div {      div {
101          { class is 'form_field' };          { class is 'form_field' };
# Line 66  template 'new_item' => sub { Line 105  template 'new_item' => sub {
105                          onclick => [                          onclick => [
106                                  {                                  {
107                                          submit => $create,                                          submit => $create,
                                         args => {  
 #                                               unit => $unit,  
                                         },  
108                                  },                                  },
109                                  {       refresh_self => 1       },                                  {       refresh_self => 1       },
110                                  {                                  {
111                                          element => Jifty->web->current_region->parent->get_element( 'div.list' ),                                          element => $attach_to,
112                                          append => $self->fragment_for('view'),                                          append => $self->fragment_for('view'),
113                                          args => {                                          args => {
114                                                  object_type => $object_type,                                                  object_type => $object_type,
115                                                  id => { result_of => $create, name => 'id' },                                                  id => { result_of => $create, name => 'id' },
 #                                               unit => $unit,  
116                                          },                                          },
117                                  },                                  },
118                          ],                          ],
119                          as_button => 1,                          as_button => 1,
120                  );                  );
121                  render_param($create => 'material');                  render_param($create => 'material');
122                  render_param($create => 'unit', default_value => $unit, reader_as => 'hidden');                  outs_raw( $create->hidden( unit => $unit ) );
123      }      };
124  };  };
125    
126    

Legend:
Removed from v.15  
changed lines
  Added in v.23

  ViewVC Help
Powered by ViewVC 1.1.26