aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-05 00:21:12 +0000
committergroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-05 00:21:12 +0000
commitcc44a3371f6bb93dfcc28961004b00064942e27b (patch)
treea937594b1e3ea8e055cae7337b6d13fd72a194b4
parent36d54b146cfba17f5c7757eced453429ee31c780 (diff)
downloadreaction-cc44a3371f6bb93dfcc28961004b00064942e27b.tar.gz
reaction-cc44a3371f6bb93dfcc28961004b00064942e27b.zip
fixed choosemany, fixed some widget stuff i broke before, renamed ordered_fields to computed_field_order to avoid ambiguity
-rw-r--r--lib/Reaction/UI/ViewPort.pm3
-rw-r--r--lib/Reaction/UI/ViewPort/Collection/Grid.pm12
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm9
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm7
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm1
-rw-r--r--lib/Reaction/UI/ViewPort/Object.pm6
-rw-r--r--lib/Reaction/UI/Widget/Action.pm28
-rw-r--r--lib/Reaction/UI/Widget/Collection/Grid.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable/DateTime.pm4
-rw-r--r--lib/Reaction/UI/Widget/Object.pm7
-rw-r--r--share/skin/default/layout/field.tt4
13 files changed, 36 insertions, 51 deletions
diff --git a/lib/Reaction/UI/ViewPort.pm b/lib/Reaction/UI/ViewPort.pm
index d7c1980..9361cae 100644
--- a/lib/Reaction/UI/ViewPort.pm
+++ b/lib/Reaction/UI/ViewPort.pm
@@ -85,7 +85,8 @@ class ViewPort which {
my ($self, $events) = @_;
foreach my $event ($self->accept_events) {
if (exists $events->{$event}) {
- # $self->ctx->log->debug("Applying Event: $event with value: ". $events->{$event});
+ #my $name = eval{$self->name};
+ #$self->ctx->log->debug("Applying Event: $event on $name with value: ". $events->{$event});
$self->$event($events->{$event});
}
}
diff --git a/lib/Reaction/UI/ViewPort/Collection/Grid.pm b/lib/Reaction/UI/ViewPort/Collection/Grid.pm
index 9d48cd1..ab33770 100644
--- a/lib/Reaction/UI/ViewPort/Collection/Grid.pm
+++ b/lib/Reaction/UI/ViewPort/Collection/Grid.pm
@@ -7,11 +7,11 @@ use aliased 'Reaction::UI::ViewPort::Collection::Grid::Member';
class Grid is 'Reaction::UI::ViewPort::Collection', which {
- has field_order => ( isa => 'ArrayRef', is => 'ro', lazy_build => 1);
- has field_labels => ( isa => 'HashRef', is => 'ro', lazy_build => 1);
+ has field_order => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has excluded_fields => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has field_labels => ( is => 'ro', isa => 'HashRef', lazy_build => 1);
- has ordered_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
- has excluded_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
####################################
implements _build_member_class => as { };
@@ -28,7 +28,7 @@ class Grid is 'Reaction::UI::ViewPort::Collection', which {
implements _build_field_order => as { []; };
implements _build_excluded_fields => as { []; };
- implements _build_ordered_fields => as {
+ implements _build_computed_field_order => as {
my ($self) = @_;
confess("current_collection lacks a value for 'member_type' attribute")
unless $self->current_collection->has_member_type;
@@ -50,7 +50,7 @@ class Grid is 'Reaction::UI::ViewPort::Collection', which {
before _build_members => sub {
my ($self) = @_;
- $self->member_args->{ordered_fields} ||= $self->ordered_fields;
+ $self->member_args->{computed_field_order} ||= $self->computed_field_order;
};
};
diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
index 17cdf53..62cfe1a 100644
--- a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
@@ -9,11 +9,11 @@ my $listify = sub{
class ChooseMany is 'Reaction::UI::ViewPort::Field', which {
- has '+value' => (isa => 'ArrayRef');
-
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
does 'Reaction::UI::ViewPort::Field::Role::Choices';
+ #MUST BE HERE, BELOW THE 'does', OR THE TRIGGER WILL NOT HAPPEN!
+ has '+value' => (isa => 'ArrayRef');
around value => sub {
my $orig = shift;
@@ -34,12 +34,13 @@ class ChooseMany is 'Reaction::UI::ViewPort::Field', which {
};
implements _build_value_string => as {
- join ", ", @{ shift->current_value_choices }
+ my $self = shift;
+ join ", ", (map {$self->obj_to_name($_->{value}) } @{ $self->current_value_choices })
};
implements is_current_value => as {
my ($self, $check_value) = @_;
- my @our_values = @{$self->value||[]};
+ my @our_values = @{$self->value || []};
$check_value = $self->obj_to_str($check_value) if ref($check_value);
return grep { $self->obj_to_str($_) eq $check_value } @our_values;
};
diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm
index 12d6d11..f7a54bb 100644
--- a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm
@@ -14,13 +14,18 @@ class ChooseOne is 'Reaction::UI::ViewPort::Field', which {
my $value = shift;
if (defined $value) {
$value = $self->str_to_ident($value) if (!ref $value);
- my $checked = $self->attribute->check_valid_value($self->action, $value);
+ my $checked = $self->attribute->check_valid_value($self->model, $value);
confess "${value} is not a valid value" unless defined($checked);
$value = $checked;
}
$orig->($self, $value);
};
+ implements _build_value_string => as {
+ my $self = shift;
+ $self->obj_to_name($self->value->{value});
+ };
+
implements is_current_value => as {
my ($self, $check_value) = @_;
my $our_value = $self->value;
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
index 66a46cf..8a90ff8 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
@@ -33,6 +33,7 @@ role Mutable, which {
}
my $writer = $attr->get_write_method;
confess "No writer for attribute" unless defined($writer);
+ my $value = $self->value;
$self->model->$writer($self->value); #should we be passing $value ?
$self->needs_sync(0);
};
diff --git a/lib/Reaction/UI/ViewPort/Object.pm b/lib/Reaction/UI/ViewPort/Object.pm
index 9730b5f..da45c23 100644
--- a/lib/Reaction/UI/ViewPort/Object.pm
+++ b/lib/Reaction/UI/ViewPort/Object.pm
@@ -25,8 +25,8 @@ class Object is 'Reaction::UI::ViewPort', which {
has field_order => (is => 'ro', isa => 'ArrayRef');
has builder_cache => (is => 'ro', isa => 'HashRef', lazy_build => 1);
- has ordered_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
has excluded_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
implements BUILD => as {
my ($self, $args) = @_;
@@ -42,7 +42,7 @@ class Object is 'Reaction::UI::ViewPort', which {
my $obj = $self->model;
my $args = $self->has_field_args ? $self->field_args : {};
my @fields;
- for my $field_name (@{ $self->ordered_fields }) {
+ for my $field_name (@{ $self->computed_field_order }) {
my $attr = $obj->meta->find_attribute_by_name($field_name);
my $meth = $self->builder_cache->{$field_name} ||= $self->get_builder_for($attr);
my $field = $self->$meth($attr, ($args->{$field_name} || {}));
@@ -51,7 +51,7 @@ class Object is 'Reaction::UI::ViewPort', which {
return \@fields;
};
- implements _build_ordered_fields => as {
+ implements _build_computed_field_order => as {
my ($self) = @_;
my %excluded = map { $_ => undef } @{ $self->excluded_fields };
#treat _$field_name as private and exclude fields with no reader
diff --git a/lib/Reaction/UI/Widget/Action.pm b/lib/Reaction/UI/Widget/Action.pm
index c7e1e04..a54afcb 100644
--- a/lib/Reaction/UI/Widget/Action.pm
+++ b/lib/Reaction/UI/Widget/Action.pm
@@ -8,14 +8,6 @@ class Action is 'Reaction::UI::Widget::Object', which {
# arg form_id => $_{viewport}->location;
#};
- #implements fragment field_list {
- # render field => over $_{viewport}->ordered_fields;
- #};
-
- #implements fragment field {
- # render 'viewport';
- #};
-
implements fragment ok_button_fragment {
if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
arg 'event_id' => event_id 'ok';
@@ -54,25 +46,11 @@ Reaction::UI::Widget::Action
=head1 FRAGMENTS
-=head2 widget
-
-Renders "header", "field_list", "buttons" and "footer"
-
-=head2 field_list
-
-Sequentially renders the C<ordered_fields> of the viewport
-
-=head2 buttons
-
-Additional variables available in topic hash: "message"
-
-=head2 header
-
-Content is a dummy value
+=head2 ok_button_fragment
-=head2 footer
+=head2 apply_button_fragment
-Content is a dummy value
+=head2 cancel_button_fragment
=head1 AUTHORS
diff --git a/lib/Reaction/UI/Widget/Collection/Grid.pm b/lib/Reaction/UI/Widget/Collection/Grid.pm
index 13c59be..bf9ad6b 100644
--- a/lib/Reaction/UI/Widget/Collection/Grid.pm
+++ b/lib/Reaction/UI/Widget/Collection/Grid.pm
@@ -6,7 +6,7 @@ class Grid is 'Reaction::UI::Widget::Collection', which {
implements fragment header_cells {
arg 'labels' => $_{viewport}->field_labels;
- render header_cell => over $_{viewport}->field_order;
+ render header_cell => over $_{viewport}->computed_field_order;
};
implements fragment header_cell {
diff --git a/lib/Reaction/UI/Widget/Field.pm b/lib/Reaction/UI/Widget/Field.pm
index fbfe1eb..4d91afa 100644
--- a/lib/Reaction/UI/Widget/Field.pm
+++ b/lib/Reaction/UI/Widget/Field.pm
@@ -12,7 +12,7 @@ class Field, which {
}
};
- implements fragment label_layout {
+ implements fragment label_fragment {
if (my $label = $_{viewport}->label) {
arg label => $label;
render 'label';
diff --git a/lib/Reaction/UI/Widget/Field/Mutable.pm b/lib/Reaction/UI/Widget/Field/Mutable.pm
index 5d658dc..5c245d8 100644
--- a/lib/Reaction/UI/Widget/Field/Mutable.pm
+++ b/lib/Reaction/UI/Widget/Field/Mutable.pm
@@ -6,7 +6,7 @@ class Mutable is 'Reaction::UI::Widget::Field', which {
before fragment widget {
arg 'field_id' => event_id 'value';
- arg 'field_name' => event_id 'value';
+ arg 'field_name' => event_id 'value' unless defined $_{field_name};
arg 'field_type' => 'text';
};
diff --git a/lib/Reaction/UI/Widget/Field/Mutable/DateTime.pm b/lib/Reaction/UI/Widget/Field/Mutable/DateTime.pm
index 0095594..f4a28e8 100644
--- a/lib/Reaction/UI/Widget/Field/Mutable/DateTime.pm
+++ b/lib/Reaction/UI/Widget/Field/Mutable/DateTime.pm
@@ -4,6 +4,10 @@ use Reaction::UI::WidgetClass;
class DateTime is 'Reaction::UI::Widget::Field::Mutable', which {
+ after fragment widget {
+ arg 'field_name' => event_id 'value_string';
+ };
+
};
1;
diff --git a/lib/Reaction/UI/Widget/Object.pm b/lib/Reaction/UI/Widget/Object.pm
index 505d00d..3889892 100644
--- a/lib/Reaction/UI/Widget/Object.pm
+++ b/lib/Reaction/UI/Widget/Object.pm
@@ -18,7 +18,6 @@ class Object, which {
__END__;
-
=head1 NAME
Reaction::UI::Widget::Object
@@ -27,13 +26,9 @@ Reaction::UI::Widget::Object
=head1 FRAGMENTS
-=head2 widget
-
-Renders C<field_list>
-
=head2 field_list
-Sequentially renders the C<ordered_fields> of the viewport.
+Sequentially renders the C<fields> of the viewport in the C<computed_field_order>
=head1 AUTHORS
diff --git a/share/skin/default/layout/field.tt b/share/skin/default/layout/field.tt
index 937ba51..99954ab 100644
--- a/share/skin/default/layout/field.tt
+++ b/share/skin/default/layout/field.tt
@@ -1,9 +1,9 @@
=for layout widget
-[% label_layout %]
+[% label_fragment %]
[% value_layout %]
-=for layout label_layout
+=for layout label
<strong > [% label %]: </strong>