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) {
36 var dist_ids = pcrud.search(
37 "sdist", {"subscription": id}, {"id_list": true}
41 "onresponse": function(r) {
42 if (r = openils.Util.readResponse(r)) {
44 var data = ssub.toStoreData([r]);
45 data.items[0].num_dist = dist_ids ? dist_ids.length : 0;
47 new dojo.data.ItemFileReadStore({"data": data})
49 sub_grid._fresh = true;
52 "oncomplete": function() {
53 if (oncomplete) oncomplete();
60 /* TODO: make these formatters caching */
61 function format_bib(bib_id) {
66 fieldmapper.standardRequest(
68 "open-ils.search.biblio.record.mods_slim.retrieve"], {
71 "oncomplete": function(r) {
72 if (r = openils.Util.readResponse(r)) {
75 parts.push(r.title());
77 parts.push(r.author());
79 parts.push(r.publisher());
84 result = parts.join(" / ");
89 return "<a href='" + oilsBasePath +
90 "/serial/list_subscription?record_entry=" + bib_id + "'>" +
95 function format_date(s) {
96 return s ? openils.Util.timeStamp(s, {"selector": "date"}) : "";
99 function format_org_unit(aou_id) {
100 return aou_id ? aou.findOrgUnit(aou_id).shortname() : "";
103 function get_sdist(rowIndex, item) {
104 if (!item) return {"id": "", "label": ""};
106 "id": this.grid.store.getValue(item, "id"),
107 "label": this.grid.store.getValue(item, "label")
111 function format_sdist_label(blob) {
112 if (!blob.id) return "";
113 var link = "<a href='" +
114 oilsBasePath + "/serial/list_stream?distribution=" + blob.id +
115 "'>" + (blob.label ? blob.label : "[None]") + "</a>"; /* XXX i18n */
117 var sstr_list = pcrud.search(
118 "sstr",{"distribution":blob.id},{"id_list":true}
120 count = sstr_list ? sstr_list.length : 0;
121 link += " " + count + " stream(s)";
125 function append_stream_count(dist_id) {
126 var span = dojo.byId("dist_link_" + dist_id);
127 if (span.childNodes.length) /* textNodes count as childnodes */
130 "sstr", {"distribution": dist_id}, {
132 "oncomplete": function(r) {
133 var resp = openils.Util.readResponse(r);
134 var count = resp ? resp.length : 0;
137 span.innerHTML = " " + count + " stream(s)";
143 function open_batch_receive() {
145 alert("Let the interface load all the way first.");
149 var url = "/xul/server/serial/batch_receive.xul?docid=" +
150 sub.record_entry() + "&subid=" + sub.id();
153 openils.XUL.newTabEasy(url, "Batch Receive"); /* XXX i18n */
159 openils.Util.addOnLoad(
161 cgi = new openils.CGI();
162 pcrud = new openils.PermaCrud();
164 sub_id = cgi.param("id");
167 (cgi.param("tab") == "distributions") ?
168 function() { tab_container.selectChild(distributions_tab); } :