[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm
raeburn
raeburn@source.lon-capa.org
Thu, 11 Nov 2010 23:58:05 -0000
raeburn Thu Nov 11 23:58:05 2010 EDT
Modified files:
/loncom/interface portfolio.pm
Log:
- Retain context if overwrite occurs in select files window used to
associate portfolio files with dropbox or bridge task.
- Use continue button on confirm overwrite page - additional click,
better accessibility.
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.229 loncom/interface/portfolio.pm:1.230
--- loncom/interface/portfolio.pm:1.229 Fri Oct 29 23:22:43 2010
+++ loncom/interface/portfolio.pm Thu Nov 11 23:58:05 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.229 2010/10/29 23:22:43 raeburn Exp $
+# $Id: portfolio.pm,v 1.230 2010/11/11 23:58:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1998,44 +1998,56 @@
conf => 'Are you sure you want to overwrite an existing file?',
cont => 'Continue',
);
+ my $parserflag;
+ my $hidden = &hidden_elems();
+ if ($mode eq 'parse') {
+ $parserflag = '<input type="hidden" name="parserflag" value="1" />';
+ }
$r->print(<<"END");
<script type="text/javascript">
// <![CDATA[
function confirmOverwrite() {
- if (confirm('$lt{'conf'}')) {
- document.existingfile.action.value = "process_overwrite";
- } else {
- if (document.existingfile.overwrite.length) {
- for (var i=0; i<document.existingfile.overwrite.length; i++) {
- if (document.existingfile.overwrite[i].value == "0") {
- document.existingfile.overwrite[i].checked = true;
+ var chosen;
+ if (document.existingfile.overwrite.length) {
+ for (var i=0; i<document.existingfile.overwrite.length; i++) {
+ if (document.existingfile.overwrite[i].checked) {
+ chosen = document.existingfile.overwrite[i].value;
+ }
+ }
+ }
+ if (chosen == 1) {
+ if (confirm('$lt{'conf'}')) {
+ document.existingfile.action.value = "process_overwrite";
+ return true;
+ } else {
+ document.existingfile.action.value = "cancel_overwrite";
+ if (document.existingfile.overwrite.length) {
+ for (var i=0; i<document.existingfile.overwrite.length; i++) {
+ if (document.existingfile.overwrite[i].value == "0") {
+ document.existingfile.overwrite[i].checked = true;
+ }
}
}
+ return false;
}
+ } else {
document.existingfile.action.value = "cancel_overwrite";
+ return true;
}
- document.existingfile.submit();
- return;
-}
-function cancelOverwrite() {
- document.existingfile.action.value = "cancel_overwrite";
- document.existingfile.submit();
}
// ]]>
</script>
$msg
-<br /><div class="LC_warning"><form method="post" action="$url" name="existingfile">
+<br /><div class="LC_warning"><form method="post" action="$url" name="existingfile" onsubmit="return confirmOverwrite();">
<span class="LC_nobreak">$lt{'over'}
-<label><input type="radio" name="overwrite" value="1" onclick="javascript:confirmOverwrite();" />
+<label><input type="radio" name="overwrite" value="1" />
$lt{'yes'}</label>
-<label><input type="radio" name="overwrite" value="0" onclick="javascript:cancelOverwrite()" />$lt{'no'}</label></span>
+<label><input type="radio" name="overwrite" value="0" checked="checked" />$lt{'no'}</label></span>
<input type="hidden" name="action" value="cancel_overwrite" />
-<input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
<input type="hidden" name="filename" value="$showfname" />
-<input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
-<input type="hidden" name="mode" value="$mode" />
<input type="hidden" name="timestamp" value="$timestamp" />
-<input type="hidden" name="showversions" value="$env{'form.showversions'}" />
+$hidden
+$parserflag
$group_elem
<br /><br />
<input type="submit" name="process" value="$lt{'cont'}" />
@@ -2061,6 +2073,20 @@
}
}
+sub hidden_elems {
+ my $contelem;
+ if ($env{'form.mode'} eq 'selectfile') {
+ $contelem = '<input type="hidden" name="continue" value="true" />';
+ }
+ return <<END;
+<input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
+<input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
+<input type="hidden" name="mode" value="$env{'form.mode'}" />
+<input type="hidden" name="showversions" value="$env{'form.showversions'}" />
+$contelem
+END
+}
+
sub print_dependency_form {
my ($r,$url,$allfiles,$codebase) = @_;
my $state = <<STATE;
@@ -2093,10 +2119,11 @@
my $port_path = &get_port_path();
my $fname = &Apache::lonnet::clean_filename($env{'form.filename'});
my (%allfiles,%codebase,$mode);
- $mode = $env{'form.mode'};
- if ($mode eq 'parse') {
- if ($fname !~ /\.s?html?$/i) {
- undef($mode);
+ unless (&suppress_embed_prompt()) {
+ if ($env{'form.parserflag'}) {
+ if ($fname =~ /\.s?html?$/i) {
+ $mode = 'parse';
+ }
}
}
if ($fname eq '') {
@@ -2114,21 +2141,44 @@
if ($result !~ m|^/uploaded/|) {
$r->print('<span class="LC_error">'.&mt('An error occurred ([_1]) while trying to overwrite [_2].'
,$result,&display_file(undef,$fname)).'</span><br />');
- $r->print(&done('Back',$url));
+ $r->print(&after_overwrite(&mt('Back'),$url));
} else {
if (%allfiles) {
if (!&suppress_embed_prompt()) {
&print_dependency_form($r,$url,\%allfiles,\%codebase);
} else {
- $r->print(&done(undef,$url));
+ $r->print(&after_overwrite(undef,$url));
}
} else {
- $r->print(&done(undef,$url));
+ $r->print(&after_overwrite(undef,$url));
}
}
return;
}
+sub after_overwrite {
+ my ($text,$url) = @_;
+ my $group_elem;
+ if (defined($env{'form.group'})) {
+ $group_elem = '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />';
+ if (defined($env{'form.ref'})) {
+ $group_elem .= '<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />'."\n";
+ }
+ }
+ if ($text eq '') {
+ $text = &mt('Done');
+ }
+ my $hidden = &hidden_elems();
+ return <<END;
+
+<h3><a href="javascript:document.overwritedone.submit();">$text</a></h3>
+<form name="overwritedone" method="post" action="$url" />
+$hidden
+$group_elem
+</form>
+END
+}
+
sub lock_info {
my ($r,$url,$group) = @_;
my ($uname,$udom) = &get_name_dom($group);