/[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

Contents of /lib/Arh/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Thu Nov 29 19:32:41 2007 UTC (16 years, 4 months ago) by dpavlin
File size: 2736 byte(s)
small tweaks, mostly visible because of *some* css :-)
1 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 if ( $fc->count ) {
16 h1 { _("Pictures available in system") };
17 }
18 table {
19 while ( my $f = $fc->next ) {
20 $present->{ $f->filename }++;
21 my $delete = new_action( class => 'DeletePicture' );
22 my $update = new_action( class => 'UpdatePicture', record => $f );
23 row {
24 cell {
25 attr { class => 'picture' };
26 img { attr { src => "static/pics/" . $f->filename } }
27 div { tt{ $f->filename } }
28 }
29 cell {
30 attr { class => 'picture-description' };
31 render_param( $update => 'campaign', render_mode => 'read' );
32 render_param( $update => 'type', render_mode => 'read' );
33 if ( $f->current_user_can('write') ) {
34 div {
35 $delete->button(
36 submit => $delete,
37 label => _('Delete'),
38 arguments => {
39 id => $f->id,
40 }
41 )
42 }
43 }
44 }
45 }
46 }
47 row {
48 cell { attr { colspan => 2 } h1 { _('Pending pictures') } }
49 };
50 warn "## present = ",dump( $present );
51 foreach my $f ( Arh::Model::Picture->all_filenames ) {
52 next if $present->{$f};
53 my $create = new_action( class => 'CreatePicture' );
54 row {
55 cell {
56 attr { class => 'picture' };
57 img { attr { src => "static/pics/$f" } }
58 div { tt{ $f } }
59 }
60 cell {
61 attr { class => 'picture-description' };
62 render_param( $create => 'campaign' );
63 render_param( $create => 'type' );
64 $create->button(
65 submit => $create,
66 label => _('Add'),
67 arguments => {
68 filename => $f,
69 }
70 );
71 }
72 }
73 }
74 }
75 }
76
77 };
78
79 template '/units' => page {
80 h1 { _("Units available in system") };
81
82 my $units = Arh::Model::UnitCollection->new;
83 $units->unlimit;
84
85 while ( my $u = $units->next ) {
86 unit( $u );
87 }
88 };
89
90 sub unit {
91 my $unit = shift || die "no unit?";
92 my $a = new_action( class => 'UpdateUnit', record => $unit );
93 warn "## current_user = ",dump( current_user );
94 form {
95 foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {
96 if ( $f eq 'material' ) {
97 my $material = $unit->material;
98 while ( my $um = $material->next ) {
99 my $m = new_action( class => 'UpdateMaterial', record => $um->material );
100 render_param( $m => 'name', label => _("Material"), render_mode => 'read' );
101 }
102 } else {
103 my %opt;
104 $opt{render_mode} = 'read'; # unless
105 warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED';
106 render_param( $a => $f, %opt );
107 }
108 }
109 }
110 }
111
112 1;

  ViewVC Help
Powered by ViewVC 1.1.26