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 { |
81 |
|
|
82 |
}; |
}; |
83 |
|
|
84 |
|
use Jifty::View::Declare::CRUD; |
85 |
|
Jifty::View::Declare::CRUD->mount_view('materials'); |
86 |
|
Jifty::View::Declare::CRUD->mount_view('UnitPictures'); |
87 |
|
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") }; |
92 |
|
|
93 |
my $units = Arh::Model::UnitCollection->new; |
show( 'toggle_edit' ); |
|
$units->unlimit; |
|
94 |
|
|
95 |
while ( my $u = $units->next ) { |
my $search = Arh::Model::UnitCollection->new; |
96 |
unit( $u ); |
$search->unlimit; |
|
} |
|
|
}; |
|
97 |
|
|
98 |
sub unit { |
set( search_collection => $search ); |
99 |
my $unit = shift || die "no unit?"; |
render_region( |
100 |
my $a = new_action( class => 'UpdateUnit', record => $unit ); |
name => 'units', |
101 |
form { |
path => '/units/list', |
102 |
foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) { |
defaults => { |
103 |
my $can_write = $unit->current_user_can('write',$f); |
page => 1, |
|
#warn "write $f ",$can_write ? 'ok' : 'DENIED'; |
|
|
if ( $f eq 'material' ) { |
|
|
set( UnitMaterialCollection => $unit->material ); |
|
|
show( '/unit/materials' ); |
|
|
} else { |
|
|
my %opt; |
|
|
$opt{render_mode} = 'read' if ! $unit->current_user_can('write',$f); |
|
|
render_param( $a => $f, %opt ); |
|
|
} |
|
104 |
} |
} |
105 |
} |
); |
|
} |
|
106 |
|
|
107 |
template '/unit/materials' => sub { |
}; |
|
my $materials = get('UnitMaterialCollection'); |
|
|
my $del_um = new_action( class => 'DeleteUnitMaterial', moniker => 'del_um' ); |
|
|
my $new_um = new_action( class => 'CreateUnitMaterial', moniker => 'new_um' ); |
|
|
my $can_write; |
|
|
while ( my $um = $materials->next ) { |
|
|
div { attr { class is 'form_field' } |
|
|
span { |
|
|
span { attr { class is 'label' } _("Material") }; |
|
|
span { $um->material->name }; |
|
|
|
|
|
$can_write ||= $um->current_user_can('write'); |
|
|
if ( $can_write ) { |
|
|
outs_raw($del_um->button( |
|
|
submit => $del_um, |
|
|
label => _('Delete'), |
|
|
arguments => { |
|
|
unit => $um->unit, |
|
|
material => $um->material |
|
|
}, |
|
|
)); |
|
|
} |
|
|
} |
|
|
}; |
|
108 |
|
|
109 |
if ( $can_write ) { |
private template '/toggle_edit' => sub { |
110 |
render_param( |
my $self = shift; |
111 |
$new_um => 'material', label => _("Material"), |
|
112 |
render_as => 'Arh::Web::Material', |
# no fun for anonymous users |
113 |
# cludge to transfer arguments |
return unless $self->current_user->id; |
114 |
hints => { |
|
115 |
unit => $um->unit, |
render_region( |
116 |
}, |
name => 'toggle-edit', |
117 |
); |
path => '/toggle_edit_region', |
118 |
} |
); |
119 |
|
|
120 |
|
}; |
121 |
|
|
122 |
|
template 'toggle_edit_region' => sub { |
123 |
|
my $self = shift; |
124 |
|
|
125 |
|
my $toggleedit = new_action( class => 'ToggleEdit' ); |
126 |
|
|
127 |
|
my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing"); |
128 |
|
|
129 |
|
warn "## $label\n"; |
130 |
|
|
131 |
|
form { |
132 |
|
hyperlink( |
133 |
|
label => $label, |
134 |
|
onclick => { |
135 |
|
submit => $toggleedit, |
136 |
|
refresh_self => 1, |
137 |
|
}, |
138 |
|
) |
139 |
} |
} |
140 |
|
|
141 |
}; |
}; |
142 |
|
|
143 |
1; |
1; |