Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Projects / js / ProjectGridPanel.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) 2011 Metaways Infosystems GmbH (http://www.metaways.de)
7  */
8 Ext.ns('Tine.Projects');
9
10 /**
11  * Project grid panel
12  * 
13  * @namespace   Tine.Projects
14  * @class       Tine.Projects.ProjectGridPanel
15  * @extends     Tine.widgets.grid.GridPanel
16  * 
17  * <p>Project 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  * 
24  * @param       {Object} config
25  * @constructor
26  * Create a new Tine.Projects.ProjectGridPanel
27  */
28 Tine.Projects.ProjectGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
29     /**
30      * record class
31      * @cfg {Tine.Projects.Model.Project} recordClass
32      */
33     recordClass: Tine.Projects.Model.Project,
34     
35     /**
36      * eval grants
37      * @cfg {Boolean} evalGrants
38      */
39     evalGrants: true,
40     
41     /**
42      * optional additional filterToolbar configs
43      * @cfg {Object} ftbConfig
44      */
45     ftbConfig: null,
46     
47     /**
48      * grid specific
49      * @private
50      */
51     defaultSortInfo: {field: 'creation_time', direction: 'DESC'},
52     gridConfig: {
53         autoExpandColumn: 'title'
54     },
55      
56     /**
57      * inits this cmp
58      * @private
59      */
60     initComponent: function() {
61         this.recordProxy = Tine.Projects.recordBackend;
62         
63         this.gridConfig.cm = this.getColumnModel();
64         
65         Tine.Projects.ProjectGridPanel.superclass.initComponent.call(this);
66     },
67     
68     /**
69      * @private
70      */
71     initActions: function() {
72         if (Tine.Tinebase.appMgr.get('SimpleFAQ')) {
73             this.actions_searchFAQ = new Ext.Action({
74                 requiredGrant: 'readGrant',
75                 text: this.app.i18n._('Search FAQ'),
76                 disabled: false,
77                 handler: Tine.Tinebase.appMgr.get('SimpleFAQ').findQuestion,
78                 iconCls: '.x-btn-large SimpleFAQIconCls',
79                 scope: this
80             });
81             this.actionUpdater.addActions(this.actions_searchFAQ);
82         }
83         this.supr().initActions.call(this);
84     },
85     
86      /**
87      * add custom items to action toolbar
88      * 
89      * @return {Object}
90      */
91     getActionToolbarItems: function() {
92         if (Tine.Tinebase.appMgr.get('SimpleFAQ')) {
93             return [
94                 Ext.apply(new Ext.Button(this.actions_searchFAQ), {
95                     scale: 'medium',
96                     rowspan: 2,
97                     iconAlign: 'top'
98                 })
99             ];
100         }
101         return [];
102     },
103     
104
105     /**
106      * returns cm
107      * 
108      * @return Ext.grid.ColumnModel
109      * @private
110      */
111     getColumnModel: function(){
112         return new Ext.grid.ColumnModel({
113             defaults: {
114                 sortable: true,
115                 resizable: true
116             },
117             columns: [
118             {   id: 'tags', header: this.app.i18n._('Tags'), width: 40,  dataIndex: 'tags', sortable: false, renderer: Tine.Tinebase.common.tagsRenderer },                
119             {
120                 id: 'number',
121                 header: this.app.i18n._("Number"),
122                 width: 100,
123                 sortable: true,
124                 dataIndex: 'number',
125                 hidden: true
126             }, {
127                 id: 'title',
128                 header: this.app.i18n._("Title"),
129                 width: 350,
130                 sortable: true,
131                 dataIndex: 'title'
132             }, {
133                 id: 'status',
134                 header: this.app.i18n._("Status"),
135                 width: 150,
136                 sortable: true,
137                 dataIndex: 'status',
138                 renderer: Tine.Tinebase.widgets.keyfield.Renderer.get('Projects', 'projectStatus')
139             }].concat(this.getModlogColumns())
140         });
141     },
142     
143     /**
144      * status column renderer
145      * @param {string} value
146      * @return {string}
147      */
148     statusRenderer: function(value) {
149         return this.app.i18n._hidden(value);
150     }
151 });