Skip to content

Commit

Permalink
Item14499: make proper use of $request->param()
Browse files Browse the repository at this point in the history
as well as some other small js gotchas
  • Loading branch information
MichaelDaum committed Sep 25, 2017
1 parent ab234bf commit 6fae466
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.gz
*.swp
*.jslint
pub/System/MultiSaveContrib/jquery.multisave.js
pub/System/MultiSaveContrib/jquery.multisave.css
MultiSaveContrib.md5
Expand All @@ -9,3 +10,4 @@ MultiSaveContrib.txt
MultiSaveContrib.zip
MultiSaveContrib_installer
MultiSaveContrib_installer.pl
locale/**/*.mo
34 changes: 18 additions & 16 deletions data/System/MultiSaveContrib.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1414597023" format="1.1" version="1"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%TOC%

Expand Down Expand Up @@ -76,23 +76,25 @@ All form elements that changed their values will be flagged so using css automat
---++ Adding beforeSaveHander and afterSaveHandler

---++ Installation Instructions

%$INSTALL_INSTRUCTIONS%

---++ Info
<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

| Author(s): | Michael Daum|
| Copyright: | &copy; 2013-2014 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
---++ Dependencies
%$DEPENDENCIES%

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 25 Sep 2017: | fixed use of =param()= api |
| 20 Sep 2014: | fixed saving of deselected checkboxes and radioboxes |
| 04 Sep 2013: | fixed manifest |
| 30 May 2013: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2013-2017 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%TOPIC%"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%TOPIC%"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%TOPIC%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
6 changes: 3 additions & 3 deletions lib/Foswiki/Contrib/MultiSaveContrib.pm
@@ -1,6 +1,6 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2013-2017 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -21,8 +21,8 @@ use warnings;
use Foswiki::Plugins();
use Foswiki::Contrib::JsonRpcContrib ();

our $VERSION = '1.10';
our $RELEASE = '1.10';
our $VERSION = '1.20';
our $RELEASE = '25 Sep 2017';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Json-RPC interface to save multiple changes in one transaction';
our $core;
Expand Down
11 changes: 6 additions & 5 deletions lib/Foswiki/Contrib/MultiSaveContrib/Core.pm
@@ -1,6 +1,6 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2013-2017 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -98,18 +98,19 @@ sub jsonRpcMultiSave {

writeDebug("called jsonRpcMultiSave()");
my $wikiName = Foswiki::Func::getWikiName();
my $params = $request->params();
my @params = $request->multi_param();
my $formName = $request->param("formName");

writeDebug("saving a $formName") if defined $formName;

# collect required changes
my %changes = ();
foreach my $key (keys %$params) {
next unless $key =~ /^multisave{(.*)}{(.*)}$/;
foreach my $key (@params) {
next if $key eq 'POSTDATA';
next unless $key =~ /^multisave\{(.*)\}\{(.*)\}$/;
my $webTopic = $1;
my $fieldName = $2;
my $fieldValue = $params->{$key};
my $fieldValue = $request->param($key);
$fieldValue = join(", ", grep {!/^$/} @$fieldValue) if ref($fieldValue);

writeDebug("found changes for $webTopic, $fieldName=$fieldValue");
Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Contrib/MultiSaveContrib/JQuery.pm
Expand Up @@ -12,7 +12,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'MultiSave',
version => '0.03',
version => '0.05',
author => 'Michael Daum',
homepage => 'http://michaeldaumconsulting.com',
puburl => '%PUBURLPATH%/%SYSTEMWEB%/MultiSaveContrib',
Expand All @@ -31,7 +31,7 @@ sub new {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2013-2014 Michael Daum http://michaeldaumconsulting.com
Copyright (C) 2013-2017 Michael Daum http://michaeldaumconsulting.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Contrib/MultiSaveContrib/MANIFEST
@@ -1,3 +1,4 @@
!noci
data/System/MultiSaveContrib.txt 0644
lib/Foswiki/Contrib/MultiSaveContrib/Config.spec 0644
lib/Foswiki/Contrib/MultiSaveContrib/Core.pm 0644
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Contrib/MultiSaveContrib/build.pl
@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
BEGIN {
foreach my $pc (split(/:/, $ENV{FOSWIKI_LIBS})) {
unshift @INC, $pc;
Expand Down
12 changes: 6 additions & 6 deletions pub/System/MultiSaveContrib/jquery.multisave.uncompressed.js
@@ -1,15 +1,15 @@
/*
* jQuery MultiSave plugin 0.04
* jQuery MultiSave plugin 0.05
*
* Copyright (c) 2013-2014 Michael Daum http://michaeldaumconsulting.com
* Copyright (c) 2013-2017 Michael Daum http://michaeldaumconsulting.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery(function($) {
"use strict";
jQuery(function($) {

$(".jqMultiSave:not(.jqMultiSaveInited)").livequery(function() {
var $form = $(this),
Expand All @@ -29,20 +29,20 @@ jQuery(function($) {
$.blockUI({message:'<h1>Saving ...</h1>'});
},

error: function(xhr, status, error) {
error: function(xhr, status) {
var json = $.parseJSON(xhr.responseText);
$.unblockUI();
$results.show().html("<div class='foswikiErrorMessage'>Error: "+status+" "+json.error.message+"</div>");
},

success: function(data, status, xhr) {
success: function(data) {
var changes = 0;

$.unblockUI();
$results.empty();

if (typeof(data.result.success) !== 'undefined') {
$.each(data.result.success, function(key) {
$.each(data.result.success, function() {
changes++;
});
}
Expand Down

0 comments on commit 6fae466

Please sign in to comment.