/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 39 - (hide annotations)
Sun Apr 6 11:12:58 2008 UTC (16 years ago) by dpavlin
File size: 3271 byte(s)
huge and merry code dump of lastest changes in middle of refactoring
1 dpavlin 15 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 dpavlin 23 sub display_columns {
12     my $self = shift;
13 dpavlin 39 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 dpavlin 23 }
53    
54 dpavlin 15 #private template search_region => sub {};
55    
56     template 'view' => sub :CRUDView {
57     my $self = shift;
58 dpavlin 23 my $id = get('id');
59     my $record = $self->_get_record( $id );
60 dpavlin 15
61     my $update = $record->as_update_action(
62     moniker => "update-" . Jifty->web->serial,
63     );
64    
65 dpavlin 23 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 dpavlin 15
73 dpavlin 28 div { { class is 'unit' }
74 dpavlin 23
75     if ( $editing ) {
76     form {
77     outs_raw($delete->button(
78 dpavlin 28 label => _('Delete unit'),
79     class => 'float-crud-button button-delete',
80 dpavlin 23 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 dpavlin 28
93 dpavlin 15 form {
94 dpavlin 23 foreach my $f ( $self->display_columns ) {
95 dpavlin 15 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 dpavlin 23 $opt{render_mode} = 'read' if ! $editing;
108 dpavlin 15 render_param( $update => $f, %opt );
109     }
110     };
111 dpavlin 23 if ( $editing ) {
112 dpavlin 20 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 dpavlin 15 };
124 dpavlin 28
125     }; # div class unit
126    
127     show('/unitpictures/fragment', $record);
128    
129 dpavlin 15 hr {};
130     };
131    
132 dpavlin 23 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 dpavlin 39 # last if $f eq 'material' && ! $id;
146 dpavlin 26 render_param( $create => $f ); # unless $f eq 'material';
147 dpavlin 39 warn "## $f";
148 dpavlin 23 }
149    
150     div {
151     { class is 'submit_button' };
152     hyperlink(
153     label => _("Add"),
154     onclick => [
155     {
156     submit => $create,
157 dpavlin 39 # args => {
158     # },
159 dpavlin 23 },
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 dpavlin 15 1;

  ViewVC Help
Powered by ViewVC 1.1.26