[Bast-commits] r3468 - in trunk/Anything/lib: Anything/Controller/Test Anything/InterfaceModel/Items/Action Anything/InterfaceModel/Items/Role DB/Anything

castaway at dev.catalyst.perl.org castaway at dev.catalyst.perl.org
Sun Jun 3 01:04:37 GMT 2007


Author: castaway
Date: 2007-06-03 01:04:36 +0100 (Sun, 03 Jun 2007)
New Revision: 3468

Modified:
   trunk/Anything/lib/Anything/Controller/Test/Item.pm
   trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Update.pm
   trunk/Anything/lib/Anything/InterfaceModel/Items/Role/Typefields.pm
   trunk/Anything/lib/DB/Anything/Items.pm
Log:
Items Update now working!


Modified: trunk/Anything/lib/Anything/Controller/Test/Item.pm
===================================================================
--- trunk/Anything/lib/Anything/Controller/Test/Item.pm	2007-06-02 13:33:08 UTC (rev 3467)
+++ trunk/Anything/lib/Anything/Controller/Test/Item.pm	2007-06-03 00:04:36 UTC (rev 3468)
@@ -15,12 +15,13 @@
   );
 
 sub get_collection {
-  my ($self, $c, $typeid) = @_;
+  my ($self, $c) = @_;
   my $model = $c->model(join('::', $self->model_base, $self->model_name));
-  if(defined $typeid)
+  my $type :Stashed;
+  if(defined $type)
   {
-      $model = $model->search({ TypeID => $typeid });
-     $model = $model->TypeID;
+      $model = $model->search({ TypeID => $type->ID });
+#     $model = $model->TypeID;
   }
   return $model;
 }
@@ -64,16 +65,16 @@
                      ctx => $c);
 }
 
-# sub list :Chained('base') :PathPart('') :Args() {
-#   my ($self, $c, $typeid) = @_;
+sub list :Chained('type') :PathPart('') :Args() {
+  my ($self, $c, $typeid) = @_;
   
-#   $self->push_viewport(
-#     $self->ListView_class, 
-#     collection => $self->get_collection($c, $typeid),
-#     exclude_columns => [qw/Created Modified/],
-#     column_order => [qw/Name Description/],                   
-#   );
-# }
+  $self->push_viewport(
+    $self->ListView_class, 
+    collection => $self->get_collection($c),
+    exclude_columns => [qw/Created Modified/],
+#    column_order => [qw/Name Description/],                   
+  );
+}
 
 ## Base list and create off type, which captures the typeid and stashes the type object ??
 

Modified: trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Update.pm
===================================================================
--- trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Update.pm	2007-06-02 13:33:08 UTC (rev 3467)
+++ trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Update.pm	2007-06-03 00:04:36 UTC (rev 3468)
@@ -36,7 +36,7 @@
       my $predicate = $attr->predicate;
       next if defined($predicate) && !$self->$predicate;
       my $field = $self->delayed_fields->{$name};
-      $row->value($field->Name, $self->$reader);
+      $row->value($field, $self->$reader);
     }
 
     return $row;

Modified: trunk/Anything/lib/Anything/InterfaceModel/Items/Role/Typefields.pm
===================================================================
--- trunk/Anything/lib/Anything/InterfaceModel/Items/Role/Typefields.pm	2007-06-02 13:33:08 UTC (rev 3467)
+++ trunk/Anything/lib/Anything/InterfaceModel/Items/Role/Typefields.pm	2007-06-03 00:04:36 UTC (rev 3468)
@@ -30,8 +30,8 @@
 
       $action_meta->add_attribute
         ($attr_name,
-         reader => 'get_field_{$attr_name}',
-         writer => 'set_field_{$attr_name}',
+         reader => "get_field_${attr_name}",
+         writer => "set_field_${attr_name}",
          is => 'rw',
          isa => $val->FieldID->TypeID->Name, #this will need fixing still
          predicate => "has_field_${attr_name}",

Modified: trunk/Anything/lib/DB/Anything/Items.pm
===================================================================
--- trunk/Anything/lib/DB/Anything/Items.pm	2007-06-02 13:33:08 UTC (rev 3467)
+++ trunk/Anything/lib/DB/Anything/Items.pm	2007-06-03 00:04:36 UTC (rev 3468)
@@ -52,7 +52,8 @@
 
 sub value_raw {
     my ($item, $field, $value) = @_;
-    
+    print STDERR "Setting field: $field, $value\n";
+
     if (not defined $field) {
         die "Attempt to get no field of an item???";
     }
@@ -67,24 +68,25 @@
         ## Calling Value on it will return undef, but we can get the Field detail
         if (@values == 0) {
            my $tfieldobj = $item->find_typefield($field);
-            return $item->new_related('itemvalues',
+            my $iv =$item->new_related('itemvalues',
                                       { 'FieldID' => $tfieldobj->FieldID->ID });
-#            return undef;
+           return $iv;
         } elsif (@values == 1) {
             return $values[0];
-#      return $values[0]->Value;
         } else {
             die "Multiple values for same field of same item???";
         }
     } else {
         my $tfieldobj = $item->find_typefield($field);
+        print STDERR "Found type: ", $tfieldobj->FieldID->Name, "\n";
         
-        return $item->find_or_create_related
+        my $iv = $item->update_or_create_related
             ('itemvalues', {
                 'FieldID' => $tfieldobj->FieldID->ID,
                 Value => $value,
             });
-#        })->Value();
+        print STDERR "IV value: ", $iv->Value, "\n";
+        return $iv;
     }
 }
 




More information about the Bast-commits mailing list