From a637f7fb60a77b290faa42d8e534424aa149e3c3 Mon Sep 17 00:00:00 2001 From: saqimtiaz Date: Mon, 16 Nov 2020 17:27:46 +0100 Subject: [PATCH 1/2] Modals: add navigator to handle tm-navigate (#5027) * Wrap modal in a navigator widget to allow tm-navigate to work * Move all story list handling to Modal * Make sure any values for story list or history list sent as variables have precedence * Code clean up --- core/modules/utils/dom/modal.js | 40 +++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index df6ef5432..561dbf298 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -13,6 +13,7 @@ Modal message mechanism "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); +var navigator = require("$:/core/modules/widgets/navigator.js"); var Modal = function(wiki) { this.wiki = wiki; @@ -41,7 +42,12 @@ Modal.prototype.display = function(title,options) { return; } // Create the variables - var variables = $tw.utils.extend({currentTiddler: title},options.variables); + var variables = $tw.utils.extend({ + currentTiddler: title, + "tv-story-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-story-list") : ""), + "tv-history-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-history-list") : "") + },options.variables); + // Create the wrapper divs var wrapper = this.srcDocument.createElement("div"), modalBackdrop = this.srcDocument.createElement("div"), @@ -75,6 +81,31 @@ Modal.prototype.display = function(title,options) { modalFooter.appendChild(modalFooterHelp); modalFooter.appendChild(modalFooterButtons); modalWrapper.appendChild(modalFooter); + var navigatorTree = { + "type": "navigator", + "attributes": { + "story": { + "name": "story", + "type": "string", + "value": variables["tv-story-list"] + }, + "history": { + "name": "history", + "type": "string", + "value": variables["tv-history-list"] + } + }, + "tag": "$navigator", + "isBlock": true, + "children": [] + }; + var navigatorWidgetNode = new navigator.navigator(navigatorTree, { + wiki: this.wiki, + document : this.srcDocument, + parentWidget: $tw.rootWidget + }); + navigatorWidgetNode.render(modalBody,null); + // Render the title of the message var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{ field: "subtitle", @@ -86,7 +117,7 @@ Modal.prototype.display = function(title,options) { type: "string", value: title }}}], - parentWidget: $tw.rootWidget, + parentWidget: navigatorWidgetNode, document: this.srcDocument, variables: variables, importPageMacros: true @@ -94,11 +125,12 @@ Modal.prototype.display = function(title,options) { headerWidgetNode.render(headerTitle,null); // Render the body of the message var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{ - parentWidget: $tw.rootWidget, + parentWidget: navigatorWidgetNode, document: this.srcDocument, variables: variables, importPageMacros: true }); + bodyWidgetNode.render(modalBody,null); // Setup the link if present if(options.downloadLink) { @@ -135,7 +167,7 @@ Modal.prototype.display = function(title,options) { value: $tw.language.getString("Buttons/Close/Caption") }}} ]}], - parentWidget: $tw.rootWidget, + parentWidget: navigatorWidgetNode, document: this.srcDocument, variables: variables, importPageMacros: true From ffd6a8cce767a6de6038168a86ceeccc4d9381aa Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Mon, 16 Nov 2020 23:32:28 +0700 Subject: [PATCH 2/2] More documentation for :intersection filter prefix (#5051) --- .../tiddlers/filters/syntax/Filter Expression.tid | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editions/tw5.com/tiddlers/filters/syntax/Filter Expression.tid b/editions/tw5.com/tiddlers/filters/syntax/Filter Expression.tid index 1289e22ad..57de4a9f9 100644 --- a/editions/tw5.com/tiddlers/filters/syntax/Filter Expression.tid +++ b/editions/tw5.com/tiddlers/filters/syntax/Filter Expression.tid @@ -56,3 +56,15 @@ In order to remove `$:/baz` in any case, existing or not, simply use the `+` pre * <$link to="is Operator">`foo bar $:/baz +[!is[system]]` * <$link to="prefix Operator">`foo bar $:/baz +[!prefix[$:/]]` + +There is also a difference between the `:intersection` and `+` prefixes due to varying inputs. + +The `+` prefix should be thought of as an "AND" in formal logic, e.g. "give me all titles that satisfy condition A ''and'' condition B". But it's not suitable for all cases; if condition B uses a filter operator that replaces its input, then it will be difficult to use the `+` prefix. For example, if you wanted to find out what tags two tiddlers have in common, you might try to write a filter expression like: + +* <$link to="tags Operator">`[[field Operator]tags[]] +[[compare Operator]tags[]]` + +But that won't work, because the second filter run will end up throwing away its input and replacing it with an input consisting of the single title `[[compare Operator]]`. So the result you'd get from that filter expression would be just the tags of the `compare Operator` tiddler. + +For cases like this, the `:intersection` prefix is what you need. It takes the filter output so far, //sets it aside// in temporary storage, and starts the next filter run with all tiddler titles as input. Then once the latest filter run has completed, it takes the latest output, compares it to the set-aside output, and produces a new output that contains only titles that appeared in both the set-aside output and the latest output. So to get only the tags that the `field Operator` and `compare Operator` tiddlers have in common, you would write a filter expresison like this: + +* <$link to="tags Operator">`[[field Operator]tags[]] :intersection[[compare Operator]tags[]]`