14 |
my $present; |
my $present; |
15 |
form { |
form { |
16 |
table { |
table { |
|
row { |
|
|
cell { _('Part of campaign') } |
|
|
cell { _('Picture filename') } |
|
|
cell { _('Type of picture') } |
|
|
cell {} |
|
|
}; |
|
17 |
while ( my $f = $fc->next ) { |
while ( my $f = $fc->next ) { |
18 |
$present->{ $f->filename }++; |
$present->{ $f->filename }++; |
19 |
my $delete = new_action( class => 'DeletePicture' ); |
my $delete = new_action( class => 'DeletePicture' ); |
20 |
|
my $update = new_action( class => 'UpdatePicture', record => $f ); |
21 |
row { |
row { |
|
cell { $f->campaign->name } |
|
22 |
cell { |
cell { |
23 |
img { attr { src => "static/pics/" . $f->filename } } |
img { attr { src => "static/pics/" . $f->filename } } |
24 |
div { tt{ $f->filename } } |
div { tt{ $f->filename } } |
25 |
} |
} |
|
cell { $f->type->name } |
|
26 |
cell { |
cell { |
27 |
$delete->button( |
render_param( $update => 'campaign', render_mode => 'read' ); |
28 |
submit => $delete, |
render_param( $update => 'type', render_mode => 'read' ); |
29 |
label => _('Delete'), |
div { |
30 |
arguments => { |
$delete->button( |
31 |
id => $f->id, |
submit => $delete, |
32 |
} |
label => _('Delete'), |
33 |
) |
arguments => { |
34 |
|
id => $f->id, |
35 |
|
} |
36 |
|
) |
37 |
|
} |
38 |
} |
} |
39 |
} |
} |
40 |
} |
} |
46 |
next if $present->{$f}; |
next if $present->{$f}; |
47 |
my $create = new_action( class => 'CreatePicture' ); |
my $create = new_action( class => 'CreatePicture' ); |
48 |
row { |
row { |
|
cell { render_param( $create => 'campaign' ) } |
|
49 |
cell { |
cell { |
50 |
img { attr { src => "static/pics/$f" } } |
img { attr { src => "static/pics/$f" } } |
51 |
div { tt{ $f } } |
div { tt{ $f } } |
52 |
} |
} |
|
cell { render_param( $create => 'type' ) } |
|
53 |
cell { |
cell { |
54 |
|
render_param( $create => 'campaign' ); |
55 |
|
render_param( $create => 'type' ); |
56 |
$create->button( |
$create->button( |
57 |
submit => $create, |
submit => $create, |
58 |
label => _('Add'), |
label => _('Add'), |
59 |
arguments => { |
arguments => { |
60 |
filename => $f, |
filename => $f, |
61 |
} |
} |
62 |
) |
); |
63 |
} |
} |
64 |
} |
} |
65 |
} |
} |
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 |
|
warn "## current_user = ",dump( current_user ); |
86 |
|
form { |
87 |
|
foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) { |
88 |
|
if ( $f eq 'material' ) { |
89 |
|
my $material = $unit->material; |
90 |
|
while ( my $um = $material->next ) { |
91 |
|
my $m = new_action( class => 'UpdateMaterial', record => $um->material ); |
92 |
|
render_param( $m => 'name', label => _("Material"), render_mode => 'read' ); |
93 |
|
} |
94 |
|
} else { |
95 |
|
my %opt; |
96 |
|
$opt{render_mode} = 'read'; # unless |
97 |
|
warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED'; |
98 |
|
render_param( $a => $f, %opt ); |
99 |
|
} |
100 |
|
} |
101 |
|
} |
102 |
|
} |
103 |
|
|
104 |
1; |
1; |