[Jifty-commit] r4497 - in apps/spensive: . etc lib/Spensive lib/Spensive/View share/web/static/css

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Nov 20 12:13:22 EST 2007


Author: jesse
Date: Tue Nov 20 12:13:20 2007
New Revision: 4497

Modified:
   apps/spensive/   (props changed)
   apps/spensive/etc/config.yml
   apps/spensive/lib/Spensive/Dispatcher.pm
   apps/spensive/lib/Spensive/Model/ExpenseReport.pm
   apps/spensive/lib/Spensive/View.pm
   apps/spensive/lib/Spensive/View/Reports.pm
   apps/spensive/share/web/static/css/app.css

Log:
 r67635 at pinglin (orig r7432):  jesse | 2007-09-28 15:45:44 -0400
 snapshot


Modified: apps/spensive/etc/config.yml
==============================================================================
--- apps/spensive/etc/config.yml	(original)
+++ apps/spensive/etc/config.yml	Tue Nov 20 12:13:20 2007
@@ -14,7 +14,7 @@
     RecordBaseClass: Jifty::DBI::Record::Cachable
     User: ''
     Version: 0.0.11
-  DevelMode: 0
+  DevelMode: 1
   L10N: 
     PoDir: share/po
   LogLevel: INFO

Modified: apps/spensive/lib/Spensive/Dispatcher.pm
==============================================================================
--- apps/spensive/lib/Spensive/Dispatcher.pm	(original)
+++ apps/spensive/lib/Spensive/Dispatcher.pm	Tue Nov 20 12:13:20 2007
@@ -23,13 +23,31 @@
 }
 };
 
+
+
+on qr'/reports' => run {
+    my $reports = Jifty->web->navigation->child('Reports');
+    my $open = $reports->child(Unsubmitted => url => '/reports/');
+    my $all = $reports->child(All => url => '/reports/all');
+};
 on qr'/reports/(\d+)/' => run {
     my $report = Spensive::Model::ExpenseReport->new();
     $report->load($1);
 
     my $reports = Jifty->web->navigation->child('Reports');
-    $reports->child( Build => label => 'Build', url => '/reports/'.$report->id.'/build');
-    $reports->child( Show => label => 'Show', url => '/reports/'.$report->id.'/show');
+    my $open = $reports->child('Unsubmitted');
+    my $all = $reports->child('All');
+    
+    my $subhead;
+
+    if ($report->status eq 'unsubmitted') {
+        $subhead=$open;
+    } else {
+        $subhead = $all;
+    }
+
+    $subhead->child( Build => label => 'Build', url => '/reports/'.$report->id.'/build');
+    $subhead->child( Show => label => 'Show', url => '/reports/'.$report->id.'/show');
 
     set( report => $report );
 };

Modified: apps/spensive/lib/Spensive/Model/ExpenseReport.pm
==============================================================================
--- apps/spensive/lib/Spensive/Model/ExpenseReport.pm	(original)
+++ apps/spensive/lib/Spensive/Model/ExpenseReport.pm	Tue Nov 20 12:13:20 2007
@@ -14,7 +14,7 @@
     column approved => type is 'datetime';
     column published_address => type is 'varchar(32)', is immutable, since is '0.0.11';
     column approved_by => references Spensive::Model::User;
-    column status => type is 'text', valid are qw(unsubmitted approved denied);
+    column status => type is 'text', valid are qw(unsubmitted submitted approved denied);
 };
 
 # Your model-specific methods go here.

Modified: apps/spensive/lib/Spensive/View.pm
==============================================================================
--- apps/spensive/lib/Spensive/View.pm	(original)
+++ apps/spensive/lib/Spensive/View.pm	Tue Nov 20 12:13:20 2007
@@ -8,9 +8,11 @@
 
 template 'index.html' => page {
 
-    h1 { _('Spensive helps you keep track of your business expenses') };
-    h2 { _('(It also helps you get reimbursed for them)') };
+    h1 { _('expense.it')};
+    h2{ _('Track your business expenses') };
+    h2 { _('(And get reimbursed for them)') };
 
+    div { { class is 'hint'}; outs_raw(_('You can record expenses by emailing %1'. a{ {href is 'mailto:'.Jifty->web->current_user->user_object->published_address;} Jifty->web->current_user->user_object->published_address})); };
     h3   { _('Unsubmitted expenses') };
     form { 
         my $search = Spensive::Model::ExpenseCollection->new();

Modified: apps/spensive/lib/Spensive/View/Reports.pm
==============================================================================
--- apps/spensive/lib/Spensive/View/Reports.pm	(original)
+++ apps/spensive/lib/Spensive/View/Reports.pm	Tue Nov 20 12:13:20 2007
@@ -11,7 +11,9 @@
 private template view_item_controls => sub {
     my $self =shift;
     my $item=shift;
+    span { { class is 'viewcontrols'};
     tangent(url => '/reports/'.$item->id."/build", label => 'Details');
+    }
 };
 
 sub display_columns {
@@ -20,6 +22,119 @@
 
 }
 
+template view => sub {
+    my $self   = shift;
+    my $record = $self->_get_record( get('id') );
+
+    my $update = $record->as_update_action(
+        moniker => "update-" . Jifty->web->serial,
+    );
+
+    div {
+        { class is 'expense-report-list-open-entry' };
+
+        h2 { $record->title };
+        div { {class is 'description'};
+            outs($record->description);
+        };
+        show ('./view_item_controls', $record, $update);
+
+    };
+
+};
+
+template view_for_all_reports => sub {
+    my $self   = shift;
+    my $record = $self->_get_record( get('id') );
+
+    my $update = $record->as_update_action( moniker => "update-" . Jifty->web->serial,);
+
+    div { { class is 'expense-report-list-all-entry' };
+
+        h2 { $record->title };
+        div { { class is 'status'}; $record->status; };
+        div { {class is 'description'}; outs($record->description); };
+        show ('./view_item_controls', $record, $update);
+
+    };
+
+};
+
+template 'index.html' => page {
+    title=> 'Unsubmitted expense reports' } content {
+    my $self = shift;
+
+    my $unsubmitted = Spensive::Model::ExpenseReportCollection->new();
+    $unsubmitted->limit( column => 'id', value => 0);#unlimit();
+
+    h2 { 'Unsubmitted expense reports'};
+
+    form {
+        render_region(
+            name     => 'unsubmitted',
+            path     => $self->fragment_base_path.'/unsubmitted_list',
+#           defaults => { fragment_for_new_item => '/__jifty/empty' }
+);  
+    };
+
+}
+
+template 'all' => page {
+    title => 'All my expense reports' } content {
+
+    my $self = shift;
+    form { render_region( name     => $self->object_type.'-list', path     => $self->fragment_base_path.'/all_list', defaults => { item_path => $self->fragment_base_path .'/view_for_all_reports'}); };
+    
+};      
+
+
+template 'all_list' => sub {
+    my $reports = Spensive::Model::ExpenseReportCollection->new();
+    $reports->limit(column => 'submitted_by', value => Jifty->web->current_user->id);
+    set( search_collection => $reports); show('./list');
+
+};
+template 'unsubmitted_list' => sub {
+    my $unsubmitted = Spensive::Model::ExpenseReportCollection->new();
+    $unsubmitted->limit( column => 'status', value => 'unsubmitted');
+    $unsubmitted->limit( column => 'status', operator =>  'is', value => 'null');
+    $unsubmitted->limit(column => 'submitted_by', value => Jifty->web->current_user->id);
+    set( search_collection => $unsubmitted); show('./list');
+
+};
+
+template 'new_item' => sub {
+    my $self = shift;
+    my ( $object_type, $id ) = ( $self->object_type, get('id') );
+
+    my $record_class = $self->record_class;
+    my $create = $record_class->as_create_action;
+
+    h2 { 'New expense report' };
+    div {
+        { class is 'new-expense-report'};
+        show('./edit_item', $create);
+    
+        outs(
+            Jifty->web->form->submit(
+                label   => _('Create'),
+                onclick => [
+                    { submit       => $create },
+                    { refresh_self => 1 },
+                    {   element =>
+                            Jifty->web->current_region->parent->get_element(
+                            'div.list'),
+                        append => $self->fragment_for('view'),
+                        args   => {
+                            object_type => $object_type,
+                            id => { result_of => $create, name => 'id' },
+                        },
+                    },
+                ]
+            )
+        );
+    }
+};
 
 
 use Jifty::Plugin::TabView::View;
@@ -141,13 +256,15 @@
     div { { class is 'hint'};
         outs_raw(_('You can add new expenses to this expense report by emailing %1'. a{ {href is 'mailto:'.get('report')->published_address;} get('report')->published_address}));
     };
+
+
+
     render_region(
         name     => 'reports',
         path     => '/reports/report_tabs',
         defaults => { report => get('report')->id }
     );
 
-    outs_raw( Jifty->web->return( label => 'Done' ) );
 };
 
 template report_tabs => sub {
@@ -155,25 +272,43 @@
     $self->render_tabs(
         'reports',
         [qw(report)],
+        {   label => 'Summary',
+            path  => 'report_summary',
+            defer => 1
+        },
         {   label => 'Attach expenses',
-            path  => 'attach_reports',
+            path  => 'attach_expenses',
             defer => 1
         },
         {   label => 'Remove expenses',
-            path  => 'remove_reports',
+            path  => 'remove_expenses',
             defer => 1,
         },
         {   label => 'Add expenses',
-            path  => 'add_report',
+            path  => 'add_expense',
             defer => 1,
         }
     );
 
-    #        qw(/attach_reports_tab /remove_reports_tab ) );
+    #        qw(/attach_expenses_tab /remove_expenses_tab ) );
 };
 
 
-template 'add_report' => sub {
+template report_summary => sub {
+    my $report_id=get('report');
+    my $report = Spensive::Model::ExpenseReport->new();
+    $report->load($report_id);
+    my $action = Jifty->web->new_action( class => 'UpdateExpenseReport', record => $report );
+
+    form {
+        for(qw(title description status)) {
+            render_param($action => $_);
+        }
+        outs_raw( $action->button( label   => 'Save changes', onclick => [ { submit => $action, }, { refresh_self => 1 } ]));
+    };
+};
+
+template 'add_expense' => sub {
     my $report_id = get('report');
     my $report    = Spensive::Model::ExpenseReport->new();
     $report->load($report_id);
@@ -188,7 +323,7 @@
 
 };
 
-template 'attach_reports' => sub {
+template 'attach_expenses' => sub {
     my $report_id = get('report');
     my $report    = Spensive::Model::ExpenseReport->new();
     $report->load($report_id);
@@ -224,7 +359,7 @@
     }
 
 };
-template 'remove_reports' => sub {
+template 'remove_expenses' => sub {
     my $report_id = get('report');
     my $report    = Spensive::Model::ExpenseReport->new();
     $report->load($report_id);
@@ -263,12 +398,7 @@
             render_param($action => $_, 
             render_as     => 'Hidden');
         }
-        outs_raw(
-            $action->button(
-                label   => 'Add',
-                onclick => [ { submit => $action, }, { refresh_self => 1 } ]
-            )
-        );
+        outs_raw( $action->button( label   => 'Add', onclick => [ { submit => $action, }, { refresh_self => 1 } ]));
         }
 };
 
@@ -276,9 +406,7 @@
     my $report = get('report');
     my $item   = Spensive::Model::Expense->new();
     $item->load( get 'id' );
-    my $action
-        = Jifty->web->new_action( class => 'UpdateExpense', record => $item,
-        );
+    my $action = Jifty->web->new_action( class => 'UpdateExpense', record => $item,);
     h3 { $item->title, ' - ', $item->cost, " - ", };
     form {
         render_param(
@@ -324,4 +452,27 @@
 
     }
 };
+
+
+
+
+
+template 'pdf' => sub {
+#   output a ps of the title page
+#   output a ps of the summary section 
+#   For each appendix, 
+#       output a ps of the title page
+#       for each bit of collateral
+#           if it's a ps, write out the ps file
+#           if it's a pdf, write out the pdf file
+#           otherwise,  output a ps of the content
+#
+#
+#   concatenate 
+#
+};
+
+
+
+
 1;

Modified: apps/spensive/share/web/static/css/app.css
==============================================================================
--- apps/spensive/share/web/static/css/app.css	(original)
+++ apps/spensive/share/web/static/css/app.css	Tue Nov 20 12:13:20 2007
@@ -48,3 +48,16 @@
     max-width: 250px;
 
 }
+
+div.hint { 
+width: 22em;
+height: 2em;
+padding: 1em;
+top: 2em;
+right: 240px;
+position: absolute;
+background: #fcc;
+-moz-border-radius: 10px;
+
+ };
+


More information about the Jifty-commit mailing list