save timezone, multiple import bug fix?
This commit is contained in:
		@@ -6,6 +6,9 @@ Ext.namespace("Zarafa.plugins.calendarimporter.dialogs");
 | 
			
		||||
 */
 | 
			
		||||
Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPanel, {
 | 
			
		||||
 | 
			
		||||
	/* store the imported timezone here... */
 | 
			
		||||
	timezone: null,
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * @constructor
 | 
			
		||||
	 * @param {object} config
 | 
			
		||||
@@ -110,11 +113,11 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
 | 
			
		||||
					sortable: true
 | 
			
		||||
				},
 | 
			
		||||
				columns: [
 | 
			
		||||
					{id: 'title', header: 'Title', width: 300, sortable: true, dataIndex: 'title'},
 | 
			
		||||
					{header: 'startDate', width: 150, sortable: true, dataIndex: 'start'},
 | 
			
		||||
					{header: 'endDate', width: 150, sortable: true, dataIndex: 'end'},
 | 
			
		||||
					{header: 'startDate', width: 150, sortable: true, dataIndex: 'location'},
 | 
			
		||||
					{header: 'endDate', width: 150, sortable: true, dataIndex: 'description'}
 | 
			
		||||
					{id: 'Summary', header: 'Title', width: 300, sortable: true, dataIndex: 'title'},
 | 
			
		||||
					{header: 'Start', width: 150, sortable: true, dataIndex: 'start'},
 | 
			
		||||
					{header: 'End', width: 150, sortable: true, dataIndex: 'end'},
 | 
			
		||||
					{header: 'Location', width: 150, sortable: true, dataIndex: 'location'},
 | 
			
		||||
					{header: 'Description', width: 150, sortable: true, dataIndex: 'description'}
 | 
			
		||||
				]
 | 
			
		||||
			}),
 | 
			
		||||
			sm: new Ext.grid.RowSelectionModel({multiSelect:true})
 | 
			
		||||
@@ -246,6 +249,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
 | 
			
		||||
				success: function(file, action){
 | 
			
		||||
					uploadField.reset();
 | 
			
		||||
					Ext.getCmp('submitButton').enable();
 | 
			
		||||
					this.timezone = action.result.response.calendar["X-WR-TIMEZONE"];
 | 
			
		||||
					this.insert(this.items.length,this.createGrid(action.result.response));
 | 
			
		||||
					this.doLayout();
 | 
			
		||||
				},
 | 
			
		||||
@@ -273,6 +277,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
 | 
			
		||||
			commonend: (entry.end) ?
 | 
			
		||||
				new Date(entry.end) :
 | 
			
		||||
				new Date(entry.start).add(Date.HOUR, 1),
 | 
			
		||||
			timezone: this.timezone,
 | 
			
		||||
			parent_entryid: calendarFolder.get('entryid'),
 | 
			
		||||
			store_entryid: calendarFolder.get('store_entryid')
 | 
			
		||||
		});
 | 
			
		||||
@@ -288,9 +293,10 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
 | 
			
		||||
		var newRecords = this.eventgrid.selModel.getSelections();
 | 
			
		||||
		Ext.each(newRecords, function(newRecord) {
 | 
			
		||||
			var record = this.convertToAppointmentRecord(calendarFolder,newRecord.data);
 | 
			
		||||
			calendarStore.add(record);
 | 
			
		||||
			calendarStore.save();
 | 
			
		||||
			console.log(record);
 | 
			
		||||
			calendarStore.add(record);			
 | 
			
		||||
		}, this);
 | 
			
		||||
		calendarStore.save();
 | 
			
		||||
		this.dialog.close();
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -1,133 +0,0 @@
 | 
			
		||||
/*############################################################################################################################
 | 
			
		||||
 * IMPORT PANEL
 | 
			
		||||
 *############################################################################################################################*/
 | 
			
		||||
Ext.namespace("Zarafa.plugins.calendarimporter");    								// Assign the right namespace
 | 
			
		||||
Zarafa.plugins.calendarimporter.ImportPanel = Ext.extend(Ext.form.FormPanel, {
 | 
			
		||||
	constructor: function (a) {
 | 
			
		||||
	    a = a || {};
 | 
			
		||||
	    var b = this;
 | 
			
		||||
	    Ext.apply(a, {
 | 
			
		||||
	        xtype: "calendarimporter.ImportPanel",
 | 
			
		||||
	        layout: {
 | 
			
		||||
	            type: "form",
 | 
			
		||||
	            align: "stretch"
 | 
			
		||||
	        },
 | 
			
		||||
	        anchor: "100%",
 | 
			
		||||
	        bodyStyle: "background-color: inherit;",
 | 
			
		||||
	        defaults: {
 | 
			
		||||
	            border: true,
 | 
			
		||||
	            bodyStyle: "background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;"
 | 
			
		||||
	        },
 | 
			
		||||
	        items: [this.createSelectBox(), this.createUploadField(), this.createSubmitButton(), this.createCancelButton()]
 | 
			
		||||
	    });
 | 
			
		||||
	    Zarafa.plugins.calendarimporter.ImportPanel.superclass.constructor.call(this, a)
 | 
			
		||||
	},
 | 
			
		||||
	createSelectBox: function() {
 | 
			
		||||
		ctx = container.getContextByName('calendar');
 | 
			
		||||
        model = ctx.getModel();
 | 
			
		||||
        defaultFolder = model.getDefaultFolder();
 | 
			
		||||
        subFolders = defaultFolder.getChildren();
 | 
			
		||||
        
 | 
			
		||||
        var myStore = new Ext.data.ArrayStore({
 | 
			
		||||
        	fields: ['calendar_id', 'calendar_displayname'],
 | 
			
		||||
        	idIndex: 0 // id for each record will be the first element
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        /* Calendar Record holds the name and real name of the calender */
 | 
			
		||||
		var CalendarRecord = Ext.data.Record.create([
 | 
			
		||||
			{name: 'realname', type: "string"},
 | 
			
		||||
			{name: 'displayname', type: "string"}
 | 
			
		||||
		]);
 | 
			
		||||
 | 
			
		||||
		/* Store the default folder */
 | 
			
		||||
		var myNewRecord = new CalendarRecord({
 | 
			
		||||
			realname: defaultFolder.getDefaultFolderKey(),
 | 
			
		||||
		    displayname: defaultFolder.getDisplayName()
 | 
			
		||||
		});        
 | 
			
		||||
		myStore.add(myNewRecord);
 | 
			
		||||
        
 | 
			
		||||
        for(i=0;i<subFolders.length;i++) {
 | 
			
		||||
			/* Store all subfolders */
 | 
			
		||||
			myNewRecord = new CalendarRecord({
 | 
			
		||||
				realname: subFolders[i].getDefaultFolderKey(),
 | 
			
		||||
			    displayname: subFolders[i].getDisplayName()
 | 
			
		||||
			});        
 | 
			
		||||
			myStore.add(myNewRecord);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        /* commit the changes to the store */
 | 
			
		||||
        myStore.commitChanges();
 | 
			
		||||
        
 | 
			
		||||
		return {
 | 
			
		||||
            xtype: "selectbox",
 | 
			
		||||
            editable: false,
 | 
			
		||||
            name: "choosen_calendar",
 | 
			
		||||
            width: 100,
 | 
			
		||||
            fieldLabel: "Select a calender",
 | 
			
		||||
            store: myStore,
 | 
			
		||||
            valueField: 'realname',
 | 
			
		||||
            displayField: 'displayname',
 | 
			
		||||
            labelSeperator: ":",
 | 
			
		||||
            border: false,
 | 
			
		||||
            anchor: "100%",
 | 
			
		||||
            scope: this,
 | 
			
		||||
            allowBlank: false
 | 
			
		||||
        }
 | 
			
		||||
	},
 | 
			
		||||
	createUploadField: function() {
 | 
			
		||||
		return {
 | 
			
		||||
            xtype: "fileuploadfield",
 | 
			
		||||
            width: 100,
 | 
			
		||||
        id: 'form-file',    
 | 
			
		||||
	name: 'icspath',
 | 
			
		||||
            fieldLabel: "Upload .ics file",
 | 
			
		||||
            emptyText: 'Select an .ics calendar',
 | 
			
		||||
            labelSeperator: ":",
 | 
			
		||||
            border: false,
 | 
			
		||||
            anchor: "100%",
 | 
			
		||||
            scope: this,
 | 
			
		||||
            allowBlank: false
 | 
			
		||||
        }
 | 
			
		||||
	},
 | 
			
		||||
	createSubmitButton: function() {
 | 
			
		||||
		return {
 | 
			
		||||
            xtype: "button",
 | 
			
		||||
            width: 100,
 | 
			
		||||
            border: false,
 | 
			
		||||
            text: _("Import"),
 | 
			
		||||
            anchor: "100%",
 | 
			
		||||
            handler: this.importAllEvents,
 | 
			
		||||
            scope: this,
 | 
			
		||||
            allowBlank: false
 | 
			
		||||
        }
 | 
			
		||||
	},
 | 
			
		||||
	createCancelButton: function() {
 | 
			
		||||
		return {
 | 
			
		||||
            xtype: "button",
 | 
			
		||||
            width: 100,
 | 
			
		||||
            border: false,
 | 
			
		||||
            text: _("Cancel"),
 | 
			
		||||
            anchor: "100%",
 | 
			
		||||
            handler: this.close,
 | 
			
		||||
            scope: this,
 | 
			
		||||
            allowBlank: false
 | 
			
		||||
        }
 | 
			
		||||
	},
 | 
			
		||||
	close: function () {
 | 
			
		||||
		this.getForm().reset();
 | 
			
		||||
		this.dialog.close()
 | 
			
		||||
	},
 | 
			
		||||
    importAllEvents: function () {
 | 
			
		||||
    	if(this.getForm().isValid()){
 | 
			
		||||
            form_action=1;
 | 
			
		||||
            this.getForm().submit({
 | 
			
		||||
                url: 'plugins/calendarimporter/php/upload.php',
 | 
			
		||||
                waitMsg: 'Uploading file...',
 | 
			
		||||
                success: function(form,action){
 | 
			
		||||
                    msg('Success', 'Processed file on the server');
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportPanel, "calendarimporter.ImportPanel");
 | 
			
		||||
@@ -7,8 +7,8 @@ X-WR-CALNAME:Testkalender
 | 
			
		||||
X-WR-TIMEZONE:Europe/Berlin
 | 
			
		||||
X-WR-CALDESC:Nur zum testen vom Google Kalender
 | 
			
		||||
BEGIN:VEVENT
 | 
			
		||||
DTSTART;VALUE=DATE:20121112
 | 
			
		||||
DTEND;VALUE=DATE:20121116
 | 
			
		||||
DTSTART:20121112T173000Z
 | 
			
		||||
DTEND:20121116T180000Z
 | 
			
		||||
DTSTAMP:20110121T195741Z
 | 
			
		||||
UID:1koigufm110c5hnq6ln57murd4@google.com
 | 
			
		||||
CREATED:20110119T142901Z
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user