From b47dcf1e0a69d244671efb56525b04215b2f445c Mon Sep 17 00:00:00 2001 From: KennethLavrsen Date: Wed, 17 Feb 2010 17:43:35 +0000 Subject: [PATCH] Item8555: Item8554: Adding new feature editmode (default on) so you can turn the edit mode on and off by url param. Fixed a bug that makes the checkbox and select field turn add option values if they are a substring of an existing value git-svn-id: http://svn.foswiki.org/trunk/MultiTopicSavePlugin@6420 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- data/System/MultiTopicSavePlugin.txt | 42 ++++++++++++++++++++- lib/Foswiki/Plugins/MultiTopicSavePlugin.pm | 12 ++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/data/System/MultiTopicSavePlugin.txt b/data/System/MultiTopicSavePlugin.txt index e9068c3..fa6d232 100644 --- a/data/System/MultiTopicSavePlugin.txt +++ b/data/System/MultiTopicSavePlugin.txt @@ -6,6 +6,8 @@ %ATTACHURL%/example.png
_Example screenshot_ +%TOC% + This plugin allows the user to submit updates to the dataform in multiple topics in one single edit/submit cycle. The users can create a topic which displays the fields from many topics as editable fields. The users can edit the field values and when they click a submit button all the topics with fields that were changed will be updated. @@ -79,7 +81,8 @@ To ease this task you can use the MULTITOPICSAVESUBMIT which creates a submit bu * topic = name of the target topic. In formatted searches you can put $topic here * value = the value that is put in the field by default * options = the values to choose between for types radio, select etc. This value is ignored for text, textarea, and hidden. Options are separated by commas, example: options="dog, cat, horse" - *Note that the input fields generated by MULTITOPICSAVEINPUT have only single quotes (') allowing the use in the format parameter of SEARCH. + * editmode = enable the field in edit mode. If this is set to "off" the value given in the value field is shown. If editmode is "on" the field is shown in edit mode. By default the editmode it "on". This enables selectively to enable editing by adding something like editmode="%URLPARAM{"multiedit" default="off"}% to MULTITOPICSAVEINPUT and control selectively if fields are editable or not. This can simply be used by appending ?multiedit=on to the URL. + * Note that the input fields generated by MULTITOPICSAVEINPUT have only single quotes (') allowing the use in the format parameter of SEARCH. * %MULTITOPICSAVEMESSAGE% * This macro shows messages about topic that were not saved due to lack access rights and it shows the total number of saved topics. This macro is only expanded when you return to the page after submitting the content. @@ -174,6 +177,42 @@ For example. You have many topics with a field with combinations of values A, B %SEARCH{"NOT(Platforms ~ '*D*') AND name ~ 'FuncReq*'" type="query" nonoise="on" format="| [[$topic][$formfield(Title)]] |$percntMULTITOPICSAVEINPUT{$quotPlatforms$quot type=$quothidden$quot web=$quot$web$quot topic=$quot$topic$quot value=$quot$formfield(Platforms)$quot }$percnt $percntMULTITOPICSAVEINPUT{$quotPlatforms$quot type=$quotcheckbox$quot size=$quot0$quot multiple=$quoton$quot web=$quot$web$quot topic=$quot$topic$quot value=$quot$quot options=$quotD$quot }$percnt |"}% +---++ Tips and Tricks + +---+++ Auto generating the options list + +Instead of manually defining the list of options in MULTITOPICSAVEINPUT you can load the list of options from the Plugin form. Assuming the values are defined in the form itself this is an example of setting a macro which you can then use later. In this example the form topic is called !RequirementsForm and the field name is Platforms. + + + * Set PLATFORMOPTIONS = %SEARCH{"\| *Platforms *\|" topic="RequirementsForm" regex="on" nonoise="on" multiple="on" format="$pattern(.*?\| *Platforms *\|[^\|]*\|[^\|]*\| *([^\|]*?) *\|.*)"}% + + +You can then use options="%PLATFORMOPTIONS%" in MULTITOPICSAVEINPUT + +If the values are defined in their own topic use instead this example + +The topic called =FieldName= defines the values in a table like + +| *Name* | *Type* | *Tooltip message* | +| Open | option | Not yet resolved | +| Closed | option | Fixed and closed | +| Rejected | option | Not accepted and closed | + +The example below sets FIELDOPTIONS = Open, Closed, Rejected + + + * Set FIELDOPTIONS = %SEARCH{ "^\|[^\|]*\| *option *\|" topic="FieldName" type="regex" multiple="on" nonoise="on" separator=", " format="$pattern(^\| *(.*?) *\|.*)" }% + + +---+++ Using the editmode parameter + +To take advantage of the =editmode= parameter for MULTITOPICSAVEINPUT add editmode="%URLPARAM{"multiedit" default="off"}% to MULTITOPICSAVEINPUT. + +This will disable editing and just show the plain content given in the value option. + +At the top of the page put a link like this =[[%TOPICURL%?multiedit=on][Edit the requirements]]=. When the user clicks the link the page is reloaded and all fields will be in edit mode. A bit like we know from EditTablePlugin. + +[[%TOPICURL%?multiedit=on][Edit the requirements]]   | +| 17 Feb 2010 (1.3) | Added the parameter editmode to MULTITOPICSAVEINPUT which can be used to show the value instead of an edit field.
Fixed bug where options were wrongly selected if they matched a substring of the one of the values. | | 17 Feb 2010 (1.2) | Added MULTITOPICSAVEMESSAGE macro so the user can get feedback on how the saving went | | 17 Feb 2010 (1.1) | Added type hidden. Added examples of use of all the different field types | | 16 Feb 2010 (1.0) | First version of plugin | diff --git a/lib/Foswiki/Plugins/MultiTopicSavePlugin.pm b/lib/Foswiki/Plugins/MultiTopicSavePlugin.pm index 98fa54f..a7fb6fb 100644 --- a/lib/Foswiki/Plugins/MultiTopicSavePlugin.pm +++ b/lib/Foswiki/Plugins/MultiTopicSavePlugin.pm @@ -29,7 +29,7 @@ use Foswiki::Plugins (); # For the API version our $VERSION = '$Rev: 5771 $'; # $RELEASE is used in the "Find More Extensions" automation in configure. -our $RELEASE = '1.2'; +our $RELEASE = '1.3'; # Short description of this plugin # One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic: @@ -177,6 +177,12 @@ sub _MULTITOPICSAVEINPUT { my $value = defined $params->{value} ? $params->{value} : ''; my @values = map { s/^\s*(.*?)\s*$/$1/; $_; } split( /\s*,\s*/, $value ); + # If edit mode is defined and set to off - just return the value + my $editmode = defined $params->{editmode} ? $params->{editmode} : 'on'; + unless ( Foswiki::Func::isTrue( $editmode ) ) { + return $value; + } + # We assume all leading and trailing spaces are unwanted. my @options = (); if ( defined $params->{options} ) { @@ -212,7 +218,7 @@ sub _MULTITOPICSAVEINPUT { if ( $type eq 'radio' && $option eq $value ) { $result .= "checked='checked' "; } - if ( $type eq 'checkbox' && grep (/$option/, @values ) ) { + if ( $type eq 'checkbox' && grep (/^$option$/, @values ) ) { $result .= "checked='checked' "; } $result .= "/> $option "; @@ -245,7 +251,7 @@ sub _MULTITOPICSAVEINPUT { foreach my $option ( @options ) { $result .= "