mauloop / tw5-table-tool

0 stars 0 forks source link

Default Template Structure (Duplication) #1

Open mathewjpotter opened 4 years ago

mathewjpotter commented 4 years ago

Hi There I am looking at a way to duplicate a table and use it as a template, any ideas? I'm building tables that outline a day work plan, and use time daily time blocks as the columns, then I add content inside those time blocks.

mauloop commented 4 years ago

I mathewjpotter,

You can clone a table structure, creating a tiddler with a little script inside

title: Clone table

<$button>Clone table
<$list filter="""[prefix[$:/tbl/momyl]]""">
<$action-setfield title={{{ [all[current]removeprefix[$:/tbl/momyl/]addprefix[$:/tbl/clone/]] }}}/>
</$list>
</$button>

Change momyl with the actual name of your table and clone with the name you planned for your cloned table.

If you use the <<tdeSelectVal>> macro for any of your table fields you have to update the drop-down items tiddlers too. For example in momyl table from my demo wiki this is the case of the "First listen" column. Add the following to the above button widget:

<$list filter="""[tag[$:/tbl/momyl/default/mml-first]]""">
<$action-listops $tags="""$:/tbl/clone/default/mml-first"""/>
</$list>

(again momyl and clone must be changed to reflect your actual scenario, as well as the involved field name, mml-first)

To run the script you have to click the button "Clone table" in the tiddler just created. After that you can start use your table adding this macro to any tiddler:

<<table-tool "clone">>

The Clone table tiddler with the script could be safely deleted or you can keep it to clone the template table again. You can simply edit it and replace the target table name every time or you can improve the script adding an edit field to insert it. (it could be a feature for next plugin release, but I have no time to spend on this by now).

Remember to backup your wiki before apply this changes. Hope this would help.

)+(auloop