Difference: EditTablePlugin (r22 vs. r21)

Edit Table Plugin

Edit TWiki tables using edit fields, date pickers and drop down boxes

Introduction

Edit TWiki tables in place, using edit fields and drop down boxes, without having to edit the complete topic.

Simply add an [ Edit table ] button to an existing table by writing %EDITTABLE{}% directly above the table. This can be added to tables that are formatted with TablePlugin: add the EDITTABLE variable just above or below the TABLE tag. It can also be used without any TABLE tag.

Customize entry fields by specifying the format: use a text field, a drop down box, a date field, radio buttons or checkboxes.

Multiple tables per topic are editable, but only one at a time can be edited.

Per Table Settings

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

  • Supported attributes:
    AttributeCommentDefault
    header Specify the header format of a new table like "|*Food*|*Drink*|". Useful to start a table with only a button (no header)
    format The format of one column when editing the table. A cell can be a text input field, or any of these edit field types:
    • Text input field (1 line):
      | text, <size>, <initial value> |
    • Textarea input field:
      | textarea, <rows>x<columns>, <initial value> |
    • Drop down box:
      | select, <size>, <option 1>, <option 2>, etc* |
      * only one item can be selected
    • Radio buttons:
      | radio, <size*>, <option 1>, <option 2>, etc |
      * size indicates the number of buttons per line in edit mode
    • Checkboxes:
      | checkbox, <size*>, <option 1>, <option 2>, etc |
      * size indicates the number of checkboxes per line in edit mode
    • Fixed label:
      | label, 0, <label text> |
    • Row number:
      | row, <offset> |
    • Date:
      | date, <size>, <initial value>, <DHTML date format*> |
      * see Date Field Type
    "text, 16"
    for all cells
    changerows Rows can be added and removed if "on"
    Rows can be added but not removed if "add"
    Rows cannot be added or removed if "off"
    CHANGEROWS
    plugin setting
    quietsave Quiet Save button is shown if "on", hidden if "off"QUIETSAVE
    plugin setting
    include Other topic defining the EDITTABLE parameters. The first %EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. (none)
    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%/%SYSTEMWEB%/TWikiDocGraphics/edittopic.gif"; hide edit button at the end of the table with "hide" (Note: Button is automatically hidden if an edit button is present in a cell) EDITBUTTON
    plugin setting
    buttonrow Set to top to put the edit buttons above the table. bottom
    javascriptinterface Use javascript to directly move and delete row without page refresh. Enable with "on", disable with "off". JAVASCRIPTINTERFACE
    plugin setting
    redirectto Set up a return page after saving changes. e.g By setting redirectto="%BASEPAGE%", you can return to base page if your editable table is included by another page. (none)

Using TWiki Variables in the Format Parameter

By default, variables in <initial value> (of text input field) and <label text> (of fixed label) get expanded when a new row is added. This can be used for example to add a timestamp to a label. You can escape characters with format tokens if you do not want that.

Any TWiki variable inside a table cell will be preserved. For instance, %TOPIC% will not get expanded to the current topic name.

The format tokens are the same as with FormattedSearch:

Escape:Expands To:
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
$nop or $nop() Is a "no operation".
$quot Double quote (")
$percnt Percent sign (%)
$dollar Dollar sign ($)

Date Field Type

The date field type allows one to choose a date with a popup calendar. Popup calendar works with all modern browsers. The date picker button is inactive if the browser cannot support the popup calendar or if Javascript is disabled.

The date format can be defined; the default is taken from the {JSCalendarContrib}{format} configure setting. Date specifiers are described in JSCalendarContrib. Example format for ISO date: format="| date, 10, , %Y-%m-%d |".

Edit Table Calendar Example

Per Cell Settings

An individual edit field type can be defined for each table cell. Place an %EDITCELL{ "type, ..." }% variable at the end of the cell content. This is useful to override the per column %EDITTABLE{ format="..." }% settings, or to create tables with key/value rows. All edit field types of the format="..." parameter are supported. For example, to define a text field, type: | cell content %EDITCELL{ "text, 20" }% |

It is also possible to place the edit button inside a cell instead of default location below the table. Type | %EDITCELL{ "editbutton, 1, Edit this table" }% | to show a button, or | %EDITCELL{ "editbutton, 1, Edit table, Image-URL" }% | to show a button image with alternate text.

Note: The %EDITCELL{ }%=variable cannot be used by itself; place an =%EDITTABLE{ }%=variable at the beginning of a table where you want to use =%EDITCELL{ }% variables.

Table Buttons

  • In page view mode:
    • - turn the table into edit mode
  • In edit mode:
    • - save your changes
    • - save your changes without alerting subscribed WebNotify users
    • - add row to the table (if enabled)
    • - remove last row from the table (if enabled)
    • - cancel without saving and release edit lock
    • - Move a row by clicking this button next to the row to be moved, then at a destination.
    • - Deletes the row next to this button.

Examples

Line before table: %EDITTABLE{ format="| row, -1 | text, 20, init | select, 1, one, two, three, four | radio, 3,:-),:-I,:-( | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }%

NrText fieldDrop downMoodTimestamp
1 hello table one smile 26 Jun 2002 12:30
2   two frown 27 Jun 2002 12:40

Note: Please do not save this example table! Use TWiki:Sandbox.EditTablePluginTesting if you want to try out this Plugin

If this plugin is installed you will see an [ Edit table ] button above; if you were to click on it (please don't, use TWiki:Sandbox.EditTablePluginTesting for testing) you get this form:

NrText fieldDrop downMoodTimestamp
1 smile indifferent frown 26 Jun 2002 12:30
2 smile indifferent frown 27 Jun 2002 12:40

The following example shows a simple table with key/value rows. The default edit field type for the value column is a text field. This is overloaded by a selector for the Gender, and a date picker for the DOB. This is typically used by TWiki applications where new topics with tables are created based on a template topic.

You type: You get: Table in edit mode:
%TABLE{"headerrows="1"}%
%EDITTABLE{ format="| label | text, 40 |" changerows="off" }%
|*Key*|*Value*|
| Name: | John Smith |
| Gender: | M %EDITCELL{select, 1, , F, M}% |
| DOB: | 1999/12/31 %EDITCELL{date, 10}% |
| City: | New York |
EDITCELL Example in view modeEDITCELL Example in edit mode

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 using edit fields, date pickers and drop down boxes
  • Set DEBUG to 1 to get debug messages in data/debug.txt. Default: 0
    • Set DEBUG = 0
  • Set JAVASCRIPTINTERFACE to 1 to be able to directly move and delete row without page refresh. Can be overridden with parameter javascriptinterface.
    • Set JAVASCRIPTINTERFACE = 1
  • Default for change rows flag: on, off, add
    • Set CHANGEROWS = on
  • Default flag for quiet save option: on to show the Quiet Save button, off to hide
    • Set QUIETSAVE = on
  • Default edit button: Specify button text, or specify alternate text, image URL. Note: Texts inside %MAKETEXT{}% are translated into other languages.
    • #Set EDIT_BUTTON = Edit table
    • Set EDIT_BUTTON = Edit this table, edittable.gif
    • Set SAVE_BUTTON = Save table
    • Set QUIET_SAVE_BUTTON = Quiet save
    • Set ADD_ROW_BUTTON = Add row
    • Set DELETE_LAST_ROW_BUTTON = Delete last row
    • Set CANCEL_BUTTON = Cancel
  • Default help texts
    • Set INCLUDED_TOPIC_DOES_NOT_EXIST = Warning: 'include' topic does not exist!

Note: The Plugin uses base settings like date format, language and style from the JSCalendarContrib.

Limitations and Known Issues

  • This Plugin does not support TWiki table formatting like Multi-span cells (e.g. | ... ||) and cell justification (e.g. |  centered  |   right |)
  • There is a performance issue when editing a large table, say, with more then 50 rows
  • You cannot put two %EDITTABLE{}% statements on the same line in the source
  • You can include %-vars now in select values, by quoting them with <nop>, as in %<nop>X% for %X%, say for instance:
    select,1,%<nop>X%,%<nop>Y%

Installation Instructions

Note: This is a pre-installed TWiki plugin. You should not need to install the plugin unless it is for an upgrade.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip EditTablePlugin.zip in your ($TWIKI_ROOT) directory.
  • Alternatively,
    • Manually resolve the dependencies listed below. None
  • The Plugin depends on the viewauth script to authenticate the user. As described in TWikiAccessControl, copy the view script to viewauth (or better, create a symbolic link) and add viewauth to the list of authenticated scripts in the .htaccess file.
  • Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.
  • Test if the Plugin is correctly installed:
    • Check above example if there is an [ Edit table ] button below the table in above example
    • Click on [ Edit table ], make changes and save the table

Plugin Info

Plugin Author: Arthur Clemens, TWiki:Main.PeterThoeny
Copyright: © 2008 Arthur Clemens;
© 2002-2012 TWiki:Main.PeterThoeny, TWiki.org;
© 2002-2012 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 2012-07-11 2012-11-12
Change History:  
2012-07-11: 2012-11-12: TWikibug:Item6900 TWikibug:Item7020 : Fix for warning: "my" Categorize TWiki Variable EDITTABLE variable %regex masks earlier declaration -- TWiki:Main.JudBarron TWiki:Main.PeterThoeny
2011-07-07: 2012-11-06: TWikibug:Item6725 TWikibug:Item7025 : Change Return global package variables from "use vars" to "our" base page after saving changes.
2010-05-25: 2012-11-06: 5.1: TWikibug:Item7024 TWikibug:Item6324 : Make - Fix for editing a table removing EDITCELL from another table - patch by EditTable TWiki:Main/NickThorpe read-only when current site mode is readonly or slave
2010-05-16: 2012-07-11: 5.0: TWikibug:Item6900 TWikibug:Item6433 : Fix for warning: "my" variable %regex masks earlier declaration -- - doc improvements; replacing TWIKIWEB with SYSTEMWEB TWiki:Main.JudBarron
17 2011-07-07: Apr 2009: 4.9.1: Save of table can only be done with http POST method, not GET TWikibug:Item6725 : Change global package variables from "use vars" to "our"
01 2010-05-25: Nov 2008: 4.9: 5.1: Arthur Clemens: Fixed rendering of verbatim TWikibug:Item6324 blocks when editing. Added parameter - Fix for editing a table removing EDITCELL from another table - patch by buttonrow="top" TWiki:Main/NickThorpe to allow the buttons to be positioned at the top of the table.
26 2010-05-16: Sep 2008: 4.8.7: 5.0: Arthur Clemens: Let empty table initialize more than one column from header TWikibug:Item6433 parameter - doc improvements; replacing TWIKIWEB with SYSTEMWEB
24 Sep 2008: 17 Apr 2009: 4.8.6: Arthur 4.9.1: Save Clemens: Fix parsing of header labels table can only be done with http POST method, not GET
21 Sep 01 Nov 2008: 4.8.5: 4.9: Arthur Clemens: Fix Fixed rendering of TML inside label verbatim blocks when editing. Added parameter buttonrow="top" to allow the buttons to be positioned at the top of the table.
03 Aug 26 Sep 2008: 4.8.4: TWiki 4.2.1 release version 4.8.7: Arthur Clemens: Let empty table initialize more than one column from header parameter
19 Jul 24 Sep 2008: 4.8.3: Bugfix release 4.8.6: Arthur Clemens: Fix parsing of header labels
20 Mar 21 Sep 2008: 4.8: 4.8.5: Arthur Clemens: Code refactoring; Fix rendering disabled table sort when editing; removed usage of TML inside label $percnt to prevent variable expansion (is now done automatically); made Javascript interface aware of headers and footers, and of changerows="off" ; improved feedback on row move.
25 Dec 2007: 03 Aug 2008: 4.7.1: Arthur Clemens: Added warning 4.8.4: TWiki 4.2.1 release version if include parameter topic does not exist.
22 Dec 2007: 19 Jul 2008: 4.7: Arthur Clemens: 4.8.3: Bugfix release Changed handling of escaped variables. To escape TWiki variable, use formatting tokens such as $percnt .
16 Dec 2007: 20 Mar 2008: 4.6: Kenneth Lavrsen: The plugin prevents 4.8: Arthur Clemens: Code refactoring; disabled table sort when editing; removed usage of TablePlugin $percnt from initsorting the table being edited. This is done by temporarily appending the attribute disableallsort="on" to the TABLE tag prevent variable expansion (is now done automatically); made Javascript interface aware of a table being edited. Additionally headers and footers, and of all header sorting is disabled while editing a table by setting a hidden formfield sort changerows="off" to "off". Disabling sorting while editing ; improved feedback on row move. is needed now that the EditTablePlugin supports moving rows up and down.
01 25 Dec 2007: 4.3: 4.7.1: Arthur Clemens: added support for Added warning if TablePlugin include parameter topic does not exist. headerrows and footerrows ; updated edit button
16 Oct 22 Dec 2007: 4.2: 4.7: Arthur Clemens: refactoring, bug fixes. Changed handling of escaped variables. To escape TWiki variable, use formatting tokens such as $percnt .
07 Oct 16 Dec 2007: 15182: PTh: Added 4.6: Kenneth Lavrsen: The plugin prevents VarEDITTABLE TablePlugin from initsorting the table being edited. This is done by temporarily appending the attribute disableallsort="on" to have it listed in the TABLE tag of a table being edited. Additionally all header sorting is disabled while editing a table by setting a hidden formfield TWikiVariables sort to "off". Disabling sorting while editing is needed now that the EditTablePlugin supports moving rows up and down.
15 Mar 01 Dec 2007: 4.3: Arthur Clemens: Fixed eating added support of double newlines; icons for Javascript buttons and interface improvements. By default the Javascript interface is turned off, set JAVASCRIPTINTERFACE TablePlugin to use it in edit mode. headerrows and footerrows ; updated edit button
05 Mar 16 Oct 2007: Byron Darrah: Added ability to dynamically 4.2: Arthur Clemens: refactoring, bug fixes. move and delete rows.
12 07 Oct 2006: 2007: Item2982 15182: PTh: Added Use default date format from VarEDITTABLE JSCalendarContrib to have it listed in TWikiVariables
02 Oct 2006: 15 Mar 2007: Item2884 Arthur Clemens: Fixed eating of double newlines; icons for Javascript buttons and interface improvements. By default the Javascript interface is turned off, set Check also for access permission in meta data; proper fix to not warn if oneself has a lock on topic JAVASCRIPTINTERFACE to use it in edit mode.
30 Aug 2006: 05 Mar 2007: Item2829 Byron Darrah: Added ability to dynamically move and delete rows. Remove whitespace from select, radio and checkbox items; restored topic lock if $TWiki::Plugins::VERSION < 1.1
29 Jul 12 Oct 2006: Item2684 Item2982 - Quietly ignore topic edit Use default date format from locks on table edit JSCalendarContrib
21 Jan 02 Oct 2006: TWiki:Main.CrawfordCurrie Item2884 ported Check also for access permission in meta data; proper fix to TWiki-4.0.0, changed to use not warn if oneself has a lock on topic JSCalendarContrib
16 Sep 2004: 30 Aug 2006: Added radio buttons and checkbox controls; escaped "|" pipe symbol found in input fields to preserve tables Item2829 Remove whitespace from select, radio and checkbox items; restored topic lock if $TWiki::Plugins::VERSION < 1.1
01 Aug 2004: 29 Jul 2006: Fixed bug where edittable did not work if at the end of a topic Item2684 - Quietly ignore topic edit locks on table edit
07 Apr 2004: 21 Jan 2006: Fixed bug where two tables got updated when you edit and save a table included into a topic containing other edit tables TWiki:Main.CrawfordCurrie ported to TWiki-4.0.0, changed to use JSCalendarContrib
02 Mar 16 Sep 2004: Default for Added radio buttons and checkbox controls; escaped "|" pipe symbol found in input fields to preserve tables %EDITCELL{editbutton}% is EDITBUTTON preference
27 Feb 01 Aug 2004: Added QUIETSAVE setting and Fixed bug where edittable did not work if at the end of a topic quietsave parameter; image for Edit button
18 Feb 07 Apr 2004: Doc fixes; allow Fixed bug where two tables got updated when you edit button anywhere and save in a cell not just table included into at the end of a cell topic containing other edit tables
17 Feb 02 Mar 2004: Added per Default for cell definition of edit field types with %EDITCELL{}% %EDITCELL{editbutton}% variable; added is EDITBUTTON preference headerislabel and editbutton parameters
20 Dec 2003: 27 Feb 2004: Fixed bug where calendar Added QUIETSAVE setting and did not work after adding a row ( TWiki:Main/PaulineCheung quietsave ); added all language files parameter; image for Edit button of Mishoo DHTML calendar 0.9.5
13 Dec 2003: 18 Feb 2004: Added CHANGEROWS, JSCALENDARDATEFORMAT, JSCALENDARLANGUAGE, JSCALENDAROPTIONS settings Doc fixes; allow edit button anywhere in a cell not just at the end of a cell
16 Oct 2003: 17 Feb 2004: small typo fixed (garbled if ---+ header on top) Added per cell definition of edit field types with %EDITCELL{}% variable; added headerislabel and editbutton parameters
15 Oct 20 Dec 2003: new date field Fixed bug where type with Javascript calendar - CN did not work after adding a row ( TWiki:Main/PaulineCheung ); added all language files of Mishoo DHTML calendar 0.9.5
14 Oct 13 Dec 2003: docfix: the documentation page was an Added CHANGEROWS, JSCALENDARDATEFORMAT, JSCALENDARLANGUAGE, JSCALENDAROPTIONS settings old one - CN
13 16 Oct 2003: bugfix: %-vars in select were resetted to small typo fixed (garbled if ---+ header first on add/del top) row - CN
18 Sep 15 Oct 2003: incompatibility: changed default of new date field type with Javascript calendar - CN changerows to on ; support for %-vars, Quiet save for saving without notification; all other fixes in Dev topic integrated - CN
08 Nov 2002: 14 Oct 2003: Prevent variable expansion in label text; added escape characters docfix: the documentation page was an old one - CN
27 Jun 2002: 13 Oct 2003: New bugfix: %-vars in select were resetted to first on add/del row - CN helptopic parameter
26 Jun 2002: 18 Sep 2003: Support for variables in incompatibility: changed default of included EDITTABLE parameters; fixed problem with HTML in cells changerows to on ; support for %-vars, Quiet save for saving without notification; all other fixes in Dev topic integrated - CN
21 May 08 Nov 2002: Added fixed Prevent variable expansion in label format; new text; added escape characters changerows="add" parameter
27 Apr Jun 2002: Fixed New bug where text after a double quote in a cell disappeared helptopic parameter
18 Apr 26 Jun 2002: Fixed bug where table was breaking when pasting multiple lines into an edit Support for variables in included EDITTABLE parameters; fixed problem with HTML in cells field using Netscape on Unix
08 Apr 21 May 2002: Check for change permission and Added fixed label format; new edit lock of topic changerows="add" parameter
05 27 Apr 2002: Initial version Fixed bug where text after a double quote in a cell disappeared
Dependencies: 18 Apr 2002: None Fixed bug where table was breaking when pasting multiple lines into an edit field using Netscape on Unix
Perl Version: 08 Apr 2002: 5.0 Check for change permission and edit lock of topic
TWiki:Plugins/Benchmark 05 Apr 2002: : GoodStyle Initial version 98%, FormattedSearch 98%, EditTablePlugin 95%
Plugin Dependencies: Home: http://TWiki.org/cgi-bin/view/Plugins/EditTablePlugin None
Feedback: Perl Version: http://TWiki.org/cgi-bin/view/Plugins/EditTablePluginDev 5.0
Appraisal: TWiki:Plugins/Benchmark : http://TWiki.org/cgi-bin/view/Plugins/EditTablePluginAppraisal GoodStyle 98%, FormattedSearch 98%, EditTablePlugin 95%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/EditTablePlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/EditTablePluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/EditTablePluginAppraisal

Related Topics: VarEDITTABLE, TWikiPreferences, TWikiPlugins

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.EditTablePlugin.