kookma / TW-Shiraz

Shiraz is a small Tiddlywiki 5 plugin contains macros, stylesheets, templates, snippets, images, static tables, dynamic tables and acts as a starter kit.
https://kookma.github.io/TW-Shiraz/
78 stars 8 forks source link

Dynamic table shows " Delete all 232 records? " on sidebar #37

Closed linonetwo closed 1 year ago

linonetwo commented 1 year ago

On my wiki https://wiki.onetwo.ren/#%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8:%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8%20Index

(This wiki is readonly, the source note is at https://github.com/linonetwo/wiki/blob/62232058e9659e32b1846fa340253af1be443318/tiddlers/%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8.tid#L12 )

截屏2023-05-25 20 20 58

This is strange.

(also, I was unable to sort it by Created field, using macro parameter, maybe same as https://github.com/kookma/TW-Shiraz/discussions/36 )

kookma commented 1 year ago

The delete all only appears if you click on delete button on the header in Edit mode.

There is a temp tiddler $:/temp/tables/delete-all delete it and see if still you have the warning red bar?

What happen when you click no on the warning bar? Is it persistent?

linonetwo commented 1 year ago

You can try it directly on my wiki ( on this, https://onetwo.ren/wiki/#%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8:%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8%20Index this site is single HTML ,so editable and not saved) ( https://wiki.onetwo.ren/#%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8:%E4%BE%A7%E8%BE%B9%E6%A0%8F%E6%83%B3%E6%B3%95%E5%88%97%E8%A1%A8%20Index is readonly)

On this sidebar tab

截屏2023-05-26 12 33 02

Clicking "no" have no effect

截屏2023-05-26 12 31 30

and $tw.wiki.getTiddler('$:/temp/tables/delete-all') don't exists.

This only happened on sidebar

kookma commented 1 year ago

While I see the error on your wiki, but I cannot reproduce it on the demo page, as I use template for tabs. I believe this is a TiddlyWiki bad design of tabs where in that the currentTiddler does not work and you have to use template.

Dynamic table uses stateTiddler for intermediate data! when it is not passed explicitly in macro call, the currentTiddler is used and when dynamic tables are called from sidebar (e.g. tabs) the issue appears.

To solve your case do as below:

\define sv-exclude-tags() 想法

<$tiddler tiddler=<<currentTab>> >

<<table-dynamic filter:"[tag[想法]]" fields:"title created tags tbl-expand" pagination:yes class:"w-100 table-center" editButton:no emptyMessage:"太好了,所有想法都整理到笔记里">>

</$tiddler>
kookma commented 1 year ago

Another solution is to use an explicit stateTiddler, like below:

<<table-dynamic filter:"[tag[想法]]" 
  fields:"title created tags tbl-expand" 
 pagination:yes class:"w-100 table-center" 
 editButton:no 
 emptyMessage:"太好了,所有想法都整理到笔记里"
stateTiddler:"Some State Tiddler Title Here" >>
linonetwo commented 1 year ago

\define sv-exclude-tags() 想法

<$tiddler tiddler=<> >

<<table-dynamic filter:"[tag[想法]]" fields:"title created tags tbl-expand" pagination:yes class:"w-100 table-center" editButton:no emptyMessage:"太好了,所有想法都整理到笔记里">>

</$tiddler>

This works, thank you!

Just wrapping things that will show in sidebar, warp in <$tiddler tiddler=<<currentTab>> > </$tiddler>

linonetwo commented 1 year ago

But this does not work state:侧边栏想法列表/state , still shows error.

And it also not presist sort state. Which I hope can be achieved by https://github.com/kookma/TW-Shiraz/discussions/36

kookma commented 1 year ago

Did you clearly set the stateTiddler on table-dynamic call?

kookma commented 1 year ago

And it also not presist sort state. Which I hope can be achieved by #36

I think when you set a stateTiddler like mystate the Shiraz creates a tiddler like $:/state/dynamictables/mystate/sortby and if you work on Node.JS this tiddler is not saved between sessions.

If you need to keep state, I have to do some changes in state handling in dynamic table.

For more info see https://kookma.github.io/TW-Shiraz/#%24%3A%2Fplugins%2Fkookma%2Fshiraz%2Fmacros%2Fdtables%2Fhelper to learn how Shiraz handles state and temp tiddlers for Dynmaic Table.

linonetwo commented 1 year ago

I think I don't really need a persist state, just a default order is enough. This also prevent changes in the git.