fix for external invitations
[tine20] / tine20 / Calendar / js / iMIPDetailsPanel.js
index 5ff6741..e90c9d1 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2011 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2011-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  */
 Ext.ns('Tine.Calendar');
 
@@ -48,9 +48,8 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
     initComponent: function() {
         this.app = Tine.Tinebase.appMgr.get('Calendar');
         
-        
         this.iMIPrecord = new Tine.Calendar.Model.iMIP(this.preparedPart.preparedData);
-        if (! Ext.isFunction(this.iMIPrecord.get('event').beginEdit)) {
+        if (! this.iMIPrecord.get('event') || ! Ext.isFunction(this.iMIPrecord.get('event').beginEdit)) {
             this.iMIPrecord.set('event', Tine.Calendar.backend.recordReader({
                 responseText: Ext.util.JSON.encode(this.preparedPart.preparedData.event)
             }));
@@ -59,7 +58,7 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
         this.initIMIPToolbar();
         
         this.on('afterrender', this.showIMIP, this);
-            
+        
         Tine.Calendar.iMIPDetailsPanel.superclass.initComponent.call(this);
     },
     
@@ -90,7 +89,27 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
      * 
      * @param {String} status
      */
-    processIMIP: function(status) {
+    processIMIP: function(status, range) {
+        if (this.iMIPrecord.get('event').isRecurBase() && status != 'ACCEPTED' && !range) {
+            Tine.widgets.dialog.MultiOptionsDialog.openWindow({
+                title: this.app.i18n._('Reply to Recurring Event'),
+                questionText: this.app.i18n._('You are responding to an recurring event. What would you like to do?'),
+                height: 170,
+                scope: this,
+                options: [
+                    {text: this.app.i18n._('Respond to whole series'), name: 'series'},
+                    {text: this.app.i18n._('Do not respond'), name: 'cancel'}
+                ],
+                
+                handler: function(option) {
+                    if (option != 'cancel') {
+                        this.processIMIP(status, option);
+                    }
+                }
+            });
+            return;
+        }
+        
         Tine.log.debug('Tine.Calendar.iMIPDetailsPanel::processIMIP status: ' + status);
         this.getLoadMask().show();
         
@@ -106,7 +125,6 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
             this.iMIPrecord.set('event', Tine.Calendar.backend.recordReader({
                 responseText: Ext.util.JSON.encode(result.event)
             }));
-            
             this.showIMIP();
         }, this);
     },
@@ -125,9 +143,9 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
             if (status.id == 'NEEDS-ACTION') return;
             
             this.statusActions.push(new Ext.Action({
-                text: status.get('status_name'),
+                text: status.get('i18nValue'),
                 handler: this.processIMIP.createDelegate(this, [status.id]),
-                iconCls: 'cal-response-action-' + status.id
+                icon: status.get('icon')
             }));
         }, this);
         
@@ -156,14 +174,19 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
      * show/layout iMIP panel
      */
     showIMIP: function() {
-        
         var singleRecordPanel = this.getSingleRecordPanel(),
             preconditions = this.iMIPrecord.get('preconditions'),
             method = this.iMIPrecord.get('method'),
             event = this.iMIPrecord.get('event'),
+            existingEvent = this.iMIPrecord.get('existing_event'),
             myAttenderRecord = event.getMyAttenderRecord(),
             myAttenderstatus = myAttenderRecord ? myAttenderRecord.get('status') : null;
             
+        // show container from existing event if exists
+        if (existingEvent && existingEvent.container_id) {
+            event.set('container_id', existingEvent.container_id);
+        }
+            
         // reset actions
         Ext.each(this.actions, function(action) {action.setHidden(true)});
         
@@ -214,7 +237,7 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
                     this.iMIPclause.setText(this.app.i18n._('An invited attendee responded to the invitation.'));
                     break;
                     
-                default:            
+                default:
                     this.iMIPclause.setText(this.app.i18n._("Unsupported method"));
                     break;
             }
@@ -224,12 +247,13 @@ Tine.Calendar.iMIPDetailsPanel = Ext.extend(Tine.Calendar.EventDetailsPanel, {
         singleRecordPanel.setVisible(true);
         singleRecordPanel.setHeight(150);
         
-        try {
-            singleRecordPanel.loadRecord(event);
-        } catch (e) {
-            singleRecordPanel.setVisible(false);
+        if (existingEvent) {
+            this.record = Tine.Calendar.backend.recordReader({
+                responseText: Ext.util.JSON.encode(existingEvent)
+            });
+        } else {
+            this.record = event;
         }
-        
+        singleRecordPanel.loadRecord(this.record);
     }
-
-});
\ No newline at end of file
+});