]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/acq/po/create.js
default ordering-agency org unit to workstation org in PO create dialog
[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                 overrideWidgetArgs : {
30                     provider : { dijitArgs : { store_options : { base_filter : { active :"t" } } } },
31                     ordering_agency : { orgDefaultsToWs : true }
32                 },
33                 "onSubmit": function(po) {
34                     fieldmapper.standardRequest(
35                         ["open-ils.acq", "open-ils.acq.purchase_order.create"],{
36                             "async": false,
37                             "params": [openils.User.authtoken, po],
38                             "onresponse": function(r) {
39                                 toOnePo(
40                                     openils.Util.readResponse(r).
41                                     purchase_order.id()
42                                 );
43                             }
44                         }
45                     );
46                 },
47                 "onCancel": function() {
48                     editDialog.hide();
49                     toPoListing();
50                     /* I'd rather do window.close() or xulG.close_tab(),
51                      * but neither of those seem to work here. */
52                 }
53             })
54         });
55         editDialog.startup();
56         editDialog.show();
57     }
58 );