1 dojo.require("dijit.form.Button");
2 dojo.require("dijit.form.RadioButton");
3 dojo.require("dijit.form.FilteringSelect");
4 dojo.require("dijit.form.DropDownButton");
5 dojo.require("dijit.TooltipDialog");
6 dojo.require("dijit.layout.TabContainer");
7 dojo.require("dijit.layout.ContentPane");
8 dojo.require("dojox.grid.DataGrid");
9 dojo.require("openils.widget.AutoGrid");
10 dojo.require("openils.widget.ProgressDialog");
11 dojo.require("openils.widget.HoldingCode");
12 dojo.require("openils.PermaCrud");
13 dojo.require("openils.CGI");
20 /* typing save: add {get,set}Value() to all HTML <select> elements */
21 HTMLSelectElement.prototype.getValue = function() {
22 return this.options[this.selectedIndex].value;
24 HTMLSelectElement.prototype.setValue = function(s) {
25 for (var i = 0; i < this.options.length; i++) {
26 if (s == this.options[i].value) {
27 this.selectedIndex = i;
33 function load_sub_grid(id, oncomplete) {
34 if (!pcrud) return; /* first run, onLoad hasn't fired yet */
35 if (!sub_grid._fresh) {
38 "onresponse": function(r) {
39 if (r = openils.Util.readResponse(r)) {
42 new dojo.data.ItemFileReadStore(
43 {"data": ssub.toStoreData([r])}
46 sub_grid._fresh = true;
49 "oncomplete": function() {
50 if (oncomplete) oncomplete();
57 /* TODO: make these formatters caching */
58 function format_bib(bib_id) {
63 fieldmapper.standardRequest(
65 "open-ils.search.biblio.record.mods_slim.retrieve"], {
68 "oncomplete": function(r) {
69 if (r = openils.Util.readResponse(r)) {
72 parts.push(r.title());
74 parts.push(r.author());
76 parts.push(r.publisher());
81 result = parts.join(" / ");
86 return "<a href='" + oilsBasePath +
87 "/serial/list_subscription?record_entry=" + bib_id + "'>" +
92 function format_date(s) {
93 return s ? openils.Util.timeStamp(s, {"selector": "date"}) : "";
96 function format_org_unit(aou_id) {
97 return aou_id ? aou.findOrgUnit(aou_id).shortname() : "";
100 function get_sdist(rowIndex, item) {
101 if (!item) return {"id": "", "label": ""};
103 "id": this.grid.store.getValue(item, "id"),
104 "label": this.grid.store.getValue(item, "label")
108 function format_sdist_label(blob) {
109 if (!blob.id) return "";
110 var link = "<a href='" +
111 oilsBasePath + "/serial/list_stream?distribution=" + blob.id +
112 "'>" + (blob.label ? blob.label : "[None]") + "</a>" + /* XXX i18n */
113 "<span id='dist_link_" + blob.id + "'></span>";
115 /* XXX kludgy kludge kludge */
116 setTimeout(function() { append_stream_count(blob.id); }, 200);
121 function append_stream_count(dist_id) {
122 var span = dojo.byId("dist_link_" + dist_id);
123 if (span.childNodes.length) /* textNodes count as childnodes */
126 "sstr", {"distribution": dist_id}, {
128 "oncomplete": function(r) {
129 var resp = openils.Util.readResponse(r);
130 var count = resp ? resp.length : 0;
133 span.innerHTML = " " + count + " stream(s)";
139 function open_batch_receive() {
141 alert("Let the interface load all the way first.");
145 var url = "/xul/server/serial/batch_receive.xul?docid=" +
146 sub.record_entry() + "&subid=" + sub.id();
149 openils.XUL.newTabEasy(url, "Batch Receive"); /* XXX i18n */
155 openils.Util.addOnLoad(
157 cgi = new openils.CGI();
158 pcrud = new openils.PermaCrud();
160 sub_id = cgi.param("id");
163 (cgi.param("tab") == "distributions") ?
164 function() { tab_container.selectChild(distributions_tab); } :