Re: [tw5] urgh.. brackets

2019-08-04 Thread MagoArcade
Thanks Jeremy, that nudged me in the right direction. The key was rather 
than passing as parameters, set as vars in main body and use these in the 
macro. I'll be taking this approach rather than parameters from hereon in.

Working code (not tackled the other issues, but seems to be working without 
addressing those):


\define TmapEdgesGen()
{"$(randrelid)$":{"to":"$(parentmapid)$","type":"$(reltype)$"}}
\end







<$vars reltype={{!!rel_type}}
randrelid={{{ [[]make[%uuid%]] }}} 
itemid={{{ [[]make[%uuid%]] }}}
desctext={{$:/_opNodeDetsEditText!!text}}>


<$set name="parentmapid" tiddler={{!!SearchTermDD}} field=tmap.id>


<$wikify name="myfinal" text=<> >


DEBUG


ParentMapID: <>


RelType: <>


>From Macro: <>


<$button popup="bob" >Create Item


<$action-setfield $tiddler="$:/_opTaskStore" 
itemTitle=<>
desctext={{$:/_opNodeDetsEditText!!text}}
/>


<$action-setfield $tiddler="$:/_opEditNode" 
item.id=<>
shorttext={{$:/_opTaskStore!!taskname}}
description=<>
tags={{$:/_opTaskStore!!tags}}
nodetype= {{!!nodetype}}
createdby={{!!createdby}}
managedby={{!!managedby}}
owner={{!!owner}}
assignedto={{!!assignedto}}
taskstatus={{!!taskstat}}
taskpercentage={{$:/_opTaskStore!!taskpercentage}}
color={{$:/_opTaskStore!!color}}
startdate= {{$:/_opTaskStore!!startdate}}
duedate =  {{$:/_opTaskStore!!duedate}}
stalldate =  {{$:/_opTaskStore!!stalldate}}
completiondate =  {{$:/_opTaskStore!!completiondate}}
tmap.edges=<>
/>


<$action-setfield $tiddler="$:/_opEditNode" 
title=<>
tmap.id={{{ [[]make[%uuid%]] }}}
/>


<$reveal type='popup' state='bob' position='below'>

New Item created successfully:
{{$:/_opTaskStore!!itemTitle}}
<$link to={{$:/_opTaskStore!!itemTitle}}>Click to View




<$action-setfield $tiddler="$:/_opTaskStore" 
taskname=""
tags=""
taskpercentage=0
/>


<$action-setfield $tiddler="$:/_opNodeDetsEditText" 
text=""
/>















-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1093eccf-1371-4b19-83c6-63626d827dcc%40googlegroups.com.


Re: [tw5] urgh.. brackets

2019-08-04 Thread Jeremy Ruston
Hi MagoArcade

I’m not sure that I fully understand what you’re trying to do, but I can see a 
few red flags in the excerpts you’ve provided.

First, the core of this task is appears to be to substitute chunks of text into 
a template. This is one of those situations where text substitution via a macro 
is called for:

\define json-output()
{"$(id1)$":{"to":"$(id2)$","type":"$(type)$"}}
\end

<$var id1=..something.. id2=..something.. type=..something..>
<$action-setfield $tiddler="my tiddler" $field="my-field" 
$value=<>/>


The macro definition uses $(var)$ syntax to refer to variable names that are 
substituted when the macro is subsequently evaluated.

For explanatory purposes, I’ve used a var widget to assign values to those 
variables, and then used the action-setfield widget to assign the result to a 
tiddler field.

With that outline in mind, I’ll briefly note a few issues with the code you 
provided:

> My heavily abridged code:
> 
> \define TmapEdgesGen(tmapid reltype)
> {"{{{ [[]make[%uuid%]] }}}":{"to":"$tmapid$","type":"$reltype$"}}
> \end
> 
> 
> 
> <$select field="SearchTermDD" class="tw-edit-texteditor myTextEdit”>

Field names should be lowercase with dots, dashes, dollars and underscores.

> <$list filter="[regexp:]" emptyMessage="No Results" >
> >><$view field='title’/>

There’s no such construction as <>. When used to quote 
attribute values, the double angle bracket syntax evaluates a macro name, not a 
tiddler text reference.

> 
> 
> 
> 
> <$select field="rel_type" class="tw-edit-texteditor myTextEdit">
> <$list filter="[[$:/_DTrelTypes]indexes[]sort[title]]" variable="key">
> <$set name="val" filter="[[$:/_DTrelTypes]getindex]">
> >><>

Here you’re using <> to display the key within the option element. That 
syntax causes the content of the variable “key” to be wikified (ie wiki syntax 
like bold and italics would be honoured). It’s usually better to use <$text> or 
<$view> to display raw text.

> 
> 
> 
> <$set name="parentmapid" tiddler={{!!SearchTermDD}} field=tmap.id>
> 
> <$wikify name="tmaprelwikid" value="""<> 
> {{!!rel_type}} >>""” >

The wikify widget isn’t needed in simple cases of text substitution. It’s only 
required if the functionality of the full wikitext parsing engine is required.

Sorry for being brief, feel free to ask followups.

Best wishes

Jeremy


> 
> DEBUG
> ParentMapID: <>
> RelTypeID: {{!!rel_type}}
> Tmap.rels: <>
> 
> 
> <> can contain spaces
> 
> <> will never contain spaces
> 
> The output I get is:
> 
> DEBUG
> ParentMapID: 1bad2a3f-e5d7-4923-8bb1-73e2cdd36314
> 
> RelTypeID: Idea About
> 
> Tmap.rels:
> 
> 
> 
> I.e. nothing in <>
> 
> 
> 
> I've messed around with various permutations of brackets and quotes - cannot 
> find anyway to get this working. 
> 
> 
> 
> Any help appreciated.
> 
> 
> 
> -- 
> 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 tiddlywiki+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/87ed32ae-07bd-4e3b-9938-e9d9be87a293%40googlegroups.com
>  
> .

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/B8B5117A-6002-4197-8A3A-DB9247DE5CCF%40gmail.com.


[tw5] urgh.. brackets

2019-08-04 Thread MagoArcade
Hi all,

Having problems constructing a string from various components. The output 
I'm looking for would be in this format (literal = to be stored in a 
tiddler field):

{"31ada977-900e-4751-8549-8320014ab42f":{"to":"45e0e73a-0bdb-4a18-8452-8fdb59407bc6","type":"Subtask
 
Of"}}


My heavily abridged code:

\define TmapEdgesGen(tmapid reltype)
{"{{{ [[]make[%uuid%]] }}}":{"to":"$tmapid$","type":"$reltype$"}}
\end



<$select field="SearchTermDD" class="tw-edit-texteditor myTextEdit">
<$list filter="[regexp:]" emptyMessage="No Results" >
>><$view field='title'/>



<$select field="rel_type" class="tw-edit-texteditor myTextEdit">
<$list filter="[[$:/_DTrelTypes]indexes[]sort[title]]" variable="key">
<$set name="val" filter="[[$:/_DTrelTypes]getindex]">
>><>



<$set name="parentmapid" tiddler={{!!SearchTermDD}} field=tmap.id>

<$wikify name="tmaprelwikid" value="""<> 
{{!!rel_type}} >>""" >

DEBUG
ParentMapID: <>
RelTypeID: {{!!rel_type}}
Tmap.rels: <>


<> can contain spaces

<> will never contain spaces

The output I get is:

DEBUG

ParentMapID: 1bad2a3f-e5d7-4923-8bb1-73e2cdd36314

RelTypeID: Idea About

Tmap.rels:


I.e. nothing in <>


I've messed around with various permutations of brackets and quotes - 
cannot find anyway to get this working. 


Any help appreciated.

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/87ed32ae-07bd-4e3b-9938-e9d9be87a293%40googlegroups.com.