Edit Tablerow Plugin

This plugin allows you to edit TWiki tables row by row, using a form with appropriate controls for each field. If preceeded by an %EDITTABLEROW{...}% variable, tables have edit links for each row, and are optionally followed by an [ Edit table ] button. Multiple tables per topic are editable, but only one row at a time can be edited.

Acknowledgment

This plugin was inspired and steals much from TWiki:Main/PeterThoeny's TWiki:Plugins/EditTablePlugin and tries be compatible with respect to the options and parameters it provides. However, as it supports editing of the table one row at a time, it is not subject to the performance limitations of TWiki:Plugins/EditTablePlugin when faced with large tables.

The idea and first implementation of form-based editing for tables goes back to TWiki:Main/ShawnBradford's approach in TWiki:Codev/SimpleTableEntryUsingForms.

Template

Before you can edit a table, you need to define a template that describes the layout of the table in the style of TWikiForms. The table format is given by a table in the form template: each row defines a table column by giving a field name, field type, size, and initial values, if any. The field type determines how the table row is edited (e.g., as text, textare, radio, checkbox, etc.).

For ease of transition of existing systems, the table schema can also be defined in the syntax of EditTablePlugin.

Per Table Settings

Add a %EDITTABLEROW{...}% variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. Parameters:

Parameter Comment Default
template Topic which defines the format of the table, in the style of TWikiForms. The table format is given by one row per table column defining field name, field type, size, and initial values, if any.  
header Must be used when the table schema is defined in the syntax of EditTablePlugin (see documentation there).  
format Must be used when the table schema is defined in the syntax of EditTablePlugin (see documentation there).  
changerows Rows can be added and removed if "on"; rows can be added but not removed if "add". CHANGEROWS Plugin setting
helptopic Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown. (no help text)
headerislabel Table header cells are read-only (labels) if "on"; header cells can be edited if "off" or "0" "on"
editbutton Set edit button text, e.g. "Edit this table"; set button image with alt text, e.g. "Edit table, %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/edittopic.gif" EDITBUTTON Plugin setting
editlink Set appearance of the per-row link, e.g. "Edit"; set button image with alt text, e.g. "Edit table, %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/edittopic.gif" EDITLINK Plugin setting
show When editing a row of a table, or adding to a table, display that table during edit. "off"
headeronempty Show the table headers when starting a table by placing the %EDITTABLEROW{...}% variable freely. "off"

The template and format attributes are mutually exclusive. If the template tag is present, the indicated template is used to define the table schema.

Initial Values

Table cells are given initial values taken from the template, when a table row is added.

Supported Field Type

All field types supported in TWikiForms are supported for table fields also. For example, in the screenshot below, the Mishoo DHTML calendar is used to select the value for a date field.

Edit Table Calendar Example

Table editing

A table row can be edited by clicking the link at the beginning of that row. This link may be represented either as

  • the first table field in the row being a link,
  • a text link (in smaller font) preceding the first table field, or
  • an icon preceding the table field,
depending on the EDITLINK preference setting (see below).

In edit mode, the following action buttons are available

    • - saves the table row with the form values
    • - delete the selected table row and save (if enabled)
    • - insert a new row into the table after the selected row, taking its values from the form (if enabled)

If enabled, below the table a link is shown that allows adding rows to the end of the table. The appearance of this link is controlled by the EDITBUTTON preference setting (see below).

In add mode, the following action button is available

    • - Add row at end of table, taking its values from the form (if enabled)

After editing, the focus is moved to the row edited, to avoid excessive scrolling when working with large tables.

Examples

Line before table: %EDITTABLEROW{ template="..." changerows="on" }%

Nr Text field Drop down Mood Timestamp
1 hello table one smile 19 Mar 2005 23:21
2   two frown 19 Mar 2005 11:21

If you click on one of the links in the first column, say for the second row, you will be able to edit that table row in a form:

Edit Table Calendar Example

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, for example, %EDITTABLEPLUGIN_SHORTDESCRIPTION%

  • One line description, shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Edit TWiki tables rows using a form

  • Set DEBUG to 1 to get debug messages in data/debug.txt. Default: 0
    • Set DEBUG = 0

  • Default for change rows flag: on, off, add
    • Set CHANGEROWS = on

  • Default edit button: Specify button text, or specify alternate text, image URL
    • Set EDITBUTTON = Edit table
    • #Set EDITBUTTON = Edit this table, edittable.gif

  • Default edit link for row: Specify button text, or specify alternate text, image URL. If empty, create link from first field.
    • #Set EDITLINK = Edit
    • #Set EDITLINK = Edit, edittopic.gif

Limitations and Known Issues

  • This Plugin does not (yet) support TWiki table formatting like Multi-span cells (e.g. | ... ||)
  • You cannot put two %EDITTABLE{}% statements on the same line in the source
  • Defining the schema in the format of EditTablePlugin requires patching of Form.pm

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this Plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip EditTablerowPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/EditTablerowPlugin.txt Plugin topic
    data/TWiki/EditTablerowPlugin.txt,v Plugin topic repository
    lib/TWiki/Plugins/EditTablerowPlugin.pm Plugin Perl module
    pub/TWiki/EditTablerowPlugin/*.jpg Screenshots for plugin topic
    bin/editTableRow  
    bin/uploadTableRow  
    templates/editTableRow.pattern.tmpl  
    templates/editTableRow.tmpl  
  • Verify access and ownership settings for the new scripts.
  • Edit your .htaccess file to require a valid user for the included scripts (if needed).
  • Apply the attached patch to lib/TWiki/Form.pm if you want to use the schema definition in the style of EditTablePlugin

Plugin Info

Plugin Author: TWiki:Main/ThomasWeigert
Plugin Version: 20 Sep 2006
Change History:  
20 Sep 2006: Add compatability with table schema definition from EditTablePlugin. Create header row when adding the first line to an empty table.
08 Sep 2006: Use strict warnings. Fix handling of checkbox fields. Move to last edited row after save to avoid scrolling. Do not insert placeholder text in first field.
01 Sep 2006: Dakar port. Fix handling of date fields in Dakar. Allow editlink in tag. Move existing table to bottom of edit view.
07 Jul 2005: Remove further warning message (thanks to TWiki:Main/KennethLavrsen and TWiki:Main/CrawfordCurrie)
30 Jun 2005: Fix access control. Remove warning messages from apache log.
21 Apr 2005: Fix to remove conflict with %TOC% rendering
26 Mar 2005: Removed dependencies on EditContrib? and made compatible with Beijing release
20 Mar 2005: Initial version
CPAN Dependencies: none
Other Dependencies: JSCalendarContrib
Perl Version: 5.0
License: GPL (GNU General Public License)
TWiki:Plugins/Benchmark: GoodStyle nn%, FormattedSearch nn%, EditTablerowPlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/EditTablerowPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/EditTablerowPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/EditTablerowPluginAppraisal

Related Topics: EditTablePlugin

-- TWiki:Main/ThomasWeigert - 20 Sep 2006

Topic revision: r2 - 22 Sep 2006 - 00:07:18 - TWikiGuest
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback