Skip to content

Commit

Permalink
Item12180: Provide unchanged items feedback for all items, whether or…
Browse files Browse the repository at this point in the history
… not provideFeedback is attached.

git-svn-id: http://svn.foswiki.org/trunk@15901 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Nov 4, 2012
1 parent 7d32385 commit 47315c5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
24 changes: 18 additions & 6 deletions core/lib/Foswiki/Configure/Feedback.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ sub deliver {
my %updated;
my $modified = $valuer->loadCGIParams( $query, \%updated );

# Get request from CGI
my $request = $query->param('FeedbackRequest');

# Handle an unsaved changes request without any checking or UI

if ( $request eq '{ConfigureGUI}{Unsaved}status' ) {
deliverResponse( {}, \%updated );
}

my $root = new Foswiki::Configure::Root();

require Foswiki::Configure::Checkers::Introduction;
Expand Down Expand Up @@ -127,9 +136,8 @@ sub deliver {
$this->{checkall} = $query->param('DEBUG') ? 2 : 1;
$this->{changed} = \%updated;

# Get request from feedback button
# Decode feedback button request

my $request = $query->param('FeedbackRequest');
$request =~ /^(\{.*\})feedreq(\d+)$/ or die "Invalid FB target $request\n";
$this->{request} = $1;
$this->{button} = $2;
Expand Down Expand Up @@ -164,6 +172,13 @@ sub deliver {
}
}

deliverResponse( $this->{fb}, \%updated );
}

sub deliverResponse {
my $fb = shift;
my $updated = shift;

my $html = '';

# Return encoded responses to each responding key.
Expand All @@ -186,10 +201,7 @@ sub deliver {
# \002 can actually update any <div> named {something}status; the {ConfigureGUI}
# namespace is reserved for such <divs>, and will not be written to LSC.

my $fb = $this->{fb};

$fb->{'{ConfigureGUI}{Unsaved}'} =
Foswiki::unsavedChangesNotice( \%updated );
$fb->{'{ConfigureGUI}{Unsaved}'} = Foswiki::unsavedChangesNotice($updated);

my $first = 1;
foreach my $keys ( keys %$fb ) {
Expand Down
38 changes: 24 additions & 14 deletions core/lib/Foswiki/Configure/resources/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,13 @@ function valueChanged(el) {
case "password":
case "radio":
case "checkbox":
$('[id^="' + configure.utils.quoteName(el.name) + 'feedreq"]').filter('[value="~"]').click();
break;
if( $('[id^="' + configure.utils.quoteName(el.name) + 'feedreq"]').filter('[value="~"]').click().size() > 0 ) {
break;
}
/* No feedback button found, fall through to default */
default:
var unsaved = { id:'{ConfigureGUI}{Unsaved}status', value:'Not a button' };
doFeedback(unsaved);
break;
}
$(el).addClass('foswikiValueChanged');
Expand Down Expand Up @@ -709,8 +713,8 @@ $(document).ready(function () {
// make sticky
$('.navigation').affix({
offset: {
top: 0
, bottom: 50
top: 0,
bottom: 50
}
});

Expand Down Expand Up @@ -786,7 +790,7 @@ function doFeedback(key, pathinfo) {
*/

if ($('#configureFeedbackErrorWindow').size() === 0) { /* Don't have error window */
$('#' + quoteKeyId).after('<a href="#configureFeedbackErrorWindow" class="configureFeedbackError" id="configureFeedbackErrorLink"></a>' + contents);
$(KeyIdSelector).after('<a href="#configureFeedbackErrorWindow" class="configureFeedbackError" id="configureFeedbackErrorLink"></a>' + contents);
$('#configureFeedbackErrorLink').nyroModal().click();
} else { /* Re-use the window and link */
$('#configureFeedbackErrorWindow').replaceWith(contents);
Expand Down Expand Up @@ -894,14 +898,16 @@ function doFeedback(key, pathinfo) {
* id="configureFeedbackWorkingText" value="Nous travaillons sur votre demande...">
*/

working = $('#configureFeedbackWorkingText').filter(':hidden').filter(':disabled');
if (working.size() === 1) {
working = working.get(0).value;
} else {
working = 'Working...';
if( key.id !== '{ConfigureGUI}{Unsaved}status' ) {
working = $('#configureFeedbackWorkingText').filter(':hidden').filter(':disabled');
if (working.size() === 1) {
working = working.get(0).value;
} else {
working = 'Working...';
}
stsWindowId = key.id.replace(/feedreq\d+$/, 'status');
$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedbackPending configureInfo\"><span class=\"configureFeedbackPendingMessage\">" + working + "</span></div>");
}
stsWindowId = key.id.replace(/feedreq\d+$/, 'status');
$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedbackPending configureInfo\"><span class=\"configureFeedbackPendingMessage\">" + working + "</span></div>");

/* Make the request
* ** N.B. Definitely broken with jQuery 1.3 (unreliable selectors), 1.8.2 used.
Expand Down Expand Up @@ -933,7 +939,9 @@ function doFeedback(key, pathinfo) {

/* Clear "working" status */

$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedback\"></div>");
if( stsWindowId ) {
$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedback\"></div>");
}

/* Perhaps this should go to the status bar? */

Expand Down Expand Up @@ -970,7 +978,9 @@ function doFeedback(key, pathinfo) {
/* Clear "working" status in case of errors or updates that don't target
* the original status div. This also updates the class.
*/
$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedback\"></div>");
if( stsWindowId ) {
$('#' + configure.utils.quoteName(stsWindowId)).replaceWith("<div id=\"" + stsWindowId + "\" class=\"configureFeedback\"></div>");
}

/* Decide what kind of response we got. */

Expand Down

0 comments on commit 47315c5

Please sign in to comment.