/[Arh]/lib/Arh/View/Units.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/Arh/View/Units.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations)
Sun Apr 6 12:04:31 2008 UTC (15 years, 11 months ago) by dpavlin
File size: 3272 byte(s)
hush debug
1 package Arh::View::Units;
2
3 use strict;
4 use warnings;
5
6 use base 'Jifty::View::Declare::CRUD';
7 use Jifty::View::Declare -base;
8
9 sub object_type { 'Unit' };
10
11 sub display_columns {
12 my $self = shift;
13 return ( qw/
14 unit_id
15 name
16 subcategory
17 category
18 site
19 gps
20 placement
21 context
22 discovery
23 function
24 reusage
25 ownership
26 presevation_place
27 inventory_nr
28 dimensions
29 condition
30 toplogy
31 technique
32 description
33 contstruction
34 iconography
35 decoration
36 motifs
37 inscription
38 language
39 font
40 author
41 chronology
42 chronostyle
43 explored
44 conservations
45 restorations
46 legal
47 links
48 sources
49 bibliography
50 copyright
51 / );
52 }
53
54 #private template search_region => sub {};
55
56 template 'view' => sub :CRUDView {
57 my $self = shift;
58 my $id = get('id');
59 my $record = $self->_get_record( $id );
60
61 my $update = $record->as_update_action(
62 moniker => "update-" . Jifty->web->serial,
63 );
64
65 my $delete = $record->as_delete_action(
66 moniker => "delete-" . Jifty->web->serial,
67 );
68 my $editing = $record->current_user_can('write');
69 warn "## current_user_can('write') = $editing\n";
70 $editing = 0 unless $self->current_user->editing;
71 warn "## editing ",$editing ? 'ok' : 'DENIED';
72
73 div { { class is 'unit' }
74
75 if ( $editing ) {
76 form {
77 outs_raw($delete->button(
78 label => _('Delete unit'),
79 class => 'float-crud-button button-delete',
80 onclick => {
81 submit => $delete,
82 confirm => _('Really delete?'),
83 # region => Jifty->web->current_region,
84 replace_with => '/__jifty/empty',
85 refresh_self => 1,
86 args => { id => $id },
87 },
88 ));
89 };
90 };
91
92
93 form {
94 foreach my $f ( $self->display_columns ) {
95 if ( $f eq 'material' ) {
96 set( search_collection => $record->material );
97 render_region(
98 name => 'unit-materials',
99 path => '/materials/list',
100 defaults => {
101 page => 1,
102 unit => $record->id,
103 }
104 );
105 } else {
106 my %opt;
107 $opt{render_mode} = 'read' if ! $editing;
108 render_param( $update => $f, %opt );
109 }
110 };
111 if ( $editing ) {
112 div {
113 { class is 'submit_button' };
114 hyperlink(
115 label => _('Update'),
116 onclick => {
117 submit => $update,
118 refresh_self => 1,
119 },
120 )
121 };
122 }
123 };
124
125 }; # div class unit
126
127 show('/unitpictures/fragment', $record);
128
129 hr {};
130 };
131
132 template 'new_item' => sub {
133 my $self = shift;
134 return unless $self->current_user->editing;
135
136 my ( $object_type, $id ) = ( $self->object_type, get('id') );
137 my $record_class = $self->record_class;
138 my $create = $record_class->as_create_action;
139
140 h1 { _("New unit") };
141
142 form {
143
144 foreach my $f ( $self->display_columns ) {
145 # last if $f eq 'material' && ! $id;
146 render_param( $create => $f ); # unless $f eq 'material';
147 #warn "## $f";
148 }
149
150 div {
151 { class is 'submit_button' };
152 hyperlink(
153 label => _("Add"),
154 onclick => [
155 {
156 submit => $create,
157 # args => {
158 # },
159 },
160 { refresh_self => 1 },
161 {
162 element => Jifty->web->current_region->parent->get_element( 'div.list' ),
163 append => $self->fragment_for('view'),
164 args => {
165 object_type => $object_type,
166 id => { result_of => $create, name => 'id' },
167 unit => get('unit'),
168 },
169 },
170 ],
171 as_button => 1,
172 );
173 }
174
175 };
176 };
177
178 1;

  ViewVC Help
Powered by ViewVC 1.1.26