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.PermaCrud");
16 /* typing save: add {get,set}Value() to all HTML <select> elements */
17 HTMLSelectElement.prototype.getValue = function() {
18 return this.options[this.selectedIndex].value;
20 HTMLSelectElement.prototype.setValue = function(s) {
21 for (var i = 0; i < this.options.length; i++) {
22 if (s == this.options[i].value) {
23 this.selectedIndex = i;
29 function load_sub_grid(id) {
30 if (!pcrud) return; /* first run, onLoad hasn't fired yet */
31 if (!sub_grid._fresh) {
34 "onresponse": function(r) {
35 if (r = openils.Util.readResponse(r)) {
38 new dojo.data.ItemFileReadStore(
39 {"data": ssub.toStoreData([r])}
42 sub_grid._fresh = true;
50 /* TODO: make these formatters caching */
51 function format_bib(bib_id) {
56 fieldmapper.standardRequest(
58 "open-ils.search.biblio.record.mods_slim.retrieve"], {
61 "oncomplete": function(r) {
62 if (r = openils.Util.readResponse(r)) {
65 parts.push(r.title());
67 parts.push(r.author());
69 parts.push(r.publisher());
74 result = parts.join(" / ");
79 return "<a href='" + oilsBasePath + "/serial/list_subscription/" +
80 bib_id + "'>" + result + "</a>";
84 function format_date(s) {
85 return s ? openils.Util.timeStamp(s, {"selector": "date"}) : "";
88 function format_org_unit(aou_id) {
89 return aou_id ? aou.findOrgUnit(aou_id).shortname() : "";
92 function get_sdist(rowIndex, item) {
93 if (!item) return {"id": "", "label": ""};
95 "id": this.grid.store.getValue(item, "id"),
96 "label": this.grid.store.getValue(item, "label")
100 function format_sdist_label(blob) {
101 if (!blob.id) return "";
102 var link = "<a href='" +
103 oilsBasePath + "/serial/list_stream/" + blob.id +
104 "'>" + (blob.label ? blob.label : "[None]") + "</a>" + /* XXX i18n */
105 "<span id='dist_link_" + blob.id + "'></span>";
107 /* XXX kludgy kludge kludge */
108 setTimeout(function() { append_stream_count(blob.id); }, 200);
113 function append_stream_count(dist_id) {
114 var span = dojo.byId("dist_link_" + dist_id);
115 if (span.childNodes.length) /* textNodes count as childnodes */
118 "sstr", {"distribution": dist_id}, {
120 "oncomplete": function(r) {
121 var resp = openils.Util.readResponse(r);
122 var count = resp ? resp.length : 0;
125 span.innerHTML = " " + count + " stream(s)";
131 function open_batch_receive() {
133 alert("Let the interface load all the way first.");
137 var url = "/xul/server/serial/batch_receive.xul?docid=" +
138 sub.record_entry() + "&subid=" + sub.id();
141 openils.XUL.newTabEasy(url, "Batch Receive"); /* XXX i18n */
147 openils.Util.addOnLoad(
149 pcrud = new openils.PermaCrud();
150 load_sub_grid(sub_id);