TagListWidget.prototype.getTiddlerList = function() {
var defaultFilter = "[list["+ this.listtag + "!!" + this.listField + "]is[tiddler]]";
return this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this);//BJ FIXME should not allow user defined filters
};
/*\
title: $:/core/modules/widgets/remove.js
type: application/javascript
module-type: widget
Action widget to remove all references to a tiddler from a specified field.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var RemoveWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
RemoveWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
RemoveWidget.prototype.render = function(parent,nextSibling) {
this.computeAttributes();
this.execute();
};
/*
Compute the internal state of the widget
*/
RemoveWidget.prototype.execute = function() {
this.removeThis = this.getAttribute("remove",this.getVariable("currentTiddler"));
this.removeFromField = this.getAttribute("removeFromField","tags");
this.removeFromField = this.removeFromField.toLowerCase();
var defaultFilter = "[search:" + this.removeFromField + "[" + this.removeThis + "]]";
this.removeFromTiddlers = this.getTiddlerList(this.getAttribute("removeFilter",defaultFilter));
};
RemoveWidget.prototype.getTiddlerList = function(filter) {
return this.wiki.filterTiddlers(filter,this);
};
/*
Refresh the widget by ensuring our attributes are up to date
*/
RemoveWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["remove"] || changedAttributes["removeFromField"] || changedAttributes["removeFilter"]) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};
/*
Create a new string for the field to be "cleaned" of the deleted tiddler
*/
RemoveWidget.prototype.getUpdatedFieldString= function(tiddler) {
var fieldFilter = "[list[" + tiddler + "!!" + this.removeFromField +"]]";
var list = this.getTiddlerList(fieldFilter);
var newList = "";
var self=this;
$tw.utils.each(list,function(title) {
if (title != self.removeThis) {newList = newList + " [[" + title + "]]";}
});
return newList;
};
/*
Invoke the action associated with this widget
*/
RemoveWidget.prototype.invokeAction = function(triggeringWidget,event) {
var self = this;
var value = "";
var appendString="";
if(this.removeFromTiddlers.length > 0) {
$tw.utils.each(self.removeFromTiddlers,function(title, index) {
value = self.getUpdatedFieldString(title);
self.wiki.setText(title,self.removeFromField,undefined,value);
});
}
return true; // Action was invoked
};
exports["remove"] = RemoveWidget;
})();RemoveWidget.prototype.execute = function() {
var defaultFilter;
this.removeThis = this.getAttribute("remove",this.getVariable("currentTiddler"));
this.removeFromField = this.getAttribute("removeFromField","tags");
if (this.removeFromField == "") { this.removeFromTiddlers = ""} else {
var defaultFilter = "[search:" + this.removeFromField + "[" + this.removeThis + "]]";
this.removeFromTiddlers = this.getTiddlerList(this.getAttribute("removeFilter",defaultFilter));
}
};Hi Tobias and BJ,
Thank you both very much for your input. Tobias, that's a great suggestion, but I don't know enough JavaScript to assign variables with comma separations. The way it is now you can use multiple remove widgets, one for each list you want to remove from, for example:
<$remove /> // removes current tiddler from all tag fields
<$remove removeFromField = "list"/> // removes current tiddler from all list fields
Not the most elegant, I know...
BJ, I made some changes to your taglist widget for this specific application. I have many tiddlers that have multiple ordered lists, but I do not necessarily want a unique tag for every ordered list in my program. Although I suppose that each list does have a unique combination of tags, and using that would have probably been a better approach.
Also, I added some things in to restrict what tiddlers can be added to what lists. For example, I do not want users to be able to accidentally drop a Task into a list of Learning Objectives. Since I am using a fair number of nested taglists, this has been helpful.
BJ I absolutely LOVE the taglist widget. It is practically the foundation of my user interface because it makes the program so much more usable. I don't have the time or the expertise to figure this out, unfortunately, but if you have the time, do you have any suggestions for the following -- say I drag a Task tiddler into a list of Tasks in a Lesson tiddler. Both Task and Lesson tiddlers have lists of Objective tiddlers. Can I add the objectives of the Task to the objectives of the Lesson? (I can do this with a button, but it would be awesome if it were automatically done on the drop event.)
I'm using TiddlyWiki to help with lesson planning - I'm a teacher. As part of the program, I have a list of tiddlers that correspond to skills I want students to learn. Each skill has an associated list of tasks that I could use to help teach the skill.
However, if I decide to delete a task, it's title still remains in all the lists. If I create a new task, it might have the same title (e.g. "Task 2") as the deleted task, and then it pops up in a list where I don't want it. I'm using a slightly modified version of BJ's taglist widget. I made this modification:TagListWidget.prototype.getTiddlerList = function() { var defaultFilter = "[list["+ this.listtag + "!!" + this.listField + "]is[tiddler]]"; return this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this);//BJ FIXME should not allow user defined filters };
Somehow, this immediately filters out all deleted tiddlers visually -- the display refreshes, the deleted tiddlers are removed -- but the list still contains the deleted tiddler until I make some other change to the list
How can I make it so that if I delete a tiddler, it is removed from all lists? Btw this also applies to tiddlers that are used as tags.
Thanks,
Patrick
Most of my tiddlers are getting system-generated titles -- Task 1, Content 3, Cue 57, etc. The user can input "titles" but these are stored in the caption field. A title like "offense" or "passing" is likely to come up in several sports so I just let the system take care of the titles and display captions instead.
This is very convenient but say I delete a tiddler titled "Task 8". Let's say that it described an activity that you could do to practice the serve in volleyball, which is what I'm working on now. Now I want to add a task for the spike, but the next task I add will be called "task 8" and if it's not removed from the list of serve tasks, it will show up there where it doesn't belong.
I get that the lists were intended to provide an order for the results of a filter, and that if the new task 8 is not tagged "serve" it won't matter if it's in the serve list or not. But there are other types of tiddlers tagged "serve," so the filter would have to be something like [tag[serve]tag[task]] and this would also require a modification to the taglist widget.
Basically, the extent of my programming experience was c++ in high school. I am trying to force tw into an OOP paradigm because it's what I understand. My "classes" are tasks, content, objectives, etc and some of these classes have arrays of objects of other classes. I repurposed the list concept to make it more like an array, so if a tiddler gets deleted, it should be removed from all arrays.
I appreciate everyone's patience with this as I am not a real programmer and I know that some of my solutions are not the best. Maybe I will post my work on tiddlyspot so you can see the changes I made and how it's being used.
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywikidev/w0R1o32Do2I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
Most of my tiddlers are getting system-generated titles -- Task 1, Content 3, Cue 57, etc. The user can input "titles" but these are stored in the caption field. A title like "offense" or "passing" is likely to come up in several sports so I just let the system take care of the titles and display captions instead.
This is very convenient but say I delete a tiddler titled "Task 8". Let's say that it described an activity that you could do to practice the serve in volleyball, which is what I'm working on now. Now I want to add a task for the spike, but the next task I add will be called "task 8" and if it's not removed from the list of serve tasks, it will show up there where it doesn't belong.
I get that the lists were intended to provide an order for the results of a filter, and that if the new task 8 is not tagged "serve" it won't matter if it's in the serve list or not. But there are other types of tiddlers tagged "serve," so the filter would have to be something like [tag[serve]tag[task]] and this would also require a modification to the taglist widget.
Basically, the extent of my programming experience was c++ in high school. I am trying to force tw into an OOP paradigm because it's what I understand. My "classes" are tasks, content, objectives, etc and some of these classes have arrays of objects of other classes. I repurposed the list concept to make it more like an array, so if a tiddler gets deleted, it should be removed from all arrays.
I appreciate everyone's patience with this as I am not a real programmer and I know that some of my solutions are not the best. Maybe I will post my work on tiddlyspot so you can see the changes I made and how it's being used.
On 26 January 2015 at 00:18, PE Pat <patrick...@gmail.com> wrote:Most of my tiddlers are getting system-generated titles -- Task 1, Content 3, Cue 57, etc. The user can input "titles" but these are stored in the caption field. A title like "offense" or "passing" is likely to come up in several sports so I just let the system take care of the titles and display captions instead.
This is very convenient but say I delete a tiddler titled "Task 8". Let's say that it described an activity that you could do to practice the serve in volleyball, which is what I'm working on now. Now I want to add a task for the spike, but the next task I add will be called "task 8" and if it's not removed from the list of serve tasks, it will show up there where it doesn't belong.I still not getting this (but I have just been on a bus for 10 hours and am a bit groggy) - do you mean it is in a list field when you edit a tiddler, or appears elsewhere?
var defaultFilter = "[list["+ this.listtag + "!!" + this.listField + "]listfield[" + this.listField + "]]";
I get that the lists were intended to provide an order for the results of a filter, and that if the new task 8 is not tagged "serve" it won't matter if it's in the serve list or not. But there are other types of tiddlers tagged "serve," so the filter would have to be something like [tag[serve]tag[task]] and this would also require a modification to the taglist widget.
Basically, the extent of my programming experience was c++ in high school. I am trying to force tw into an OOP paradigm because it's what I understand. My "classes" are tasks, content, objectives, etc and some of these classes have arrays of objects of other classes. I repurposed the list concept to make it more like an array, so if a tiddler gets deleted, it should be removed from all arrays.
I appreciate everyone's patience with this as I am not a real programmer and I know that some of my solutions are not the best. Maybe I will post my work on tiddlyspot so you can see the changes I made and how it's being used.
I don't know if I know any 'real' programmers - maybe they have flat fingers!
To me programming is a skill (like carpentry) - something that can be develop in oneself. The thing that is really interesting (to me at least) is what you make using the skill - you seem to be very creative with yours.
It would be good if you could put something on tiddlyspot for us to have a look and give some feed-back.
On Monday, January 26, 2015 at 9:10:37 PM UTC-5, BJ wrote:On 26 January 2015 at 00:18, PE Pat <patrick...@gmail.com> wrote:Most of my tiddlers are getting system-generated titles -- Task 1, Content 3, Cue 57, etc. The user can input "titles" but these are stored in the caption field. A title like "offense" or "passing" is likely to come up in several sports so I just let the system take care of the titles and display captions instead.
This is very convenient but say I delete a tiddler titled "Task 8". Let's say that it described an activity that you could do to practice the serve in volleyball, which is what I'm working on now. Now I want to add a task for the spike, but the next task I add will be called "task 8" and if it's not removed from the list of serve tasks, it will show up there where it doesn't belong.I still not getting this (but I have just been on a bus for 10 hours and am a bit groggy) - do you mean it is in a list field when you edit a tiddler, or appears elsewhere?I modified the taglist widget so that the filter uses a "listField" instead of a tag to find tiddlers:var defaultFilter = "[list["+ this.listtag + "!!" + this.listField + "]listfield[" + this.listField + "]]";Using the example above, let's say that "Task 8" was originally created and put into the "task" field of the "Content 1" tiddler. In the table of contents, I use the following:<$taglist tag="Content 1" field="tasks">to display all tasks associated with Content 1.Now say I delete Task 8. It is no longer displayed in the table of contents, but it remains in the "task" field of Content 1.Now I hit the "new task button" for Content 2. Its title will be "Task 8" because that is the next available system title for a new tiddler using the template tiddler "Task". It will appear in the table of contents under Content 2 because the "new task button" adds it to the "task" field of Content 2.BUT, it will also reappear under Content 1, because it was never removed from the task field of Content 1. This was indeed what used to happen. This is a problem because it doesn't belong there. It's not a task for Content 1, it's a task for Content 2. I've resolved this problem with the remove widget I posted ealier.
I get that the lists were intended to provide an order for the results of a filter, and that if the new task 8 is not tagged "serve" it won't matter if it's in the serve list or not. But there are other types of tiddlers tagged "serve," so the filter would have to be something like [tag[serve]tag[task]] and this would also require a modification to the taglist widget.
Basically, the extent of my programming experience was c++ in high school. I am trying to force tw into an OOP paradigm because it's what I understand. My "classes" are tasks, content, objectives, etc and some of these classes have arrays of objects of other classes. I repurposed the list concept to make it more like an array, so if a tiddler gets deleted, it should be removed from all arrays.
I appreciate everyone's patience with this as I am not a real programmer and I know that some of my solutions are not the best. Maybe I will post my work on tiddlyspot so you can see the changes I made and how it's being used.
I don't know if I know any 'real' programmers - maybe they have flat fingers!
To me programming is a skill (like carpentry) - something that can be develop in oneself. The thing that is really interesting (to me at least) is what you make using the skill - you seem to be very creative with yours.
It would be good if you could put something on tiddlyspot for us to have a look and give some feed-back.Thanks for the encouragement BJ. I posted what I have right now at pespot.tiddlyspot.com. It is very much a work in progress and there are a lot of simple things that don't work right now because I had to redo the whole thing, but you can see the modifications I made to the taglist widget, as well as some other widgets which I think may be useful outside of this application. One is an "append" widget which adds a list of tiddlers to a tag field or list field of another list of tiddlers, and the other is a "setfieldlist" widget which is the same as the action-setfield widget except it acts on a list of tiddlers rather than just one. You can find links to these in the "Base" tab of the sidebar under "Scripts." They can definitely be improved with some "splice" or "slice" statements but I don't know those too well so I used strings instead.I would love to get some feedback but I can't promise that I will implement anything. I'm in grad school and student teaching and this was supposed to help me save time on my schoolwork by helping me organize information and automate some repetitive parts of the lesson planning process. Instead it has become a massive time suck and I need to be done with it very soon. To be honest it's kind of a mess, kind of a Frankenstein of a program. Nevertheless it's about to work well for what I need at the moment. I will have more time to clean it up this summer, but I will also update it when I am finished for now.
I know enough about programming to know that a lot of the "solutions" I used are not "good practice" in the sense that they are not structured so that they will be broadly and easily reusable. I can take criticism and I know this program has a ton of room for improvement -- a lot of it was done late at night and sometimes when I look back I don't even understand how/why some of it works. At the very least it is an example of an attempt to use Tiddlywiki as a computer programming platform.