use base 'Reaction::UI::Controller::Collection::CRUD';
use Reaction::Class;
+use ComponentUI::UI::ViewPort::Baz::ListView::Member;
__PACKAGE__->config(
model_name => 'TestModel',
base => { Chained => '/base', PathPart => 'testmodel/baz' },
list => {
ViewPort => {
- enable_order_by => [qw/id name/],
+ enable_order_by => [qw/id name bool_field description/],
+ member_class => 'ComponentUI::UI::ViewPort::Baz::ListView::Member',
+ Member => {
+ Field => {
+ description => {
+ max_length => 40,
+ layout => 'value/string',
+ },
+ },
+ },
},
},
},
--- /dev/null
+package ComponentUI::UI::ViewPort::Baz::ListView::Member;
+
+use Reaction::Class;
+use namespace::clean -except => [ qw(meta) ];
+use aliased 'Reaction::UI::ViewPort::Field::String::Fragment';
+
+extends 'Reaction::UI::ViewPort::Collection::Grid::Member::WithActions';
+
+sub _build_layout {
+ 'collection/grid/member/with_actions';
+}
+
+sub _build_fields_for_name_description {
+ my ($self, $attr, $args) = @_;
+ $self->_build_simple_field(attribute => $attr, class => Fragment, %$args);
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__;
+
--- /dev/null
+package Reaction::UI::ViewPort::Field::String::Fragment;
+
+use Reaction::Class;
+use MooseX::Types::Moose qw/Int/;
+extends 'Reaction::UI::ViewPort::Field::String';
+
+has max_length => (
+ is => 'rw',
+ isa => Int,
+ required => 1,
+ default => sub { 80 }
+);
+
+sub _build_layout { 'field/string' };
+
+around _build_value_string => sub {
+ my $super = shift;
+ my $self = $_[0];
+ my $string = $super->(@_);
+ my $max_len = $self->max_length;
+ if(length($string) > $max_len){
+ $string = join('', substr( $string, 0, $max_len - 3 ), '...');
+ }
+ return $string;
+};
+
+1;
+
+__END__;
+
+=head1 DESCRIPTION
+
+If it was possible to address the widgets in any way this wouldn't be necessary.
+
+Ideally this would be a widget instead of a viewport. But there is currently no
+way to implement this in a widget, because it is impossible to pass any
+arguments to widgets.
+
+Using this module will require subclassing the Object or Member Viewport to
+override the builder classes for the field you desire to render as a string
+fragment. If we ever get a way to pass arguments to layouts or widgets, this
+will be greatly simplified. Don't hold your breath.
+
+=cut
my %attrs = map { $_->name => $_ } $member->parameter_attributes;
my $target;
if( $sm eq "Bar"){$target = 4; }
- elsif($sm eq "Baz"){$target = 4; }
+ elsif($sm eq "Baz"){$target = 5; }
elsif($sm eq "Foo"){$target = 5; }
Test::More::is( scalar keys %attrs, $target, "Correct # of attributes for $sm");
my $attr_num;
if($action_name =~ /Delete/){next; }
elsif($sm eq "Bar"){$attr_num = 4; }
- elsif($sm eq "Baz"){$attr_num = 3; }
+ elsif($sm eq "Baz"){$attr_num = 4; }
elsif($sm eq "Foo"){$attr_num = 3; }
Test::More::is( scalar keys %attrs, $attr_num, "Correct # of attributes for $sm");
if($attr_num != keys %attrs ){
) } (1 .. 50)
]);
$self->populate('Baz' => [
- [ qw/ name / ],
- map { [ "Baz $_" ] } (1 .. 4)
+ [ qw/ name description/ ],
+ map { [ "Baz $_", ("lorem ipsum dolor sit amet," x $_) ] } (1 .. 4)
]);
$self->populate('Bar' => [
[ qw/ name foo_id / ],
use Moose;
extends 'DBIx::Class::Core';
-use MooseX::Types::Moose qw/ArrayRef Int Bool/;
+use MooseX::Types::Moose qw/ArrayRef Int Bool Str/;
use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
has 'id' => (isa => Int, is => 'ro', required => 1);
has 'name' => (isa => NonEmptySimpleStr, is => 'rw', required => 1);
+has 'description' => (isa => Str, is => 'rw',);
has 'bool_field' => (isa => Bool, is => 'rw', required => 0);
has 'foo_list' => (
isa => ArrayRef,
__PACKAGE__->add_columns(
id => { data_type => 'integer', size => 16, is_auto_increment => 1 },
name => { data_type => 'varchar', size => 255 },
+ description => { data_type => 'text', is_nullable => 1 },
bool_field => {
data_type => 'char',
size => '1',