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

Annotation of /lib/Arh/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Fri Nov 30 23:23:14 2007 UTC (16 years, 4 months ago) by dpavlin
File size: 3028 byte(s)
another huge code dump:
- rename database columns to prevent conficts with standards
- added editing accessor to user which returns edit mode
- ToggleEdit action to change editing state (broken)
- tweaks all over templates to make units entry a breeze
- version bump [0.03]
1 dpavlin 6 package Arh::View;
2    
3     use strict;
4     use warnings;
5    
6     use Jifty::View::Declare -base;
7    
8     use Data::Dump qw/dump/;
9    
10     template '/pictures' => page {
11     my $fc = Arh::Model::PictureCollection->new;
12     $fc->unlimit;
13     my $present;
14     form {
15 dpavlin 12 if ( $fc->count ) {
16     h1 { _("Pictures available in system") };
17 dpavlin 19 } else {
18     span { outs _("No pubicly available pictures at this time...") }
19 dpavlin 12 }
20 dpavlin 6 table {
21     while ( my $f = $fc->next ) {
22     $present->{ $f->filename }++;
23     my $delete = new_action( class => 'DeletePicture' );
24 dpavlin 8 my $update = new_action( class => 'UpdatePicture', record => $f );
25 dpavlin 6 row {
26     cell {
27 dpavlin 12 attr { class => 'picture' };
28 dpavlin 6 img { attr { src => "static/pics/" . $f->filename } }
29     div { tt{ $f->filename } }
30     }
31     cell {
32 dpavlin 12 attr { class => 'picture-description' };
33 dpavlin 8 render_param( $update => 'campaign', render_mode => 'read' );
34     render_param( $update => 'type', render_mode => 'read' );
35 dpavlin 12 if ( $f->current_user_can('write') ) {
36     div {
37     $delete->button(
38     submit => $delete,
39     label => _('Delete'),
40     arguments => {
41     id => $f->id,
42     }
43     )
44     }
45 dpavlin 7 }
46 dpavlin 6 }
47     }
48     }
49 dpavlin 13 warn "current_user->id: ",current_user->id;
50     if ( current_user->id ) {
51 dpavlin 6 row {
52 dpavlin 13 cell { attr { colspan => 2 } h1 { _('Pending pictures') } }
53     };
54     warn "## present = ",dump( $present );
55     foreach my $f ( Arh::Model::Picture->all_filenames ) {
56     next if $present->{$f};
57     my $create = new_action( class => 'CreatePicture' );
58     row {
59     cell {
60     attr { class => 'picture' };
61     img { attr { src => "static/pics/$f" } }
62     div { tt{ $f } }
63     }
64     cell {
65     attr { class => 'picture-description' };
66     render_param( $create => 'campaign' );
67     render_param( $create => 'type' );
68     $create->button(
69     submit => $create,
70     label => _('Add'),
71     arguments => {
72     filename => $f,
73     }
74     );
75     }
76 dpavlin 6 }
77     }
78     }
79     }
80     }
81    
82     };
83    
84 dpavlin 15 use Jifty::View::Declare::CRUD;
85     Jifty::View::Declare::CRUD->mount_view('materials');
86    
87     use Jifty::View::Declare::CRUD;
88     Jifty::View::Declare::CRUD->mount_view('units');
89    
90 dpavlin 8 template '/units' => page {
91     h1 { _("Units available in system") };
92    
93 dpavlin 23 show( 'toggle_edit' );
94    
95 dpavlin 15 my $search = Arh::Model::UnitCollection->new;
96     $search->unlimit;
97 dpavlin 8
98 dpavlin 15 set( search_collection => $search );
99     render_region(
100     name => 'units',
101     path => '/units/list',
102     defaults => {
103     page => 1,
104 dpavlin 8 }
105 dpavlin 15 );
106 dpavlin 8
107 dpavlin 13 };
108    
109 dpavlin 23 private template '/toggle_edit' => sub {
110     my $self = shift;
111    
112     # no fun for anonymous users
113     return unless $self->current_user->id;
114    
115     render_region(
116     name => 'toggle-edit',
117     path => '/toggle_edit_region',
118     );
119    
120     };
121    
122     template 'toggle_edit_region' => sub {
123     my $self = shift;
124    
125     my $toggleedit = new_action( class => 'ToggleEdit' );
126    
127     my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing");
128    
129     warn "## $label\n";
130    
131     form {
132     hyperlink(
133     label => $label,
134     onclick => {
135     submit => $toggleedit,
136     refresh_self => 1,
137     },
138     )
139     }
140    
141     };
142    
143 dpavlin 6 1;

  ViewVC Help
Powered by ViewVC 1.1.26