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

raeburn raeburn at source.lon-capa.org
Mon Apr 1 20:07:08 EDT 2013


raeburn		Tue Apr  2 00:07:08 2013 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 4900.
    - alert pop-up if "Paste selected" or "Clear selected" buttons pressed
      and no items selected in clipboard.
    - display error messages if read or store of map fails during paste
      from clipboard.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.540 loncom/interface/londocs.pm:1.541
--- loncom/interface/londocs.pm:1.540	Mon Apr  1 22:09:56 2013
+++ loncom/interface/londocs.pm	Tue Apr  2 00:07:08 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.540 2013/04/01 22:09:56 raeburn Exp $
+# $Id: londocs.pm,v 1.541 2013/04/02 00:07:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -902,7 +902,7 @@
     my ($pasteform,$form_start,$buttons,$form_end);
     if ($pasteitems) {
         $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
-        $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post">';
+        $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
         if (@pasteable) {
             $buttons = '<input type="submit" name="pastemarked" value="'.&mt('Paste selected').'" />'.(' 'x2);
         }
@@ -1009,6 +1009,7 @@
     my %lt = &Apache::lonlocal::texthash(
                                           show => 'Show Options',
                                           hide => 'Hide Options',
+                                          none => 'No items selected from clipboard.',
                                         );
     return <<"END";
 
@@ -1038,6 +1039,29 @@
     return;
 }
 
+function validateClipboard() {
+    var numchk = 0;
+    if (document.pasteform.pasting.length > 1) {
+        for (var i=0; i<document.pasteform.pasting.length; i++) {
+            if (document.pasteform.pasting[i].checked) {
+                numchk ++;
+            }
+        }
+    } else {
+        if (document.pasteform.pasting.type == 'checkbox') {
+            if (document.pasteform.pasting.checked) {
+                numchk ++; 
+            } 
+        }
+    }
+    if (numchk > 0) { 
+        return true;
+    } else {
+        alert("$lt{'none'}");
+        return false;
+    }
+}
+
 END
 
 }
@@ -2351,24 +2375,30 @@
             my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
                 &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
                                       \%paste_errors);
-                if (ref($pastemsgarray) eq 'ARRAY') {
-                    if (@{$pastemsgarray} > 0) {
-                          
-                        $r->print('<p class="LC_info">'.
-                                  join('<br />',@{$pastemsgarray}).
-                                  '</p>');
-                    }
-                }
-                if ($lockerror) {
-                    $r->print('<p class="LC_error">'.
-                              $lockerror.
+            if (ref($pastemsgarray) eq 'ARRAY') {
+                if (@{$pastemsgarray} > 0) {
+                    $r->print('<p class="LC_info">'.
+                              join('<br />',@{$pastemsgarray}).
                               '</p>');
                 }
-                if ($save_error ne '') {
-                    return $save_error; 
+            }
+            if ($lockerror) {
+                $r->print('<p class="LC_error">'.
+                          $lockerror.
+                          '</p>');
+            }
+            if ($save_error ne '') {
+                return $save_error; 
+            }
+            if ($paste_res) {
+                my %errortext = &Apache::lonlocal::texthash (
+                                    fail      => 'Storage of folder contents failed',
+                                    failread  => 'Reading folder contents failed',
+                                    failstore => 'Storage of folder contents failed',
+                                );
+                if ($errortext{$paste_res}) {
+                    $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
                 }
-            if ($paste_res ne 'ok') {
-                $r->print('<p class="LC_error">'.$paste_res.'</p>');
             }
             if (keys(%paste_errors) > 0) {
                 $r->print('<p class="LC_warning">'."\n".




More information about the LON-CAPA-cvs mailing list