[tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-28 Thread Spangenhelm
Congratulations apparently it works great ! Hope the pull request will be 
accepted for the next version!

-S

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3456ce22-6a03-4d71-a73f-51705bf2105b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-19 Thread Evan Balster


I managed to modify the set widget to fix the problem described here. 
 While I don't understand the system enough to guarantee this code is bug 
free, it doesn't break the wiki and seems to work with all my test-cases.


(I don't really know how to go about submitting this to the project...)


To use this modification, replace the content of 
*$:/core/modules/widgets/set.js* with the code below:

/*\
title: $:/core/modules/widgets/set.js
type: application/javascript
module-type: widget

Set variable widget

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var Widget = require("$:/core/modules/widgets/widget.js").widget;

var SetWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};

/*
Inherit from the base widget class
*/
SetWidget.prototype = new Widget();

/*
Render this widget into the DOM
*/
SetWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
this.execute();
this.renderChildren(parent,nextSibling);
};

/*
Compute the internal state of the widget
*/
SetWidget.prototype.execute = function() {
// Get our parameters
this.setName = this.getAttribute("name","currentTiddler");
this.setFilter = this.getAttribute("filter");
this.setValue = this.getAttribute("value");
this.setEmptyValue = this.getAttribute("emptyValue");

// Set context variable
this.setVariable(this.setName,this.getValue(),this.parseTreeNode.params);

// Construct the child widgets
this.makeChildWidgets();
};

/*
Get the value to be assigned
*/
SetWidget.prototype.getValue = function() {
var value = this.setValue;
if(this.setFilter) {
var results = this.wiki.filterTiddlers(this.setFilter,this);
if(!this.setValue) {
value = $tw.utils.stringifyList(results);
}
if(results.length === 0 && this.setEmptyValue !== undefined) {
value = this.setEmptyValue;
}
}
return value;
};

/*
Selectively refreshes the widget if needed. Returns true if the widget or any 
of its children needed re-rendering
*/
SetWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.name || changedAttributes.filter || 
changedAttributes.value || changedAttributes.emptyValue
|| (this.setFilter && this.getValue() != 
this.variables[this.setName].value)) {
this.refreshSelf();
return true;
} else {
return this.refreshChildren(changedTiddlers);   
}
};

exports.setvariable = SetWidget;
exports.set = SetWidget;

})();


On Friday, 18 September 2015 13:15:41 UTC-5, Evan Balster wrote:
>
> Note that the issue with <$set> not refreshing occurs regardless of 
> whether a value/emptyValue condition is used.
>
> On Friday, 18 September 2015 10:00:44 UTC-5, Tobias Beer wrote:
>>
>> Despite the limitations, I have added the example here...
>>
>> Conditional Variable Assignment @ tb5 
>> 
>>
>> Best wishes,
>>
>> — tb
>>
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/76e8eced-16b0-43de-92e8-b9931d852ecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-18 Thread Evan Balster
Note that the issue with <$set> not refreshing occurs regardless of whether 
a value/emptyValue condition is used.

On Friday, 18 September 2015 10:00:44 UTC-5, Tobias Beer wrote:
>
> Despite the limitations, I have added the example here...
>
> Conditional Variable Assignment @ tb5 
> 
>
> Best wishes,
>
> — tb
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/2f00c58a-4cdb-443a-aac3-ceb7f16e7238%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-18 Thread Tobias Beer
Despite the limitations, I have added the example here...

Conditional Variable Assignment 


Best wishes,

— tb

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5a74df92-3db6-4a85-b175-e6fc53a2ccc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-17 Thread Spangenhelm

>
> Unfortunately, it's really hard to make example code for your case, 
> because drafts have a title of "Draft of myMagicTitle", and editing the 
> title of a non-draft tiddler creates duplicates!

 
Well apparently this works in my case (for a tiddler nammed "Test")

<$set name="myVariable" filter="[field:title[Test]]" value="exists" 
emptyValue="do not exist">
<$text text=<>/>


But still have the refresh issue like you do.. maybe i will just try to use 
the "reveal" widget which can work a little like this i think.
While waiting for a solution..

++

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/03c2e50a-6bc5-4014-a29d-87905fdc612b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-16 Thread Spangenhelm
Hi, i am interested in this issue too because i have a problem with 
conditionnal assignement of a variable using the <$set> widget (see below 
the summary)

Conditional Variable Assignment:

This form of the set variable widget chooses one of two specified values 
according to whether a filter evaluates to an empty list. Here's an example 
that sets a variable according to whether the current tiddler is called 
"myMagicTitle":

<$set name="myVariable" filter="[all[current]field:title[myMagicTitle]]" 
value="It's magic" emptyValue="It's not magic">
<$text text=<>/>




This one does not seem to refresh either so whatever you put in the filter 
part the widget display the default value. Strange but it might be simply 
related to your problem..
Also if, as pmario proposed, you do publish it in github's issue please 
don't forget to add the link to it here so we can follow it.

Thank you

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c0dfaa6b-29f0-4d77-b9c2-93cacd05045f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-16 Thread Evan Balster
I posted an issue on github shortly after PMario's remark.

See:  https://github.com/Jermolene/TiddlyWiki5/issues/1937

My work-around for this issue is to either substitute a <$list> widget for
the <$set>, or to enclose the <$set> code in a <$list> widget with a
similar filter and an unused variable, so as to force a refresh whenever
the filter parameter changes.  This sometimes takes some clever hackery
with dummy values and first[]...

Unfortunately, it's really hard to make example code for your case, because
drafts have a title of "Draft of myMagicTitle", and editing the title of a
non-draft tiddler creates duplicates!

Regards,
Evan

On Wed, Sep 16, 2015 at 11:42 AM, Spangenhelm  wrote:

> Hi, i am interested in this issue too because i have a problem with
> conditionnal assignement of a variable using the <$set> widget (see below
> the summary)
>
> Conditional Variable Assignment:
>
> This form of the set variable widget chooses one of two specified values
> according to whether a filter evaluates to an empty list. Here's an example
> that sets a variable according to whether the current tiddler is called
> "myMagicTitle":
>
> <$set name="myVariable" filter="[all[current]field:title[myMagicTitle]]" 
> value="It's magic" emptyValue="It's not magic">
> <$text text=<>/>
> 
>
>
>
> This one does not seem to refresh either so whatever you put in the filter
> part the widget display the default value. Strange but it might be simply
> related to your problem..
> Also if, as pmario proposed, you do publish it in github's issue please
> don't forget to add the link to it here so we can follow it.
>
> Thank you
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/tiddlywiki/uNeLW76wmWM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> tiddlywiki+unsubscr...@googlegroups.com.
> To post to this group, send email to tiddlywiki@googlegroups.com.
> Visit this group at http://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/c0dfaa6b-29f0-4d77-b9c2-93cacd05045f%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAEKipHnMwHS2YyQTzBNGnAAbVHEbD1AzgvdCgR8FY0%2Brto%3DLeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TW5] Bug? <$set> widget with filter does not trigger refresh

2015-09-14 Thread PMario
Hi Evan,

I didn't test the issue, but it may get lost here. please move it to: 
https://github.com/Jermolene/TiddlyWiki5/issues

There is quite some backlog, but it won't be lost.

-mario

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6ee48879-f94a-4691-998e-4fed2fd33b35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.