/[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 149 - (show annotations)
Wed Jul 16 21:23:27 2008 UTC (14 years, 4 months ago) by dpavlin
File size: 1764 byte(s)
partially working label editor in ObjectDesigner -- no save yet! [0.13]
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 our $labels;
15 our $label_order;
16 our $label_editable;
17 our $label_count = 0;
18
19 =for removed
20
21 has 'labels' => (
22 is => 'rw',
23 isa => 'HashRef[Str]',
24 default => sub { {} },
25 );
26
27 has 'label_order' => (
28 is => 'rw',
29 isa => 'HashRef[Int]',
30 default => sub { {} },
31 );
32
33 has 'label_editable' => (
34 is => 'rw',
35 isa => 'HashRef[Frey::Web::Editable]',
36 default => sub { {} },
37 );
38 =cut
39
40 use Frey::Web::Editable;
41
42 our $first_uuid;
43
44 around 'field_label' => sub {
45 my ($next, $self, $name) = @_;
46 my $orig_label = $self->$next($name);
47
48 my $label = $labels->{ $name } ||= $orig_label;
49
50 if ( ! defined $label_order->{ $name } ) {
51 warn "field_label $label_count $name -> $label\n";
52 $label_order->{ $name } = $label_count++;
53 $label_editable->{ $name } = Frey::Web::Editable->new(
54 name => $name,
55 value => $label,
56 render_as => 'edit',
57 save_callback => sub {
58 my ( $self, $val ) = @_;
59 $labels->{ $name } = $val;
60 # XXX we really need this since we are in continutation and have old value!
61 $self->value( $val );
62 warn "## saved $val new labels = ",dump( $labels, $self->value );
63 }
64 );
65 }
66
67 warn "around field_label ", $self->uuid, ' ', $label_order->{ $name }, ' ', $label_count, dump( $labels ), $/;
68
69 $first_uuid ||= $self->uuid;
70 return $label unless $first_uuid eq $self->uuid;
71
72 my $edit = $label_editable->{ $name };
73
74 my $html;
75 $html .= qq|<a style="color:#888" href="">&larr;</a>| if $label_order->{ $name } > 0 ;
76 $html .= $edit->process( Frey::Request->params );
77 $html .= qq|<a style="color:#888" href="">&rarr;</a>|;
78
79 return $html;
80 };
81
82 1;

  ViewVC Help
Powered by ViewVC 1.1.26