]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/conify/global/config/coded_value_map.tt2
LP#1269911 composite attributes admin UI
[working/Evergreen.git] / Open-ILS / src / templates / conify / global / config / coded_value_map.tt2
1 [% WRAPPER base.tt2 %]
2 <h1>[% l('Coded Value Maps') %]</h1> <br/>
3
4 <div dojoType="dijit.layout.ContentPane" layoutAlign="client" class='oils-header-panel'>
5     <div>[% l('Coded Value Maps') %]</div>
6     <div>
7         <button dojoType='dijit.form.Button' onClick='ccvmGrid.showCreateDialog()'>[% l('New Map') %]</button>
8         <button dojoType='dijit.form.Button' onClick='ccvmGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
9     </div>
10 </div>
11
12 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
13     <span>[% l('Record Attribute Type: ') %]</span><div id='attr-def-div'></div>
14 </div>
15
16 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
17     <table  jsId="ccvmGrid"
18             autoHeight='true'
19             dojoType="openils.widget.AutoGrid"
20             fieldOrder="['ctype', 'code', 'value', 'description', 'opac_visible', 'search_label', 'is_simple', 'composite_def']"
21             query="{code: '*'}"
22             defaultCellWidth='"25%"'
23             fmClass='ccvm'
24             showPaginator='true'
25             editOnEnter='true'>
26       <thead>
27         <tr><th field='composite_def' 
28                 get='getCompositeDefLink' 
29                 formatter='formatCompositeDefLink'>
30             [% l('Composite Definition') %]</th></tr>
31       </thead>
32     </table>
33  </div>
34
35 <script type ="text/javascript">
36
37     dojo.require('dijit.form.FilteringSelect');
38     dojo.require('openils.widget.AutoGrid');
39     dojo.require('openils.widget.AutoFieldWidget');
40
41     function getCompositeDefLink(rowId, item) {
42       if (!item) return '';
43       return this.grid.store.getValue(item, 'id');
44     }
45
46     var isComposite = false;
47     function formatCompositeDefLink(id) {
48       if (id && isComposite) {
49         return "<a href='" + oilsBasePath +
50           "/conify/global/config/composite_attr_entry_definition/" 
51           + id + "'>[% l('Manage') %]</a>";
52         } else {
53           return "";
54       }
55     }
56
57     var cradName = '[% ctx.page_args.0 %]';
58
59     openils.Util.addOnLoad(
60         function() {
61
62             var selector = new openils.widget.AutoFieldWidget({
63                 fmClass : 'ccvm',
64                 fmField : 'ctype',
65                 parentNode : dojo.byId('attr-def-div')
66             });
67
68             selector.build(
69                 function(w, ww) {
70                     dojo.connect(w, 'onChange', 
71                         function(newVal) {
72
73                             // see if this attr def supports composite entries
74                             w.store.fetch({
75                               onComplete : function(list) {
76                                 if (!list.length) return;
77                                 var comp = w.store.getValue(list[0], 'composite');
78                                 if (comp == 't') {
79                                   isComposite = true;
80                                 } else {
81                                   isComposite = false;
82                                 }
83                               },
84                               query : {name : ''+newVal}
85                             });
86                             
87                             ccvmGrid.resetStore();
88                             ccvmGrid.loadAll({order_by : {ccvm : 'code'}}, {ctype : newVal});
89                             ccvmGrid.overrideWidgetArgs.ctype = {dijitArgs : {value : newVal}};
90                             // ^-- why is this not working?
91                         }
92                     );
93
94                     // if a crad is already selected via URL, fetch the ccvm's
95                     if (cradName) w.attr('value', cradName);
96                 }
97             );
98
99             // hide the progress indicator since we're not loading any data up front
100             dojo.style(ccvmGrid.loadProgressIndicator, 'visibility', 'hidden');
101         }
102     );
103
104 </script>
105
106 [% END %]