0009926: CalDAV URL field to be added to task collection
[tine20] / tine20 / Tinebase / js / widgets / container / CalDAVContainerPropertiesHookField.js
1 /*
2  * Tine 2.0
3  * 
4  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
5  * @author      Cornelius Weiss <c.weiss@metaways.de>
6  * @copyright   Copyright (c) 2011-2014 Metaways Infosystems GmbH (http://www.metaways.de)
7  */
8 Ext.ns('Tine.widgets', 'Tine.widgets.container');
9
10 /**
11  * render the CalDAV Url into property panel of containers
12  * 
13  * @class   Tine.widgets.container.CalDAVContainerPropertiesHookField
14  * @extends Ext.form.TextField
15  */
16 Tine.widgets.container.CalDAVContainerPropertiesHookField = Ext.extend(Ext.form.TextField, {
17
18     anchor: '100%',
19     readOnly: true,
20     
21     /**
22      * @private
23      */
24     initComponent: function() {
25         this.on('added', this.onContainerAdded, this);
26
27         Tine.widgets.container.CalDAVContainerPropertiesHookField.superclass.initComponent.call(this);
28     },
29     
30     /**
31      * @private
32      */
33     onContainerAdded: function() {
34         this.app = Tine.Tinebase.appMgr.get(this.appName);
35         this.fieldLabel = _('CalDAV URL');
36         
37         this.propertiesDialog = this.findParentBy(function(p) {return !! p.grantContainer});
38         this.grantContainer = this.propertiesDialog.grantContainer;
39         
40         if (this.grantContainer.application_id && this.grantContainer.application_id.name) {
41             this.hasCalDAVSupport = (this.grantContainer.application_id.name == this.appName);
42         } else {
43             this.hasCalDAVSupport = this.grantContainer.application_id === this.app.id;
44         }
45         
46         this.hidden = ! this.hasCalDAVSupport;
47         // calDAV URL
48         this.value = [
49             window.location.href.replace(/\/?(index\.php.*)?$/, ''),
50             '/calendars/',
51             Tine.Tinebase.registry.get('currentAccount').contact_id,
52             '/',
53             this.grantContainer.id
54         ].join('');
55     }
56 });