Remove located URI scope notes from 2.2 Release Notes
[working/Evergreen.git] / Open-ILS / web / js / ui / default / serial / edit_siss.js
1 dojo.require('dijit.form.TextBox');
2 dojo.require('dijit.form.Button');
3 dojo.require('dijit.form.FilteringSelect');
4 dojo.require('openils.PermaCrud');
5 dojo.require('openils.widget.EditPane');
6 dojo.require("openils.widget.HoldingCode");
7
8 dojo.requireLocalization('openils.serial', 'serial');
9 var localeStrings = dojo.i18n.getLocalization('openils.serial', 'serial');
10
11 // fresh_scap_selector needs these defined as globals XXX rework?
12 var pcrud;
13 var sub_id;
14
15 function drawSiss(siss_id, ssub_id) {
16     var iss_grid = { overrideEditWidgets : {} };
17
18     iss_grid.overrideEditWidgets.creator =
19         new dijit.form.TextBox({"disabled": true});
20     iss_grid.overrideEditWidgets.creator.shove = {
21         "create": openils.User.user.id()
22     };
23
24     iss_grid.overrideEditWidgets.editor =
25         new dijit.form.TextBox({
26             "disabled": true, "value": openils.User.user.id()
27         });
28
29     iss_grid.overrideEditWidgets.holding_type =
30         new dijit.form.TextBox({"disabled": true});
31
32     var pane_args = {
33         hideActionButtons : true,
34         overrideWidgets : iss_grid.overrideEditWidgets
35     }
36
37     var button_label;
38     pcrud = new openils.PermaCrud();
39     if (siss_id == 'new') {
40         sub_id = ssub_id;
41         pane_args.fmClass = 'siss';
42         pane_args.mode = 'create';
43         pane_args.onPostSubmit = function(req, cudResults){
44             //TODO: better success check
45             alert(localeStrings.SAVE_SUCCESSFUL);
46             //location.href = location.href.replace(/new\/.*/, cudResults[0].id());
47             parent.document.getElementById(window.name).refresh_command();
48         }
49         button_label = localeStrings.CREATE_ISSUANCE;
50     } else {
51         pane_args.fmObject = pcrud.retrieve('siss', siss_id);
52         pane_args.onPostSubmit = function(req, cudResults){
53             //alert('req: '+req.toSource());
54             //alert('cudResults: '+cudResults);
55             //TODO: better success check
56             alert(localeStrings.SAVE_SUCCESSFUL);
57             parent.document.getElementById(window.name).refresh_command();
58         }
59         sub_id = pane_args.fmObject.subscription();
60         button_label = localeStrings.MODIFY_ISSUANCE;
61     }
62     iss_grid.overrideEditWidgets.subscription =
63         new dijit.form.TextBox({
64             "disabled": true, "value": sub_id
65         });
66     fresh_scap_selector(iss_grid); // embed scap wizard into generated form
67
68     var pane = new openils.widget.EditPane(
69         pane_args, dojo.byId('edit-pane')
70     );
71
72     pane.fieldOrder = ['subscription','creator','editor','label','date_published','caption_and_pattern','holding_type'];
73     pane.suppressFields = ['id', 'holding_link_id','create_date','edit_date'];
74     pane.startup();
75
76     var tbody = pane.table.getElementsByTagName('tbody')[0];
77     var applySpan = document.createElement('span');
78     tbody.appendChild(document.createElement('tr').appendChild(document.createElement('td').appendChild(applySpan)));
79     new dijit.form.Button({
80         label: button_label,
81         onClick: function() {pane.performAutoEditAction();}
82     }, applySpan);
83
84 }