diff options
author | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-08-21 00:55:12 +0000 |
---|---|---|
committer | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-08-21 00:55:12 +0000 |
commit | e984a788c5ee855209cb6a4cc4fc07c085009b47 (patch) | |
tree | cb48986956e4992460aa4008711e0b34d851dc29 | |
parent | 599c1172394e3377d8e3e28c06557a99a1a10d1e (diff) | |
download | reaction-e984a788c5ee855209cb6a4cc4fc07c085009b47.tar.gz reaction-e984a788c5ee855209cb6a4cc4fc07c085009b47.zip |
svk add FAIL
-rw-r--r-- | lib/Reaction/UI/ViewPort/Field/Container.pm | 16 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/Object/Mutable.pm | 162 | ||||
-rw-r--r-- | lib/Reaction/UI/Widget/Field/Container.pm | 56 | ||||
-rw-r--r-- | lib/Reaction/UI/Widget/Object/Mutable.pm | 31 | ||||
-rw-r--r-- | share/skin/base/layout/field/container.tt | 18 |
5 files changed, 283 insertions, 0 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Container.pm b/lib/Reaction/UI/ViewPort/Field/Container.pm new file mode 100644 index 0000000..8f7dd3b --- /dev/null +++ b/lib/Reaction/UI/ViewPort/Field/Container.pm @@ -0,0 +1,16 @@ +package Reaction::UI::ViewPort::Field::Container; + +use Reaction::Class; + +use namespace::clean -except => [ qw(meta) ]; +extends 'Reaction::UI::ViewPort'; + +has label => (is => 'ro', isa => 'Str'); +has name => (is => 'ro', isa => 'Str', required => 1); +has fields => (is => 'ro', isa => 'ArrayRef', required => 1); + +__PACKAGE__->meta->make_immutable; + +1; + +__END__; diff --git a/lib/Reaction/UI/ViewPort/Object/Mutable.pm b/lib/Reaction/UI/ViewPort/Object/Mutable.pm new file mode 100644 index 0000000..797f8c6 --- /dev/null +++ b/lib/Reaction/UI/ViewPort/Object/Mutable.pm @@ -0,0 +1,162 @@ +package Reaction::UI::ViewPort::Object::Mutable; + +use Reaction::Class; + +use aliased 'Reaction::UI::ViewPort::Object'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Text'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Array'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::String'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Number'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Integer'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Boolean'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::Password'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::DateTime'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseOne'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseMany'; +use aliased 'Reaction::UI::ViewPort::Field::Mutable::File'; + +use namespace::clean -except => [ qw(meta) ]; +extends Object; + +#this her for now. mutable fields need an action to build correctly +has model => ( + is => 'ro', + isa => 'Reaction::InterfaceModel::Action', + required => 1, +); + +sub _build_fields_for_type_Num { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => Number, %$args); +} + +sub _build_fields_for_type_Int { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => Integer, %$args); +} + +sub _build_fields_for_type_Bool { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => Boolean, %$args); +} + +sub _build_fields_for_type_Reaction_Types_Core_SimpleStr { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => String, %$args); +} + +sub _build_fields_for_type_Reaction_Types_File_File { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => File, %$args); +} + +sub _build_fields_for_type_Str { + my ($self, $attr, $args) = @_; + if ($attr->has_valid_values) { # There's probably a better way to do this + $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args); + } else { + $self->_build_simple_field(attribute => $attr, class => Text, %$args); + } +} + +sub _build_fields_for_type_Reaction_Types_Core_Password { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => Password, %$args); +} + +sub _build_fields_for_type_Reaction_Types_DateTime_DateTime { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => DateTime, %$args); +} + +sub _build_fields_for_type_Enum { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args); +} + +#this needs to be fixed. somehow. beats the shit our of me. really. +#implements build_fields_for_type_Reaction_InterfaceModel_Object => as { +sub _build_fields_for_type_DBIx_Class_Row { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args); +} + +sub _build_fields_for_type_ArrayRef { + my ($self, $attr, $args) = @_; + if ($attr->has_valid_values) { + $self->_build_simple_field(attribute => $attr, class => ChooseMany, %$args); + } else { + $self->_build_simple_field + ( + attribute => $attr, + class => Array, + layout => 'field/mutable/hidden_array', + %$args); + } +} + +__PACKAGE__->meta->make_immutable; + +1; + +__END__; + +=head1 NAME + +Reaction::UI::ViewPort::Object::Mutable + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +This subclass of L<Reaction::UI::ViewPort::Object> is used for rendering a +collection of C<Reaction::UI::ViewPort::Field::Mutable::*> objects for user editing. + +=head1 ATTRIBUTES + +=head2 model + +L<Reaction::InterfaceModel::Action> + +=head1 METHODS + +=head2 _build_fields_for_type_Num + +=head2 _build_fields_for_type_Int + +=head2 _build_fields_for_type_Bool + +=head2 _build_fields_for_type_Reaction_Types_Core_SimpleStr + +=head2 _build_fields_for_type_Reaction_Types_File_File + +=head2 _build_fields_for_type_Str + +=head2 _build_fields_for_type_Reaction_Types_Core_Password + +=head2 _build_fields_for_type_Reaction_Types_DateTime_DateTime + +=head2 _build_fields_for_type_Enum + +=head2 _build_fields_for_type_DBIx_Class_Row + +=head2 _build_fields_for_type_ArrayRef + +=head1 SEE ALSO + +L<Reaction::UI::ViewPort::Object> + +L<Reaction::UI::ViewPort> + +L<Reaction::InterfaceModel::Action> + +=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/Container.pm b/lib/Reaction/UI/Widget/Field/Container.pm new file mode 100644 index 0000000..ba7fa28 --- /dev/null +++ b/lib/Reaction/UI/Widget/Field/Container.pm @@ -0,0 +1,56 @@ +package Reaction::UI::Widget::Field::Container; + +use Reaction::UI::WidgetClass; + +use namespace::clean -except => [ qw(meta) ]; + +before fragment widget { + arg name => $_{viewport}->name; +}; + +implements fragment maybe_label { + return unless $_{viewport}->has_label; + arg label => $_{viewport}->label; + render 'label'; +}; + +implements fragment field_list { + render field => over $_{viewport}->fields; +}; + +implements fragment field { + render 'viewport'; +}; + +__PACKAGE__->meta->make_immutable; + +1; + +__END__; + +=head1 NAME + +Reaction::UI::Widget::Field::Container + +=head1 DESCRIPTION + +=head1 FRAGMENTS + +=head2 field_list + +Sequentially renders the C<fields> of the viewport; + +=head2 field + +Renders the C<field> viewport passed by C<field_list> + +=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/Object/Mutable.pm b/lib/Reaction/UI/Widget/Object/Mutable.pm new file mode 100644 index 0000000..563c72b --- /dev/null +++ b/lib/Reaction/UI/Widget/Object/Mutable.pm @@ -0,0 +1,31 @@ +package Reaction::UI::Widget::Object::Mutable; + +use Reaction::UI::WidgetClass; + +use namespace::clean -except => [ qw(meta) ]; +extends 'Reaction::UI::Widget::Object'; + +__PACKAGE__->meta->make_immutable; + +1; + +__END__; + +=head1 NAME + +Reaction::UI::Widget::Object::Mutable + +=head1 DESCRIPTION + +=head1 FRAGMENTS + +=head1 AUTHORS + +See L<Reaction::Class> for authors. + +=head1 LICENSE + +See L<Reaction::Class> for the license. + +=cut + diff --git a/share/skin/base/layout/field/container.tt b/share/skin/base/layout/field/container.tt new file mode 100644 index 0000000..78bbdc0 --- /dev/null +++ b/share/skin/base/layout/field/container.tt @@ -0,0 +1,18 @@ +=for layout widget + +<fieldset class="field_container"> + [% maybe_label %] + [% field_list %] +</fieldset> + +=for layout label + +<legend> [% label %] </legend> + +=for layout field + +<span class="field_container_field"> + [% call_next %] +</span> + +=cut |