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");
17 /* typing save: add {get,set}Value() to all HTML <select> elements */
18 HTMLSelectElement.prototype.getValue = function() {
19 return this.options[this.selectedIndex].value;
21 HTMLSelectElement.prototype.setValue = function(s) {
22 for (var i = 0; i < this.options.length; i++) {
23 if (s == this.options[i].value) {
24 this.selectedIndex = i;
30 function load_sub_grid(id) {
31 if (!pcrud) return; /* first run, onLoad hasn't fired yet */
32 if (!sub_grid._fresh) {
35 "onresponse": function(r) {
36 if (r = openils.Util.readResponse(r)) {
39 new dojo.data.ItemFileReadStore(
40 {"data": ssub.toStoreData([r])}
43 sub_grid._fresh = true;
51 /* TODO: make these formatters caching */
52 function format_bib(bib_id) {
57 fieldmapper.standardRequest(
59 "open-ils.search.biblio.record.mods_slim.retrieve"], {
62 "oncomplete": function(r) {
63 if (r = openils.Util.readResponse(r)) {
66 parts.push(r.title());
68 parts.push(r.author());
70 parts.push(r.publisher());
75 result = parts.join(" / ");
80 return "<a href='" + oilsBasePath + "/serial/list_subscription/" +
81 bib_id + "'>" + result + "</a>";
85 function format_date(s) {
86 return s ? openils.Util.timeStamp(s, {"selector": "date"}) : "";
89 function format_org_unit(aou_id) {
90 return aou_id ? aou.findOrgUnit(aou_id).shortname() : "";
93 function get_sdist(rowIndex, item) {
94 if (!item) return {"id": "", "label": ""};
96 "id": this.grid.store.getValue(item, "id"),
97 "label": this.grid.store.getValue(item, "label")
101 function format_sdist_label(blob) {
102 if (!blob.id) return "";
103 var link = "<a href='" +
104 oilsBasePath + "/serial/list_stream/" + blob.id +
105 "'>" + (blob.label ? blob.label : "[None]") + "</a>" + /* XXX i18n */
106 "<span id='dist_link_" + blob.id + "'></span>";
108 /* XXX kludgy kludge kludge */
109 setTimeout(function() { append_stream_count(blob.id); }, 200);
114 function append_stream_count(dist_id) {
115 var span = dojo.byId("dist_link_" + dist_id);
116 if (span.childNodes.length) /* textNodes count as childnodes */
119 "sstr", {"distribution": dist_id}, {
121 "oncomplete": function(r) {
122 var resp = openils.Util.readResponse(r);
123 var count = resp ? resp.length : 0;
126 span.innerHTML = " " + count + " stream(s)";
132 function open_batch_receive() {
134 alert("Let the interface load all the way first.");
138 var url = "/xul/server/serial/batch_receive.xul?docid=" +
139 sub.record_entry() + "&subid=" + sub.id();
142 openils.XUL.newTabEasy(url, "Batch Receive"); /* XXX i18n */
148 openils.Util.addOnLoad(
150 pcrud = new openils.PermaCrud();
151 load_sub_grid(sub_id);