*/
dojo.declare(
"openils.vandelay.TreeDndSource", dijit._tree.dndSource, {
+ "constructor": function() {
+ /* Given a tree object, there seems to be no way to access its
+ * dndController, which seems to be the only thing that knows
+ * about a tree's selected nodes. So we register instances
+ * in a global variable in order to find them later. :-(
+ */
+ if (!window._tree_dnd_controllers)
+ window._tree_dnd_controllers = [];
+
+ window._tree_dnd_controllers.push(this);
+ },
"checkItemAcceptance": function(target, source, position) {
return (
source._ready && (
dojo.require("openils.PermaCrud");
dojo.require("openils.widget.ProgressDialog");
-var localeStrings;
-var node_editor;
-var _crads;
-var CGI;
+var localeStrings, node_editor, _crads, CGI, tree;
function _find_crad_by_name(name) {
for (var i = 0; i < _crads.length; i++) {
}
}
+function delete_selected_from_tree() {
+ /* relies on the fact that we only have one tree that would have
+ * registered a dnd controller. */
+ _tree_dnd_controllers[0].getSelectedItems().forEach(
+ function(item) {
+ tree.model.store.deleteItem(item);
+ }
+ );
+}
+
/* 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
return results;
}
+function render_match_set_description(match_set) {
+ dojo.byId("vms-name").innerHTML = match_set.name();
+ dojo.byId("vms-owner").innerHTML =
+ aou.findOrgUnit(match_set.owner()).name();
+ dojo.byId("vms-mtype").innerHTML = match_set.mtype();
+}
+
function init_test() {
progress_dialog.show(true);
dojo.requireLocalization("openils.vandelay", "match_set");
localeStrings = dojo.i18n.getLocalization("openils.vandelay", "match_set");
+ pcrud = new openils.PermaCrud();
CGI = new openils.CGI();
+ var match_set = pcrud.retrieve("vms", CGI.param("match_set"));
+ render_match_set_description(match_set);
+
/* 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(
+ _crads = pcrud.retrieveAll(
"crad", {"order_by": {"crad": "label"}}
);
store: store, "query": {"id": "root"}
});
- var src = new dojo.dnd.Source("src_here");
- var tree = new dijit.Tree(
+ var src = new dojo.dnd.Source("src-here");
+ tree = new dijit.Tree(
{
"model": treeModel,
"dndController": openils.vandelay.TreeDndSource,
"dragThreshold": 8,
"betweenThreshold": 5,
"persist": false
- }, "tree_here"
+ }, "tree-here"
);
node_editor = new NodeEditor(src, "node-editor-container");
[% WRAPPER 'default/base.tt2' %]
[% ctx.page_title = 'Vandelay Match Set Editor' %]
<style type="text/css">
- h1 { margin: 0.5em 0; }
+ h1 { margin: 1ex 0; }
.outer { clear: both; }
- #vmsp-buttons button { padding: 0 1.5em; }
- .node-editor { margin-bottom: 2em; }
+ #vmsp-buttons button { margin: 0 0.5em; }
+ #tree-here { margin-bottom: 1.5em; }
+ #vms-table { padding-bottom: 2ex; }
+ #vms-table th { text-align: right; }
+ #vms-table td { padding-left: 1em; }
+ #src-pane { float: left; width: 49%; }
+ #tree-pane { float: right; width: 50%; }
+ .node-editor { margin-bottom: 1.5ex; }
.node-editor td { padding: 0.5ex; }
li { background-color: #ddd; }
</style>
<h1>[% ctx.page_title %]</h1>
+<table id="vms-table">
+ <tbody>
+ <tr>
+ <th>Match set name:</th>
+ <td><strong id="vms-name"></strong></td>
+ </tr>
+ <tr>
+ <th>Owning Library:</th>
+ <td id="vms-owner"></td>
+ </tr>
+ <tr>
+ <th>Type:</th>
+ <td id="vms-mtype"></td>
+ </tr>
+ </tbody>
+</table>
+<hr />
<!-- XXX TODO
give some indication of which match set we're editing the tree for
-->
<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>
+ New
+ <button onclick="node_editor.add('svf');">Single-Value-Field</button>
+ <button onclick="node_editor.add('tag');">MARC Tag and Subfield</button>
+ <button onclick="node_editor.add('bool_op');">Boolean Operator</button>
</div>
</div>
<div class="outer" style="margin-top: 2ex;">
- <div style="float: left; width: 49%">
+ <div id="src-pane">
<div>
<form id="node-editor-container" onsubmit="return false;"></form>
</div>
- <ul id="src_here"></ul>
+ <ul id="src-here"></ul>
</div>
- <div style="float: right; width: 50%">
+ <div id="tree-pane">
<div><big>Your Expression</big></div>
- <div id="tree_here"></div>
+ <div id="tree-here"></div>
+ <button id="deleter" onclick="delete_selected_from_tree()">
+ Deleted Selected Node
+ </button>
</div>
</div>
<div jsId="progress_dialog" dojoType="openils.widget.ProgressDialog"></div>