Very basic non-ExtJS version of the inventory page
authorDiane Trout <diane@caltech.edu>
Sun, 7 Nov 2010 23:54:22 +0000 (15:54 -0800)
committerDiane Trout <diane@caltech.edu>
Sun, 7 Nov 2010 23:54:22 +0000 (15:54 -0800)
It needs to group by object type. Possible with an index of types
followed by index of objects before getting to the detail page.

The component where it forces you to login before viewing the
inventory page is broken. It shows a super-plain form, but
fails on submit with some kind of cross site forgery prevention
cookie fails

htsworkflow/frontend/inventory/views.py
htsworkflow/frontend/templates/inventory/inventory_index.html
htsworkflow/frontend/templates/inventory/inventory_summary.html

index 7ff5b401f0e9dc6f19b0d6e2f1e968789700707e..dfb92a96ba8c41007b562f9cca750c6a8cd9a1b5 100644 (file)
@@ -1,3 +1,4 @@
+from htsworkflow.frontend.samples.changelist import ChangeList
 from htsworkflow.frontend.inventory.models import Item, LongTermStorage, ItemType
 from htsworkflow.frontend.inventory.bcmagic import item_search
 from htsworkflow.frontend.bcmagic.plugin import register_search_plugin
@@ -137,7 +138,16 @@ def index(request):
     """
     Inventory Index View
     """
+    # build changelist
+    item_changelist = ChangeList(request, Item,
+        list_filter=[],                 
+        search_fields=[],
+        list_per_page=200,
+        queryset=Item.objects.all()
+    )
+
     context_dict = {
+        'item_changelist': item_changelist,
         'page_name': 'Inventory Index'
     }
     context_dict.update(INVENTORY_CONTEXT_DEFAULTS)
index 1a1e32b85594bd12da97b43bb62041a993fc0e1e..399dae1c6940ac4abf21bfad5fa7a2e749188f9e 100644 (file)
@@ -1,10 +1,69 @@
-{% extends "inventory/inventory_app.html" %}
-
-{% block additional_javascript %}
-<script type="text/javascript" src="/static/js/htsw-inventory.js"></script>
+{% extends "base_site.html" %}
+{% load adminmedia admin_list i18n %}
+{% block extrahead %}
+    <script type="text/javascript">
+      $(document).ready(function() {
+        $(window).resize(function() {
+           var window_height = $(window).height();
+           var position = $("#changelist table").position();
+           height = window_height - position.top;
+           $("#changelist table.filtered").height(height);
+           $("#changelist-filter").height(height);
+        });
+        $(window).resize();
+      });
+    </script>
 {% endblock %}
-
+{% block bodyclass %}change-list{% endblock %}
+{% block coltype %}flex{% endblock %}
 {% block content %}
-<div id="grid_target"></div>
+<div id="inventory-index-div" >
+  <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
+    {% block search %}{% search_form item_changelist %}{% endblock %}
+    {% block pagination %}{% pagination item_changelist %}{% endblock %}
+
+    {% block filters %}
+    {% if item_changelist.has_filters %}
+    <div id="changelist-filter">
+      <h2 >{% trans 'Filter' %}</h2>
+      {% for spec in item_changelist.filter_specs %}
+         {% admin_list_filter cl spec %}
+         {% endfor %}
+       </div>
+    {% endif %}
+    {% endblock %}
+  {% block summary_stats %}
+  <table class="{% if cl.has_filters %} filtered{% endif %}">
+    <thead >
+      <tr >
+        <td >UUID</td>
+        <td >Barcode ID</td>
+        <td >Location</td>
+        <td >Model</td>
+        <td >Vendor</td>
+        <td >Created</td>
+        <td >Contains</td>
+      </tr>
+    </thead>
+    <tbody >
+      {% for item in item_changelist.get_query_set %}
+      <tr >
+        <td >{{ item.uuid }}</td>
+        <td >{{ item.barcode_id}}</td>
+        <td >{{ item.location }}</td>
+        <td >{{ item.item_type }}</td>
+        <td ></td>      
+        <td >{{ item.creation_date }}</td>      
+        <td >
+          {% for content in item.longtermstorage_set.all %}
+          {{ content.flowcell }}
+          {% endfor %}
+        </td>
+      </tr>
+      {% endfor %}
+    </tbody>
+  </table>
+  {% endblock %}
+</div>
 {% endblock %}
-    
\ No newline at end of file
index d057ec9f1703fbd29fd3b52afc4dba01bd313086..3d462ddd4d58cc51ffce4f2e8769b84211e7923c 100644 (file)
         </p>
         <br />
         <center><div id="lts-grid"></div></center>
-        <script>
-                var lts_data = [
-                {% for lts in item.longtermstorage_set.all %}
-                        {% for lib in lts.libraries.iterator %}[ "{{ lts.flowcell.flowcell_id }}","{{ lib.id }}","{% for sd in lts.storage_devices.iterator %}{{ sd }}{% if forloop.last %}"{% else %}|{% endif %}{% endfor %}{% if forloop.parentloop.last %}{% if forloop.last %}]{% else %}],{% endif %}{% else %}],{% endif %}
-                        {% endfor %}
-                {% endfor %}
-                ];
-                
-                var lts_reader = new Ext.data.ArrayReader({}, [
-                        {name: 'flowcell'},
-                        {name: 'library'},
-                        {name: 'storage_devices'}
-                ]);
-                
-                var lts_grid = new Ext.grid.GridPanel({
-                        store: new Ext.data.GroupingStore({
-                                reader: lts_reader,
-                                data: lts_data,
-                                sortInfo: {'field': 'flowcell', 'direction': 'DESC'},
-                                groupField: 'flowcell'
-                        }),
-                        
-                        columns: [
-                                {id: 'flowcell', header: 'Flowcell', width: 30, sortable: true, dataIndex: 'flowcell', hidden: true},
-                                {header: 'Library', width: 30, sortable: true, dataIndex: 'library'},
-                                {header: 'Storage Devices', width: 60, sortable: true, dataIndex: 'storage_devices'}
-                        ],
-                        
-                        view: new Ext.grid.GroupingView({
-                                forceFit: true,
-                                groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
-                        }),
-                        
-                        frame: true,
-                        width: 700,
-                        autoHeight: true,
-                        collapisble: true,
-                        animCollapisble: true,
-                        stateful: true,
-                        stateId: 'inventory-item-lts-storage-grid',
-                        title: 'Long Term Storage Info',
-                        iconCls: 'icon-grid',
-                        renderTo: 'lts-grid'
-                })
-        </script>
         
 {% else %}
         <h3>Item with UUID of {{ uuid }} not found.</h3>