aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-02 22:57:32 +0000
committergroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-02 22:57:32 +0000
commit36d54b146cfba17f5c7757eced453429ee31c780 (patch)
treeb6b64cdf2c279bc7337c3dad7043f43e57e64de2
parentc03f75a7322e8194591d2f8bd02fb3f83df8833f (diff)
downloadreaction-36d54b146cfba17f5c7757eced453429ee31c780.tar.gz
reaction-36d54b146cfba17f5c7757eced453429ee31c780.zip
choosemany is still broken (not applying changes) but everything else is looking better
-rw-r--r--lib/Reaction/UI/View.pm3
-rw-r--r--lib/Reaction/UI/ViewPort.pm4
-rw-r--r--lib/Reaction/UI/ViewPort/Action.pm10
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm7
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Mutable/DateTime.pm3
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Choices.pm2
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm4
-rw-r--r--lib/Reaction/UI/ViewPort/Object.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field/Integer.pm29
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable/Integer.pm30
-rw-r--r--share/skin/default/layout/field/mutable/choose_many.tt4
-rw-r--r--share/skin/default/layout/field/mutable/integer.tt3
14 files changed, 88 insertions, 17 deletions
diff --git a/lib/Reaction/UI/View.pm b/lib/Reaction/UI/View.pm
index daf1bbc..5fb9056 100644
--- a/lib/Reaction/UI/View.pm
+++ b/lib/Reaction/UI/View.pm
@@ -89,7 +89,8 @@ class View which {
#warn "Loaded ${class}" unless $@;
$@ ? next : return $cache->{ $lset_name } = $class;
}
- confess "Couldn't load widget '$tail': tried: @haystack";
+ confess "Couldn't load widget '$tail' for layout '$lset_name': tried: " .
+ join(", ", @haystack);
};
implements 'layout_set_for' => as {
diff --git a/lib/Reaction/UI/ViewPort.pm b/lib/Reaction/UI/ViewPort.pm
index 8cc6917..d7c1980 100644
--- a/lib/Reaction/UI/ViewPort.pm
+++ b/lib/Reaction/UI/ViewPort.pm
@@ -1,6 +1,7 @@
package Reaction::UI::ViewPort;
use Reaction::Class;
+use Scalar::Util qw/blessed/;
class ViewPort which {
@@ -15,7 +16,6 @@ class ViewPort which {
isa => 'HashRef', is => 'ro', default => sub { {} }
);
has ctx => (isa => 'Catalyst', is => 'ro', required => 1);
- has column_order => (is => 'rw');
implements _build_layout => as {
'';
@@ -60,6 +60,8 @@ class ViewPort which {
implements apply_child_events => as {
my ($self, $ctx, $events) = @_;
foreach my $child ($self->child_event_sinks) {
+ confess blessed($child) ."($child) is not a valid object"
+ unless blessed($child) && $child->can('apply_events');
$child->apply_events($ctx, $events);
}
};
diff --git a/lib/Reaction/UI/ViewPort/Action.pm b/lib/Reaction/UI/ViewPort/Action.pm
index 9da7191..c382bdb 100644
--- a/lib/Reaction/UI/ViewPort/Action.pm
+++ b/lib/Reaction/UI/ViewPort/Action.pm
@@ -37,13 +37,13 @@ class Action is 'Reaction::UI::ViewPort::Object', which {
};
implements _build_ok_label => as{ 'ok' };
- implements _build_apply_label_ => as{ 'apply' };
+ implements _build_apply_label => as{ 'apply' };
implements _build_close_label_close => as{ 'close' };
implements _build_close_label_cancel => as{ 'cancel' };
implements can_apply => as {
my ($self) = @_;
- foreach my $field ( @{ $self->ordered_fields } ) {
+ foreach my $field ( @{ $self->fields } ) {
return 0 if $field->needs_sync;
# if e.g. a datetime field has an invalid value that can't be re-assembled
# into a datetime object, the action may be in a consistent state but
@@ -96,11 +96,11 @@ class Action is 'Reaction::UI::ViewPort::Object', which {
implements sync_action_from_fields => as {
my ($self) = @_;
- foreach my $field ($self->fields) {
+ foreach my $field (@{$self->fields}) {
$field->sync_to_action; # get the field to populate the $action if possible
}
- $self->action->sync_all;
- foreach my $field ($self->fields) {
+ $self->model->sync_all;
+ foreach my $field (@{$self->fields}) {
$field->sync_from_action; # get errors from $action if applicable
}
};
diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
index f60d433..17cdf53 100644
--- a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm
@@ -14,13 +14,14 @@ class ChooseMany is 'Reaction::UI::ViewPort::Field', which {
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
does 'Reaction::UI::ViewPort::Field::Role::Choices';
+
around value => sub {
my $orig = shift;
my $self = shift;
return $orig->($self) unless @_;
my $value = $listify->(shift);
$_ = $self->str_to_ident($_) for @$value;
- my $checked = $self->attribute->check_valid_value($self->action, $value);
+ my $checked = $self->attribute->check_valid_value($self->model, $value);
# i.e. fail if any of the values fail
confess "Not a valid set of values"
if (@$checked < @$value || grep { !defined($_) } @$checked);
@@ -32,6 +33,10 @@ class ChooseMany is 'Reaction::UI::ViewPort::Field', which {
return super() || [];
};
+ implements _build_value_string => as {
+ join ", ", @{ shift->current_value_choices }
+ };
+
implements is_current_value => as {
my ($self, $check_value) = @_;
my @our_values = @{$self->value||[]};
diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/DateTime.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/DateTime.pm
index 4950aa1..71428e5 100644
--- a/lib/Reaction/UI/ViewPort/Field/Mutable/DateTime.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Mutable/DateTime.pm
@@ -4,7 +4,8 @@ use Reaction::Class;
use Time::ParseDate;
use DateTime;
-class 'Reaction::UI::ViewPort::Field::Mutable::DateTime', is 'Reaction::UI::ViewPort::Field::DateTime', which {
+class 'Reaction::UI::ViewPort::Field::Mutable::DateTime',
+ is 'Reaction::UI::ViewPort::Field::DateTime', which {
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Choices.pm b/lib/Reaction/UI/ViewPort/Field/Role/Choices.pm
index 326dc54..09874a5 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Choices.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Choices.pm
@@ -39,7 +39,7 @@ role Choices, which {
implements _build_valid_values => as {
my $self = shift;
- return [ $self->attribute->all_valid_values($self->action) ];
+ return [ $self->attribute->all_valid_values($self->model) ];
};
implements _build_value_choices => sub{
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
index db6c4f3..66a46cf 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
@@ -33,14 +33,14 @@ role Mutable, which {
}
my $writer = $attr->get_write_method;
confess "No writer for attribute" unless defined($writer);
- $self->action->$writer($self->value); #should we be passing $value ?
+ $self->model->$writer($self->value); #should we be passing $value ?
$self->needs_sync(0);
};
implements sync_from_action => as {
my ($self) = @_;
return unless !$self->needs_sync; # && $self->has_attribute;
- $self->message($self->action->error_for($self->attribute) || '');
+ $self->message($self->model->error_for($self->attribute) || '');
};
around accept_events => sub { ('value', shift->(@_)) };
diff --git a/lib/Reaction/UI/ViewPort/Object.pm b/lib/Reaction/UI/ViewPort/Object.pm
index 326394f..9730b5f 100644
--- a/lib/Reaction/UI/ViewPort/Object.pm
+++ b/lib/Reaction/UI/ViewPort/Object.pm
@@ -61,7 +61,7 @@ class Object is 'Reaction::UI::ViewPort', which {
};
override child_event_sinks => sub {
- return ( shift->fields, super());
+ return ( @{shift->fields}, super());
};
#candidate for shared role!
diff --git a/lib/Reaction/UI/Widget/Field.pm b/lib/Reaction/UI/Widget/Field.pm
index 4d91afa..fbfe1eb 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_fragment {
+ implements fragment label_layout {
if (my $label = $_{viewport}->label) {
arg label => $label;
render 'label';
diff --git a/lib/Reaction/UI/Widget/Field/Integer.pm b/lib/Reaction/UI/Widget/Field/Integer.pm
new file mode 100644
index 0000000..5b5e724
--- /dev/null
+++ b/lib/Reaction/UI/Widget/Field/Integer.pm
@@ -0,0 +1,29 @@
+package Reaction::UI::Widget::Field::Integer;
+
+use Reaction::UI::WidgetClass;
+
+class Integer is 'Reaction::UI::Widget::Field', which {
+
+};
+
+1;
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::Widget::DisplayField::Integer
+
+=head1 DESCRIPTION
+
+See L<Reaction::UI::Widget::Field>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut
diff --git a/lib/Reaction/UI/Widget/Field/Mutable.pm b/lib/Reaction/UI/Widget/Field/Mutable.pm
index 2ff669a..5d658dc 100644
--- a/lib/Reaction/UI/Widget/Field/Mutable.pm
+++ b/lib/Reaction/UI/Widget/Field/Mutable.pm
@@ -2,7 +2,7 @@ package Reaction::UI::Widget::Field::Mutable;
use Reaction::UI::WidgetClass;
-class Field is 'Reaction::UI::Widget::Field', which {
+class Mutable is 'Reaction::UI::Widget::Field', which {
before fragment widget {
arg 'field_id' => event_id 'value';
diff --git a/lib/Reaction/UI/Widget/Field/Mutable/Integer.pm b/lib/Reaction/UI/Widget/Field/Mutable/Integer.pm
new file mode 100644
index 0000000..677082d
--- /dev/null
+++ b/lib/Reaction/UI/Widget/Field/Mutable/Integer.pm
@@ -0,0 +1,30 @@
+package Reaction::UI::Widget::Field::Mutable::Integer;
+
+use Reaction::UI::WidgetClass;
+
+class Integer is 'Reaction::UI::Widget::Field::Mutable', which {
+
+};
+
+1;
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::Widget::Field::Integer
+
+=head1 DESCRIPTION
+
+See L<Reaction::UI::Widget::Field>
+See L<Reaction::UI::Widget::Field::Mutable>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut
diff --git a/share/skin/default/layout/field/mutable/choose_many.tt b/share/skin/default/layout/field/mutable/choose_many.tt
index ef0b937..ed6c136 100644
--- a/share/skin/default/layout/field/mutable/choose_many.tt
+++ b/share/skin/default/layout/field/mutable/choose_many.tt
@@ -23,13 +23,13 @@
=for layout available_values
<select size="10" multiple="multiple" name="[% event_id_add_values %]">
- [% call_next %]
+ [% call_next %]
</select>
=for layout selected_values
<select size="10" multiple="multiple" name="[% event_id_remove_values %]">
- [% call_next %]
+ [% call_next %]
</select>
=for layout hidden_value
diff --git a/share/skin/default/layout/field/mutable/integer.tt b/share/skin/default/layout/field/mutable/integer.tt
new file mode 100644
index 0000000..05a69a5
--- /dev/null
+++ b/share/skin/default/layout/field/mutable/integer.tt
@@ -0,0 +1,3 @@
+=extends field/mutable
+
+=cut