fix missing extraFreetime Icons
[tine20] / tine20 / HumanResources / js / ExtraFreeTimeEditDialog.js
1 /*
2  * Tine 2.0
3  * 
4  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
5  * @author      Alexander Stintzing <a.stintzing@metaways.de>
6  * @copyright   Copyright (c) 2013 Metaways Infosystems GmbH (http://www.metaways.de)
7  */
8 Ext.ns('Tine.HumanResources');
9
10 /**
11  * @namespace   Tine.HumanResources
12  * @class       Tine.HumanResources.ExtraFreeTimeEditDialog
13  * @extends     Tine.widgets.dialog.EditDialog
14  * 
15  * <p>ExtraFreeTime Compose Dialog</p>
16  * <p></p>
17  * 
18  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
19  * @author      Alexander Stintzing <a.stintzing@metaways.de>
20  * Create a new Tine.HumanResources.ExtraFreeTimeEditDialog
21  */
22 Tine.HumanResources.ExtraFreeTimeEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
23     
24     /**
25      * @private
26      */
27     windowNamePrefix: 'ExtraFreeTimeEditWindow_',
28     appName: 'HumanResources',
29     recordClass: Tine.HumanResources.Model.ExtraFreeTime,
30     recordProxy: Tine.HumanResources.freetimeBackend,
31     evalGrants: false,
32     showContainerSelector: false,
33     mode: 'local',
34     windowWidth: 400,
35     windowHeight: 350,
36     /**
37      * show private Information (autoset due to rights)
38      * @type 
39      */
40     showPrivateInformation: null,
41     
42     /**
43      * overwrite update toolbars function (we don't have record grants yet)
44      * @private
45      */
46     updateToolbars: Ext.emptyFn,
47     
48     /**
49      * inits the component
50      */
51     initComponent: function() {
52         this.app = Tine.Tinebase.appMgr.get('HumanResources')
53         Tine.HumanResources.ExtraFreeTimeEditDialog.superclass.initComponent.call(this);
54     },
55     
56     /**
57      * executed after record got updated from proxy
58      * 
59      * @private
60      */
61     onRecordLoad: function() {
62         // interrupt process flow until dialog is rendered
63         if (! this.rendered) {
64             this.onRecordLoad.defer(250, this);
65             return;
66         }
67         
68         if (Ext.isString(this.record)) {
69             this.record = this.recordProxy.recordReader({responseText: this.record});
70         }
71         
72         Tine.HumanResources.ExtraFreeTimeEditDialog.superclass.onRecordLoad.call(this);
73     },
74     
75     /**
76      * returns dialog
77      * 
78      * NOTE: when this method gets called, all initalisation is done.
79      * 
80      * @return {Object}
81      * @private
82      */
83     getFormItems: function() {
84         return {
85             xtype: 'tabpanel',
86             border: false,
87             plain:true,
88             plugins: [{
89                 ptype : 'ux.tabpanelkeyplugin'
90             }],
91             defaults: {
92                 hideMode: 'offsets'
93             },
94             activeTab: 0,
95             border: false,
96             items:[{
97                 title: this.app.i18n._('Extra free time'),
98                 autoScroll: true,
99                 border: false,
100                 frame: true,
101                 layout: 'border',
102                 items: [{
103                     region: 'center',
104                     layout: 'hfit',
105                     border: false,
106                     items: [{
107                         xtype: 'fieldset',
108                         autoHeight: true,
109                         title: this.app.i18n._('Extra free time'),
110                         items: [{
111                             xtype: 'columnform',
112                             labelAlign: 'top',
113                             formDefaults: {
114                                 xtype:'numberfield',
115                                 anchor: '100%',
116                                 labelSeparator: '',
117                                 allowBlank: false,
118                                 columnWidth: 1
119                             },
120                             items: [[{
121                                     name: 'days', 
122                                     fieldLabel: this.app.i18n._('Days')
123                                 }], [{
124                                     xtype: 'widget-keyfieldcombo',
125                                     app: 'HumanResources',
126                                     keyFieldName: 'extraFreetimeType',
127                                     fieldLabel: this.app.i18n._('Type'),
128                                     name: 'type',
129                                     showIcon: false
130                                 }], [{
131                                     fieldLabel: this.app.i18n._('Expiration date'),
132                                     xtype: 'datefield',
133                                     name: 'expires'
134                                 }]
135                             ]
136                         }]
137                     }]
138                 }, 
139                 {
140                 // activities and tags
141                 layout: 'accordion',
142                 animate: true,
143                 region: 'east',
144                 width: 210,
145                 split: true,
146                 collapsible: true,
147                 collapseMode: 'mini',
148                 header: false,
149                 margins: '0 5 0 5',
150                 border: true,
151                 items: [
152                     new Ext.Panel({
153                         title: this.app.i18n._('Description'),
154                         iconCls: 'descriptionIcon',
155                         layout: 'form',
156                         labelAlign: 'top',
157                         border: false,
158                         items: [{
159                             style: 'margin-top: -4px; border 0px;',
160                             labelSeparator: '',
161                             xtype: 'textarea',
162                             name: 'description',
163                             hideLabel: true,
164                             grow: false,
165                             preventScrollbars: false,
166                             anchor: '100% 100%',
167                             emptyText: this.app.i18n._('Enter description'),
168                             requiredGrant: 'editGrant'
169                         }]
170                     }),
171                     new Tine.widgets.tags.TagPanel({
172                         app: 'HumanResources',
173                         border: false,
174                         bodyStyle: 'border:1px solid #B5B8C8;'
175                     })
176                 ]
177             }
178                 
179                 ]
180             }, 
181             new Tine.widgets.activities.ActivitiesTabPanel({
182                 app: this.appName,
183                 record_id: this.record.id,
184                 record_model: this.appName + '_Model_' + this.recordClass.getMeta('modelName')
185                 }) 
186             ]
187         };
188     },
189     
190     /**
191      * updates the statusbox wrap
192      * 
193      * @param {Tine.Tinebase.widgets.keyfield.ComboBox} the calling combo
194      * @param {Tine.Tinebase.data.Record} the selected record
195      * @param {Integer} the index of the selected value of the typecombo store
196      */
197     updateStatusBox: function(typeCombo, keyfieldRecord, index) {
198         this.statusBoxWrap.layout.setActiveItem(index);
199     },
200     
201     /**
202      * initializes the status box
203      */
204     initStatusBox: function() {
205         var isSickness = this.fixedFields.get('type') == 'SICKNESS';
206         this.updateStatusBox(null, null, isSickness ? 0 : 1);
207         var fieldName = isSickness ? 'sicknessStatus' : 'vacationStatus';
208         this.getForm().findField(fieldName).setValue(this.record.get('status'));
209     }
210 });