TIP MultiSaveContrib is not installed on Foswiki.org.

MultiSaveContrib

Json-RPC interface to save multiple changes in one transaction

MultiSaveContrib can be used to build wiki applications that change one or more properties in multiple topics in one transaction. So users won't have to edit each single topic turn by turn. All changes are submitted to a multi-save backend which then applies them automatically. By now, only DataForm properties can be changed. A further version of this extension will allow to change other properties as well.

This extension is heavily inspired by Foswiki:Extensions/MultiTopicSavePlugin but strips down some of its features while adding new ones thus rendering its interface incompatible to MultiTopicSavePlugin. The basic idea how to transmit a multi-save change still remains similarly.

Rendering of input forms is best delegated to Foswiki:Extensions/FlexFormPlugin which will use the Foswiki's core features to render DataForm edit widgets.

Usage

A multi-save form is created using a formatted search like this:

<form class="jqMultiSave" name="MyMultiSave">
%DBQUERY{"form='TestForm'"
  header="<table class='foswikiTable'>
    <tr><th>Topic</th><th>Field1</th><th><th>Field2</th><th>Field3</th></tr>$n"
  footer="</table>"
  separator="$n"
  format="<tr><td> [[$web.$topic]] </td><td> 
    $percntRENDERFOREDIT{topic=\"$web.$topic\"
      fields=\"Field1, Field2, Field3\"
      format=\"$edit\"
      separator=\" </td><td> \"
      Field1_name=\"multisave{$web.$topic}{Field1}\"
      Field2_name=\"multisave{$web.$topic}{Field2}\"
      Field3_name=\"multisave{$web.$topic}{Field3}\"
    }$percnt 
    </td></tr>"
}%
%BUTTON{"Save" icon="disk" type="submit"}%
</form>
%JQREQUIRE{"multisave"}%

There are a couple of things to note:

There's a %JQREQUIRE{"multisave"}% that will load the javascript required to handle all forms having a css class "jqMultiSave" This will attach a jquery.multisave instance to this form.

The multi-save form will be posted to the appropriate jsonrpc endpoint of this extension asynchronously.

Results by the jsonrpc endpoint are processed by the jquery.multisave javascript code and displayed in a message box following the form.

The multi-save action will also transmit the form's name which helps to identify it from other multi-save wiki applications in subsequent beforeSaveHandler and afterSaveHandler (see below).

The formatted search in the example looks up topics that have a specific TestForm attached to it. In this example TestForm comprises of at least three formfield Field1, Field2, Field3.

The formatted search makes use of FlexFormPlugin's %RENDERFOREDIT macro that will generate the edit interface based on the DataForm definition of TestForm.

The form elements used to edit each formfield requires it's name attribute to be altered in a specific way so that MultiSaveContrib knows where to save this formfield. It must be of the form

multisave{web.topic}{fieldname}

For instance, the Field1_name parameter in the example above will override the normal name attribute used by %RENDERFOREDIT while creating an edit widget for that element. So changing Field1 in a topic FooWeb.BarTopic will performed by an form element such as:

<input type="text" size="75" name="multisave{FooWeb.BarTopic}{Field1}" value="..." />

All form elements that changed their values will be flagged so using css automatically. Only these will be transferred to the multi-save backend.

Adding beforeSaveHander and afterSaveHandler

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Dependencies

NameVersionDescription
Foswiki::Contrib::JsonRpcContrib>=2.00Required.
Foswiki::Plugins::FlexFormPlugin>=2.70Optional.

Change History

25 Sep 2017: fixed use of param() api
20 Sep 2014: fixed saving of deselected checkboxes and radioboxes
04 Sep 2013: fixed manifest
30 May 2013: initial release
Topic revision: r5 - 25 Sep 2017, MichaelDaum - This page was cached on 15 Nov 2017 - 02:02.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License