diff --git a/data/System/MetaDataPlugin.txt b/data/System/MetaDataPlugin.txt index aa93095..ca2678d 100644 --- a/data/System/MetaDataPlugin.txt +++ b/data/System/MetaDataPlugin.txt @@ -128,6 +128,7 @@ render a modal edit dialog according to the associated !DataForm definition. | title | display title for the modal dialog | | | buttontitle | display title for the button (default is =title=) | | | hideempty | boolean flag to hide/show empty formfields | off | +| icon | name of a famfamfam icon to be used on the button | add | ---++ Registering !MetaData @@ -191,9 +192,12 @@ have a database of efforts recorded on that tracker. | Author(s): | Michael Daum| | Copyright: | © 2011-2013 Michael Daum http://michaeldaumconsulting.com | | License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] | -| Release: | %$RELEASE% | | Version: | %$VERSION% | +| Release: | %$RELEASE% | | Change History: |   | +| 10 Jul 2013: | fixed dependencies on jQuery plugins; \ + improved params to NEWMETADATA; \ + improved table ui | | 14 Mar 2013: | fixed redirecting from edit | | 01 Nov 2012: | replace TML table default format strings with HTML tables for more robustness; removed automatic \n -> <br /> conversion | | 06 Sep 2012: | implemented proper locking | diff --git a/lib/Foswiki/Plugins/MetaDataPlugin.pm b/lib/Foswiki/Plugins/MetaDataPlugin.pm index 4cc2b88..7d6dd41 100644 --- a/lib/Foswiki/Plugins/MetaDataPlugin.pm +++ b/lib/Foswiki/Plugins/MetaDataPlugin.pm @@ -24,8 +24,8 @@ use Foswiki::Contrib::JsonRpcContrib (); use Foswiki::Plugins::MetaDataPlugin::Core(); use Error qw( :try ); -our $VERSION = '3.11'; -our $RELEASE = '3.11'; +use version; our $VERSION = version->declare("v3.2.0"); +our $RELEASE = '10 Jul 2013'; our $SHORTDESCRIPTION = 'Bring custom meta data to wiki apps'; our $NO_PREFS_IN_TOPIC = 1; our $core; diff --git a/lib/Foswiki/Plugins/MetaDataPlugin/Core.pm b/lib/Foswiki/Plugins/MetaDataPlugin/Core.pm index 6f49cf9..6743e0a 100644 --- a/lib/Foswiki/Plugins/MetaDataPlugin/Core.pm +++ b/lib/Foswiki/Plugins/MetaDataPlugin/Core.pm @@ -64,12 +64,13 @@ sub init { Foswiki::Plugins::JQueryPlugin::createPlugin("ui::dialog"); Foswiki::Plugins::JQueryPlugin::createPlugin("ui::button"); - Foswiki::Plugins::JQueryPlugin::createPlugin("ui::validate"); + Foswiki::Plugins::JQueryPlugin::createPlugin("validate"); Foswiki::Plugins::JQueryPlugin::createPlugin("blockui"); Foswiki::Plugins::JQueryPlugin::createPlugin("form"); + Foswiki::Plugins::JQueryPlugin::createPlugin("jsonrpc"); #my ( $zone, $tag, $data, $requires ) = @_; - Foswiki::Func::addToZone("script", "METADATAPLUGIN", <<'EOB', "JQUERYPLUGIN, JQUERYPLUGIN::UI::DIALOG, JQUERYPLUGIN::UI::BUTTON"); + Foswiki::Func::addToZone("script", "METADATAPLUGIN", <<'EOB', "JQUERYPLUGIN, JQUERYPLUGIN::UI::DIALOG, JQUERYPLUGIN::UI::BUTTON, JQUERYPLUGIN::JSONRPC"); EOB @@ -129,6 +130,7 @@ sub NEWMETADATA { my $theTemplate = $params->{template} || 'metadata::new'; my $theTopic = $params->{topic} || $this->{baseWeb}.'.'.$this->{baseTopic}; my $theMap = $params->{map} || ''; + my $theIcon = $params->{icon} || 'add'; foreach my $map (split(/\s*,\s*/, $theMap)) { $map =~ s/\s*$//; @@ -138,16 +140,20 @@ sub NEWMETADATA { } } - # rebuild the mapping string my @mapping = (); + my @values = (); foreach my $key (keys %$params) { + my $val = $params->{$key}; if ($key =~ /_title$/) { - my $val = $params->{$key}; $key =~ s/_title$//; push @mapping, $key.'='.$val; + } elsif ($key =~ /_value$/) { + $key =~ s/_value$//; + push @values, $key.'='.$val; } } $theMap = join(",", @mapping); + my $theValues = join("&", @values); $theTitle = '%MAKETEXT{"New [_1]" args="'.ucfirst($theMetaData).'"}%' unless defined $theTitle; $theButtonTitle = $theTitle unless defined $theButtonTitle; @@ -168,6 +174,8 @@ sub NEWMETADATA { $theFormat =~ s/%title%/$theTitle/g; $theFormat =~ s/%buttontitle%/$theButtonTitle/g; $theFormat =~ s/%map%/$theMap/g; + $theFormat =~ s/%values%/$theValues/g; + $theFormat =~ s/%icon%/$theIcon/g; #writeDebug("done NEWMETADATA()"); @@ -262,6 +270,9 @@ sub renderMetaData { my $theFilter = $params->{filter}; my $theWarn = Foswiki::Func::isTrue($params->{warn}, 1); my $theMap = $params->{map} || ''; + my $theFieldHeader = $params->{fieldheader} || ''; + my $theFieldFooter = $params->{fieldfooter} || ''; + my $theFieldSep = $params->{fieldseparator} || ''; foreach my $map (split(/\s*,\s*/, $theMap)) { $map =~ s/\s*$//; @@ -440,9 +451,8 @@ sub renderMetaData { $theFieldFormat = '$value'; } else { $theFieldFormat = ' $n'. - ' $title:$mandatory$n'. - ' $n$edit$n'. - '
$description
$n'. + ' $title:$mandatory$n'. + ' $n$edit$n
$description
'. ' '; } } @@ -496,6 +506,7 @@ sub renderMetaData { next if defined $theExclude && $excludeMap{$name}; # loop over all fields of a record + my @fieldResult = (); foreach my $field (@selectedFields) { next unless $field; @@ -580,11 +591,12 @@ sub renderMetaData { if ($theAction eq 'edit') { # or get value from url (highest prio) my $urlValue; + my $key = 'META_'.uc($metaData).'_'.$fieldName; if ($field->isMultiValued) { - my @urlValue = $query->param('META:'.$metaData.':'.$fieldName); + my @urlValue = $query->param($key); $urlValue = join(", ", @urlValue) if @urlValue; } else { - $urlValue = $query->param('META:'.$metaData.':'.$fieldName); + $urlValue = $query->param($key); } $fieldValue = $urlValue if defined $urlValue; } @@ -685,6 +697,8 @@ sub renderMetaData { $row =~ s/\$$fieldName/$line/g; $row =~ s/\$orig$fieldName/$fieldValue/g; + push @fieldResult, $line; + # cleanup $fieldClone->finish() if defined $fieldClone; $field->{name} = $origFieldName; @@ -718,8 +732,12 @@ sub renderMetaData { $fieldActions =~ s/\%map\%/$theMap/g; } + my $fieldResult = ''; + $fieldResult = $theFieldHeader.join($theFieldSep, @fieldResult).$theFieldFooter if @fieldResult; + $row =~ s/\$actions\b/$fieldActions/g; $row =~ s/\$index\b/$index/g; + $row =~ s/\$fields\b/$fieldResult/g; push @result, $row; $index++; diff --git a/pub/System/MetaDataPlugin/metadata.uncompressed.css b/pub/System/MetaDataPlugin/metadata.uncompressed.css index 82c508f..444f952 100644 --- a/pub/System/MetaDataPlugin/metadata.uncompressed.css +++ b/pub/System/MetaDataPlugin/metadata.uncompressed.css @@ -1,25 +1,33 @@ .metaDataView table { - margin-right:60px; + width:100%; position:relative; cursor:pointer; + border-collapse:separate; } .metaDataReadOnly table { margin-right:0px; } -.metaDataView tr.hover td { - background: #F4F4F4; +.metaDataActions, +.metaDataView table tr.hover td { + border-color:#E7B6B9 !important; } -/* -.metaDataView tr.selected td { - background:#f2f7ff; +.metaDataActions, +.metaDataView table tr.hover td { + background-color:#FBE3E4; +} + +.metaDataView tbody tr td { + border-width:1px 0px 1px 0px; + border-style:solid; + border-color:transparent; } -*/ .metaDataActions { display:none; position:absolute; - right:-63px; - margin-top:-10px; - padding:5px; + right:7px; + border-style:solid; + border-width:1px 1px 0 1px; + border-radius:0.5em 0.5em 0 0; } .metaDataActions a { padding:5px; @@ -27,6 +35,9 @@ float:left; vertical-align:middle; } +.hover .metaDataActions { + display:block; +} #metaDataForm tr.name { display:none; } diff --git a/pub/System/MetaDataPlugin/metadata.uncompressed.js b/pub/System/MetaDataPlugin/metadata.uncompressed.js index 0e55d60..5d00b6d 100644 --- a/pub/System/MetaDataPlugin/metadata.uncompressed.js +++ b/pub/System/MetaDataPlugin/metadata.uncompressed.js @@ -5,7 +5,7 @@ pluginName = 'metaDataView', pluginClass = '.metaDataView', defaults = { - actionFadeoutTime: 1000 + hideActionDelay: 1500 }; @@ -23,30 +23,69 @@ return self; }; + // show actions + MetaDataView.prototype.showActions = function($row) { + var self = this, + $actions = $row.find(".metaDataActions"), + rowPos = $row.position(), + height = $actions.outerHeight()-1; + + self.elem.find(".hover").removeClass("hover"); + $row.addClass("hover"); + $actions.show().css("top", rowPos.top-height); + }; + + // hide actions + MetaDataView.prototype.hideActions = function() { + var self = this; + + self.elem.find(".hover").removeClass("hover"); + }; + + // adds a hide-action timer + MetaDataView.prototype.startTimer = function() { + var self = this; + self.timeout = setTimeout(function() { + if (!self.active) { + self.hideActions(); + } + }, self.opts.hideActionDelay); + }; + // init method MetaDataView.prototype.init = function() { var self = this; + + self.active = false; + + self.elem.find(".metaDataActions").hover( + function() { + self.active = true; + }, + function() { + self.active = false; + self.startTimer(); + } + ); - self.elem.find("tr") - .hover( + self.elem.find("tbody tr").hover( function() { - var $row = $(this); - $row.addClass("hover"); - self.elem.find(".metaDataActions").hide(); - $row.find(".metaDataActions").show(); - if (self.timeout) { - clearTimeout(self.timeout); + var $row = $(this), + $actions = $row.find(".metaDataActions"); + + if ($actions.length) { + self.active = true; + if (self.timeout) { + clearTimeout(self.timeout); + } + self.showActions($row); } }, function() { - var $row = $(this); - $row.removeClass("hover"); - self.timeout = setTimeout(function() { - $row.find(".metaDataActions").stop().fadeOut(); - }, self.opts.actionFadeoutTime); + self.active = false; + self.startTimer(); } - ) - .click(function(e) { + ).click(function(e) { var $this = $(this), $editAction = $this.find(".metaDataEditAction"); diff --git a/templates/metadataplugin.tmpl b/templates/metadataplugin.tmpl index ff429a8..ae23275 100644 --- a/templates/metadataplugin.tmpl +++ b/templates/metadataplugin.tmpl @@ -1,7 +1,8 @@ %TMPL:DEF{"metadata::edit"}%%JQICON{"pencil"}%%TMPL:END% %TMPL:DEF{"metadata::duplicate"}%%JQICON{"page_white_copy"}%%TMPL:END% %TMPL:DEF{"metadata::delete"}%%JQICON{"bin"}%%TMPL:END% -%TMPL:DEF{"metadata::new"}%%buttontitle%%TMPL:END% +%TMPL:DEF{"DISmetadata::new"}%%buttontitle%%TMPL:END% +%TMPL:DEF{"metadata::new"}%%BUTTON{"%buttontitle%" icon="%icon%" href="%SCRIPTURL{"rest"}%/RenderPlugin/template?topic=%topic%&name=metadataplugin&expand=metadata::editor&metadata=%meta%&metadata::title=%title%&map=%ENCODE{"%map%"}%&querystring=%ENCODE{"%QUERYSTRING%"}%&%values%&t=%GMTIME{"$epoch"}%" class="jqUIDialogLink metaDataNewAction {cache:false}"}%%TMPL:END% %TMPL:DEF{"metadata::editor"}%%IF{ "%RENDERMETADATA{"%URLPARAM{"metadata"}%" header="$islocked" footer="" format=""}%"