]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/URLVerify/Sessions.js
Link checker: Some UI tweaks suggested by George Duimovich
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / URLVerify / Sessions.js
1 if (!dojo._hasResource["openils.URLVerify.Sessions"]) {
2     dojo.require("dojo.string");
3     dojo.require("openils.Util");
4     dojo.require("openils.URLVerify.Verify");
5
6     dojo.requireLocalization("openils.URLVerify", "URLVerify");
7
8     dojo._hasResource["openils.URLVerify.Sessions"] = true;
9     dojo.provide("openils.URLVerify.Sessions");
10
11     dojo.declare("openils.URLVerify.Sessions", null, {});
12
13     /* Take care that we add nothing to the global namespace.
14      * This is not an OO module so much as a container for
15      * functions needed by a specific interface. */
16
17 (function() {
18     var module = openils.URLVerify.Sessions;
19     var localeStrings =
20         dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
21
22     module.setup = function(grid, org_selector) {
23         module.grid = grid;
24
25         module.setup_org_selector_for_grid(org_selector);
26     };
27
28     module.setup_org_selector_for_grid = function(org_selector) {
29         function filter_grid_by_selected_org() {
30             module.grid.query = {
31                 "owning_lib": org_selector.attr("value")
32             };
33             module.grid.refresh();
34         }
35
36         new openils.User().buildPermOrgSelector(
37             "URL_VERIFY", org_selector, null,
38             function() {
39                 dojo.connect(
40                     org_selector, "onChange", filter_grid_by_selected_org
41                 );
42                 filter_grid_by_selected_org();
43             }
44         );
45     };
46
47     module.format_id = function(str) {
48         if (!str)
49             return "";
50
51         return str + " [<a href='select_urls?session_id=" + str + "' title='" +
52             localeStrings.REREVIEW + "'>" + localeStrings.REREVIEW +
53             "</a>] [<a href='create_session?clone=" + str + "' title='" +
54             localeStrings.CLONE_SESSION + "'>" +
55             localeStrings.CLONE_SESSION + "</a>]";
56     };
57
58     module.format_attempts = function(list) {
59         if (!dojo.isArray(list)) return "";
60
61         return dojo.map(
62             list, function(id) {
63                 if (isNaN(id))
64                     return "";
65                 return id + " [<a title='" + localeStrings.REVIEW_ATTEMPT +
66                     "' href='review_attempt?attempt_id=" + id + "'>" +
67                     localeStrings.REREVIEW + "</a>]";
68             }
69         ).join(" / ");
70     };
71
72 }());
73
74 }