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 function node_by_name(name, ctx) {
21 return dojo.query("[name='" + name + "']", ctx)[0];
24 /* typing save: add {get,set}Value() to all HTML <select> elements */
25 HTMLSelectElement.prototype.getValue = function() {
26 return this.options[this.selectedIndex].value;
28 HTMLSelectElement.prototype.setValue = function(s) {
29 for (var i = 0; i < this.options.length; i++) {
30 if (s == this.options[i].value) {
31 this.selectedIndex = i;
37 function load_sub_grid(id, oncomplete) {
38 if (!pcrud) return; /* first run, onLoad hasn't fired yet */
39 if (!sub_grid._fresh) {
40 var dist_ids = pcrud.search(
41 "sdist", {"subscription": id}, {"id_list": true}
45 "onresponse": function(r) {
46 if (r = openils.Util.readResponse(r)) {
48 var data = ssub.toStoreData([r]);
49 data.items[0].num_dist = dist_ids ? dist_ids.length : 0;
51 new dojo.data.ItemFileReadStore({"data": data})
53 sub_grid._fresh = true;
56 "oncomplete": function() {
57 if (oncomplete) oncomplete();
64 /* TODO: make these formatters caching */
65 function format_bib(bib_id) {
70 fieldmapper.standardRequest(
72 "open-ils.search.biblio.record.mods_slim.retrieve"], {
75 "oncomplete": function(r) {
76 if (r = openils.Util.readResponse(r)) {
79 parts.push(r.title());
81 parts.push(r.author());
83 parts.push(r.publisher());
88 result = parts.join(" / ");
93 return "<a href='" + oilsBasePath +
94 "/serial/list_subscription?record_entry=" + bib_id + "'>" +
99 function format_date(s) {
100 return s ? openils.Util.timeStamp(s, {"selector": "date"}) : "";
103 function format_org_unit(aou_id) {
104 return aou_id ? aou.findOrgUnit(aou_id).shortname() : "";
107 function get_id_and_label(rowIndex, item) {
108 if (!item) return {"id": "", "label": ""};
110 "id": this.grid.store.getValue(item, "id"),
111 "label": this.grid.store.getValue(item, "label")
115 function format_siss_label(blob) {
116 if (!blob.id) return "";
118 oilsBasePath + "/serial/list_item?issuance=" + blob.id +
119 "'>" + (blob.label ? blob.label : "[None]") + "</a>"; /* XXX i18n */
122 function format_sdist_label(blob) {
123 if (!blob.id) return "";
124 var link = "<a href='" +
125 oilsBasePath + "/serial/list_stream?distribution=" + blob.id +
126 "'>" + (blob.label ? blob.label : "[None]") + "</a>"; /* XXX i18n */
128 var sstr_list = pcrud.search(
129 "sstr",{"distribution":blob.id},{"id_list":true}
131 count = sstr_list ? sstr_list.length : 0;
132 link += " " + count + " stream(s)";
136 function append_stream_count(dist_id) {
137 var span = dojo.byId("dist_link_" + dist_id);
138 if (span.childNodes.length) /* textNodes count as childnodes */
141 "sstr", {"distribution": dist_id}, {
143 "oncomplete": function(r) {
144 var resp = openils.Util.readResponse(r);
145 var count = resp ? resp.length : 0;
148 span.innerHTML = " " + count + " stream(s)";
154 function open_batch_receive() {
156 alert("Let the interface load all the way first.");
160 var url = "/xul/server/serial/batch_receive.xul?docid=" +
161 sub.record_entry() + "&subid=" + sub.id();
164 openils.XUL.newTabEasy(url, "Batch Receive"); /* XXX i18n */
170 openils.Util.addOnLoad(
173 "distributions": distributions_tab,
174 "issuances": issuances_tab
177 cgi = new openils.CGI();
178 pcrud = new openils.PermaCrud();
180 sub_id = cgi.param("id");
183 (cgi.param("tab") in tab_dispatch) ?
185 tab_container.selectChild(
186 tab_dispatch[cgi.param("tab")]