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 |
h1 { _("Pictures available in system") }; |
12 |
my $fc = Arh::Model::PictureCollection->new; |
13 |
$fc->unlimit; |
14 |
my $present; |
15 |
form { |
16 |
table { |
17 |
while ( my $f = $fc->next ) { |
18 |
$present->{ $f->filename }++; |
19 |
my $delete = new_action( class => 'DeletePicture' ); |
20 |
my $update = new_action( class => 'UpdatePicture', record => $f ); |
21 |
row { |
22 |
cell { |
23 |
img { attr { src => "static/pics/" . $f->filename } } |
24 |
div { tt{ $f->filename } } |
25 |
} |
26 |
cell { |
27 |
render_param( $update => 'campaign', render_mode => 'read' ); |
28 |
render_param( $update => 'type', render_mode => 'read' ); |
29 |
div { |
30 |
$delete->button( |
31 |
submit => $delete, |
32 |
label => _('Delete'), |
33 |
arguments => { |
34 |
id => $f->id, |
35 |
} |
36 |
) |
37 |
} |
38 |
} |
39 |
} |
40 |
} |
41 |
row { |
42 |
cell { attr { colspan => 4 } outs _('Pending pictures') } |
43 |
}; |
44 |
warn "## present = ",dump( $present ); |
45 |
foreach my $f ( Arh::Model::Picture->all_filenames ) { |
46 |
next if $present->{$f}; |
47 |
my $create = new_action( class => 'CreatePicture' ); |
48 |
row { |
49 |
cell { |
50 |
img { attr { src => "static/pics/$f" } } |
51 |
div { tt{ $f } } |
52 |
} |
53 |
cell { |
54 |
render_param( $create => 'campaign' ); |
55 |
render_param( $create => 'type' ); |
56 |
$create->button( |
57 |
submit => $create, |
58 |
label => _('Add'), |
59 |
arguments => { |
60 |
filename => $f, |
61 |
} |
62 |
); |
63 |
} |
64 |
} |
65 |
} |
66 |
} |
67 |
} |
68 |
|
69 |
}; |
70 |
|
71 |
template '/units' => page { |
72 |
h1 { _("Units available in system") }; |
73 |
|
74 |
my $units = Arh::Model::UnitCollection->new; |
75 |
$units->unlimit; |
76 |
|
77 |
while ( my $u = $units->next ) { |
78 |
unit( $u ); |
79 |
} |
80 |
}; |
81 |
|
82 |
sub unit { |
83 |
my $unit = shift || die "no unit?"; |
84 |
my $a = new_action( class => 'UpdateUnit', record => $unit ); |
85 |
form { |
86 |
foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) { |
87 |
if ( $f eq 'material' ) { |
88 |
my $material = $unit->material; |
89 |
while ( my $um = $material->next ) { |
90 |
my $m = new_action( class => 'UpdateMaterial', record => $um->material ); |
91 |
render_param( $m => 'name', label => _("Material"), render_mode => 'read' ); |
92 |
} |
93 |
} else { |
94 |
render_param( $a => $f, render_mode => 'read' ); |
95 |
} |
96 |
} |
97 |
} |
98 |
} |
99 |
|
100 |
1; |