Skip to content

Commit

Permalink
Item14182: fix column mapping, fix SolrConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Sep 9, 2016
1 parent 7abee86 commit ccc23b7
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 60 deletions.
14 changes: 7 additions & 7 deletions .gitignore
Expand Up @@ -45,10 +45,10 @@ pub/System/JQGridPlugin/i18n/grid.locale-ua.js
pub/System/JQGridPlugin/jquery.jqgrid.init.js
pub/System/JQGridPlugin/jquery.jqgrid.js

JQGridPlugin.md5
JQGridPlugin.sha1
JQGridPlugin.tgz
JQGridPlugin.txt
JQGridPlugin.zip
JQGridPlugin_installer
JQGridPlugin_installer.pl
/JQGridPlugin.md5
/JQGridPlugin.sha1
/JQGridPlugin.tgz
/JQGridPlugin.txt
/JQGridPlugin.zip
/JQGridPlugin_installer
/JQGridPlugin_installer.pl
28 changes: 18 additions & 10 deletions data/System/JQGridPlugin.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="topic" date="1436976367" format="1.1" version="1"}%
---+ %TOPIC%
%$SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%STARTSECTION{"summary"}%
jqGrid is an Ajax-enabled !JavaScript control that provides solutions for
Expand Down Expand Up @@ -67,17 +67,24 @@ render a grid of topics matching the given query
| =onSelectRow= | event handler triggered when a row is selected | |
| =onSelectAll= | event handler triggered when all rows selected at once | |
| =gridComplete= | event handler triggered when the grid is loaded | |

---++ Special columns

Normally, the data and the way it is displayed in a GRID is specified by the !DataForm definition the GRID expression points to.
However, there's a set of additional properties of a topic that can be displayed in a GRID. These are specified in the =columns=
parameter to %GRID and are mapped to the actual property as follows:

| *Colname* | *Data* | *Displayed* |
| Topic | topic name | link to topic |
| Modified, Changed | time when the topic has been changed recently | standard date format |
| By, Author | author of the last modification | link to author's homepage |
| Author, By | author of the last modification | link to author's profile page |
| Create Author, Creator | author that created the initial revision of the topic | link to author's profile page |
| Created, Create Date | date when the initial revision was created | standard date format |
| Form | the name of a <nop>DataForm being attached | |
| Image, Photo | formfields of that name | displayed as html &lt;img&gt; tag where the data is used as src link ||
| Modified, Changed | time when the topic has been changed recently | standard date format |
| Topic | topic name | link to topic |
| Title, TopicTitle | title of the topic | string |
| Workflow | workflow state of the topic | string |

When [[Foswiki:Extensions/FlexFormPlugin][FlexFormPlugin]] is installed, each cell is rendered using
=%RENDERFORDISPLAY= expression.

Expand Down Expand Up @@ -167,6 +174,7 @@ Custom grid connectors must process the following parameters:
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 09 Sep 2016: | (2.50) bringing column mapping in line with each other; fixed <nop>SolrConnector |
| 17 Jul 2015: | (2.41) default to =dbcache= connector now as it is the only one really working; fixed example in docu; fixed grid resizer |
| 02 Dec 2014: | (2.40) moving from jquery.tmpl to jsrender |
| 28 Aug 2014: | (2.31) fully specify REST security |
Expand Down Expand Up @@ -203,11 +211,11 @@ Custom grid connectors must process the following parameters:

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="2009-2015 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FIELD{name="Copyright" title="Copyright" value="2009-2016 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="https://foswiki.org/Extensions/JQGridPlugin"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Repository" value="https://github.com/foswiki/JQGridPlugin"}%
%META:FIELD{name="Home" value="http://foswiki.org/Extensions/JQGridPlugin"}%
%META:FIELD{name="Support" value="http://foswiki.org/Support/JQGridPlugin"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/JQGridPlugin"}%
%META:FIELD{name="Support" title="Support" value="https://foswiki.org/Support/JQGridPlugin"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/JQGridPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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 @@ -17,7 +17,7 @@ use strict;
use warnings;

our $VERSION = '2.50';
our $RELEASE = '21 Sep 2015';
our $RELEASE = '09 Sep 2016';
our $SHORTDESCRIPTION = 'jQuery grid widget for Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our $doInit = 0;
Expand Down
10 changes: 9 additions & 1 deletion lib/Foswiki/Plugins/JQGridPlugin/Connector.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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 @@ -33,6 +33,7 @@ sub new {
my $this = {
session => $session,
propertyMap => {},
sortPropertyMap => {},
};

return bless($this, $class);
Expand Down Expand Up @@ -79,6 +80,13 @@ sub column2Property {
return $this->{propertyMap}{$columnName} || $columnName;
}

sub column2SortProperty {
my ($this, $columnName) = @_;

return unless defined $columnName;
return $this->{sortPropertyMap}{$columnName} || $this->column2Property($columnName) || $columnName;
}


=begin TML
Expand Down
28 changes: 19 additions & 9 deletions lib/Foswiki/Plugins/JQGridPlugin/DBCacheConnector.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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 @@ -48,15 +48,25 @@ sub new {

# maps column names to accessors to the actual property being displayed
$this->{propertyMap} = {
'topic' => 'Topic',
'Topic' => 'topic',
'TopicTitle' => 'topictitle',
'info.date' => 'Modified',
'Modified' => 'info.date',
'info.date' => 'Changed',
'Changed' => 'info.date',
'By' => 'info.author',
'Author' => 'info.author',
'By' => 'info.author',
# 'Category' => 'Category',
'Changed' => 'info.date',
'Create Author' => 'createauthor',
'Create Date' => 'createdate',
'Created' => 'createdate',
'Creator' => 'createauthor',
'Form' => 'form',
'Modified' => 'info.date',
# 'Size' => 'size',
# 'State' => 'state',
# 'Tag' => 'tag',
'Title' => 'topictitle',
'TopicTitle' => 'topictitle',
# 'TopicType' => 'TopicType',
'Topic' => 'topic',
'Web' => 'web',
'Workflow' => 'workflow.name',
};

return $this;
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/JQGridPlugin/FoswikiConnector.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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 @@ -317,7 +317,7 @@ EOT


} else {
if ($fieldName =~ /^(Date|Changed|Modified|info.date|info.createdate)$/) {
if ($fieldName =~ /^(Date|Changed|Modified|Created)$/) {
push @colModel, "formatter:'date'";
push @colModel, "formatoptions: {srcformat: 's', newformat: 'd M Y - H:i'}";
push @colModel, "sorttype:'date'";
Expand Down Expand Up @@ -348,7 +348,7 @@ EOT

# edit
if ($theEdit eq 'on') {
if ($fieldName =~ /^(Changed|Modified|Author|info.date|info.author|Topic|topic)$/) {
if ($fieldName =~ /^(Changed|Modified|Author|Creator|Create Date|createauthor|createdate|info.date|info.author|Topic|topic)$/) {
push @colModel, "editable:false";
} else {
push @colModel, "editable:true";
Expand Down
9 changes: 5 additions & 4 deletions lib/Foswiki/Plugins/JQGridPlugin/SearchConnector.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2009-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2009-2016 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 @@ -31,7 +31,7 @@ sub writeDebug {

=begin TML
---+ package Foswiki::Plugins::JQGridPlugin::DBCacheConnector
---+ package Foswiki::Plugins::JQGridPlugin::SearchConnector
implements the grid connector interface using the standard SEARCH interface
Expand Down Expand Up @@ -123,9 +123,10 @@ sub restHandleSearch {
}

sub column2SortProperty {
my ($this, $column) = @_;
my ($this, $columnName) = @_;

return $this->{sortPropertyMap}{$column} || "formfield($column)";
return unless defined $columnName;
return $this->{sortPropertyMap}{$columnName} || $this->column2Property($columnName) || "formfield($columnName)";
}

=begin TML
Expand Down
45 changes: 26 additions & 19 deletions lib/Foswiki/Plugins/JQGridPlugin/SolrConnector.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2011-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2011-2016 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 @@ -48,23 +48,30 @@ sub new {

# maps column names to accessors to the actual property being displayed
$this->{propertyMap} = {
'Topic' => 'topic',
'Web' => 'web',
'TopicTitle' => 'title',
'Author' => 'author',
'By' => 'author',
'Modified' => 'date',
'Category' => 'category',
'Changed' => 'date',
'Author' => 'author',
'Created' => 'createdate',
'Create Date' => 'createdate',
'Creater' => 'createauthor',
'Create Author' => 'createauthor',
'TopicType' => 'field_TopicType_lst',
'Create Date' => 'createdate',
'Created' => 'createdate',
'Creator' => 'createauthor',
'Form' => 'form',
'Category' => 'category',
'Tag' => 'tag',
'State' => 'state',
'Modified' => 'date',
'Size' => 'size',
'State' => 'state',
'Tag' => 'tag',
'Title' => 'title',
'TopicTitle' => 'title',
'Topic' => 'topic',
'TopicType' => 'field_TopicType_lst',
'Web' => 'web',
'Workflow' => 'field_WorkflowState_s',
};

$this->{sortPropertyMap} = {
'Title' => 'title_search',
'TopicTitle' => 'title_search',
};

return $this;
Expand Down Expand Up @@ -100,7 +107,7 @@ sub restHandleSearch {

my $columns = Foswiki::Plugins::JQGridPlugin::Connector::urlDecode($request->param('columns') || '');
foreach my $columnName (split(/\s*,\s*/, $columns)) {
my $propertyName = $this->column2Property($columnName);
my $propertyName = $this->column2SortProperty($columnName);
my $values = $request->param($columnName);
next unless $values;

Expand Down Expand Up @@ -177,8 +184,8 @@ HERE
@values = $doc->values_for("field_".$propertyName."_dt") unless @values;
next unless @values;

my $value = join(", ", @values);
$value = $searcher->fromUtf8($value);
my $cell = join(", ", @values);
#$cell = $searcher->fromUtf8($cell);

# try to render it for display
$fieldDef = $form->getField($columnName) if $form;
Expand All @@ -192,15 +199,15 @@ HERE
if ($fieldDef->can("getDisplayValue")) {
$cell = $fieldDef->getDisplayValue($cell);
} else {
$cell = $fieldDef->renderForDisplay('$value', $cell, undef, $params{web}, $topic);
$cell = $fieldDef->renderForDisplay('$value', $cell, undef, $web, $topic);
}
$cell = Foswiki::Func::expandCommonVariables($cell, $topic, $params{web});
$cell = Foswiki::Func::expandCommonVariables($cell, $topic, $web);

# restore original name in form definition to prevent sideeffects
$fieldDef->{name} = $oldFieldName;
}

$line .= '<cell name="'.$columnName.'"><![CDATA[' . $value . ']]></cell>' . "\n";
$line .= '<cell name="'.$columnName.'"><![CDATA[' . $cell . ']]></cell>' . "\n";
}

$line .= "</row>\n";
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/JQGridPlugin/build.pl
@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
BEGIN {
unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} );
}
Expand Down
3 changes: 0 additions & 3 deletions pub/System/JQGridPlugin/css/Makefile
Expand Up @@ -7,9 +7,6 @@ CSSSOURCE=\
ui.multiselect.css \
jquery.searchFilter.css


# myfixes.css

jquery.jqgrid.uncompressed.css: $(CSSSOURCE)
@echo creating $@ from $^
@$(CAT) $^ > $@
Expand Down

0 comments on commit ccc23b7

Please sign in to comment.