From 8fb199ac2dc67a6cbdbd3dc484eb631785c3c92c Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Wed, 25 Jan 2017 14:09:27 +0100 Subject: [PATCH] Item14303: fixes to topic formfield * store web dot topic names * be more robust when parsing strange values * jslint fixes --- data/System/MoreFormfieldsPlugin.txt | 3 ++- lib/Foswiki/Form/Topic.pm | 10 ++++---- lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm | 4 ++-- .../clockpicker.init.uncompressed.js | 1 + .../iconfield.uncompressed.js | 2 +- .../networkaddress.uncompressed.js | 2 +- .../phonenumber.uncompressed.js | 2 +- .../select2.uncompressed.js | 5 ++-- pub/System/MoreFormfieldsPlugin/smartbox.js | 2 +- .../smartbox.uncompressed.js | 2 +- .../topicfield.uncompressed.js | 23 ++++++++++++++----- .../userfield.uncompressed.js | 5 ++-- 12 files changed, 37 insertions(+), 24 deletions(-) diff --git a/data/System/MoreFormfieldsPlugin.txt b/data/System/MoreFormfieldsPlugin.txt index 949c074..1dc3dff 100644 --- a/data/System/MoreFormfieldsPlugin.txt +++ b/data/System/MoreFormfieldsPlugin.txt @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="ProjectContributor" comment="" date="1467204325" format="1.1" version="1"}% +%META:TOPICINFO{author="ProjectContributor" comment="" date="1485349736" format="1.1" version="1"}% ---+!! %TOPIC% %FORMFIELD{"Description"}% @@ -205,6 +205,7 @@ A user reference using JQSelect2Contrib for autocompletion. ---++ Change History %TABLE{columnwidths="7em" tablewidth="100%"}% +| 25 Jan 2017: | fixed =topic= formfield to properly store web dot topic values | | 16 Jan 2017: | replace MoreFormfieldsAjaxHelper with a template solution to be able to override it when required; \ fixes in =id= and =autofill= formfields; \ defaulting to YYYY/MM/DD in =date2= formfield now to prevent browsers from interpreting date formfields using their own idea of locales; \ diff --git a/lib/Foswiki/Form/Topic.pm b/lib/Foswiki/Form/Topic.pm index 15f8f68..7fa9a82 100644 --- a/lib/Foswiki/Form/Topic.pm +++ b/lib/Foswiki/Form/Topic.pm @@ -111,28 +111,26 @@ sub getDisplayValue { if ($this->isMultiValued) { my @result = (); foreach my $val (split(/\s*,\s*/, $value)) { - my $origVal = $val; + my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($this->{_web}, $val); if ($this->isValueMapped) { if (defined($this->{valueMap}{$val})) { $val = $this->{valueMap}{$val}; } } else { - $val = $this->getTopicTitle($this->{_web}, $val); + $val = $this->getTopicTitle($web, $topic); } - my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($this->{_web}, $origVal); push @result, "$val"; } $value = join(", ", @result); } else { - my $origVal = $value; + my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($this->{_web}, $value); if ($this->isValueMapped) { if (defined($this->{valueMap}{$value})) { $value = $this->{valueMap}{$value}; } } else { - $value = $this->getTopicTitle($this->{_web}, $value); + $value = $this->getTopicTitle($web, $topic); } - my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($this->{_web}, $origVal); $value = "$value"; } diff --git a/lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm b/lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm index 6ef6e26..f6bbadd 100644 --- a/lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm +++ b/lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm @@ -25,8 +25,8 @@ use Foswiki::Plugins (); use Error qw(:try); -our $VERSION = '3.00'; -our $RELEASE = '16 Jan 2017'; +our $VERSION = '3.01'; +our $RELEASE = '25 Jan 2017'; our $SHORTDESCRIPTION = 'Additional formfield types for %SYSTEMWEB%.DataForms'; our $NO_PREFS_IN_TOPIC = 1; diff --git a/pub/System/MoreFormfieldsPlugin/clockpicker.init.uncompressed.js b/pub/System/MoreFormfieldsPlugin/clockpicker.init.uncompressed.js index 1045f81..9ed7a48 100644 --- a/pub/System/MoreFormfieldsPlugin/clockpicker.init.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/clockpicker.init.uncompressed.js @@ -1,3 +1,4 @@ +"use strict"; jQuery(function($) { $(".jqClockPicker").livequery(function() { $(this).clockpicker(); diff --git a/pub/System/MoreFormfieldsPlugin/iconfield.uncompressed.js b/pub/System/MoreFormfieldsPlugin/iconfield.uncompressed.js index 774265a..dd74813 100644 --- a/pub/System/MoreFormfieldsPlugin/iconfield.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/iconfield.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { var defaults = { minimumInputLength: 0, diff --git a/pub/System/MoreFormfieldsPlugin/networkaddress.uncompressed.js b/pub/System/MoreFormfieldsPlugin/networkaddress.uncompressed.js index 2d2a295..aac9514 100644 --- a/pub/System/MoreFormfieldsPlugin/networkaddress.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/networkaddress.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { // methods jQuery.validator.addMethod("ipv4_address", function(value, element, param) { diff --git a/pub/System/MoreFormfieldsPlugin/phonenumber.uncompressed.js b/pub/System/MoreFormfieldsPlugin/phonenumber.uncompressed.js index e8adcee..2bb0a6c 100644 --- a/pub/System/MoreFormfieldsPlugin/phonenumber.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/phonenumber.uncompressed.js @@ -1,5 +1,5 @@ -(function($) { "use strict"; +(function($) { $.validator.addMethod('phone', function(value, element) { value = value.replace(/\s/g,''); diff --git a/pub/System/MoreFormfieldsPlugin/select2.uncompressed.js b/pub/System/MoreFormfieldsPlugin/select2.uncompressed.js index 6b4aa7f..a1d4c9a 100644 --- a/pub/System/MoreFormfieldsPlugin/select2.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/select2.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { var defaults = { minimumInputLength: 0, @@ -51,8 +51,9 @@ jQuery(function($) { } }, initSelection: function(elem, callback) { - var data = [], text; + var data, text; if (opts.multiple) { + data = []; $(val.split(/\s*,\s*/)).each(function () { text = decodeURIComponent(opts.valueText[this]||this); data.push({id: this, text: text}); diff --git a/pub/System/MoreFormfieldsPlugin/smartbox.js b/pub/System/MoreFormfieldsPlugin/smartbox.js index 5bf1910..78e39b3 100644 --- a/pub/System/MoreFormfieldsPlugin/smartbox.js +++ b/pub/System/MoreFormfieldsPlugin/smartbox.js @@ -1 +1 @@ -jQuery(function(e){"use strict";e(document).on("change",".foswikiSmartboxItem",function(){var t=e(this),i=t.parents(".foswikiSmartbox").first(),n=i.data(),a=t.val(),c=t.is(":checked"),o=i.find(".foswikiSmartboxItem"),r=i.find("input[value='"+n.anyValue+"']");if(a===n.anyValue){o.prop("checked",c)}else{if(o.length==o.not(r).filter(":checked").length+1){r.prop("checked",true)}else{r.prop("checked",false)}}})}); \ No newline at end of file +"use strict";jQuery(function(e){e(document).on("change",".foswikiSmartboxItem",function(){var t=e(this),i=t.parents(".foswikiSmartbox").first(),n=i.data(),a=t.val(),c=t.is(":checked"),o=i.find(".foswikiSmartboxItem"),r=i.find("input[value='"+n.anyValue+"']");if(a===n.anyValue){o.prop("checked",c)}else{if(o.length==o.not(r).filter(":checked").length+1){r.prop("checked",true)}else{r.prop("checked",false)}}})}); \ No newline at end of file diff --git a/pub/System/MoreFormfieldsPlugin/smartbox.uncompressed.js b/pub/System/MoreFormfieldsPlugin/smartbox.uncompressed.js index ecc81f6..e789ea2 100644 --- a/pub/System/MoreFormfieldsPlugin/smartbox.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/smartbox.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { $(document).on("change", ".foswikiSmartboxItem", function() { var $this = $(this), diff --git a/pub/System/MoreFormfieldsPlugin/topicfield.uncompressed.js b/pub/System/MoreFormfieldsPlugin/topicfield.uncompressed.js index cf6189e..8892523 100644 --- a/pub/System/MoreFormfieldsPlugin/topicfield.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/topicfield.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { var defaults = { minimumInputLength: 0, @@ -62,15 +62,26 @@ jQuery(function($) { } }, initSelection: function(elem, callback) { - var data = [], text; + var data, text; if (opts.multiple) { + data = []; $(val.split(/\s*,\s*/)).each(function () { - text = decodeURIComponent(opts.valueText[this]||this); - data.push({id: this, text: text}); + text = opts.valueText[this]||this; + try { + text = decodeURIComponent(text); + data.push({id: this, text: text}); + } catch(err) { + console && console.error("Error: illegal value in topicfield:",text); + }; }); } else { - text = decodeURIComponent(opts.valueText); - data = {id:val, text:text}; + text = opts.valueText; + try { + text = decodeURIComponent(text); + data = {id: this, text: text}; + } catch(err) { + console && console.error("Error: illegal value in topicfield:",text); + }; } callback(data); }, diff --git a/pub/System/MoreFormfieldsPlugin/userfield.uncompressed.js b/pub/System/MoreFormfieldsPlugin/userfield.uncompressed.js index ae9d964..b4d3a3a 100644 --- a/pub/System/MoreFormfieldsPlugin/userfield.uncompressed.js +++ b/pub/System/MoreFormfieldsPlugin/userfield.uncompressed.js @@ -1,5 +1,5 @@ -jQuery(function($) { "use strict"; +jQuery(function($) { var defaults = { minimumInputLength: 0, @@ -61,8 +61,9 @@ jQuery(function($) { } }, initSelection: function(elem, callback) { - var data = [], text; + var data, text; if (opts.multiple) { + data = []; $(val.split(/\s*,\s*/)).each(function () { text = decodeURIComponent(opts.valueText[this]||this); data.push({id: this, text: text});