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

raeburn raeburn at source.lon-capa.org
Tue Apr 2 22:00:19 EDT 2013


raeburn		Wed Apr  3 02:00:19 2013 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 4900 (part).
    (Checkboxes for hidden, enc URL, Randomly Pick, Order multiple items)
    - javascript alert pop-up if no settings changes when "Make changes"
      button pressed. 
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.542 loncom/interface/londocs.pm:1.543
--- loncom/interface/londocs.pm:1.542	Tue Apr  2 20:33:41 2013
+++ loncom/interface/londocs.pm	Wed Apr  3 02:00:19 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.542 2013/04/02 20:33:41 raeburn Exp $
+# $Id: londocs.pm,v 1.543 2013/04/03 02:00:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2269,7 +2269,9 @@
 
 sub handle_edit_cmd {
     my ($coursenum,$coursedom) =@_;
-    return if ($env{'form.cmd'} eq '');
+    if ($env{'form.cmd'} eq '') {
+        return 0;
+    }
     my ($cmd,$idx)=split('_',$env{'form.cmd'});
 
     my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
@@ -2597,9 +2599,13 @@
 
     my ($to_show,$output, at allidx, at allmapidx,%filters,%lists,%curr_groups);
     %filters =  (
-                  canremove => [],
-                  cancut    => [],
-                  cancopy   => [],
+                  canremove      => [],
+                  cancut         => [],
+                  cancopy        => [],
+                  hiddenresource => [],
+                  encrypturl     => [],
+                  randomorder    => [],
+                  randompick     => [],
                 );
     %curr_groups = &Apache::longroup::coursegroups();
     &Apache::loncommon::start_data_table_count(); #setup a row counter 
@@ -2649,9 +2655,13 @@
                 if ($folder !~ /^supplemental/) {
                     $lists{'canhide'} = join(',', at allidx);
                     $lists{'canrandomlyorder'} = join(',', at allmapidx);
-                    foreach my $item ('canremove','cancut','cancopy') {
+                    my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
+                                       'randomorder','randompick');
+                    foreach my $item (@possfilters) {
                         if (ref($filters{$item}) eq 'ARRAY') {
-                            $lists{$item} = join(',',@{$filters{$item}}); 
+                            if (@{$filters{$item}} > 0) {
+                                $lists{$item} = join(',',@{$filters{$item}});
+                            }
                         }
                     }
                     if (@allidx > 0) {
@@ -2773,7 +2783,11 @@
         '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
     if ($caller eq 'settings') {
         $output .= 
-        '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />';
+        '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
+        '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
+        '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
+        '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
+        '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
     } elsif ($caller eq 'actions') {
         $output .=
         '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
@@ -3056,7 +3070,7 @@
 	}
 
 	if ($denied{'copy'}) {
-            $copylink=(<<ENDCOPY);
+            $copylink=(<<ENDCOPY)
 <span style="visibility: hidden;">$lt{'cp'}</span>
 ENDCOPY
         } else {
@@ -3223,6 +3237,9 @@
             my $rpckchk;
             if ($rpicknum) {
                 $rpckchk = ' checked="checked"';
+                if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
+                    push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
+                }
             }
             my $formname = 'edit_randompick_'.$orderidx;
 	    $rand_pick_text = 
@@ -3235,8 +3252,13 @@
             }
             $rand_pick_text .= '</span></span>'.
                                $form_end;
-    	    my $ro_set=
-	        ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+            my $ro_set;
+            if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
+                $ro_set = 'checked="checked"';
+                if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
+                    push(@{$filtersref->{'randomorder'}},$orderidx);
+                }
+            }
             my $formname = 'edit_rorder_'.$orderidx;
 	    $rand_order_text = 
 '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
@@ -3313,10 +3335,19 @@
  	my %lt=&Apache::lonlocal::texthash(
  			      'hd' => 'Hidden',
  			      'ec' => 'URL hidden');
-	my $enctext=
-	    ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
-	my $hidtext=
-	    ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
+        my ($enctext,$hidtext);
+        if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
+            $enctext = ' checked="checked"';
+            if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
+                push(@{$filtersref->{'encrypturl'}},$orderidx);
+            }
+        }
+        if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+            $hidtext = ' checked="checked"';
+            if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
+                push(@{$filtersref->{'hiddenresource'}},$orderidx);
+            }
+        }
         my $formhidden = 'edit_hiddenresource_'.$orderidx;
         my $formurlhidden = 'edit_encrypturl_'.$orderidx;
 	$line.=(<<ENDPARMS);
@@ -5322,6 +5353,9 @@
                                           titbl   => 'Title is blank',
                                           more    => '(More ...)',
                                           less    => '(Less ...)',
+                                          noor    => 'No actions selected or changes to settings specified.',
+                                          noch    => 'No changes to settings specified.',
+                                          noac    => 'No actions selected.',
                                         );
 
     my $crstype = &Apache::loncommon::course_type();
@@ -6009,10 +6043,12 @@
         }
     }
     var dosettings = multiSettings();
+    var haschanges = 0;
     if (dosettings == 1) {
         form.allencrypturl.value = '';
         form.allhiddenresource.value = '';
-        form.changeparms.value = 'all'; 
+        form.changeparms.value = 'all';
+        var patt=new RegExp(",\$");
         var allidxlist = document.cumulativesettings.allidx.value;
         if ((allidxlist != '') && (allidxlist != null)) {
             var allidxs = allidxlist.split(',');
@@ -6029,6 +6065,8 @@
                         }
                     }
                 }
+                form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
+                form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
             }
         }
         form.allrandompick.value = '';
@@ -6047,9 +6085,23 @@
                     form.allrandomorder.value += allmapidxs[i]+',';
                 }
             }
+            form.allrandompick.value = form.allrandompick.value.replace(patt,"");
+            form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
+        }
+        if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
+            haschanges = 1;
+        }
+        if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
+            haschanges = 1;
+        }
+        if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
+            haschanges = 1;
+        }
+        if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
+            haschanges = 1;
         }
     }
-    if ((numchanges > 0) || (dosettings == 1)) {
+    if (doactions == 1) {
         if (numchanges > 0) {
             if ((cutwarnings > 0) || (remwarnings > 0)) {
                 if (remwarnings > 0) {
@@ -6065,11 +6117,23 @@
             }
             form.submit();
             return true;
-        } else {
+        }
+    }
+    if (dosettings == 1) {
+        if (haschanges == 1) {
             form.submit();
             return true;
         }
-    } 
+    }
+    if ((dosettings == 1) && (doactions == 1)) {
+        alert("$lt{'noor'}");
+    } else {
+        if (dosettings == 1) {
+            alert("$lt{'noch'}");
+        } else {
+            alert("$lt{'noac'}");
+        }
+    }
     return false;
 }
 


More information about the LON-CAPA-cvs mailing list