]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/acq/picklist/brief_record.js
begining of brief record entry form, based on defined marc attr defs. just need...
[working/Evergreen.git] / Open-ILS / web / js / ui / default / acq / picklist / brief_record.js
1 dojo.require('dojo.data.ItemFileReadStore');
2 dojo.require('dijit.form.Form');
3 dojo.require('dijit.form.TextBox');
4 dojo.require('dijit.form.DateTextBox');
5 dojo.require('dijit.form.Button');
6 dojo.require('openils.User');
7 dojo.require('openils.widget.AutoFieldWidget');
8 dojo.require('openils.MarcXPathParser');
9
10 function drawBriefRecordForm(fields) {
11
12     var tbody = dojo.byId('acq-brief-record-tbody');
13     var rowTmpl = dojo.byId('acq-brief-record-row');
14
15     fieldmapper.standardRequest(
16         ['open-ils.acq', 'open-ils.acq.lineitem_attr_definition.retrieve.all'],
17         {   async : true,
18             params : [openils.User.authtoken],
19
20             oncomplete : function(r) {
21                 var attrs = openils.Util.readResponse(r);
22                 if(attrs && attrs.marc) {
23
24                     attrs = attrs.marc.sort(
25                         function(a, b) {
26                             if(a.description < b.description)
27                                 return 1;
28                             return -1;
29                         }
30                     );
31
32                     dojo.forEach(attrs,
33                         function(def) {
34                             var row = rowTmpl.cloneNode(true);
35                             dojo.query('[name=name]', row)[0].innerHTML = def.description();
36                             new dijit.form.TextBox({name : def.code()}, dojo.query('[name=widget]', row)[0]);
37                             tbody.appendChild(row);
38                         }
39                     );
40                 }
41             }
42         }
43     );
44 }
45
46 function compileBriefRecord(fields) {
47     console.log(js2JSON(fields));
48     return false;
49 }
50
51 openils.Util.addOnLoad(drawBriefRecordForm);