my $im_class = $cfg{im_class};
Class::MOP::load_class($im_class);
- my $model_name = $class;
- $model_name =~ s/^[\w:]+::(?:Model|M):://;
-
#XXXthis could be cut out later for a more elegant method
my @domain_models = $im_class->domain_models;
confess "Unable to locate domain model in ${im_class}"
my $schema_class = $domain_model->_isa_metadata;
Class::MOP::load_class($schema_class);
- {
- #I should probably MOPize this at some point maybe? nahhhh
- #XXXMaybe I should just fix CRUDController and eliminate this shit period.
- #pure bloat and namespace pollution
- no strict 'refs';
- foreach my $collection ( $im_class->parameter_attributes ){
- my $classname = join '::', $class, $collection->name, 'ACCEPT_CONTEXT';
- my $reader = $collection->get_read_method;
- *$classname = sub{ $_[1]->model($model_name)->$reader };
- }
- }
-
my $params = $cfg{db_params} || {};
my $schema = $schema_class
->connect($cfg{db_dsn}, $cfg{db_user}, $cfg{db_password}, $params);
use Reaction::Class;
__PACKAGE__->config(
- model_base => 'TestModel',
- model_name => 'Bar',
+ model_name => 'TestModel',
+ collection_name => 'Bar',
action => { base => { Chained => '/base', PathPart => 'testmodel/bar' }},
);
use Reaction::Class;
__PACKAGE__->config(
- model_base => 'TestModel',
- model_name => 'Baz',
+ model_name => 'TestModel',
+ collection_name => 'Baz',
action => { base => { Chained => '/base', PathPart => 'testmodel/baz' } },
);
use Reaction::Class;
__PACKAGE__->config(
- model_base => 'TestModel',
- model_name => 'Foo',
+ model_name => 'TestModel',
+ collection_name => 'Foo',
action => { base => { Chained => '/base', PathPart => 'testmodel/foo' } },
);
class Layout which {
- widget renders [ qw(menu sidebar header main_content) =>
- { viewport => func('self', 'viewport') } ];
+ widget renders [ qw(menu sidebar header main_content) ];
menu renders [ string { "DUMMY" } ];
sidebar renders [ string { "Sidebar Shit" } ];
};
implements build_builtin_collection_actions => as {
- { Create => {name => 'Create', base => Create } };
- { DeleteAll => {name => 'DeleteAll', base => DeleteAll } };
+ {
+ Create => {name => 'Create', base => Create },
+ DeleteAll => {name => 'DeleteAll', base => DeleteAll }
+ };
};
implements _all_object_actions => as {
unless( $reader ){
$reader = $source;
$reader =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ;
- $reader = lc($reader) . "_collection";
+ $reader = lc($reader) . "_collection"; #XXX change to not use _collection ?
}
unless( $dm_name ){
my @haystack = $meta->domain_models;
use aliased 'Reaction::UI::ViewPort::ActionForm';
use aliased 'Reaction::UI::ViewPort::ObjectView';
-has 'model_base' => (isa => 'Str', is => 'rw', required => 1);
-has 'model_name' => (isa => 'Str', is => 'rw', required => 1);
+has 'model_name' => (isa => 'Str', is => 'rw', required => 1);
+has 'collection_name' => (isa => 'Str', is => 'rw', required => 1);
has action_viewport_map => (isa => 'HashRef', is => 'rw', lazy_build => 1);
has action_viewport_args => (isa => 'HashRef', is => 'rw', lazy_build => 1);
sub get_collection {
my ($self, $c) = @_;
- #this sucks and should be fixed
- return $c->model(join('::', $self->model_base, $self->model_name));
+ my $model = $c->model( $self->model_name );
+ my $attr = $model->meta->find_attribute_by_name( $self->collection_name );
+ my $reader = $attr->get_read_method;
+ return $model->$reader;
}
sub get_model_action {
my @search_path = ($base, $app_name, 'Reaction::UI');
my @haystack = map { join '::', $_, 'Widget', $tail } @search_path;
for my $class (@haystack){
+ #here we should throw if exits and error instead of eating the error
+ #only next when !exists
eval { Class::MOP::load_class($class) };
#$@ ? next : return $class;
$@ ? next : return $cache->{ $lset_name } = $class;
fields renders [field over func('viewport','ordered_fields')];
field renders [ 'viewport' ];
+ #move button logic here
buttons renders [ string {"DUMMY"} ],
{message => sub{ $_{viewport}->can('message') ? $_{viewport}->message : "" } };
header renders [ string {"DUMMY"} ];