/[Frey]/trunk/lib/Frey/Web/Design.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 /trunk/lib/Frey/Web/Design.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations)
Wed Jul 16 21:51:23 2008 UTC (14 years, 2 months ago) by dpavlin
File size: 1725 byte(s)
cleanup and use Moose attributes
1 package Frey::Web::Design;
2 use Moose;
3 extends 'Frey::Web::Item';
4 with 'Frey::Web::Button';
5
6 =head1 NAME
7
8 Frey::Web::Design - field designer for L<Frey::Web::Item>
9
10 =cut
11
12 use Data::Dump qw/dump/;
13
14 has 'labels' => (
15 is => 'rw',
16 isa => 'HashRef[Str]',
17 default => sub { {} },
18 );
19
20 has 'label_order' => (
21 is => 'rw',
22 isa => 'HashRef[Int]',
23 default => sub { {} },
24 );
25
26 has 'label_editable' => (
27 is => 'rw',
28 isa => 'HashRef[Frey::Web::Editable]',
29 default => sub { {} },
30 );
31
32 has 'label_count' => (
33 is => 'rw',
34 isa => 'Int',
35 default => 0,
36 );
37
38 use Frey::Web::Editable;
39
40 around 'field_label' => sub {
41 my ($next, $self, $name) = @_;
42 my $orig_label = $self->$next($name);
43
44 my $label = $self->labels->{ $name } ||= $orig_label;
45 my $order = $self->label_order->{ $name };
46 my $count = $self->label_count;
47
48 if ( ! defined $order ) {
49 warn "field_label $count $name -> $label\n";
50 $self->label_order->{ $name } = $count++;
51 $self->label_count( $count );
52 $self->label_editable->{ $name } = Frey::Web::Editable->new(
53 name => $name,
54 value => $label,
55 render_as => 'edit',
56 save_callback => sub {
57 my ( $caller, $val ) = @_;
58 $self->labels->{ $name } = $val;
59 # XXX we really need this since we are in continutation and have old value!
60 $caller->value( $val );
61 warn "## saved $val new labels = ",dump( $self->labels, $caller->value );
62 }
63 );
64 }
65
66 warn "around field_label ", $self->uuid, " $order $count ", dump( $self->labels ), $/;
67
68 my $html;
69 $html .= qq|<a style="color:#888" href="">&larr;</a>| if $self->label_order->{ $name } > 0 ;
70 $html .= $self->label_editable->{ $name }->process( Frey::Request->params );
71 $html .= qq|<a style="color:#888" href="">&rarr;</a>|;
72
73 return $html;
74 };
75
76 1;

  ViewVC Help
Powered by ViewVC 1.1.26