[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm

bisitz bisitz@source.lon-capa.org
Mon, 12 Apr 2010 17:27:24 -0000


bisitz		Mon Apr 12 17:27:24 2010 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  - Optimized portfolio file list:
  Also display header for empty directories and show empty message.
  This should avoid confusion about a screen with many functions but no portfolio files.
  - Optimized spacing for "Portfolio FileList" help link
  - Optimized "Delete Directory" button:
      - Moved button from above to below the list, right below the empty message (see above)
      - Removed unnecessary variable
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.222 loncom/interface/portfolio.pm:1.223
--- loncom/interface/portfolio.pm:1.222	Fri Mar 26 23:08:41 2010
+++ loncom/interface/portfolio.pm	Mon Apr 12 17:27:24 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.222 2010/03/26 23:08:41 raeburn Exp $
+# $Id: portfolio.pm,v 1.223 2010/04/12 17:27:24 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -287,7 +287,6 @@
     my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
         $can_modify,$can_delete,$can_setacl)=@_;
     my $iconpath= $r->dir_config('lonIconsURL') . "/";
-    my $display_out;
     my $select_mode;
     my $checked_files;
     my $port_path = &get_port_path();
@@ -304,30 +303,17 @@
     my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);
     my $now = time;
     if ($env{"form.mode"} eq 'selectfile') {
-	&select_files($r);
-	$checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
-	$select_mode = 'true';
-    } 
-    if ($is_empty && ($current_path ne '/') && $can_delete) {
-        $display_out = '<form method="post" action="'.$url.'">'.
-	    &group_form_data().
-        '<input type="hidden" name="action" value="deletedir" />'.
-        '<p>'.
-        '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
-        '</p>'.
-        '<input type="hidden" name="selectfile" value="" />'.
-        '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '</form>';
-        
-        $r->print($display_out);
-	return;
+        &select_files($r);
+        $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
+        $select_mode = 'true';
     }
     if ($select_mode eq 'true') {
         $r->print('<form method="post" name="checkselect" action="'.$url.'">');
         $r->print(&Apache::loncommon::start_data_table()
                  .&Apache::loncommon::start_data_table_header_row()
                  .'<th>'.&mt('Select').'</th>'
-                 .'<th>&nbsp;</th><th>&nbsp;</th>'
+                 .'<th>&nbsp;</th>'
+                 .'<th>&nbsp;</th>'
                  .'<th>'.&mt('Name').'</th>'
                  .'<th>'.&mt('Size').'</th>'
                  .'<th>'.&mt('Last Modified').'</th>'
@@ -336,12 +322,18 @@
         );
     } else {
         $r->print('<form method="post" action="'.$url.'">');
-	$r->print(&Apache::loncommon::help_open_topic('Portfolio FileList',
-						      &mt('Using the portfolio file list')));
+        $r->print(
+            '<p>'
+           .&Apache::loncommon::help_open_topic(
+                'Portfolio FileList',
+                &mt('Using the portfolio file list'))
+           .'</p>'
+        );
         $r->print(&Apache::loncommon::start_data_table()
                  .&Apache::loncommon::start_data_table_header_row()
                  .'<th colspan="2">'.&mt('Actions'). &Apache::loncommon::help_open_topic('Portfolio FileAction').'</th>'
-                 .'<th>&nbsp;</th><th>&nbsp;</th>'
+                 .'<th>&nbsp;</th>'
+                 .'<th>&nbsp;</th>'
                  .'<th>'.&mt('Name').&Apache::loncommon::help_open_topic('Portfolio OpenFile').'</th>'
                  .'<th>'.&mt('Size').'</th>'
                  .'<th>'.&mt('Last Modified').'</th>'
@@ -349,6 +341,38 @@
                  .'<th>'.&mt('Current Access Status').&Apache::loncommon::help_open_topic('Portfolio ShareFile').'</th>'
                  .&Apache::loncommon::end_data_table_header_row());
     }
+
+    # Empty directory?
+    if ($is_empty && ($current_path ne '/') && $can_delete) {
+        my $cols = ($select_mode eq 'true') ? 7 : 9;
+        # Empty message
+        $r->print(
+            &Apache::loncommon::start_data_table_row()
+           .'<td colspan="'.$cols.'">'
+           .'<p class="LC_info">'
+           .&mt('This directory is empty.')
+           .'</p>'
+           .'</td>'
+           .&Apache::loncommon::end_data_table_row()
+           .&Apache::loncommon::end_data_table()
+           .'</form>'
+        );
+        # Delete button
+        $r->print(
+            '<form method="post" action="'.$url.'">'.
+            &group_form_data().
+            '<input type="hidden" name="action" value="deletedir" />'.
+            '<p>'.
+            '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
+            '</p>'.
+            '<input type="hidden" name="selectfile" value="" />'.
+            '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
+            '</form>'
+        );
+        # Directory is empty, so nothing else to display
+        return;
+    }
+
     $r->print("\n".&group_form_data()."\n");
 
     my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;