]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/serial/subscription/distribution.js
LP1615805 No inputs after submit in patron search (AngularJS)
[working/Evergreen.git] / Open-ILS / web / js / ui / default / serial / subscription / distribution.js
1 /* Build maps of sre details for both display and selection purposes */
2
3 function build_sre_maps(grid) {
4     try {
5         //grid.sre_id_map = {};
6         grid.sres_ou_map = {};
7         var parent_g = window.parent.parent.g;
8         if (parent_g.mfhd) {
9             var mfhd_details = parent_g.mfhd.details;
10             for (var i = 0; i < mfhd_details.length; i++) {
11                 var mfhd_detail = {};
12                 for (j in mfhd_details[i]) {
13                     mfhd_detail[j] = mfhd_details[i][j];
14                 }
15                 var entry = {};
16                 entry.label = mfhd_detail.label + ' (' + (mfhd_detail.entryNum + 1) + ')';
17                 entry.record_entry = mfhd_detail.id;
18                 var org_unit_id = mfhd_detail.owning_lib;
19                 //grid.sre_id_map[sre_id] = mfhd_detail;
20                 if (!grid.sres_ou_map[org_unit_id]) {
21                     grid.sres_ou_map[org_unit_id] = 
22                         {
23                             "identifier": "record_entry",
24                             "label": "label",
25                             "items": []
26                         };
27                 }
28                 grid.sres_ou_map[org_unit_id].items.push(entry);
29             }
30
31             for (i in grid.sres_ou_map) {
32                 grid.sres_ou_map[i] = new dojo.data.ItemFileReadStore({
33                     "data": grid.sres_ou_map[i]
34                 });
35             }
36         }
37     } catch(E) {
38         alert(E); //XXX
39     }
40 }
41
42
43 function populate_sre_selector(grid, holding_lib_id, temp) {
44     if (grid.sres_ou_map[holding_lib_id]) {
45         grid.overrideEditWidgets.record_entry.attr
46             ("store", grid.sres_ou_map[holding_lib_id]);
47         grid.overrideEditWidgets.record_entry.shove = {};
48         grid.overrideEditWidgets.record_entry.attr("disabled", false);
49         // this is needed to reload the value after we change the store
50         // XXX is there a better way to do this?
51         grid.overrideEditWidgets.record_entry.setValue
52             (grid.overrideEditWidgets.record_entry._lastQuery);
53     } else {
54         grid.overrideEditWidgets.record_entry.attr
55             ("store", grid.empty_store);
56         grid.overrideEditWidgets.record_entry.attr("disabled", true);
57         grid.overrideEditWidgets.record_entry.attr("value", "");
58     }
59 }
60