]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/acq/po/create.js
Acq: add a Create PO interface for workflows starting with new, blank POs
[working/Evergreen.git] / Open-ILS / web / js / ui / default / acq / po / create.js
1 dojo.require("openils.widget.EditDialog");
2 dojo.require("openils.widget.EditPane");
3
4 var editDialog;
5
6 function toPoListing() {
7     location.href = oilsBasePath + "/acq/search/unified?ca=po";
8 }
9
10 function toOnePo(id) {
11     location.href = oilsBasePath + "/acq/po/view/" + id;
12 }
13
14 openils.Util.addOnLoad(
15     function() {
16         editDialog = new openils.widget.EditDialog({
17             "editPane": new openils.widget.EditPane({
18                 "fmObject": new acqpo(),
19                 /* After realizing how many fields should be excluded from this
20                  * interface because users shouldn't set them arbitrarily,
21                  * it hardly seems like using these Edit widgets gives much
22                  * much advantage over a hardcoded interface. */
23                 "suppressFields": [
24                     "create_time", "edit_time", "editor", "order_date",
25                     "owner", "cancel_reason", "creator", "state", "name"
26                 ],
27                 "fieldOrder": ["ordering_agency", "provider"],
28                 "mode": "create",
29                 "onSubmit": function(po) {
30                     fieldmapper.standardRequest(
31                         ["open-ils.acq", "open-ils.acq.purchase_order.create"],{
32                             "async": false,
33                             "params": [openils.User.authtoken, po],
34                             "onresponse": function(r) {
35                                 toOnePo(
36                                     openils.Util.readResponse(r).
37                                     purchase_order.id()
38                                 );
39                             }
40                         }
41                     );
42                 },
43                 "onCancel": function() {
44                     editDialog.hide();
45                     toPoListing();
46                     /* I'd rather do window.close() or xulG.close_tab(),
47                      * but neither of those seem to work here. */
48                 }
49             })
50         });
51         editDialog.startup();
52         editDialog.show();
53     }
54 );