You are here: Foswiki>Tasks Web>Item5146 (15 Mar 2009, ArthurClemens)Edit Attach

Item5146: EDITTABLE plays Too nicely with SEARCH

Priority: Enhancement
Current State: Closed
Released In:
Target Release: n/a
Applies To: Extension
Component: EditTablePlugin
Reported By: TWiki:Main.VickiBrown
Waiting For:
Last Change By: ArthurClemens
I ran into an "interesting" interaction between EDITTABLE and SEARCH.

Let's say you have a table like this

| *Project* | *Assignee* | *Launch Date* |  |
%SEARCH{search="META:FIELD.*?AssignedTo.*?VickiBrown.*" topic="Projects_.*"   format="| $formfield(ProjectName) | $formfield(AssignedTo)  | $formfield(LaunchDate) |" }%

It returns all Project pages where AssignedTo is VickiBrown. Standard TWiki Forms search. No problem.

Then, lets say someone edits the page.

| *Project* | *Assignee* | *Launch Date* |  |
%SEARCH{search="META:FIELD.*?AssignedTo.*?VickiBrown.*" topic="Projects_.*"   format="| $formfield(ProjectName) | $formfield(AssignedTo)  | $formfield(LaunchDate) |" }%

What I expected to happen:

There is only one "real" table row here. Everything else is virtual, ephemeral, dynamic. I would expect clicking the edit button to show a table with no rows except the header and the ability to add one or more rows above the Search results.

What actually does happen:

EDITTABLE merrily picks up the Search results and presents them as an editable table. When you save, it writes these (now static) rows into the page. They are immediately followed by the Search results.

If SEARCH returns four rows, following an edit, you now see 8. Then 12. Ever recursively down the Rabbit Hole we plunge. Yargh!

I realize that the quick response is "don't hold your arm like that". But it would be nice if TWiki (in the person of EditTablePlugin) could help protect the naive user from his own error by not picking up the "dynamic" rows returned by Search!

-- TWiki:Main.VickyBrown - 18 Dec 2007

This can actually be (mis)used as feature for capturing search results. wink

-- TWiki:Main.FranzJosefGigler - 18 Dec 2007

Do you have any idea yourself how we could 'protect' the SEARCH variable? I don't find it very obvious. footerrows cannot be used as the number will vary with the search. %EDITTABLESTARTPROTECT% and %EDITTABLESTOPPROTECT% looks ugly. The plugin cannot detect that the SEARCH should be protected by itself. Moreover it may be intended.

-- TWiki:Main.ArthurClemens - 20 Dec 2007

Franz - agreed. But my guess is that intentional capture is less likely than misuse. The people at my company simply didn't realize what they were doing.

Arthur - If it were me, I would think that EDITTABLE and SEARCH would need to cooperate. So, by defaulkt, SEARCH would produce some hidden information, perhaps in the form of an HTML comment, that EDITTABLE would see and use to ignore that section of the table. A SEARCH parameter could be used to allow editing of SEARCH results for those who understood the ramifications.

-- TWiki:Main.VickiBrown - 22 Dec 2007

That would mean there need to be a PROTECT variable. I favor TWiki syntax over html comments.

-- TWiki:Main.ArthurClemens - 24 Dec 2007

Unsurprisingly EditRowPlugin suffers from the same disease.

I think it would be a mistake to lard the text with more variables. Much better to tell the EditTablePlugin and EditRowPlugin that only a subset of the rows in the table are editable. For example, %EDITTABLE{editablerows="1"}%. The value of editablerows could be a range expression (perhaps even disjoint?) for example %EDITTABLE{editablerows="1:3,-2:-1"}% would indicate that rows 1, 2 and 3 are editable, and so are the last 2 rows in the table (-2 and -1).

-- CrawfordCurrie - 28 Jan 2008

Looks very geeky. wink

-- TWiki:Main.FranzJosefGigler - 28 Jan 2008

Fixed with Item1292. Without geeky syntax.

-- ArthurClemens - 15 Mar 2009

ItemTemplate edit

Summary EDITTABLE plays Too nicely with SEARCH
ReportedBy TWiki:Main.VickiBrown
SVN Range TWiki-4.3.0, Tue, 18 Dec 2007, build 16029
AppliesTo Extension
Component EditTablePlugin
Priority Enhancement
CurrentState Closed
TargetRelease n/a
Topic revision: r11 - 15 Mar 2009, ArthurClemens
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy