Item11027: Support for image/photo columns

pencil
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: JQGridPlugin
Branches:
Reported By: PaulHarvey
Waiting For:
Last Change By: MichaelDaum
Well, this is not a proper solution, but it's hack I'm using

diff --git a/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm b/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
index f70a254..b507196 100644
--- a/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
+++ b/lib/Foswiki/Plugins/JQGridPlugin/GRID.pm
@@ -120,6 +120,7 @@ sub handleGrid {
   my $theOnSelectAll = $params->{onSelectAll};
   my $theConnector = $params->{connector} || $Foswiki::cfg{JQGridPlugin}{DefaultConnector};
   my $theTopicFieldRegex = $params->{topicfieldregex} || 'Topic|TopicTitle';
topicfieldregex ...? that's not committed either -- MD

+  my $theImageFieldRegex = $params->{imagefieldregex} || 'Photo|Image';
 
   # sanitize params
   $theRowNumbers = ($theRowNumbers eq 'on')?'true':'false';
@@ -214,7 +215,9 @@ HERE
         push @selectedFields, $fieldName;
       }
     } else {
-      my $form = new Foswiki::Form($this->{session}, $theFormWeb, $theForm);
+      my $form = Foswiki::Form->new($this->{session}, $theFormWeb, $theForm);
+      require Data::Dumper;
+      print STDERR Data::Dumper->Dump([$form->{_parsed}]);

umpf: debugging leftover? -- MD

       @selectedFields = map {$_->{name}} @{$form->getFields()} if $form;
     }
 
@@ -271,7 +274,7 @@ HERE
       if ($fieldName =~ /^(.*$theTopicFieldRegex)$/) {
         push @colModel, "formatter:'topic'";
       }
-      if ($fieldName =~ /(Image|Photo)$/) {
+      if ($fieldName =~ /($theImageFieldRegex)/) {

Probably a good interim solution and for certain a better hack than the hack before hardcoding Image|Photo -- MD

         push @colModel, "formatter:'image'";
       }
 
diff --git a/pub/System/JQGridPlugin/jquery.jqgrid.uncompressed.js b/pub/System/JQGridPlugin/jquery.jqgrid.uncompressed.js
index 29fe573..1ed51b2 100644
--- a/pub/System/JQGridPlugin/jquery.jqgrid.uncompressed.js
+++ b/pub/System/JQGridPlugin/jquery.jqgrid.uncompressed.js
@@ -4154,7 +4154,7 @@ $.jgrid.extend({
             width: 80,
             baseUrl: '',
             params: '',
-            urlFormat: '%url%%value%?%params%'
+            urlFormat: '%url%/bin/rest/ImagePlugin/resize?topic=' + opts.rowId + ';file=%value%;height=80'

Introduces a dependency on ImagePlugin. Better would be to detect whether it is installed or not -- MD

           };
 
       if(!$.fmatter.isUndefined(opts.colModel.formatoptions)) {
@@ -4179,9 +4179,12 @@ $.jgrid.extend({
     }, 
     target = "", 
     url, 
-    topic = cellVal.match(/[\/\.]/)? cellVal.replace(/\./, '/'): opts.rowId.replace(/\./, '/'),
+    topic,
     viewUrl = foswiki.getPreference("SCRIPTURLPATH")+'/view';
 
+    if (cellVal) {
+        topic = cellVal.match(/[\/\.]/)? cellVal.replace(/\./, '/'): opts.rowId.replace(/\./, '/');
+    }

Good catch but probably unrelated to this bug item. -- MD


     if(!$.fmatter.isUndefined(opts.colModel.formatoptions)) {
       op = $.extend({},op,opts.colModel.formatoptions);
     }

-- PaulHarvey - 08 Aug 2011

https://github.com/csirac2/JQGridPlugin/commit/cd01a18ba6b2d4042739c1c830a7c9b961ca8c8d

-- PaulHarvey - 08 Aug 2011

Added some comments on the patch above.

-- MichaelDaum - 08 Aug 2011

Yeah, the patch(es) is slightly terrible at the moment smile

There are two special types of columns so far... 'topic' and 'photo', AFAIK. Anyway, the branches are at https://github.com/csirac2/JQGridPlugin

I will try to find time to clean this up. Would you rather see a regex param? I think a list of formfields would be better

-- PaulHarvey - 08 Aug 2011

Rather than having more specific (image) parameters, there's a new one now to use JQueryTmpl to format cells. Image columns can now be formated that way instead of adding a special case just for these. Please reopen this item if jquery.tmpl doesn't suffice.

-- MichaelDaum - 12 Sep 2011
 

ItemTemplate edit

Summary Support for image/photo columns
ReportedBy PaulHarvey
Codebase trunk
SVN Range
AppliesTo Extension
Component JQGridPlugin
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
Topic revision: r4 - 12 Sep 2011, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy