]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/URLVerify/ReviewAttempt.js
Link checker: Links to MARC Editor in verification review interface
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / URLVerify / ReviewAttempt.js
1 if (!dojo._hasResource["openils.URLVerify.ReviewAttempt"]) {
2     dojo.require("dojo.string");
3     dojo.require("openils.CGI");
4     dojo.require("openils.PermaCrud");
5     dojo.require("openils.XUL");
6     dojo.require("dijit.Tooltip");
7
8     dojo.requireLocalization("openils.URLVerify", "URLVerify");
9
10     dojo._hasResource["openils.URLVerify.ReviewAttempt"] = true;
11     dojo.provide("openils.URLVerify.ReviewAttempt");
12
13     dojo.declare("openils.URLVerify.ReviewAttempt", null, {});
14
15     /* Take care that we add nothing to the global namespace.
16      * This is not an OO module so much as a container for
17      * functions needed by a specific interface. */
18
19 (function() {
20     var module = openils.URLVerify.ReviewAttempt;
21     var localeStrings =
22         dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
23
24     module._display_session_name = function() {
25         var pcrud = new openils.PermaCrud();
26
27         var attempt = pcrud.retrieve(
28             "uvva", module.attempt_id, {
29                 "flesh": 1, "flesh_fields": {"uvva": ["session"]}
30             }
31         );
32
33         dojo.byId("session-link-here").innerHTML =
34             "<a href='select_urls?session_id=" + attempt.session().id() + "'>" +
35             dojo.string.substitute(
36                 localeStrings.SESSION_NAME, [attempt.session().name()]
37             ) + "</a>";
38
39         pcrud.disconnect();
40
41         new dijit.Tooltip({
42             "connectId": "session-link-here",
43             "label": localeStrings.SELECT_MORE
44         });
45     };
46
47     module.setup = function(grid, progress_dialog) {
48         module.progress_dialog = progress_dialog;
49         module.progress_dialog.attr("title", localeStrings.INTERFACE_SETUP);
50         module.progress_dialog.show(true);
51
52         var cgi = new openils.CGI();
53         module.attempt_id = cgi.param("attempt_id");
54
55         module.grid = grid;
56
57         module.grid.setBaseQuery({"attempt_id": module.attempt_id});
58
59         module.grid.refresh();
60
61         module._display_session_name();
62
63         module.progress_dialog.hide();
64     };
65
66     module.open_marc_editor = function(/* bib id */ id) {
67         openils.XUL.newTabEasy(
68             "oils://remote/xul/server/cat/marcedit.xul",
69             dojo.string.substitute(localeStrings.MARC_EDITOR_TITLE, [id]), {
70                 "record": {
71                     "url": "/opac/extras/supercat/retrieve/marcxml/record/"+id,
72                     "id": id,
73                     "rtype": "bre"
74                 },
75                 "save": {
76                     "label": localeStrings.MARC_EDITOR_SAVE_RECORD,
77                     "func": function(marcxml) {
78                         fieldmapper.standardRequest(
79                             ["open-ils.cat", "open-ils.cat.biblio.record.xml.update"], {
80                                 "async": true,
81                                 "params": [openils.User.authtoken, id, marcxml],
82                                 "onresponse": function(r) {
83                                     /* just to do /something/ upon error */
84                                     openils.Util.readResponse(r);
85                                 }
86                             }
87                         );
88                         /* marcedit.js just expects this kind of result; meh */
89                         return {"id": id, "oncomplete": function() { }};
90                     }
91                 }
92             }
93         );
94     };
95
96     module.format_bib_id = function(id) {
97         if (!id) return "";
98
99         return "<a title='" + localeStrings.MARC_EDITOR_LINK +
100             "' href='javascript:void(0);' " +
101             "onclick='openils.URLVerify.ReviewAttempt.open_marc_editor(" +
102             id + "); return false;'>" + id + "</a>";
103     };
104
105 }());
106
107 }