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 |
warn "current_user->id: ",current_user->id; |
48 |
if ( current_user->id ) { |
49 |
row { |
50 |
cell { attr { colspan => 2 } h1 { _('Pending pictures') } } |
51 |
}; |
52 |
warn "## present = ",dump( $present ); |
53 |
foreach my $f ( Arh::Model::Picture->all_filenames ) { |
54 |
next if $present->{$f}; |
55 |
my $create = new_action( class => 'CreatePicture' ); |
56 |
row { |
57 |
cell { |
58 |
attr { class => 'picture' }; |
59 |
img { attr { src => "static/pics/$f" } } |
60 |
div { tt{ $f } } |
61 |
} |
62 |
cell { |
63 |
attr { class => 'picture-description' }; |
64 |
render_param( $create => 'campaign' ); |
65 |
render_param( $create => 'type' ); |
66 |
$create->button( |
67 |
submit => $create, |
68 |
label => _('Add'), |
69 |
arguments => { |
70 |
filename => $f, |
71 |
} |
72 |
); |
73 |
} |
74 |
} |
75 |
} |
76 |
} |
77 |
} |
78 |
} |
79 |
|
80 |
}; |
81 |
|
82 |
use Jifty::View::Declare::CRUD; |
83 |
Jifty::View::Declare::CRUD->mount_view('materials'); |
84 |
|
85 |
use Jifty::View::Declare::CRUD; |
86 |
Jifty::View::Declare::CRUD->mount_view('units'); |
87 |
|
88 |
template '/units' => page { |
89 |
h1 { _("Units available in system") }; |
90 |
|
91 |
my $search = Arh::Model::UnitCollection->new; |
92 |
$search->unlimit; |
93 |
|
94 |
set( search_collection => $search ); |
95 |
render_region( |
96 |
name => 'units', |
97 |
path => '/units/list', |
98 |
defaults => { |
99 |
page => 1, |
100 |
} |
101 |
); |
102 |
|
103 |
}; |
104 |
|
105 |
1; |