changes
[tine20] / tine20 / Inventory / js / InventoryItemGridPanel.js
1 /*
2  * Tine 2.0
3  * 
4  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
5  * @author      Philipp Schüle <p.schuele@metaways.de>
6  * @copyright   Copyright (c) 2007-2011 Metaways Infosystems GmbH (http://www.metaways.de)
7  */
8 Ext.ns('Tine.Inventory');
9
10 /**
11  * InventoryItem grid panel
12  * 
13  * @namespace   Tine.Inventory
14  * @class       Tine.Inventory.InventoryItemGridPanel
15  * @extends     Tine.widgets.grid.GridPanel
16  * 
17  * <p>InventoryItem Grid Panel</p>
18  * <p><pre>
19  * </pre></p>
20  * 
21  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
22  * @author      Philipp Schuele <p.schuele@metaways.de>
23  * @copyright   Copyright (c) 2007-2008 Metaways Infosystems GmbH (http://www.metaways.de)
24  * 
25  * @param       {Object} config
26  * @constructor
27  * Create a new Tine.Inventory.InventoryItemGridPanel
28  */
29 Tine.Inventory.InventoryItemGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
30     /**
31      * record class
32      * @cfg {Tine.Inventory.Model.InventoryItem} recordClass
33      */
34     recordClass: Tine.Inventory.Model.InventoryItem,
35    
36     /**
37      * eval grants
38      * @cfg {Boolean} evalGrants
39      */
40     evalGrants: true,
41     
42     /**
43      * grid specific
44      * @private
45      */
46     defaultSortInfo: {field: 'creation_time', direction: 'DESC'},
47     gridConfig: {
48         autoExpandColumn: 'inventory_id'
49     },
50      
51     /**
52      * inits this cmp
53      * @private
54      */
55     initComponent: function() {
56         this.recordProxy = Tine.Inventory.recordBackend;
57         
58         this.gridConfig.cm = this.getColumnModel();
59         this.filterToolbar = this.filterToolbar || this.getFilterToolbar();
60         
61         this.plugins = this.plugins || [];
62         this.plugins.push(this.filterToolbar);
63         
64         Tine.Inventory.InventoryItemGridPanel.superclass.initComponent.call(this);
65     },
66     
67     /**
68      * returns cm
69      * 
70      * @return Ext.grid.ColumnModel
71      * @private
72      * 
73      * TODO    add more columns
74      */
75     getColumnModel: function(){
76         return new Ext.grid.ColumnModel({ 
77             defaults: {
78                 sortable: true,
79                 resizable: true
80             },
81             columns: [{
82                 id: 'inventory_id',
83                 header: this.app.i18n._("ID"),
84                 width: 50,
85                 sortable: true,
86                 dataIndex: 'inventory_id'
87             }, {
88                 id: 'name',
89                 header: this.app.i18n._("Name"),
90                 width: 50,
91                 sortable: true,
92                 dataIndex: 'name'
93             }, {
94                 id: 'type',
95                 header: this.app.i18n._("Type"),
96                 width: 50,
97                 sortable: true,
98                 dataIndex: 'type',
99                 renderer: Tine.Tinebase.widgets.keyfield.Renderer.get('Inventory', 'inventoryType')
100             },{
101                 id: 'add_time',
102                 header: this.app.i18n._("Added"),
103                 width: 50,
104                 sortable: true,
105                 dataIndex: 'add_time', 
106                 renderer: Tine.Tinebase.common.dateRenderer
107             },{
108                 id: 'location',
109                 header: this.app.i18n._("Location"),
110                 width: 50,
111                 sortable: true,
112                 dataIndex: 'location'
113             },{
114                 id: 'total_number',
115                 header: this.app.i18n._("Total number"),
116                 width: 50,
117                 sortable: true,
118                 dataIndex: 'total_number'
119             },{
120                 id: 'active_number',
121                 header: this.app.i18n._("Active number"),
122                 width: 50,
123                 sortable: true,
124                 dataIndex: 'active_number'
125             },{
126                 id: 'description',
127                 header: this.app.i18n._("Description"),
128                 width: 50,
129                 sortable: true,
130                 dataIndex: 'description'
131             }
132             
133             
134             
135             
136             
137             /*,{
138                 id: 'title',
139                 header: this.app.i18n._("Title"),
140                 width: 350,
141                 sortable: true,
142                 dataIndex: 'title'
143             },{
144                 id: 'budget',
145                 header: this.app.i18n._("Budget"),
146                 width: 100,
147                 sortable: true,
148                 dataIndex: 'budget'
149             }*/].concat(this.getModlogColumns())
150         });
151     },
152     
153     /**
154      * status column renderer
155      * @param {string} value
156      * @return {string}
157      */
158     statusRenderer: function(value) {
159         return this.app.i18n._hidden(value);
160     },
161     
162     /**
163      * return additional tb items
164      * @private
165      */
166     getToolbarItems: function(){
167         /*
168         this.action_showClosedToggle = new Tine.widgets.grid.FilterButton({
169             text: this.app.i18n._('Show closed'),
170             iconCls: 'action_showArchived',
171             field: 'showClosed'
172         });
173         */
174         
175         return [
176             /*
177             new Ext.Toolbar.Separator(),
178             this.action_showClosedToggle
179             */
180         ];
181     }    
182 });