[Bps-public-commit] r17229 - in sd/trunk/lib/App/SD: Server

jesse at bestpractical.com jesse at bestpractical.com
Mon Dec 15 02:50:21 EST 2008


Author: jesse
Date: Mon Dec 15 02:50:21 2008
New Revision: 17229

Modified:
   sd/trunk/lib/App/SD/Model/Attachment.pm
   sd/trunk/lib/App/SD/Model/Comment.pm
   sd/trunk/lib/App/SD/Model/Ticket.pm
   sd/trunk/lib/App/SD/Server/Dispatcher.pm
   sd/trunk/lib/App/SD/Server/View.pm

Log:
* added the ability to comment on newly created tickets.

Modified: sd/trunk/lib/App/SD/Model/Attachment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Attachment.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Attachment.pm	Mon Dec 15 02:50:21 2008
@@ -7,7 +7,7 @@
 use Params::Validate qw/validate/;
 
 use constant collection_class => 'App::SD::Collection::Attachment';
-use constant type => 'attachment';
+has type => ( default => 'attachment');
 
 
 sub _default_summary_format { '%s,$luid | %s,name | %s,content_type'}

Modified: sd/trunk/lib/App/SD/Model/Comment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Comment.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Comment.pm	Mon Dec 15 02:50:21 2008
@@ -3,7 +3,7 @@
 extends 'App::SD::Record';
 
 use constant collection_class => 'App::SD::Collection::Comment';
-use constant type => 'comment';
+has type => ( default => 'comment');
 
 
 sub _default_summary_format { '%s,$uuid | %s,content'}

Modified: sd/trunk/lib/App/SD/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/Model/Ticket.pm	Mon Dec 15 02:50:21 2008
@@ -98,37 +98,6 @@
     return $self->validate_prop_from_recommended_values( 'milestone', \%args );
 }
 
-sub validate_prop_from_recommended_values {
-    my $self = shift;
-    my $prop = shift;
-    my $args = shift;
-
-    if ( my @options = $self->recommended_values_for_prop($prop) ) {
-        return 1 if scalar grep { $args->{props}{$prop} eq $_ } @options;
-
-        $args->{errors}{$prop}
-            = "'" . $args->{props}->{$prop} . "' is not a valid $prop";
-        return 0;
-    }
-    return 1;
-
-}
-
-
-
-
-sub recommended_values_for_prop {
-    my $self = shift;
-    my $prop = shift;
-
-    if (my $code = $self->can("_recommended_values_for_prop_".$prop)) {
-        $code->($self, @_);
-    } else {
-        return undef;
-    }
-    
-}
-
 sub _recommended_values_for_prop_milestone {
    return @{ shift->app_handle->setting( label => 'milestones' )->get() };
 }

Modified: sd/trunk/lib/App/SD/Server/Dispatcher.pm
==============================================================================
--- sd/trunk/lib/App/SD/Server/Dispatcher.pm	(original)
+++ sd/trunk/lib/App/SD/Server/Dispatcher.pm	Mon Dec 15 02:50:21 2008
@@ -38,12 +38,16 @@
         shift->show_template( 'milestone', $milestone );
 
     };
+
+    on qr'^issue/new' => sub {
+        shift->show_template( 'new_issue');
+
+    };
+
     on qr'^issue/?$' => sub {
         my $self = shift;
-        my $id = $self->server->cgi->param('id');
-        if ($id) {
+        if (my $id = $self->server->cgi->param('id') ) {
             $self->server->_send_redirect( to => "/issue/$id" );
-
         } else {
             next_rule;
         }

Modified: sd/trunk/lib/App/SD/Server/View.pm
==============================================================================
--- sd/trunk/lib/App/SD/Server/View.pm	(original)
+++ sd/trunk/lib/App/SD/Server/View.pm	Mon Dec 15 02:50:21 2008
@@ -8,6 +8,7 @@
 use Prophet::Server::ViewHelpers;
 
 use App::SD::Model::Ticket;
+use App::SD::Model::Comment;
 use App::SD::Collection::Ticket;
 
 
@@ -23,7 +24,7 @@
 h1 {
     clear: both;
 }
-div.issue_list {
+ul.issue_list {
 
  border: 1px solid grey;
   -moz-border-radius: 0.5em;
@@ -133,6 +134,50 @@
     show( '/issue_list', $issues );
 }
 
+template update_issue => page {
+    my $self = shift;
+    my $uuid = shift;
+    title is 'Update an issue';
+
+    form {
+        my $f = function(
+            record =>
+                App::SD::Model::Ticket->new( app_handle => $self->app_handle, uuid => $uuid),
+            action => 'update',
+            order => 1,
+            name => 'edit-ticket'
+        );
+        for my $prop (
+            'summary', 'status',  'owner',    'created',
+            'due',     'creator', 'reporter', 'milestone'
+            ) {
+
+            div { widget( function => $f, prop => $prop ) };
+        }
+        h2 { 'Comments' };
+
+        my $c = function(
+            record => App::SD::Model::Comment->new(     
+                    app_handle => $self->app_handle ),
+            action => 'create',
+            order => 2,
+            name => 'create-ticket-comment'
+        );
+
+            param_from_function(
+                function      => $c,
+                prop          => 'ticket',
+                from_function => $f,
+                from_result   => 'record_uuid'
+            );
+        for my $prop (qw(content)) {
+
+            div { widget( function => $c, prop => $prop)};
+        }
+
+        input { attr { label => 'save', type => 'submit' } };
+    };
+};
 template new_issue => page {
     my $self = shift;
     title is 'Create a new issue';
@@ -142,16 +187,37 @@
             record =>
                 App::SD::Model::Ticket->new( app_handle => $self->app_handle ),
             action => 'create',
+            order => 1,
             name => 'create-ticket'
         );
         for my $prop (
             'summary', 'status',  'owner',    'created',
             'due',     'creator', 'reporter', 'milestone'
-            )
-        {
+            ) {
 
             div { widget( function => $f, prop => $prop ) };
         }
+        h2 { 'Comments' };
+
+        my $c = function(
+            record => App::SD::Model::Comment->new(     
+                    app_handle => $self->app_handle ),
+            action => 'create',
+            order => 2,
+            name => 'create-ticket-comment'
+        );
+
+            param_from_function(
+                function      => $c,
+                prop          => 'ticket',
+                from_function => $f,
+                from_result   => 'record_uuid'
+            );
+        for my $prop (qw(content)) {
+
+            div { widget( function => $c, prop => $prop)};
+        }
+
         input { attr { label => 'save', type => 'submit' } };
     };
 };
@@ -290,24 +356,21 @@
 };
 
 template issue_comments => sub {
-    my $self = shift;
-    my $issue = shift;
-    my @comments = sort _by_creation_date @{$issue->comments};
+    my $self     = shift;
+    my $issue    = shift;
+    my @comments = sort  @{ $issue->comments };
     if (@comments) {
-
-        h2 { 'Comments'};
-
+        h2 {'Comments'};
         ul {
-        for my $comment (@comments) {
-            li { 
-span {
- $comment->prop('created') ." " .
-$comment->prop('creator') }
-blockquote { $comment->prop('content');};
+            for my $comment (@comments) {
+                li {
+                    span { $comment->prop('created') . " " . $comment->prop('creator'); }
+                    blockquote { $comment->prop('content'); };
+                }
+            }
         }
     }
-    }}
- 
+
 };
 
 



More information about the Bps-public-commit mailing list