7 |
|
|
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
|
|
10 |
template '/pictures' => page { |
template 'pictures' => page { |
11 |
my $fc = Arh::Model::PictureCollection->new; |
my $fc = Arh::Model::PictureCollection->new; |
12 |
$fc->unlimit; |
$fc->unlimit; |
13 |
my $present; |
my $present; |
14 |
form { |
form { |
15 |
if ( $fc->count ) { |
if ( $fc->count ) { |
16 |
h1 { _("Pictures available in system") }; |
h1 { _("Pictures available in system") }; |
17 |
|
} else { |
18 |
|
span { outs _("No pubicly available pictures at this time...") } |
19 |
} |
} |
20 |
table { |
table { |
21 |
while ( my $f = $fc->next ) { |
while ( my $f = $fc->next ) { |
25 |
row { |
row { |
26 |
cell { |
cell { |
27 |
attr { class => 'picture' }; |
attr { class => 'picture' }; |
28 |
img { attr { src => "static/pics/" . $f->filename } } |
img { attr { src => "/static/pics/" . $f->filename } } |
29 |
div { tt{ $f->filename } } |
div { tt{ $f->filename } } |
30 |
} |
} |
31 |
cell { |
cell { |
36 |
div { |
div { |
37 |
$delete->button( |
$delete->button( |
38 |
submit => $delete, |
submit => $delete, |
39 |
label => _('Delete'), |
label => _('Delete picture'), |
40 |
arguments => { |
arguments => { |
41 |
id => $f->id, |
id => $f->id, |
42 |
} |
} |
58 |
row { |
row { |
59 |
cell { |
cell { |
60 |
attr { class => 'picture' }; |
attr { class => 'picture' }; |
61 |
img { attr { src => "static/pics/$f" } } |
img { attr { src => "/static/pics/$f" } } |
62 |
div { tt{ $f } } |
div { tt{ $f } } |
63 |
} |
} |
64 |
cell { |
cell { |
83 |
|
|
84 |
use Jifty::View::Declare::CRUD; |
use Jifty::View::Declare::CRUD; |
85 |
Jifty::View::Declare::CRUD->mount_view('materials'); |
Jifty::View::Declare::CRUD->mount_view('materials'); |
86 |
|
Jifty::View::Declare::CRUD->mount_view('UnitPictures'); |
|
use Jifty::View::Declare::CRUD; |
|
87 |
Jifty::View::Declare::CRUD->mount_view('units'); |
Jifty::View::Declare::CRUD->mount_view('units'); |
88 |
|
#Jifty::View::Declare::CRUD->mount_view('locations'); |
89 |
|
|
90 |
template '/units' => page { |
template '/units' => page { |
91 |
h1 { _("Units available in system") }; |
h1 { _("Units available in system") }; |
93 |
my $search = Arh::Model::UnitCollection->new; |
my $search = Arh::Model::UnitCollection->new; |
94 |
$search->unlimit; |
$search->unlimit; |
95 |
|
|
96 |
|
show( 'toggle_edit' ) if $search->count; |
97 |
|
|
98 |
set( search_collection => $search ); |
set( search_collection => $search ); |
99 |
render_region( |
render_region( |
100 |
name => 'units', |
name => 'units', |
106 |
|
|
107 |
}; |
}; |
108 |
|
|
109 |
|
template 'toggle_edit' => sub { |
110 |
|
my $self = shift; |
111 |
|
|
112 |
|
my $toggleedit = new_action( |
113 |
|
class => 'ToggleEdit', |
114 |
|
# moniker => 'toggle-edit', |
115 |
|
); |
116 |
|
|
117 |
|
my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing"); |
118 |
|
|
119 |
|
warn "## $label\n"; |
120 |
|
|
121 |
|
form { |
122 |
|
outs_raw( $toggleedit->button( |
123 |
|
label => $label, |
124 |
|
submit => $toggleedit, |
125 |
|
)); |
126 |
|
} |
127 |
|
|
128 |
|
}; |
129 |
|
|
130 |
|
template 'raw_pic' => sub { |
131 |
|
my $filename = get('image') or die "no image?"; |
132 |
|
my $image = Arh::Model::Picture->new; |
133 |
|
$image->load_by_cols( filename => $filename ); |
134 |
|
if ( $image->id ) { |
135 |
|
Jifty->handler->apache->content_type('image/jpg'); |
136 |
|
Jifty->web->out($image->content); |
137 |
|
} else { |
138 |
|
die "can't find picture $filename"; |
139 |
|
} |
140 |
|
}; |
141 |
|
|
142 |
1; |
1; |