dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.TextBox");
dojo.require("openils.Util");
- dojo.require("openils.widget.OrgUnitFilteringSelect");
dojo.require("openils.widget.ProgressDialog");
+
+ openils.Util.addOnLoad(
+ function() {
+ progress_dialog.show(true);
+ create_session.populate_saved_searches(dojo.byId("saved-searches"));
+ create_session.prepare_org_selector(dojo.byId("org-selector"));
+ progress_dialog.hide();
+ }
+ );
</script>
<script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/url_verify/create_session.js"></script>
<style type="text/css">
#uv-search { width: 20em; }
+ .note { font-style: italic; background-color: #eee; }
+ #uv-tags-and-subfields { background-color: #ddd; }
+ table.create-session-form th { text-align: right; }
+ table.create-session-form {
+ border-collapse: separate;
+ border-spacing: 0.5ex;
+ }
</style>
<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
<div dojoType="dijit.layout.ContentPane"
<div> [% ctx.page_title %] </div>
<div>
<button dojoType="dijit.form.Button"
- onClick="alert('XXX do something');">[% l('XXX Clone Existing') %]</button>
+ onClick="alert('XXX TODO');">[% l('Clone Existing') %]</button>
</div>
</div>
-<!-- <div class="oils-acq-basic-roomy">
- <label for="org_selector">[% l('Show events at and below') %]:</label>
- <select
- id="org_selector" jsId="org_selector"
- dojoType="openils.widget.OrgUnitFilteringSelect"
- searchAttr="name" labelAttr="name">
- </select>
- </div> -->
<div>
- <table>
+ <table class="create-session-form">
<tr>
<th>
<label for="uv-session-name">[% l("Sesssion name:") %]</label>
<input dojoType="dijit.form.TextBox"
id="uv-session-name" jsId="uv_session_name" />
</td>
+ <td class="note">
+ </td>
</tr>
<tr>
<label for="org-selector">[% l('Search scope:') %]</label>
</th>
<td>
- <select id="org-selector" jsId="org_selector"
- dojoType="openils.widget.OrgUnitFilteringSelect"
- searchAttr="name" labelAttr="name"> </select>
- <span class="note">[% l("This will only be used if your search doesn't contain a hand-entered filter such as site(BR1)") %]</span>
+ <div id="org-selector"></div>
+ </td>
+ <td class="note">
+ [% l("This will only be used if your search doesn't contain a hand-entered filter such as site(BR1)") %]
</td>
</tr>
<input dojoType="dijit.form.TextBox" id="uv-search"
jsId="uv_search" />
</td>
+ <td class="note">
+ </td>
</tr>
- <!-- XXX TODO multiselect from saved searches here -->
+ <tr>
+ <th>
+ <label for="saved-searches">[% l("Saved searches:") %]</label>
+ </th>
+ <td><!-- XXX we're just assuming this list won't grow so
+ large as to be unrepresentable in a multiselect? We
+ could switch to a PCrudAutocompleteBox if needed for
+ constant load time regardless of dataset size. -->
+ <select id="saved-searches" multiple="true" size="6"></select>
+ </td>
+ <td class="note">[% l("Optionally select one or more to combine with 'Search' field above.") %]
+ </td>
+ </tr>
<tr>
<th>
<input dojoType="dijit.form.CheckBox" id="no-url-selection"
jsId="no_url_selection" />
</td>
+ <td class="note">
+ </td>
</tr>
<tr>
<th>
- [% l('Tags and subfields with URLs:') %]
+ [% l('Tags and subfields possibly containing URLs:') %]
</th>
<td>
<div id="uv-tags-and-subfields">
[% l("Tag") %]
<input type="text" size="4" maxlength="3" />
[% l("Subfield(s)") %]
- <input type="text" size="20" />
+ <input type="text" size="15" />
<a href="javascript:create_session.tag_and_subfields.add();">[% l('Add') %]
</div>
</td>
+ <td class="note">
+ </td>
</tr>
</table>
+dojo.require("dojo.data.ItemFileWriteStore");
+dojo.require("dojox.jsonPath");
+
+dojo.require("fieldmapper.OrgUtils");
+dojo.require("openils.PermaCrud");
+dojo.require("openils.widget.FilteringTreeSelect");
+
var create_session = {};
(function() {
create_session.begin = function() {
alert("XXX TODO implement");
- }
+ };
+
+ /* At least in Dojo 1.3.3 (I know, I know), dijit.form.MultiSelect does
+ * not behave like FilteringSelect, like you might thing, and work from a
+ * data store. So we'll use a native <select> control, which will have
+ * fewer moving parts to go haywire anyway.
+ */
+ create_session.populate_saved_searches = function(node) {
+ var list = (new openils.PermaCrud()).retrieveAll(
+ "asq", {"order_by": {"asq": "label"}}
+ );
+
+ dojo.forEach(
+ list,
+ function(o) {
+ dojo.create(
+ "option", {
+ "innerHTML": o.label(),
+ "value": o.id(),
+ "title": o.query_text()
+ }, node, "last"
+ );
+ }
+ );
+ };
+
+ /* set up an all-org-units-in-the-tree selector */
+ create_session.prepare_org_selector = function(node) {
+ var widget = new openils.widget.FilteringTreeSelect(null, node);
+ widget.searchAttr = "name";
+ widget.labelAttr = "name";
+ widget.tree = fieldmapper.aou.globalOrgTree;
+ widget.parentField = 'parent_ou';
+ widget.startup();
+ widget.attr("value", openils.User.user.ws_ou());
+ };
+ /* This is the thing that lets you add/remove rows of tab/subfield pairs */
function TagAndSubfieldsMgr(container_id) {
var self = this;
"innerHTML": "<span class='t-and-s-tag'>" +
newdata.tag +
"</span> \u2021<span class='t-and-s-subfields'>" +
- newdata.subfields + "</span>"
+ newdata.subfields + "</span> "
}, this.container_id, "last"
);
dojo.create(