a little progress on the match set editor:
authorsenator <lebbeous@esilibrary.com>
Mon, 11 Apr 2011 21:25:25 +0000 (17:25 -0400)
committersenator <lebbeous@esilibrary.com>
Mon, 11 Apr 2011 21:25:25 +0000 (17:25 -0400)
now we can retrieve a tree from the server and use it as the basis of
our dijit.Tree widget. Still work to be done. Can't save anything yet.

Note to self: borrow dojo dnd's "copy" operation (as opposed to move) to
mean replacing a node in the tree, rather than adding to the tree.

Re the permissions I changed, actual users of Evergreen hate having as
much granularity as there was before, and it just confuses people trying
to figure out what perms to give to whom.

Note to self 2: add ADMIN_IMPORT_MATCH_SET to ppl

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Open-ILS/web/js/ui/default/vandelay/match_set.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/vandelay/treetest.js [deleted file]
Open-ILS/web/templates/default/vandelay/match_set.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/vandelay/treetest.tt2 [deleted file]

index ae41a47..b4891d3 100644 (file)
@@ -540,10 +540,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
-                               <create permission="CREATE_IMPORT_MATCH_SET ADMIN_IMPORT_IMPORT_MATCH_SET" context_field="owner"/>
-                               <retrieve permission="CREATE_IMPORT_MATCH_SET UPDATE_IMPORT_MATCH_SET DELETE_IMPORT_MATCH_SET" context_field="owner"/>
-                               <update permission="UPDATE_IMPORT_MATCH_SET" context_field="owner"/>
-                               <delete permission="DELETE_IMPORT_MATCH_SET" context_field="owner"/>
+                               <create permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <retrieve permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <update permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <delete permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
                        </actions>
                </permacrud>
        </class>
@@ -557,6 +557,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Coded Field" name="svf" reporter:datatype="link"/>
                        <field reporter:label="Tag" name="tag" reporter:datatype="text"/>
                        <field reporter:label="Subfield" name="subfield" reporter:datatype="text"/>
+            <field reporter:label="Negate" name="negate"  reporter:datatype="bool"/>
                        <field reporter:label="Importance" name="quality" reporter:datatype="int"/>
                        <field reporter:label="Expression Tree Children" name="children" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
@@ -568,16 +569,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
-                               <create permission="CREATE_IMPORT_MATCH_SET ADMIN_IMPORT_IMPORT_MATCH_SET">
+                               <create permission="ADMIN_IMPORT_MATCH_SET">
                     <context link="match_set" field="owner"/>
                                </create>
-                               <retrieve permission="CREATE_IMPORT_MATCH_SET UPDATE_IMPORT_MATCH_SET DELETE_IMPORT_MATCH_SET">
+                               <retrieve permission="ADMIN_IMPORT_MATCH_SET">
                     <context link="match_set" field="owner"/>
                                </retrieve>
-                               <update permission="UPDATE_IMPORT_MATCH_SET">
+                               <update permission="ADMIN_IMPORT_MATCH_SET">
                     <context link="match_set" field="owner"/>
                                </update>
-                               <delete permission="DELETE_IMPORT_MATCH_SET">
+                               <delete permission="ADMIN_IMPORT_MATCH_SET">
                     <context link="match_set" field="owner"/>
                                </delete>
                        </actions>
@@ -599,10 +600,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
-                               <create permission="CREATE_IMPORT_MATCH_SET ADMIN_IMPORT_IMPORT_MATCH_SET" context_field="owner"/>
-                               <retrieve permission="CREATE_IMPORT_MATCH_SET UPDATE_IMPORT_MATCH_SET DELETE_IMPORT_MATCH_SET" context_field="owner"/>
-                               <update permission="UPDATE_IMPORT_MATCH_SET" context_field="owner"/>
-                               <delete permission="DELETE_IMPORT_MATCH_SET" context_field="owner"/>
+                               <create permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <retrieve permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <update permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
+                               <delete permission="ADMIN_IMPORT_MATCH_SET" context_field="owner"/>
                        </actions>
                </permacrud>
        </class>
index ca6963c..024be08 100644 (file)
@@ -1108,23 +1108,32 @@ sub respond_with_status {
 }
 
 __PACKAGE__->register_method(  
-    api_name    => "open-ils.vandelay.match_set_point.get_tree",
-    method      => "match_set_point_get_tree",
+    api_name    => "open-ils.vandelay.match_set.get_tree",
+    method      => "match_set_get_tree",
     api_level   => 1,
     argc        => 1
 );
 
-sub match_set_point_get_tree {
-    my ($self, $conn, $parent_id) = @_;
+sub match_set_get_tree {
+    my ($self, $conn, $authtoken, $match_set_id) = @_;
 
-    $parent_id = int($parent_id) or return;
+    $match_set_id = int($match_set_id) or return;
 
-    my $tree = new_editor->search_vandelay_match_set_point([
-        {"parent" => $parent_id},
-        {"flesh" => -1, "flesh_fields" => ["children"]}
+    my $e = new_editor("authtoken" => $authtoken);
+    $e->checkauth or return $e->die_event;
+
+    my $set = $e->retrieve_vandelay_match_set($match_set_id) or
+        return $e->die_event;
+
+    $e->allowed("ADMIN_IMPORT_MATCH_SET", $set->owner) or
+        return $e->die_event;
+
+    my $tree = $e->search_vandelay_match_set_point([
+        {"match_set" => $match_set_id, "parent" => undef},
+        {"flesh" => -1, "flesh_fields" => {"vmsp" => ["children"]}}
     ]) or return $e->die_event;
 
-    return $tree;
+    return pop @$tree;
 }
 
 
index 804d8ad..9bfd413 100644 (file)
@@ -23,6 +23,7 @@ CREATE TABLE vandelay.match_set_point (
     svf         TEXT    REFERENCES config.record_attr_definition (name),
     tag         TEXT,
     subfield    TEXT,
+    negate      BOOL    DEFAULT FALSE,
     quality     INT     NOT NULL DEFAULT 1, -- higher is better
     CONSTRAINT vmsp_need_a_subfield_with_a_tag CHECK ((tag IS NOT NULL AND subfield IS NOT NULL) OR tag IS NULL),
     CONSTRAINT vmsp_need_a_tag_or_a_ff_or_a_bo CHECK (
diff --git a/Open-ILS/web/js/ui/default/vandelay/match_set.js b/Open-ILS/web/js/ui/default/vandelay/match_set.js
new file mode 100644 (file)
index 0000000..1e51b1a
--- /dev/null
@@ -0,0 +1,355 @@
+dojo.require("dojo.data.ItemFileWriteStore");
+dojo.require("dijit.Tree");
+dojo.require("dijit.form.Button");
+dojo.require("dojo.dnd.Source");
+dojo.require("dijit._tree.dndSource");
+//dojo.require("openils.vandelay.TreeDndSource");
+dojo.require("openils.vandelay.TreeStoreModel");
+dojo.require("openils.CGI");
+dojo.require("openils.User");
+dojo.require("openils.Util");
+dojo.require("openils.PermaCrud");
+dojo.require("openils.widget.ProgressDialog");
+
+var node_editor;
+var _crads;
+var CGI;
+
+function _find_crad_by_name(name) {
+    for (var i = 0; i < _crads.length; i++) {
+        if (_crads[i].name() == name)
+            return _crads[i];
+    }
+    return null;
+}
+
+function NodeEditor() {
+    var self = this;
+
+    var _svf_select_template = null;
+    var _factories_by_type = {
+        "svf": function() {
+            if (!_svf_select_template) {
+                _svf_select_template = dojo.create(
+                    "select", {"fmfield": "svf"}
+                );
+                for (var i=0; i<_crads.length; i++) {
+                    dojo.create(
+                        "option", {
+                            "value": _crads[i].name(),
+                            "innerHTML": _crads[i].label()
+                        }, _svf_select_template
+                    );
+                }
+            }
+
+            var select = dojo.clone(_svf_select_template);
+            dojo.attr(select, "id", "svf-select");
+            var label = dojo.create(
+                "label", {
+                    "for": "svf-select", "innerHTML": "Single-Value-Field:"
+                }
+            );
+
+            var tr = dojo.create("tr");
+            dojo.place(label, dojo.create("td", null, tr));
+            dojo.place(select, dojo.create("td", null, tr));
+
+            return [tr];
+        },
+        "tag": function() {
+            var rows = [dojo.create("tr"), dojo.create("tr")];
+            dojo.create(
+                "label", {
+                    "for": "tag-input", "innerHTML": "Tag:"
+                }, dojo.create("td", null, rows[0])
+            );
+            dojo.create(
+                "input", {
+                    "id": "tag-input",
+                    "type": "text",
+                    "size": 4,
+                    "maxlength": 3,
+                    "fmfield": "tag"
+                }, dojo.create("td", null, rows[0])
+            );
+            dojo.create(
+                "label", {
+                    "for": "subfield-input", "innerHTML": "Subfield: \u2021"
+                }, dojo.create("td", null, rows[1])
+            );
+            dojo.create(
+                "input", {
+                    "id": "subfield-input",
+                    "type": "text",
+                    "size": 2,
+                    "maxlength": 1,
+                    "fmfield": "subfield"
+                }, dojo.create("td", null, rows[1])
+            );
+            return rows;
+        },
+        "bool_op": function() {
+            var tr = dojo.create("tr");
+            dojo.create(
+                "label",
+                {"for": "operator-select", "innerHTML": "Operator:"},
+                dojo.create("td", null, tr)
+            );
+            var select = dojo.create(
+                "select", {"fmfield": "bool_op", "id": "operator-select"},
+                dojo.create("td", null, tr)
+            );
+            dojo.create("option", {"value": "AND", "innerHTML": "AND"}, select);
+            dojo.create("option", {"value": "OR", "innerHTML": "OR"}, select);
+
+            return [tr];
+        }
+    };
+
+    function _simple_value_getter(control) {
+        if (typeof control.selectedIndex != "undefined")
+            return control.options[control.selectedIndex].value;
+        else if (dojo.attr(control, "type") == "checkbox")
+            return control.checked;
+        else
+            return control.value;
+    };
+
+    this._init = function(dnd_source, node_editor_container) {
+        this.dnd_source = dnd_source;
+        this.node_editor_container = dojo.byId(node_editor_container);
+    };
+
+    this.clear = function() {
+        this.dnd_source.selectAll().deleteSelectedNodes();
+        dojo.empty(this.node_editor_container);
+    };
+
+    this.update_draggable = function(draggable) {
+        var s = "";
+        draggable.data = {"match_point": new vmsp()};
+        var had_op = false;
+        dojo.query("[fmfield]", this.node_editor_container).forEach(
+            function(control) {
+                var used_svf = null;
+                var field = dojo.attr(control, "fmfield");
+                var value = _simple_value_getter(control);
+                draggable.data.match_point[field](value);
+
+                if (field == "subfield")
+                    s += " \u2021";
+                if (field == "svf")
+                    used_svf = value;
+                if (field == "quality")
+                    return;
+                if (field == "bool_op")
+                    had_op = true;
+                if (field == "negate") {
+                    if (value) {
+                        if (had_op)
+                            s = "<strong>N</strong>" + s;
+                        else
+                            s = "<strong>NOT</strong> " + s;
+                    }
+                } else {
+                    s += value;
+                }
+
+                if (used_svf !== null) {
+                    var our_crad = _find_crad_by_name(used_svf);
+                    /* XXX i18n, use fmtted strings */
+                    s += " / " + our_crad.label() + "<br /><em>" +
+                        (our_crad.description() || "") + "</em><br />";
+                }
+            }
+        );
+        dojo.attr(draggable, "innerHTML", s);
+    };
+
+    this._add_consistent_controls = function(tgt) {
+        if (!this._consistent_controls) {
+            var trs = dojo.query("[consistent-controls]");
+            this._consistent_controls = [];
+            for (var i = 0; i < trs.length; i++)
+                this._consistent_controls[i] = dojo.clone(trs[i]);
+            dojo.empty(trs[0].parentNode);
+        }
+
+        this._consistent_controls.forEach(
+            function(node) { dojo.place(dojo.clone(node), tgt); }
+        );
+    };
+
+    this.add = function(type) {
+        this.clear();
+
+        /* a representation, not the editing widgets, but will also carry
+         * the fieldmapper object when dragged to the tree */
+        var draggable = dojo.create(
+            "li", {
+                "innerHTML": "Define your match point and drag me<br/>" +
+                    "to the tree on the right"
+            }
+        );
+
+        /* these are the editing widgets */
+        var table = dojo.create("table", {"className": "node-editor"});
+
+        var nodes = _factories_by_type[type]();
+        for (var i = 0; i < nodes.length; i++) dojo.place(nodes[i], table);
+
+        this._add_consistent_controls(table);
+
+        dojo.create(
+            "input", {
+                "type": "submit", "value": "Ok",
+                "onclick": function() { self.update_draggable(draggable); }
+            }, dojo.create(
+                "td", {"colspan": 2, "align": "center"},
+                dojo.create("tr", null, table)
+            )
+        );
+
+        dojo.place(table, this.node_editor_container, "only");
+        /* XXX around here attach other data structures to the node */
+        this.dnd_source.insertNodes(false, [draggable]);
+    };
+
+    this._init.apply(this, arguments);
+}
+
+/* XXX replace later with code that will suit this function's purpose
+ * as well as that of update_draggable. */
+function display_name_from_point(point) {
+    /* quick and dirty */
+    if (point.bool_op()) {
+        return (point.negate() == "t" ? "N" : "") + point.bool_op();
+    } else if (point.svf()) {
+        return (point.negate() == "t" ? "NOT " : "") + point.svf();
+    } else {
+        return (point.negate() == "t" ? "NOT " : "") + point.tag() +
+            "\u2021" + point.subfield();
+    }
+}
+
+/* dojoize_match_set_tree() takes an argument, "point", that is actually a
+ * vmsp fieldmapper object with descendants fleshed hierarchically. It turns
+ * that into a syntactically flat array but preserving the hierarchy
+ * semantically in the language used by dojo data stores, i.e.,
+ *
+ * [
+ *  {'id': 'root', children:[{'_reference': '0'}, {'_reference': '1'}]},
+ *  {'id': '0', children:[]},
+ *  {'id': '1', children:[]}
+ * ],
+ *
+ */
+function dojoize_match_set_tree(point, refgen) {
+    /* XXX TODO test with deeper trees! */
+    var root = false;
+    if (!refgen) {
+        refgen = 0;
+        root = true;
+    }
+
+    var bathwater = point.children();
+    point.children([]);
+    var item = {
+        "id": (root ? "root" : refgen),
+        "name": display_name_from_point(point),
+        "match_point": point.clone(),
+        "children": []
+    };
+    point.children(bathwater);
+
+    var results = [item];
+
+    if (point.children()) {
+        for (var i = 0; i < point.children().length; i++) {
+            var child = point.children()[i];
+            item.children.push({"_reference": ++refgen});
+            results = results.concat(
+                dojoize_match_set_tree(child, refgen)
+            );
+        }
+    }
+
+    return results;
+}
+
+function init_test() {
+    progress_dialog.show(true);
+
+    CGI = new openils.CGI();
+
+    /* XXX No-one should have hundreds of these or anything, but theoretically
+     * this could be problematic with a big enough list of crad objects. */
+    _crads = new openils.PermaCrud().retrieveAll(
+        "crad", {"order_by": {"crad": "label"}}
+    );
+
+    var match_set_tree = fieldmapper.standardRequest(
+        ["open-ils.vandelay", "open-ils.vandelay.match_set.get_tree"],
+        [openils.User.authtoken, CGI.param("match_set")]
+    );
+
+//        {
+//            "identifier": "id", "label": "name", "items": [
+//                {
+//                    "id": "root", "name": "AND",
+//                    "children": [
+//                        {"_reference": "leaf0"}, {"_reference": "leaf1"}
+//                    ]
+//                },
+//                {"id": "leaf0", "name": "nonsense test"},
+//                {"id": "leaf1", "name": "more nonsense"}
+//            ]
+//        }
+
+    var store = new dojo.data.ItemFileWriteStore({
+        "data": {
+            "identifier": "id",
+            "label": "name",
+            "items": dojoize_match_set_tree(match_set_tree)
+        }
+    });
+
+    var treeModel = new openils.vandelay.TreeStoreModel({
+        store: store, "query": {"id": "root"}
+    });
+
+    var tree = new dijit.Tree(
+        {
+            "model": treeModel,
+            "dndController": dijit._tree.dndSource,
+            "dragThreshold": 8,
+            "betweenThreshold": 5,
+            "persist": false
+        }, "treeOne"
+    );
+
+    node_editor = new NodeEditor(mysrc, "node-editor-container");
+
+    dojo.connect(
+        mysrc, "onDndDrop", null,
+        function(source, nodes, copy, target) {
+            if (source == this) {
+                var model = target.tree.model;
+                model.getRoot(
+                    function(root) {
+                        model.getSimpleTree(
+                            root, function(results) { alert(js2JSON(results)); }
+                        );
+                    }
+                );
+                node_editor.clear();  /* because otherwise this acts like a copy! */
+            } else {
+                alert("XXX [mysrc] nodes length is " + nodes.length); /* XXX DEBUG */
+            }
+        }
+    );
+    progress_dialog.hide();
+}
+
+openils.Util.addOnLoad(init_test);
diff --git a/Open-ILS/web/js/ui/default/vandelay/treetest.js b/Open-ILS/web/js/ui/default/vandelay/treetest.js
deleted file mode 100644 (file)
index 4d4b7b2..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-dojo.require("dojo.data.ItemFileWriteStore");
-dojo.require("dijit.Tree");
-dojo.require("dijit.form.Button");
-dojo.require("dojo.dnd.Source");
-dojo.require("dijit._tree.dndSource");
-//dojo.require("openils.vandelay.TreeDndSource");
-dojo.require("openils.vandelay.TreeStoreModel");
-dojo.require("openils.User");
-dojo.require("openils.Util");
-dojo.require("openils.PermaCrud");
-dojo.require("openils.widget.ProgressDialog");
-
-var node_editor;
-var _crads;
-
-function _find_crad_by_name(name) {
-    for (var i = 0; i < _crads.length; i++) {
-        if (_crads[i].name() == name)
-            return _crads[i];
-    }
-    return null;
-}
-
-function NodeEditor() {
-    var self = this;
-
-    var _svf_select_template = null;
-    var _factories_by_type = {
-        "svf": function() {
-            if (!_svf_select_template) {
-                _svf_select_template = dojo.create(
-                    "select", {"fmfield": "svf"}
-                );
-                for (var i=0; i<_crads.length; i++) {
-                    dojo.create(
-                        "option", {
-                            "value": _crads[i].name(),
-                            "innerHTML": _crads[i].label()
-                        }, _svf_select_template
-                    );
-                }
-            }
-
-            var select = dojo.clone(_svf_select_template);
-            dojo.attr(select, "id", "svf-select");
-            var label = dojo.create(
-                "label", {
-                    "for": "svf-select", "innerHTML": "Single-Value-Field:"
-                }
-            );
-
-            var tr = dojo.create("tr");
-            dojo.place(label, dojo.create("td", null, tr));
-            dojo.place(select, dojo.create("td", null, tr));
-
-            return [tr];
-        },
-        "tag": function() {
-            var rows = [dojo.create("tr"), dojo.create("tr")];
-            dojo.create(
-                "label", {
-                    "for": "tag-input", "innerHTML": "Tag:"
-                }, dojo.create("td", null, rows[0])
-            );
-            dojo.create(
-                "input", {
-                    "id": "tag-input",
-                    "type": "text",
-                    "size": 4,
-                    "maxlength": 3,
-                    "fmfield": "tag"
-                }, dojo.create("td", null, rows[0])
-            );
-            dojo.create(
-                "label", {
-                    "for": "subfield-input", "innerHTML": "Subfield: \u2021"
-                }, dojo.create("td", null, rows[1])
-            );
-            dojo.create(
-                "input", {
-                    "id": "subfield-input",
-                    "type": "text",
-                    "size": 2,
-                    "maxlength": 1,
-                    "fmfield": "subfield"
-                }, dojo.create("td", null, rows[1])
-            );
-            return rows;
-        },
-        "bool_op": function() {
-            var tr = dojo.create("tr");
-            dojo.create(
-                "label",
-                {"for": "operator-select", "innerHTML": "Operator:"},
-                dojo.create("td", null, tr)
-            );
-            var select = dojo.create(
-                "select", {"fmfield": "bool_op", "id": "operator-select"},
-                dojo.create("td", null, tr)
-            );
-            dojo.create("option", {"value": "AND", "innerHTML": "AND"}, select);
-            dojo.create("option", {"value": "OR", "innerHTML": "OR"}, select);
-
-            return [tr];
-        }
-    };
-
-    function _simple_value_getter(control) {
-        if (typeof control.selectedIndex != "undefined")
-            return control.options[control.selectedIndex].value;
-        else if (dojo.attr(control, "type") == "checkbox")
-            return control.checked;
-        else
-            return control.value;
-    };
-
-    this._init = function(dnd_source, node_editor_container) {
-        this.dnd_source = dnd_source;
-        this.node_editor_container = dojo.byId(node_editor_container);
-    };
-
-    this.clear = function() {
-        this.dnd_source.selectAll().deleteSelectedNodes();
-        dojo.empty(this.node_editor_container);
-    };
-
-    this.update_draggable = function(draggable) {
-        var s = "";
-//        draggable.data = {"match_point": new vmsp()};
-        var had_op = false;
-        dojo.query("[fmfield]", this.node_editor_container).forEach(
-            function(control) {
-                var used_svf = null;
-                var field = dojo.attr(control, "fmfield");
-                var value = _simple_value_getter(control);
-//                draggable.data.match_point[field](value);
-
-                if (field == "subfield")
-                    s += " \u2021";
-                if (field == "svf")
-                    used_svf = value;
-                if (field == "quality")
-                    return;
-                if (field == "bool_op")
-                    had_op = true;
-                if (field == "negate") {
-                    if (value) {
-                        if (had_op)
-                            s = "<strong>N</strong>" + s;
-                        else
-                            s = "<strong>NOT</strong> " + s;
-                    }
-                } else {
-                    s += value;
-                }
-
-                if (used_svf !== null) {
-                    var our_crad = _find_crad_by_name(used_svf);
-                    /* XXX i18n, use fmtted strings */
-                    s += " / " + our_crad.label() + "<br /><em>" +
-                        (our_crad.description() || "") + "</em><br />";
-                }
-            }
-        );
-        dojo.attr(draggable, "innerHTML", s);
-    };
-
-    this._add_consistent_controls = function(tgt) {
-        if (!this._consistent_controls) {
-            var trs = dojo.query("[consistent-controls]");
-            this._consistent_controls = [];
-            for (var i = 0; i < trs.length; i++)
-                this._consistent_controls[i] = dojo.clone(trs[i]);
-            dojo.empty(trs[0].parentNode);
-        }
-
-        this._consistent_controls.forEach(
-            function(node) { dojo.place(dojo.clone(node), tgt); }
-        );
-    };
-
-    this.add = function(type) {
-        this.clear();
-
-        /* a representation, not the editing widgets, but will also carry
-         * the fieldmapper object when dragged to the tree */
-        var draggable = dojo.create(
-            "li", {
-                "innerHTML": "Define your match point and drag me<br/>" +
-                    "to the tree on the right"
-            }
-        );
-
-        /* these are the editing widgets */
-        var table = dojo.create("table", {"className": "node-editor"});
-
-        var nodes = _factories_by_type[type]();
-        for (var i = 0; i < nodes.length; i++) dojo.place(nodes[i], table);
-
-        this._add_consistent_controls(table);
-
-        dojo.create(
-            "input", {
-                "type": "submit", "value": "Ok",
-                "onclick": function() { self.update_draggable(draggable); }
-            }, dojo.create(
-                "td", {"colspan": 2, "align": "center"},
-                dojo.create("tr", null, table)
-            )
-        );
-
-        dojo.place(table, this.node_editor_container, "only");
-        /* XXX around here attach other data structures to the node */
-        this.dnd_source.insertNodes(false, [draggable]);
-    };
-
-    this._init.apply(this, arguments);
-}
-
-function init_test() {
-    progress_dialog.show(true);
-
-    /* XXX No-one should have hundreds of these or anything, but theoretically
-     * this could be problematic with a big enough list of crad objects. */
-    _crads = new openils.PermaCrud().retrieveAll(
-        "crad", {"order_by": {"crad": "label"}}
-    );
-
-    var store = new dojo.data.ItemFileWriteStore({
-        "data": {
-            "identifier": "id", "label": "name", "items": [
-                {
-                    "id": "root", "name": "AND",
-                    "children": [
-                        {"_reference": "leaf0"}, {"_reference": "leaf1"}
-                    ]
-                },
-                {"id": "leaf0", "name": "nonsense test"},
-                {"id": "leaf1", "name": "more nonsense"}
-            ]
-        }
-    });
-
-    var treeModel = new openils.vandelay.TreeStoreModel({
-        store: store, "query": {"id": "root"}
-    });
-
-    var tree = new dijit.Tree(
-        {
-            "model": treeModel,
-            "dndController": dijit._tree.dndSource,
-            "dragThreshold": 8,
-            "betweenThreshold": 5,
-            "persist": false
-        }, "treeOne"
-    );
-
-    node_editor = new NodeEditor(mysrc, "node-editor-container");
-
-    dojo.connect(
-        mysrc, "onDndDrop", null,
-        function(source, nodes, copy, target) {
-            if (source == this) {
-                var model = target.tree.model;
-                model.getRoot(
-                    function(root) {
-                        model.getSimpleTree(
-                            root, function(results) { alert(js2JSON(results)); }
-                        );
-                    }
-                );
-                node_editor.clear();  /* because otherwise this acts like a copy! */
-            } else {
-                alert("XXX [mysrc] nodes length is " + nodes.length); /* XXX DEBUG */
-            }
-        }
-    );
-    progress_dialog.hide();
-}
-
-openils.Util.addOnLoad(init_test);
diff --git a/Open-ILS/web/templates/default/vandelay/match_set.tt2 b/Open-ILS/web/templates/default/vandelay/match_set.tt2
new file mode 100644 (file)
index 0000000..7883cf4
--- /dev/null
@@ -0,0 +1,59 @@
+[% WRAPPER 'default/base.tt2' %]
+[% ctx.page_title = 'Vandelay Match Set' %]
+<style type="text/css">
+    h1 { margin: 0.5em 0; }
+    .outer { clear: both; }
+    #vmsp-buttons button { padding: 0 1.5em; }
+    .node-editor { margin-bottom: 2em; }
+    .node-editor td { padding: 0.5ex; }
+    li { background-color: #ddd; }
+</style>
+<h1>[% ctx.page_title %]</h1>
+<table class="hidden">
+    <tr consistent-controls="1">
+        <td>
+            <label for="quality-input"
+                title="A relative number representing the impact of this expression on the quality of the overall record match"><!-- XXX tooltipize -->
+                Quality:
+            </label>
+        </td>
+        <td>
+            <input id="quality-input" type="text" value="1"
+                size="4" maxlength="3" fmfield="quality" />
+        </td>
+    </tr>
+    <tr consistent-controls="1">
+        <td>
+            <label for="negate-input">Negate?</label>
+        </td>
+        <td>
+            <input id="negate-input" type="checkbox" fmfield="negate" />
+        </td>
+    </tr>
+</table>
+<div class="outer">
+    <div><!-- XXX TODO: consider a read-only display here of the query as built
+        so far from the treet --></div>
+    <div id="vmsp-buttons">
+        <button onclick="node_editor.add('svf');">New Single-Value-Field</button>
+        <button onclick="node_editor.add('tag');">New MARC Tag and Subfield</button>
+        <button onclick="node_editor.add('bool_op');">New Boolean Operator</button>
+    </div>
+</div>
+<div class="outer" style="margin-top: 2ex;">
+    <div style="float: left; width: 49%">
+        <div>
+            <form id="node-editor-container" onsubmit="return false;"></form>
+        </div>
+        <ul dojoType="dojo.dnd.Source" jsId="mysrc"></ul>
+    </div>
+
+    <div style="float: right; width: 50%">
+        <div><big>Your Expression</big></div>
+        <div id="treeOne"></div>
+    </div>
+</div>
+<div jsId="progress_dialog" dojoType="openils.widget.ProgressDialog"></div>
+<script type="text/javascript"
+    src="[% ctx.media_prefix %]/js/ui/default/vandelay/match_set.js"></script>
+[% END %]
diff --git a/Open-ILS/web/templates/default/vandelay/treetest.tt2 b/Open-ILS/web/templates/default/vandelay/treetest.tt2
deleted file mode 100644 (file)
index 32e72c9..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-[% WRAPPER 'default/base.tt2' %]
-[% ctx.page_title = 'Vandelay Match Set Points' %]
-<style type="text/css">
-    .outer { clear: both; }
-    #vmsp-buttons button { padding: 0 1.5em; }
-    .node-editor { margin-bottom: 2em; }
-    .node-editor td { padding: 0.5ex; }
-    label[title] { border-bottom: 1px dashed #666; }
-    li { background-color: #ddd; }
-</style>
-<h1>[% ctx.page_title %]</h1>
-<table class="hidden">
-    <tr consistent-controls="1">
-        <td>
-            <label for="quality-input"
-                title="A relative number representing the impact of this expression on the quality of the overall record match">
-                Quality:
-            </label>
-        </td>
-        <td>
-            <input id="quality-input" type="text" value="1"
-                size="4" maxlength="3" fmfield="quality" />
-        </td>
-    </tr>
-    <tr consistent-controls="1">
-        <td>
-            <label for="negate-input">Negate?</label>
-        </td>
-        <td>
-            <input id="negate-input" type="checkbox" fmfield="negate" />
-        </td>
-    </tr>
-</table>
-<div class="outer">
-    <div><!-- XXX TODO: consider a read-only display here of the query as built
-        so far from the treet --></div>
-    <div id="vmsp-buttons">
-        <button onclick="node_editor.add('svf');">New Single-Value-Field</button>
-        <button onclick="node_editor.add('tag');">New MARC Tag and Subfield</button>
-        <button onclick="node_editor.add('bool_op');">New Boolean Operator</button>
-    </div>
-</div>
-<div class="outer" style="margin-top: 2ex;">
-    <div style="float: left; width: 49%">
-        <div>
-            <form id="node-editor-container" onsubmit="return false;"></form>
-        </div>
-        <ul dojoType="dojo.dnd.Source" jsId="mysrc"></ul>
-    </div>
-
-    <div style="float: right; width: 50%">
-        <div><big>Your Expression</big></div>
-        <div id="treeOne"></div>
-    </div>
-</div>
-<div jsId="progress_dialog" dojoType="openils.widget.ProgressDialog"></div>
-<script type="text/javascript"
-    src="[% ctx.media_prefix %]/js/ui/default/vandelay/treetest.js"></script>
-[% END %]