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 |
|
|
h1 { _("Pictures available in system") }; |
12 |
|
|
my $fc = Arh::Model::PictureCollection->new; |
13 |
|
|
$fc->unlimit; |
14 |
|
|
my $present; |
15 |
|
|
form { |
16 |
|
|
table { |
17 |
|
|
row { |
18 |
|
|
cell { _('Part of campaign') } |
19 |
|
|
cell { _('Picture filename') } |
20 |
|
|
cell { _('Type of picture') } |
21 |
|
|
cell {} |
22 |
|
|
}; |
23 |
|
|
while ( my $f = $fc->next ) { |
24 |
|
|
$present->{ $f->filename }++; |
25 |
|
|
my $delete = new_action( class => 'DeletePicture' ); |
26 |
|
|
row { |
27 |
|
|
cell { $f->campaign->name } |
28 |
|
|
cell { |
29 |
|
|
img { attr { src => "static/pics/" . $f->filename } } |
30 |
|
|
div { tt{ $f->filename } } |
31 |
|
|
} |
32 |
|
|
cell { $f->type->name } |
33 |
|
|
cell { |
34 |
|
|
$delete->button( |
35 |
|
|
submit => $delete, |
36 |
|
|
label => _('Delete'), |
37 |
|
|
arguments => { |
38 |
|
|
id => $f->id, |
39 |
|
|
} |
40 |
|
|
) |
41 |
|
|
} |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
row { |
45 |
|
|
cell { attr { colspan => 4 } outs _('Pending pictures') } |
46 |
|
|
}; |
47 |
|
|
warn "## present = ",dump( $present ); |
48 |
|
|
foreach my $f ( Arh::Model::Picture->all_filenames ) { |
49 |
|
|
next if $present->{$f}; |
50 |
|
|
my $create = new_action( class => 'CreatePicture' ); |
51 |
|
|
row { |
52 |
|
|
cell { render_param( $create => 'campaign' ) } |
53 |
|
|
cell { |
54 |
|
|
img { attr { src => "static/pics/$f" } } |
55 |
|
|
div { tt{ $f } } |
56 |
|
|
} |
57 |
|
|
cell { render_param( $create => 'type' ) } |
58 |
|
|
cell { |
59 |
|
|
$create->button( |
60 |
|
|
submit => $create, |
61 |
|
|
label => _('Add'), |
62 |
|
|
arguments => { |
63 |
|
|
filename => $f, |
64 |
|
|
} |
65 |
|
|
) |
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
} |
69 |
|
|
} |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
}; |
73 |
|
|
|
74 |
|
|
1; |