6 |
use base 'Jifty::View::Declare::CRUD'; |
use base 'Jifty::View::Declare::CRUD'; |
7 |
use Jifty::View::Declare -base; |
use Jifty::View::Declare -base; |
8 |
|
|
9 |
|
use Data::Dump qw/dump/; |
10 |
|
|
11 |
sub object_type { 'Unit' }; |
sub object_type { 'Unit' }; |
12 |
|
|
13 |
|
sub per_page { get('per_page') || 5 }; |
14 |
|
|
15 |
sub display_columns { |
sub display_columns { |
16 |
my $self = shift; |
my $self = shift; |
17 |
return ( qw/ |
return ( qw/ |
34 |
toplogy |
toplogy |
35 |
technique |
technique |
36 |
description |
description |
37 |
contstruction |
construction |
38 |
iconography |
iconography |
39 |
decoration |
decoration |
40 |
motifs |
motifs |
52 |
sources |
sources |
53 |
bibliography |
bibliography |
54 |
copyright |
copyright |
55 |
|
material |
56 |
/ ); |
/ ); |
57 |
} |
} |
58 |
|
|
59 |
#private template search_region => sub {}; |
#private template search_region => sub {}; |
60 |
|
|
61 |
|
private template 'paging_top' => sub { |
62 |
|
my $self = shift; |
63 |
|
my $collection = shift; |
64 |
|
my $page = shift || 1; |
65 |
|
|
66 |
|
if ( $collection->pager->last_page > 1 ) { |
67 |
|
span { |
68 |
|
{ class is 'page-count' }; |
69 |
|
outs( |
70 |
|
_( "Found %1 units, showing %2-%3 on page %4/%5", |
71 |
|
$collection->pager->total_entries, |
72 |
|
$collection->pager->first, |
73 |
|
$collection->pager->last, |
74 |
|
$page, |
75 |
|
$collection->pager->last_page |
76 |
|
) |
77 |
|
); |
78 |
|
} |
79 |
|
} |
80 |
|
|
81 |
|
show( './paging_bottom', $collection, $page ); |
82 |
|
|
83 |
|
}; |
84 |
|
|
85 |
|
|
86 |
template 'view' => sub :CRUDView { |
template 'view' => sub :CRUDView { |
87 |
my $self = shift; |
my $self = shift; |
88 |
my $id = get('id'); |
my $id = get('id'); |
134 |
); |
); |
135 |
} else { |
} else { |
136 |
my %opt; |
my %opt; |
137 |
$opt{render_mode} = 'read' if ! $editing; |
if ( ! $editing ) { |
138 |
|
$opt{render_mode} = 'read'; |
139 |
|
# skip fields without values |
140 |
|
$opt{render_as} = 'hidden' if ! defined( $update->record->$f ); |
141 |
|
} |
142 |
render_param( $update => $f, %opt ); |
render_param( $update => $f, %opt ); |
143 |
} |
} |
144 |
}; |
}; |
167 |
my $self = shift; |
my $self = shift; |
168 |
return unless $self->current_user->editing; |
return unless $self->current_user->editing; |
169 |
|
|
170 |
my ( $object_type, $id ) = ( $self->object_type, get('id') ); |
my ( $object_type, $id ) = ( $self->object_type, get('id') ); |
171 |
my $record_class = $self->record_class; |
my $record_class = $self->record_class; |
172 |
my $create = $record_class->as_create_action; |
my $create = $record_class->as_create_action; |
173 |
|
|
174 |
h1 { _("New unit") }; |
h1 { _("New unit") }; |
175 |
|
|
177 |
|
|
178 |
foreach my $f ( $self->display_columns ) { |
foreach my $f ( $self->display_columns ) { |
179 |
# last if $f eq 'material' && ! $id; |
# last if $f eq 'material' && ! $id; |
180 |
render_param( $create => $f ); # unless $f eq 'material'; |
render_param( $create => $f ) unless $f eq 'material'; |
181 |
warn "## $f"; |
#warn "## $f"; |
182 |
} |
} |
183 |
|
|
184 |
div { |
div { |