Skip to content

Commit

Permalink
Item14303: fixes to topic formfield
Browse files Browse the repository at this point in the history
   * store web dot topic names
   * be more robust when parsing strange values
   * jslint fixes
  • Loading branch information
MichaelDaum committed Jan 25, 2017
1 parent 6133cf1 commit 8fb199a
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 24 deletions.
3 changes: 2 additions & 1 deletion 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"}%

Expand Down Expand Up @@ -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 <nop>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; \
Expand Down
10 changes: 4 additions & 6 deletions lib/Foswiki/Form/Topic.pm
Expand Up @@ -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, "<a href='%SCRIPTURLPATH{view}%/$web/$topic'>$val</a>";
}
$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 = "<a href='%SCRIPTURLPATH{view}%/$web/$topic'>$value</a>";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/MoreFormfieldsPlugin.pm
Expand Up @@ -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;

Expand Down
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {
$(".jqClockPicker").livequery(function() {
$(this).clockpicker();
Expand Down
2 changes: 1 addition & 1 deletion pub/System/MoreFormfieldsPlugin/iconfield.uncompressed.js
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

var defaults = {
minimumInputLength: 0,
Expand Down
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

// methods
jQuery.validator.addMethod("ipv4_address", function(value, element, param) {
Expand Down
@@ -1,5 +1,5 @@
(function($) {
"use strict";
(function($) {

$.validator.addMethod('phone', function(value, element) {
value = value.replace(/\s/g,'');
Expand Down
5 changes: 3 additions & 2 deletions pub/System/MoreFormfieldsPlugin/select2.uncompressed.js
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

var defaults = {
minimumInputLength: 0,
Expand Down Expand Up @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion pub/System/MoreFormfieldsPlugin/smartbox.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pub/System/MoreFormfieldsPlugin/smartbox.uncompressed.js
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

$(document).on("change", ".foswikiSmartboxItem", function() {
var $this = $(this),
Expand Down
23 changes: 17 additions & 6 deletions pub/System/MoreFormfieldsPlugin/topicfield.uncompressed.js
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

var defaults = {
minimumInputLength: 0,
Expand Down Expand Up @@ -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);
},
Expand Down
5 changes: 3 additions & 2 deletions pub/System/MoreFormfieldsPlugin/userfield.uncompressed.js
@@ -1,5 +1,5 @@
jQuery(function($) {
"use strict";
jQuery(function($) {

var defaults = {
minimumInputLength: 0,
Expand Down Expand Up @@ -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});
Expand Down

0 comments on commit 8fb199a

Please sign in to comment.