big re-work of the provider config page
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 29 Apr 2009 20:05:31 +0000 (20:05 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 29 Apr 2009 20:05:31 +0000 (20:05 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13020 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/acq/provider.js
Open-ILS/web/templates/default/conify/global/acq/provider.tt2

index d6d3056..abfe064 100644 (file)
+dojo.require('dijit.layout.TabContainer');
 dojo.require('openils.widget.AutoGrid');
 dojo.require('dijit.form.FilteringSelect');
 dojo.require('openils.PermaCrud');
 var provider;
 dojo.require('openils.widget.AutoGrid');
 dojo.require('dijit.form.FilteringSelect');
 dojo.require('openils.PermaCrud');
 var provider;
-var contactIds = [];
+
 function draw() {
     if(providerId) {
         openils.Util.addCSSClass(dojo.byId('provider-list-div'), 'hidden');
 function draw() {
     if(providerId) {
         openils.Util.addCSSClass(dojo.byId('provider-list-div'), 'hidden');
+        console.log('in draw');
+        var pcrud = new openils.PermaCrud();
+        pcrud.retrieve('acqpro', providerId, {
+                oncomplete : function(r) {
+                    provider = openils.Util.readResponse(r);
+                    console.log('provider is' + js2JSON(provider));
+                    var pane = new openils.widget.EditPane({fmObject:provider}, dojo.byId('provider-summary-pane'));
+                    pane.startup();
+                    console.log("pane started");
+                    dojo.connect(providerTabs, 'selectChild', drawProviderSummary);                        
+                }
+            });
+      
         drawProviderSummary();
     } else {
         drawProviderSummary();
     } else {
+        console.log('in else block');
         openils.Util.addCSSClass(dojo.byId('provider-details-div'), 'hidden');
         openils.Util.addCSSClass(dojo.byId('provider-details-div'), 'hidden');
+        pListGrid.loadAll({order_by:{acqpro : 'name'}});       
         pListGrid.onPostCreate = function(fmObject) {
             location.href = location.href + '/' + fmObject.id();
         }
         pListGrid.onPostCreate = function(fmObject) {
             location.href = location.href + '/' + fmObject.id();
         }
-        pListGrid.loadAll({order_by:{acqpro : 'name'}});
+        
     }
     }
+   
 }
 }
-openils.Util.addOnLoad(draw);
-
-function drawProviderSummary() {
-    openils.Util.removeCSSClass(dojo.byId('provider-details-div'), 'hidden');
-    var pcrud = new openils.PermaCrud();
-    pcrud.retrieve('acqpro', providerId, {
-        oncomplete : function(r) {
-            provider = openils.Util.readResponse(r);
-            var pane = new openils.widget.EditPane({fmObject:provider}, dojo.byId('provider-summary-pane'));
-            pane.startup();
-
-        }
-    });
-    paListGrid.overrideEditWidgets.provider = new
-        dijit.form.TextBox({style:'display:none', value: providerId});
-    paListGrid.loadAll({order_by:{acqpa : 'provider'}}, {provider : providerId});
-    pcListGrid.overrideEditWidgets.provider = new
-        dijit.form.TextBox({style:'display:none', value: providerId});
-    pcListGrid.loadAll(
-    {
-        order_by:{acqpc : 'name'},
-
-        oncomplete:  function(){
-            pcListGrid.store.fetch({
-                onComplete: function(items) {
-                    dojo.forEach(items, function(item) {
-                        contactIds.push(pcListGrid.store.getValue(item, 'id')); }
-                    );
-                    console.log("contact IDs are " + js2JSON(contactIds));
-                    pcaListGrid.overrideEditWidgets.contact = new
-                        dijit.form.FilteringSelect({store: pcListGrid.store});
-                    pcaListGrid.loadAll({order_by:{acqpca : 'contact'}}, {contact: contactIds});
+function drawProviderSummary(child) {
+    console.log(child);
+    openils.Util.addCSSClass(dojo.byId('provider-details-div'), 'visible');
+    console.log("hidden provider-details");
+  
+    var loadedTabs = {'provider-address' : true};
+    if(child){   
+        if(loadedTabs[child.id]) return;
+        loadedTabs[child.id] = true;
+        switch(child.id) {
+        case 'tab-pro-contact': 
+            pcListGrid.overrideEditWidgets.provider = new
+                dijit.form.TextBox({disabled: 'true', value: providerId});
+            openils.Util.removeCSSClass(dojo.byId('contact-addr-div'), 'hidden');
+            pcListGrid.resetStore();
+            pcListGrid.loadAll( {oncomplete:function(r){
+            var count = 0; 
+            pcListGrid.store.fetch( {onComplete:function(list) { 
+                        count =  list.length
+                            if(count>=1){
+                                var contactIds = [];                           
+                                dojo.forEach(list, function(item) {
+                                        contactIds.push(pcListGrid.store.getValue(item, 'id')); }
+                                    );
+                                openils.Util.addCSSClass(dojo.byId('contact-addr-div'), 'visible');
+                                pcaListGrid.overrideEditWidgets.contact = new
+                                dijit.form.FilteringSelect({store: pcListGrid.store});
+                                pcaListGrid.resetStore();
+                                pcaListGrid.loadAll({order_by:{acqpca : 'contact'}}, {contact: contactIds});
+                            }else{ 
+                                return;
+                            }            
+                    }
                 }
                 }
-            });
+                );
+                    }
+                }, {provider : providerId});
+            
+            break;
+        case 'tab-attr': 
+            padListGrid.overrideEditWidgets.provider = new
+                dijit.form.TextBox({disabled: 'true', value: providerId});
+            padListGrid.resetStore();
+            padListGrid.loadAll({order_by:{acqlipad : 'provider'}}, {provider : providerId});
+            break;
+        case 'tab-hold': 
+            phsListGrid.overrideEditWidgets.provider = new
+                dijit.form.TextBox({disabled: 'true', value: providerId});
+            phsListGrid.overrideEditWidgets.name = nameSelect;
+            phsListGrid.resetStore();
+            phsListGrid.loadAll({order_by:{acqphsm : 'provider'}}, {provider : providerId});
+            break;
+        default:
+            paListGrid.overrideEditWidgets.provider = new
+                dijit.form.TextBox({disabled: 'true', value: providerId});
+            paListGrid.resetStore();
+            paListGrid.loadAll({order_by:{acqpa:'provider'}}, {provider: providerId}); 
         }
         }
-    }, {provider : providerId});
+        
+    } else {
+        paListGrid.overrideEditWidgets.provider = new
+            dijit.form.TextBox({disabled: 'true', value: providerId});
+        paListGrid.resetStore();
+        paListGrid.loadAll({order_by:{acqpa:'provider'}}, {provider: providerId}); 
+    }
 }
 
 function getProviderName(rowIndex, item) {
 }
 
 function getProviderName(rowIndex, item) {
@@ -60,3 +107,4 @@ function getProviderName(rowIndex, item) {
         this.grid.store.getValue(item, 'name') + '</a>';
 }
 
         this.grid.store.getValue(item, 'name') + '</a>';
 }
 
+openils.Util.addOnLoad(draw);
index 1b28daa..8fffef7 100644 (file)
@@ -1,16 +1,54 @@
 [% WRAPPER default/base.tt2 %]
 <script src='[% ctx.media_prefix %]/js/ui/default/conify/global/acq/provider.js'> </script>
 <script> var providerId = '[% ctx.page_args.0 %]';</script>
 [% WRAPPER default/base.tt2 %]
 <script src='[% ctx.media_prefix %]/js/ui/default/conify/global/acq/provider.js'> </script>
 <script> var providerId = '[% ctx.page_args.0 %]';</script>
+ <script type ="text/javascript">
+        function formatName(inDatum) {
+        switch (inDatum) {
+        case 'owning_lib':
+        return 'Owning Library';
+        case 'quantity':
+        return 'Quantity';
+        case 'call_number':
+        return 'Call Number';
+        case 'fund_code':
+        return 'Fund Code';
+        case 'local_note':
+        return 'Local Note';
+        case 'price':
+        return 'Price';
+        case 'circ-Modifier':
+        return 'Circulation Modifier';
+        case 'copy_location':
+        return 'Copy Location';
+        case 'collection_code':
+        return 'Collection Code';
+        }
+        }
 
 
-
-<div id='provider-list-div'>
-    <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ </script>
+<div class="hidden"><select dojoType="dijit.form.FilteringSelect" jsId="nameSelect">
+    <option value='owning_lib'>Owning Library</option>
+    <option value='quantity'>Quantity</option>
+    <option value='call_number'>Call Number</option>
+    <option value='fund_code'>Fund Code</option>
+    <option value='local_note'>Local Note</option>
+    <option value='price'>Price</option>
+    <option value='circ_modifier'>Circulation Modifier</option>
+    <option value='copy_location'>Copy Locations</option>
+    <option value='collection_code'>Collection Code</option>
+</select>
+</div> 
+<div id='provider-list-div' style='height: 600px;'>
+    <div dojoType="dijit.layout.ContentPane" layoutAlign='top'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
-        <div>Provider</div>
-        <div>
-            <button dojoType='dijit.form.Button' onClick='pListGrid.showCreateDialog()'>New Provider</button>
-            <button dojoType='dijit.form.Button' onClick='pListGrid.deleteSelected()'>Delete Selected</button> </div>
+            <div>Provider</div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='pListGrid.showCreateDialog()'>New Provider</button>
+                <button dojoType='dijit.form.Button' onClick='pListGrid.deleteSelected()'>Delete Selected</button> </div>
         </div>
         </div>
+    </div>
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
         <table  jsId="pListGrid"
                 dojoType="openils.widget.AutoGrid"
                 fieldOrder="['id', 'name', 'code', 'owner', 'currency_type']"
         <table  jsId="pListGrid"
                 dojoType="openils.widget.AutoGrid"
                 fieldOrder="['id', 'name', 'code', 'owner', 'currency_type']"
         </table>
     </div>
 </div>
         </table>
     </div>
 </div>
+ <div id='provider-summary-pane'></div>     
+<div id='provider-details-div' style='height:600px;'>
+<div dojoType="dijit.layout.TabContainer" style='height:100%;' jsId='providerTabs'>
 
 
-
-
-<div id='provider-details-div'>
-    <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
-        <div id='provider-summary-pane'/>
-    </div>
+    <div dojoType="dijit.layout.ContentPane" title='Provider Address' select='true' id='provider-address'>
+        
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
-            <div>Provider Address</div>
+            <div> Provider Address</div>
             <button dojoType='dijit.form.Button' onClick='paListGrid.showCreateDialog()'>New Provider Address</button>
             <button dojoType='dijit.form.Button' onClick='paListGrid.showCreateDialog()'>New Provider Address</button>
+            <button dojoType='dijit.form.Button' onClick='paListGrid.deleteSelected()'>Delete Selected</button>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:100px'>
             <table  jsId="paListGrid"
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:100px'>
             <table  jsId="paListGrid"
                     editOnEnter='true'>
             </table>
         </div>
                     editOnEnter='true'>
             </table>
         </div>
-
+    </div>
+    
+    <div dojoType="dijit.layout.ContentPane" title='Provider Contact' id='tab-pro-contact'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
-            <div>Provider Contact</div>
+            <div> Provider Contact</div>
             <button dojoType='dijit.form.Button' onClick='pcListGrid.showCreateDialog()'>New Contact</button>
             <button dojoType='dijit.form.Button' onClick='pcListGrid.showCreateDialog()'>New Contact</button>
+            <button dojoType='dijit.form.Button' onClick='pcListGrid.deleteSelected()'>Delete Selected</button>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
             <table  jsId="pcListGrid"
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
             <table  jsId="pcListGrid"
                     editOnEnter='true'>
             </table>
         </div>
                     editOnEnter='true'>
             </table>
         </div>
-
-
-
+    
+    <div id='contact-addr-div'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Contact Address</div>
             <button dojoType='dijit.form.Button' onClick='pcaListGrid.showCreateDialog()'>New Contact Address</button>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Contact Address</div>
             <button dojoType='dijit.form.Button' onClick='pcaListGrid.showCreateDialog()'>New Contact Address</button>
+            <button dojoType='dijit.form.Button' onClick='pcaListGrid.deleteSelected()'>Delete Selected</button>
         </div>
         </div>
-        <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:400px'>
             <table  jsId="pcaListGrid"
                     dojoType="openils.widget.AutoGrid"
             <table  jsId="pcaListGrid"
                     dojoType="openils.widget.AutoGrid"
-                    fieldOrder="['id', 'address_type', 'provider', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
+                    fieldOrder="['id', 'address_type', 'contact', 'street1', 'street2', 'city', 'county', 'state', 'country', 'post_code']"
                     query="{id: '*'}"
                     fmClass='acqpca'
                     editOnEnter='true'>
                     query="{id: '*'}"
                     fmClass='acqpca'
                     editOnEnter='true'>
-
+                
+            </table>
+        </div>
+    </div> 
+</div>
+    <div dojoType="dijit.layout.ContentPane" title='Attribute Definitions' id='tab-attr'>       
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+            <div> Attribute Definitions</div>
+            <button dojoType='dijit.form.Button' onClick='padListGrid.showCreateDialog()'>New Attribute Definition</button>
+            <button dojoType='dijit.form.Button' onClick='padListGrid.deleteSelected()'>Delete Selected</button>
+        </div>
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+            <table  jsId="padListGrid"
+                    dojoType="openils.widget.AutoGrid"
+                    fieldOrder="['id', 'provider', 'code', 'description', 'xpath', 'provider', 'ident']"
+                    defaultCellWidth='20'
+                    query="{id: '*'}"
+                    fmClass='acqlipad'
+                    editOnEnter='true'>
+                
+            </table>
+        </div>
+    </div>
+    
+    <div dojoType="dijit.layout.ContentPane" title='Holding Subfield' id='tab-hold'>       
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+            <div>Holding Subfield</div>
+            <button dojoType='dijit.form.Button' onClick='phsListGrid.showCreateDialog()'>New Holding Subfield</button>
+            <button dojoType='dijit.form.Button' onClick='phsListGrid.deleteSelected()'>Delete Selected</button>
+        </div>
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:200px'>
+            <table  jsId="phsListGrid"
+                    dojoType="openils.widget.AutoGrid"
+                    fieldOrder="['id', 'provider', 'name', 'subfield']"
+                    defaultCellWidth='20'
+                    query="{id: '*'}"
+                    fmClass='acqphsm'
+                    editOnEnter='true'>
+                <thead>
+                    <tr>
+                        <th field="name" formatter='formatName'/>
+                        </tr>
+                    </thead>
             </table>
         </div>
     </div>
             </table>
         </div>
     </div>
+</div>  
 </div>
 [% END %]
 
 </div>
 [% END %]