From 381f12beac8583c48c8d8d82643b120f72c75740 Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Mon, 16 Feb 2015 12:22:27 +0100 Subject: [PATCH] Item13030: complete port to jsrender also: - hide buttons on static context - require JsonRpcContrib > 2.21 - updated translation strings --- .gitignore | 1 + lib/Foswiki/Plugins/ListyPlugin/Core.pm | 2 +- lib/Foswiki/Plugins/ListyPlugin/DEPENDENCIES | 2 +- locale/ListyPlugin/Foswiki.pot | 86 ++++++++++++---- locale/ListyPlugin/de.po | 97 +++++++++++++++---- .../ListyPlugin/jquery.listy.uncompressed.js | 30 +++--- templates/listyplugin.tmpl | 2 +- 7 files changed, 161 insertions(+), 59 deletions(-) diff --git a/.gitignore b/.gitignore index 484ddbc..5a5f131 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ *.gz *.swp pub/System/ListyPlugin/jquery.listy.js diff --git a/lib/Foswiki/Plugins/ListyPlugin/Core.pm b/lib/Foswiki/Plugins/ListyPlugin/Core.pm index a9f806c..8ba8e2f 100644 --- a/lib/Foswiki/Plugins/ListyPlugin/Core.pm +++ b/lib/Foswiki/Plugins/ListyPlugin/Core.pm @@ -294,7 +294,7 @@ sub _expandButtons { my $buttons = ''; - if (Foswiki::Func::checkAccessPermission('CHANGE', $wikiName, undef, $topic, $web)) { + if (!Foswiki::Func::getContext()->{static} && Foswiki::Func::checkAccessPermission('CHANGE', $wikiName, undef, $topic, $web)) { $buttons = Foswiki::Func::expandTemplate("listy::buttons"); } diff --git a/lib/Foswiki/Plugins/ListyPlugin/DEPENDENCIES b/lib/Foswiki/Plugins/ListyPlugin/DEPENDENCIES index eac514b..688e67b 100644 --- a/lib/Foswiki/Plugins/ListyPlugin/DEPENDENCIES +++ b/lib/Foswiki/Plugins/ListyPlugin/DEPENDENCIES @@ -1,6 +1,6 @@ Foswiki::Plugins::RenderPlugin,>=3.10,perl,Required. Foswiki::Plugins::JQueryPlugin,>=6.00,perl,Required. -Foswiki::Contrib::JsonRpcContrib,>=1.0,perl,Required. +Foswiki::Contrib::JsonRpcContrib,>=2.21,perl,Required. ONLYIF ( $Foswiki::Plugins::VERSION < 2.1) Foswiki::Plugins::ZonePlugin,>=3.1,perl,Required. required for Foswiki < 1.1 diff --git a/locale/ListyPlugin/Foswiki.pot b/locale/ListyPlugin/Foswiki.pot index 57a526b..1cae446 100644 --- a/locale/ListyPlugin/Foswiki.pot +++ b/locale/ListyPlugin/Foswiki.pot @@ -13,43 +13,83 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: templates/listyplugin.tmpl:235 templates/listyplugin.tmpl:80 +msgid ":collection" +msgstr "" + +#: templates/listyplugin.tmpl:147 templates/listyplugin.tmpl:81 +msgid ":name" +msgstr "" + +#: templates/listyplugin.tmpl:146 templates/listyplugin.tmpl:82 +msgid ":source" +msgstr "" + +#: templates/listyplugin.tmpl:222 +msgid ":summary" +msgstr "" + +#: templates/listyplugin.tmpl:190 templates/listyplugin.tmpl:83 +msgid ":title" +msgstr "" + +#: templates/listyplugin.tmpl:206 +msgid ":topic" +msgstr "" + +#: templates/listyplugin.tmpl:145 +msgid ":type" +msgstr "" + +#: templates/listyplugin.tmpl:214 +msgid ":url" +msgstr "" + +#: templates/listyplugin.tmpl:202 +msgid ":web" +msgstr "" + +#: templates/listyplugin.tmpl:231 +msgid ":~renderCollections()" +msgstr "" + #: templates/listyplugin.tmpl:53 msgid "Add Item" msgstr "" -#: templates/listyplugin.tmpl:177 -msgid "Add a description to this listy item." +#: templates/listyplugin.tmpl:223 +msgid "Add a description for this item." msgstr "" -#: templates/listyplugin.tmpl:88 +#: templates/listyplugin.tmpl:99 msgid "Add an item" msgstr "" -#: templates/listyplugin.tmpl:196 +#: templates/listyplugin.tmpl:83 msgid "Are you sure that you want to delete %1?" msgstr "" -#: templates/listyplugin.tmpl:185 -msgid "Cancel" +#: templates/listyplugin.tmpl:230 +msgid "Collection" msgstr "" -#: templates/listyplugin.tmpl:148 -msgid "Customize the text of your listy item." +#: templates/listyplugin.tmpl:191 +msgid "Customize the text of your item." msgstr "" -#: templates/listyplugin.tmpl:191 -msgid "Delete Listy Item" +#: templates/listyplugin.tmpl:78 +msgid "Delete Item" msgstr "" #: templates/listyplugin.tmpl:21 msgid "Delete this item" msgstr "" -#: templates/listyplugin.tmpl:111 templates/listyplugin.tmpl:20 +#: templates/listyplugin.tmpl:139 templates/listyplugin.tmpl:20 msgid "Edit this item" msgstr "" -#: templates/listyplugin.tmpl:136 +#: templates/listyplugin.tmpl:181 msgid "External" msgstr "" @@ -57,30 +97,34 @@ msgstr "" msgid "Revert changes" msgstr "" -#: templates/listyplugin.tmpl:184 -msgid "Save" -msgstr "" - #: templates/listyplugin.tmpl:64 msgid "Save changes" msgstr "" -#: templates/listyplugin.tmpl:175 +#: templates/listyplugin.tmpl:232 +msgid "Select the collection to hold the item." +msgstr "" + +#: templates/listyplugin.tmpl:221 msgid "Summary" msgstr "" -#: templates/listyplugin.tmpl:146 +#: templates/listyplugin.tmpl:171 +msgid "Text" +msgstr "" + +#: templates/listyplugin.tmpl:189 msgid "Title" msgstr "" -#: templates/listyplugin.tmpl:133 templates/listyplugin.tmpl:159 +#: templates/listyplugin.tmpl:176 templates/listyplugin.tmpl:205 msgid "Topic" msgstr "" -#: templates/listyplugin.tmpl:167 +#: templates/listyplugin.tmpl:213 msgid "Url" msgstr "" -#: templates/listyplugin.tmpl:155 +#: templates/listyplugin.tmpl:201 msgid "Web" msgstr "" diff --git a/locale/ListyPlugin/de.po b/locale/ListyPlugin/de.po index 4c804c7..2bc8079 100644 --- a/locale/ListyPlugin/de.po +++ b/locale/ListyPlugin/de.po @@ -13,31 +13,76 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: templates/listyplugin.tmpl:235 templates/listyplugin.tmpl:80 +msgid ":collection" +msgstr "" + +#: templates/listyplugin.tmpl:147 templates/listyplugin.tmpl:81 +msgid ":name" +msgstr "" + +#: templates/listyplugin.tmpl:146 templates/listyplugin.tmpl:82 +msgid ":source" +msgstr "" + +#: templates/listyplugin.tmpl:222 +#, fuzzy +msgid ":summary" +msgstr "Zusammenfassung" + +#: templates/listyplugin.tmpl:190 templates/listyplugin.tmpl:83 +#, fuzzy +msgid ":title" +msgstr "Titel" + +#: templates/listyplugin.tmpl:206 +#, fuzzy +msgid ":topic" +msgstr "Topic" + +#: templates/listyplugin.tmpl:145 +msgid ":type" +msgstr "" + +#: templates/listyplugin.tmpl:214 +msgid ":url" +msgstr "" + +#: templates/listyplugin.tmpl:202 +msgid ":web" +msgstr "" + +#: templates/listyplugin.tmpl:231 +msgid ":~renderCollections()" +msgstr "" + #: templates/listyplugin.tmpl:53 msgid "Add Item" msgstr "Neuer Eintrag" -#: templates/listyplugin.tmpl:177 -msgid "Add a description to this listy item." +#: templates/listyplugin.tmpl:223 +#, fuzzy +msgid "Add a description for this item." msgstr "Geben Sie eine Beschreibung für diesen Eintrag an." -#: templates/listyplugin.tmpl:88 +#: templates/listyplugin.tmpl:99 msgid "Add an item" msgstr "Eintrag hinzufügen" -#: templates/listyplugin.tmpl:196 +#: templates/listyplugin.tmpl:83 msgid "Are you sure that you want to delete %1?" msgstr "Sind Sie sicher, dass Sie diesen Eintrag löschen wollen? %BR% %2" -#: templates/listyplugin.tmpl:185 -msgid "Cancel" -msgstr "Abbrechen" +#: templates/listyplugin.tmpl:230 +msgid "Collection" +msgstr "" -#: templates/listyplugin.tmpl:148 -msgid "Customize the text of your listy item." +#: templates/listyplugin.tmpl:191 +#, fuzzy +msgid "Customize the text of your item." msgstr "Passen Sie den Text dieses Eintrags an." -#: templates/listyplugin.tmpl:191 +#: templates/listyplugin.tmpl:78 msgid "Delete Item" msgstr "Eintrag löschen" @@ -45,11 +90,11 @@ msgstr "Eintrag löschen" msgid "Delete this item" msgstr "Diesen Eintrag löschen" -#: templates/listyplugin.tmpl:111 templates/listyplugin.tmpl:20 +#: templates/listyplugin.tmpl:139 templates/listyplugin.tmpl:20 msgid "Edit this item" msgstr "Eintrag bearbeiten" -#: templates/listyplugin.tmpl:136 +#: templates/listyplugin.tmpl:181 msgid "External" msgstr "Extern" @@ -57,30 +102,40 @@ msgstr "Extern" msgid "Revert changes" msgstr "Rückgängig" -#: templates/listyplugin.tmpl:184 -msgid "Save" -msgstr "Speichern" - #: templates/listyplugin.tmpl:64 msgid "Save changes" msgstr "Speichern" -#: templates/listyplugin.tmpl:175 +#: templates/listyplugin.tmpl:232 +msgid "Select the collection to hold the item." +msgstr "" + +#: templates/listyplugin.tmpl:221 msgid "Summary" msgstr "Zusammenfassung" -#: templates/listyplugin.tmpl:146 +#: templates/listyplugin.tmpl:171 +msgid "Text" +msgstr "" + +#: templates/listyplugin.tmpl:189 msgid "Title" msgstr "Titel" -#: templates/listyplugin.tmpl:133 templates/listyplugin.tmpl:159 +#: templates/listyplugin.tmpl:176 templates/listyplugin.tmpl:205 msgid "Topic" msgstr "Topic" -#: templates/listyplugin.tmpl:167 +#: templates/listyplugin.tmpl:213 msgid "Url" msgstr "Url" -#: templates/listyplugin.tmpl:155 +#: templates/listyplugin.tmpl:201 msgid "Web" msgstr "Web" + +#~ msgid "Cancel" +#~ msgstr "Abbrechen" + +#~ msgid "Save" +#~ msgstr "Speichern" diff --git a/pub/System/ListyPlugin/jquery.listy.uncompressed.js b/pub/System/ListyPlugin/jquery.listy.uncompressed.js index 6a8f467..0ccd6c2 100644 --- a/pub/System/ListyPlugin/jquery.listy.uncompressed.js +++ b/pub/System/ListyPlugin/jquery.listy.uncompressed.js @@ -272,9 +272,6 @@ data: { collection: self.opts.collection, allCollections: self.opts.allCollections, - renderCollections: function() { - return self.renderCollections(); - }, name: name, source: self.opts.source, summary: decodeURIComponent(data.summary), @@ -283,14 +280,18 @@ topic: data.topic, url: data.url, type: data.type + }, + methods: { + renderCollections: function() { + return self.renderCollections(); + }, } }).then( function(dialog) { $(dialog).children("form").ajaxSubmit({ - success: function(data) { - var json = $.parseJSON(data), - collection = json.result.collection, + success: function(json) { + var collection = json.result.collection, listies = findListiesOfCollection(collection); if (listies) { @@ -327,23 +328,24 @@ data: { collection: self.opts.collection, allCollections: self.opts.allCollections, - renderCollections: function() { - return self.renderCollections(); - }, source: self.opts.source, summary: "", title: "", web: foswiki.getPreference("WEB"), topic: foswiki.getPreference("TOPIC"), url: "" + }, + methods: { + renderCollections: function() { + return self.renderCollections(); + }, } }).then( function(dialog) { $(dialog).children("form").ajaxSubmit({ - success: function(data) { - var json = $.parseJSON(data), - collection = json.result.collection, + success: function(json) { + var collection = json.result.collection, listies = findListiesOfCollection(collection); if (listies) { @@ -613,7 +615,7 @@ }, open: function() {}, data: { - /* default variables to be used in jquery.tmpl */ + /* default variables to be used in jquery.render */ /* web: self.opts.web, topic: self.opts.topic,*/ @@ -646,7 +648,7 @@ $.loadTemplate({ url: opts.url }).then(function(template) { - $(template.render(opts.data)).dialog({ + $(template.render(opts.data, opts.methods)).dialog({ buttons: [{ text: opts.okayText, icons: { diff --git a/templates/listyplugin.tmpl b/templates/listyplugin.tmpl index d4612dc..dc8fb8a 100644 --- a/templates/listyplugin.tmpl +++ b/templates/listyplugin.tmpl @@ -228,7 +228,7 @@ %TMPL:DEF{"listy::editor::collectionstep"}%

%MAKETEXT{"Collection"}%:

- {{html renderCollections()}} + {{:~renderCollections()}}
%MAKETEXT{"Select the collection to hold the item."}%
%TMPL:END%