use Reaction::UI::WidgetClass;
-class Layout which {
+class Layout, which {
implements fragment main_content {
if (my $inner = $_{viewport}->inner) {
metaclass => DomainModelAttribute,
);
+ has 'member_type' => (is => 'ro', isa => 'ClassName');
+
implements _build__collection_store => as { [] };
implements members => as {
isa => 'DBIx::Class::ResultSet',
);
- has '_im_class' => (
- is => 'ro',
- isa => 'Str',
- lazy_build => 1,
- );
+ has 'member_type' => (is => 'ro', isa => 'ClassName', lazy_build => 1);
+
#implements BUILD => as {
# my $self = shift;
# unless $self->_im_class->can("inflate_result");
#};
+
+
#Oh man. I have a bad feeling about this one.
- implements _build__im_class => as {
+ implements _build_member_type => as {
my $self = shift;
my $class = blessed($self) || $self;
$class =~ s/::Collection$//;
implements _build__collection_store => as {
my $self = shift;
- my $im_class = $self->_im_class;
- [ $self->_source_resultset->search({}, {result_class => $im_class})->all ];
+ [ $self->_source_resultset->search({}, {result_class => $self->member_type})->all ];
};
implements clone => as {
#should the clone include the arrayref of IM::Objects too?
return (blessed $self)->new(
_source_resultset => $rs,
- _im_class => $self->_im_class, @_
+ member_type => $self->member_type, @_
);
};
my $rs = $self->_source_resultset->page(@_);
return (blessed $self)->new(
_source_resultset => $rs,
- _im_class => $self->_im_class,
+ member_type => $self->member_type,
);
};
Required, Read-only. Contains the L<DBIx::Class::ResultSet> used to populate the
collection.
-=head2 _im_class
+=head2 member_type
Read-only, lazy_build. The name of the IM Object Class that the resultset inside this
-collection will inflate to. Predicate: C<_has_im_class>
+collection will inflate to. Predicate: C<has_member_type>
=head1 METHODS
my $rs = $self->_source_resultset->search_rs(@_);
return (blessed $self)->new(
_source_resultset => $rs,
- _im_class => $self->_im_class
+ member_type => $self->member_type
);
};
implements find => as {
my $self = shift;
$self->_source_resultset
- ->search({},{result_class => $self->_im_class})
+ ->search({},{result_class => $self->member_type})
->find(@_);
};
};
my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;;
$meta->make_mutable if $meta->is_immutable;
- $meta->add_method(_build__im_class => sub{ $object } );
+ $meta->add_method(_build_member_type => sub{ $object } );
#XXX as a default pass the domain model as a target_model until i come up with something
#better through the coercion method
my $def_act_args = sub {
use Reaction::Class;
use aliased 'Reaction::UI::ViewPort::ListView';
-use aliased 'Reaction::UI::ViewPort::ObjectView';
+use aliased 'Reaction::UI::ViewPort::Object';
has 'model_name' => (isa => 'Str', is => 'rw', required => 1);
has 'collection_name' => (isa => 'Str', is => 'rw', required => 1);
sub _build_action_viewport_map {
return {
list => ListView,
- view => ObjectView,
+ view => Object,
};
}
sub view :Chained('object') :Args(0) {
my ($self, $c) = @_;
my $object :Stashed;
- $c->forward(basic_page => [{object => $object}]);
+ $c->forward(basic_page => [{model => $object}]);
}
sub basic_page : Private {
use base 'Reaction::UI::Controller::Collection';
use Reaction::Class;
-use aliased 'Reaction::UI::ViewPort::ActionForm';
+use aliased 'Reaction::UI::ViewPort::Action';
sub _build_action_viewport_map {
my $map = shift->next::method(@_);
- map{ $map->{$_} = ActionForm } qw/create update delete delete_all/;
+ map{ $map->{$_} = Action } qw/create update delete delete_all/;
return $map;
}
{ label => 'Delete all', action => sub {
[ '', 'delete_all', $_[1]->req->captures ] } },
],
- Entity =>
+ Member =>
{ action_prototypes =>
[ { label => 'View', action => sub {
[ '', 'view', [ @{$_[1]->req->captures}, $_[0]->__id ] ] } },
return $self->push_viewport
(
$self->action_viewport_map->{$cat_action_name},
- action => $self->get_model_action($c, $im_action_name, $target),
+ model => $self->get_model_action($c, $im_action_name, $target),
%{ $vp_args || {} },
%{ $self->action_viewport_args->{$cat_action_name} || {} },
);
# doesn't have the match pos go past the latter = and lose name2
while ($data =~ m/=(.*?)\n(.*?)(?:\n(?==)|$)/sg) {
my ($data, $text) = ($1, $2);
-
if ($data =~ /^for layout (\S+)/) {
my $fname = $1;
$layouts->{$fname} = $text;
#use aliased 'Reaction::UI::ViewPort::InterfaceModel::Field::Mutable::TimeRange';
class Action is 'Reaction::UI::ViewPort::Object', which {
- has '+model' => (isa => 'Reaction::InterfaceModel::Action');
+ has model => (is => 'ro', isa => 'Reaction::InterfaceModel::Action', required => 1);
+ #has '+model' => (isa => 'Reaction::InterfaceModel::Action');
has next_action => (is => 'rw', isa => 'ArrayRef');
has on_apply_callback => (is => 'rw', isa => 'CodeRef');
-package Reaction::UI::ViewPort::InterfaceModel::Action::Link;
+package Reaction::UI::ViewPort::Action::Link;
use Reaction::Class;
implements BUILD => as {
my ($self, $args) = @_;
- my $entity_args = delete $args->{Member};
+ my $member_args = delete $args->{Member};
$self->member_args( $member_args ) if ref $member_args;
};
+ implements _build_member_args => as{ {} };
+
implements _build_member_class => as{ Object };
after clear_current_collection => sub{
- shift->clear_entities; #clear the entitiesis the current collection changes, duh
+ shift->clear_members; #clear the members the current collection changes, duh
};
implements _build_current_collection => as {
shift->collection;
};
- implements model
+ #I'm not really sure why this is here all of a sudden.
+ implements model => as { shift->current_collection };
implements _build_members => as {
my ($self) = @_;
my $builder_cache = $builders->{$type} ||= {};
my $member = $class->new(
ctx => $ctx,
- object => $obj,
+ model => $obj,
location => join('-', $loc, $i++),
builder_cache => $builder_cache,
%$args
return \%labels;
};
+ implements _build_field_order => as { []; };
+ implements _build_excluded_fields => as { []; };
+
implements _build_ordered_fields => as {
my ($self) = @_;
confess("current_collection lacks a value for 'member_type' attribute")
unless $self->current_collection->has_member_type;
my %excluded = map { $_ => undef } @{ $self->excluded_fields };
#treat _$field_name as private and exclude fields with no reader
- my @names = grep { $_ !~ /^_/ && !exists($exclude{$_})} map { $_->name }
+ my @names = grep { $_ !~ /^_/ && !exists($excluded{$_})} map { $_->name }
grep { defined $_->get_read_method }
$self->current_collection->member_type->meta->parameter_attributes;
return $self->sort_by_spec($self->field_order, \@names);
use Reaction::Class;
-Class Member is 'Reaction::UI::ViewPort::Object', which {
+class Member is 'Reaction::UI::ViewPort::Object', which {
around _build_fields_for_type_Num => sub {
$_[0]->(@_[1..3], { layout => 'value/number', %{ $_[4] } })
around _build_fields_for_type_Reaction_InterfaceModel_Collection => sub { return };
};
+
+1;
my $orig = shift;
my $self = shift;
return $orig->($self) unless @_;
- my $value = defined $_[0] ? $_[0] || [];
+ my $value = defined $_[0] ? $_[0] : [];
$orig->($self, (ref $value eq 'ARRAY' ? $value : [ $value ]));
$self->sync_to_action;
};
class ChooseOne is 'Reaction::UI::ViewPort::Field', which {
- does 'Reaction::UI::ViewPort::Object::Field::Role::Mutable';
- does 'Reaction::UI::ViewPort::Object::Field::Role::Choices';
+ does 'Reaction::UI::ViewPort::Field::Role::Mutable';
+ does 'Reaction::UI::ViewPort::Field::Role::Choices';
around value => sub {
my $orig = shift;
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';
}
};
- override accept_events => sub {
- ('value_string', super());
- };
+ around accept_events => sub { ('value_string', shift->(@_)) };
};
use Reaction::Class;
-class Number 'Reaction::UI::ViewPort::Field::Number', which {
+class Number is 'Reaction::UI::ViewPort::Field::Number', which {
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
};
package Reaction::UI::ViewPort::Field::Role::Choices;
-use Reaction::Class;
+use Reaction::Role;
use URI;
use Scalar::Util 'blessed';
package Reaction::UI::ViewPort::Field::Role::Mutable;
+use Reaction::Role;
+
use aliased 'Reaction::InterfaceModel::Action';
use aliased 'Reaction::Meta::InterfaceModel::Action::ParameterAttribute';
around accept_events => sub { ('value', shift->(@_)) };
};
+
+1;
package Reaction::UI::ViewPort::ListView;
use Reaction::Class;
-use aliased 'Reaction::UI::ViewPort::GridView::Entity::WithActions';
+use aliased 'Reaction::UI::ViewPort::Collection::Grid::Member::WithActions';
-class ListView is 'Reaction::UI::ViewPort::GridView', which {
+class ListView is 'Reaction::UI::ViewPort::Collection::Grid', which {
- does 'Reaction::UI::ViewPort::GridView::Role::Order';
- does 'Reaction::UI::ViewPort::GridView::Role::Pager';
- does 'Reaction::UI::ViewPort::GridView::Role::Actions';
+ does 'Reaction::UI::ViewPort::Collection::Role::Order';
+ does 'Reaction::UI::ViewPort::Collection::Role::Pager';
+ does 'Reaction::UI::ViewPort::Role::Actions';
#If I decide that object actions and collection actions should be
#lumped together i oculd move these into the collection action role
#ooor we could create a third role that does this, but gah, no?
- implements _build_entity_class => as { WithActions };
+ implements _build_member_class => as { WithActions };
#You'se has to goes aways. sorry.
#if i saved the args as an attribute i could probably get around this....
implements object_action_count => as {
my $self = shift;
- for ( @{ $self->entities } ) {
+ for ( @{ $self->members } ) {
#pickup here, and of to the widget for listview
return scalar @{ $_->action_prototypes };
}
use aliased 'Reaction::UI::ViewPort::Field::String';
use aliased 'Reaction::UI::ViewPort::Field::DateTime';
use aliased 'Reaction::UI::ViewPort::Field::RelatedObject';
-use aliased 'Reaction::UI::ViewPort::Field::List';
+use aliased 'Reaction::UI::ViewPort::Field::Array';
use aliased 'Reaction::UI::ViewPort::Field::Collection';
use aliased 'Reaction::InterfaceModel::Object' => 'IM_Object';
my $field = $self->$meth($obj, $attr, ($args->{$field_name} || {}));
push(@fields, $field) if $field;
}
- return \@field;
+ return \@fields;
};
implements _build_ordered_fields => as {
my ($self) = @_;
my %excluded = map { $_ => undef } @{ $self->excluded_fields };
#treat _$field_name as private and exclude fields with no reader
- my @names = grep { $_ !~ /^_/ && !exists($exclude{$_})} map { $_->name }
+ my @names = grep { $_ !~ /^_/ && !exists($excluded{$_})} map { $_->name }
grep { defined $_->get_read_method } $self->model->meta->parameter_attributes;
return $self->sort_by_spec($self->field_order, \@names);
};
implements _build_fields_for_type_ArrayRef => as {
my ($self, $attr, $args) = @_;
- $self->_build_simple_field(attribute => $attr, class => List, %$args);
+ $self->_build_simple_field(attribute => $attr, class => Array, %$args);
};
implements _build_fields_for_type_Reaction_InterfaceModel_Object => as {
my ($self) = @_;
my (@act, $i);
my $ctx = $self->ctx;
- #if i could abstract this vs ->object for row we could eliminate the entity
- #version of this role and just use one for both things. that would be cool.
- my $obj = $self->current_collection;
my $loc = $self->location;
foreach my $proto (@{ $self->action_prototypes }) {
my $action = Reaction::UI::ViewPort::Action::Link->new
(
ctx => $ctx,
- target => $obj,
+ target => $self->model,
location => join ('-', $loc, 'action', $i++),
%$proto,
);
-package Reaction::UI::Widget::Field::List;
+package Reaction::UI::Widget::Field::Array;
use Reaction::UI::WidgetClass;
-class List, which {
+class Array, which {
before fragment widget {
arg 'label' => $_{viewport}->label;
=head1 NAME
-Reaction::UI::Widget::DisplayField::List
+Reaction::UI::Widget::DisplayField::Array
=head1 DESCRIPTION
use Reaction::UI::WidgetClass;
-class ListView is 'Reaction::UI::Widget::GridView', which {
+class ListView is 'Reaction::UI::Widget::Collection::Grid', which {
after fragment widget {
arg pager_obj => $_{viewport}->pager;
--- /dev/null
+=for layout widget
+
+[% members %]
+
+=cut
\ No newline at end of file
[% label %]
-=for layout footer
-
-<tfoot>
- [% footer_row %]
-</tfoot>
-
-=for layout footer_row
-
-[% header_row %]
-
=for layout body
<tbody>
- [% body_rows %]
+
+ [% members %]
+
</tbody>
=cut
-=extends grid_view/entity
+=extends collection/grid/member
=for layout field_list
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
+++ /dev/null
-=for layout widget
-
-[% label_layout %]
-[% value_layout %]
-
-=for layout label_layout
-
-<strong > [% label %]: </strong>
-
-=for layout value_layout
-
-[% value %]
-
-=cut
=for layout widget
-[% label_fragment %] [% field %] [% message_fragment %] <br />
+[% label_layout %]
+[% value_layout %]
-=for layout label
+=for layout label_layout
-<label>[% label %]:</label>
+<strong > [% label %]: </strong>
-=for layout field
+=for layout value_layout
-FIELD GOES HERE
-
-=for layout message
-
-<span>[% message %]</span><br />
-
-=for layout field
-
-<input type="[% field_type %]" name="[% field_name %]" id="[% field_id %]"
- [% field_body %] />
-
-=for layout field_body
-
-value="[% field_value %]"
+[% value %]
=cut
=extends field
-=for layout field_body
-
-value="1" [% is_checked %]
-
-=for layout is_checked_yes
-
-checked="checked"
-
-=for layout is_checked_no
-
=cut
--- /dev/null
+=for layout widget
+
+[% label_fragment %] [% field %] [% message_fragment %] <br />
+
+=for layout label
+
+<label for="[%field_id%]">[% label %]:</label>
+
+=for layout field
+
+<!-- Why is this here??? -->
+FIELD GOES HERE
+
+=for layout message
+
+<span>[% message %]</span><br />
+
+=for layout field
+
+<input type="[% field_type %]" name="[% field_name %]" id="[% field_id %]"
+ [% field_body %] />
+
+=for layout field_body
+
+value="[% field_value %]"
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=for layout field_body
+
+value="1" [% is_checked %]
+
+=for layout is_checked_yes
+
+checked="checked"
+
+=for layout is_checked_no
+
+=cut
-=extends field
+=extends field/mutable
=for layout widget
-=extends field
+=extends field/mutable
=for layout field
--- /dev/null
+=extends field/mutable
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=cut
--- /dev/null
+=extends field/mutable
+
+=for layout field
+
+<textarea name="[% field_name %]" id="[% field_id %]">
+ [% field_value %]
+</textarea>
+
+=cut
-=for layout widget
-
-[% label %] [% field %] [% message %]
-
-=for layout field
-
-<!-- We need a replacement for process_attrs -->
-<input type="text" name="[% name | html%]" id="[% id | html %]" value="[% content | html %]" />
-
-=for layout label
-
-<!-- This conditional goes away when mst comes up with something better -->
-[% content_str = GET content; %]
-[% IF content_str.length; %]
- <label> [% content_str | html %]: </label>
-[% END; %]
-
-=for layout message
-
-<!-- This conditional goes away when mst comes up with something better -->
-[% content_str = GET content; %]
-[% IF content_str.length; %]
- <span> [% content_str | html %] </span> <br />
-[% END %]
+=extends field
=cut
=extends field
-=for layout field
-
-<textarea name="[% field_name %]" id="[% field_id %]">
- [% field_value %]
-</textarea>
-
=cut
-=extends grid_view
+=extends collection/grid
=for layout widget