Further input to handle multiple tags I did some elaboration and see

\define toc-item-dragdata()      $:/temp/TOC/dragdata
\define toc-item-dragdata-path() $:/temp/TOC/dragdata/path
\define toc-item-dragstart()   
<$action-setfield  $tiddler=<<toc-item-dragdata>> text=<<actionTiddler>> />
<$action-setfield  $tiddler=<<toc-item-dragdata-path>> text=<<path>> />
\end


\define toc-item-drop()
<$reveal default=<<actionTiddler>> type="nomatch" text=<<item>>> <!-- DON'T 
DROP ON SELF -->
   <!-- get OLDTAG and NEWTAG, exclude special TiddlyBook tags -->
   <$vars sourcetags={{{ [<actionTiddler>get[tags]] }}}
  sourcepath={{{ [<toc-item-dragdata-path>get[text]] }}}
          targettags={{{ [<item>get[tags]] }}}>
   <$vars  oldtag={{{ [<sourcepath>split[/]]-[<actionTiddler>]+[last[]]  }}}
           newtag={{{ [enlist<targettags>!enlist<toc-ignore-tags>] }}}>
   ......
 .....

It seems it work! I actually use the path to see what is the immediate 
parent! Then I just removed it and the code add the new tag correctly!
Of course this may be used when the target has also several tags!

What do you think?

--Mohammad


On Wednesday, February 26, 2020 at 1:28:24 AM UTC+3:30, Mohammad wrote:
>
> Hi Eric,
>  many thanks for this update! Yes it works great!
>  I also try use 
>
> <$action-listops $tiddler=<<newtag>>        $field="list" 
> $subfilter="[enlist<order>] -[<actionTiddler>] 
> +[insertbefore:item<actionTiddler>]" />
>
>
> and it works! but I see your solution is more consistent as it uses the 
> same mechanism for putting before and after item!
>
> On Wednesday, February 26, 2020 at 1:12:26 AM UTC+3:30, Eric Shulman wrote:
>>
>> On Monday, February 24, 2020 at 11:04:02 AM UTC-8, Mohammad wrote:
>>>
>>> Further input:  It seems append does not work with tiddler have space in 
>>> their name and it needs to get the input using double brackets when there 
>>> is a space in title.
>>>
>>
>> Instead of using: 
>>       <$action-listops $tiddler=<<newtag>>  $field="list" 
>> $subfilter="[enlist<order>] -[<actionTiddler>] +[append<actionTiddler>
>> putbefore<item>]" />
>> TiddlyTools/TOC now uses:
>>       <$action-listops $tiddler=<<newtag>>  $field="list" 
>> $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] 
>> +[putbefore<item>]" />
>> This avoids the use of the "append" filter (which expects a space 
>> separated list) and instead, just explicitly appends the actionTiddler at 
>> the end, then moves it into position
>>
>> Similarly, when using "shift drop" (drop after), it now does:
>>       <$action-listops $tiddler=<<newtag>>  $field="list" 
>> $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] 
>> +[putafter<item>]" />
>>
>> Also, I added handling to "ctrl drop" (drop into) so it works like the 
>> other handlers and builds the full "order" while removing any "list-before" 
>> or "list-after" fields on the individual entries:
>>       <$set name="order" filter="[<item>tagging[]]">
>>       <$list filter=<<order>>> <$action-deletefield 
>> $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>
>>       <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
>> $subfilter="-[<oldtag>] [<item>]" />
>>       <$action-listops $tiddler=<<oldtag>>        $field="list" 
>> $subfilter="-[<actionTiddler>]" />
>>       <$action-listops $tiddler=<<item>>          $field="list" 
>> $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>]" />
>>       </$set>
>>
>>
> I do not understand this, as *DROP AS CHILD*  means the target tiddler is 
> a branch but it is closed, so one drops an actionTiddler on it!
> If the branch is open, I expect the drop before OR drop after mechanism 
> work as expected!
>  
>
>> With these code tweaks, TiddlyTools/TOC now handles drag-and-drop of 
>> tiddlers with spaces in their titles.
>>
>> Thank for all your help testing the various edge cases for 
>> TiddlyTools/TOC.
>>
>>
> I really learn from it! and every aspects of it is a lesson in Tiddlywiki 
> scripting! I like the toggle mechanism and the way it processes branches.
>  
>
>> enjoy,
>> -e
>>
>>
> One more question:
>
> I confused with drag and drop when there are more than a tag! (I mean an 
> entry in the TOC tree has more than one tags)
>
> Example:
>
> * *root*
> **  *child1*
> ***    gchild1
> ***    gchild2
> **  *child2*
> **  *child3*
>
>
> they have a hierarchy and create a tree.
> Now assume *gchild2 *not only tagged with *child1 *but also tagged with foo 
> and bar!
> Then I tried to drag and drop *gchild2 *over *child3 *(no modifier) I see 
> *gchild2 
> *remains under *child1 *branch and also appears before *child3 *(gets the 
> *root 
> *tag as expected)
>
> Is there any limitation here, or I made a mistake?
>
> --Mohammad
>
>
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8cfc968f-619c-44c2-a8c0-404f902ab2ea%40googlegroups.com.

Reply via email to