diff --git a/js/dialogs/ImportContentPanel.js b/js/dialogs/ImportContentPanel.js new file mode 100644 index 0000000..88f7608 --- /dev/null +++ b/js/dialogs/ImportContentPanel.js @@ -0,0 +1,41 @@ +Ext.namespace("Zarafa.plugins.calendarimporter.dialogs"); + +/** + * @class Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel + * @extends Zarafa.core.ui.ContentPanel + * + * The content panel which shows the hierarchy tree of Owncloud account files. + * @xtype calendarimportercontentpanel + */ +Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { + + /** + * @constructor + * @param config Configuration structure + */ + constructor : function(config) + { + config = config || {}; + + Ext.applyIf(config, { + layout : 'fit', + title : _('Import Calendar File'), + closeOnSave : true, + width : 400, + height : 300, + //Add panel + items : [/* + { + xtype : 'owncloudrcvattachment.folderpanel', + ref : 'treePanel', + response : config.record + }*/ + ] + }); + + Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config); + } + +}); + +Ext.reg('calendarimportercontentpanel' ,Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel); \ No newline at end of file diff --git a/js/calendarimporter.js b/js/dialogs/MainPanel.js similarity index 56% rename from js/calendarimporter.js rename to js/dialogs/MainPanel.js index 21a630f..f6c4c82 100644 --- a/js/calendarimporter.js +++ b/js/dialogs/MainPanel.js @@ -130,88 +130,4 @@ Zarafa.plugins.calendarimporter.ImportPanel = Ext.extend(Ext.form.FormPanel, { } } }); -Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportPanel, "calendarimporter.ImportPanel"); - -/*############################################################################################################################ - * IMPORT DIALOG - *############################################################################################################################*/ -Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace -Zarafa.plugins.calendarimporter.ImportDialog = Ext.extend(Zarafa.core.ui.Dialog, { - constructor: function (a) { - a = a || {}; - Ext.applyIf(a, { - layout: "", - title: _("Calender Import"), - alwaysUseDefaultTitle: true, - useShadowStore: false, - closeOnSave: true, - width : 500, - height : 300, - items: [{ - xtype: "calendarimporter.ImportPanel" - }] - }); - Zarafa.plugins.calendarimporter.ImportDialog.superclass.constructor.call(this, a) - } -}); -Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportDialog, "calendarimporter.ImportDialog"); - -/*############################################################################################################################ - * IMPORT BUTTON - *############################################################################################################################*/ -Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace -Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin - /** - * @constructor - * @param {Object} config Configuration object - * - */ - constructor: function (config) { - config = config || {}; - Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config); - this.init(); - }, - - /** - * Called after constructor. - * Registers insertion point for import button. - * @private - */ - init: function () { - this.registerInsertionPoint("navigation.south", this.createButton, this) - }, - - /** - * Creates the button - * - * @return {Object} Configuration object for a {@link Ext.Button button} - * @private - */ - createButton: function () { // eine Button definition - return { - xtype: "button", - text: _("Import Calendar"), - iconCls: "icon_calendarimporter_button", - navigationContext: container.getContextByName("calendar"), - handler: this.onImportButtonClick, - scope: this - } - }, - - /** - * Clickhandler for the button - */ - onImportButtonClick: function () { - Zarafa.plugins.calendarimporter.ImportDialog.create() - } -}); - - -/*############################################################################################################################ - * STARTUP - *############################################################################################################################*/ -Zarafa.onReady(function() { - if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) { - container.registerPlugin(new Zarafa.plugins.calendarimporter.ImportPlugin) - } -}); +Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportPanel, "calendarimporter.ImportPanel"); \ No newline at end of file diff --git a/js/plugin.calendarimporter.js b/js/plugin.calendarimporter.js new file mode 100644 index 0000000..e8b73ac --- /dev/null +++ b/js/plugin.calendarimporter.js @@ -0,0 +1,106 @@ +Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace + +Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin + /** + * @constructor + * @param {Object} config Configuration object + * + */ + constructor: function (config) { + config = config || {}; + + Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config); + + Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.dialogs.importevents'); + }, + + /** + * initialises insertion point for plugin + * @protected + */ + initPlugin : function() + { + Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments); + + /* add import button to south navigation */ + this.registerInsertionPoint("navigation.south", this.createImportButton, this); + }, + + /** + * Creates the button + * + * @return {Object} Configuration object for a {@link Ext.Button button} + * @private + */ + createImportButton: function () { // eine Button definition + return { + xtype : "button", + text : _("Import Calendar"), + iconCls : "icon_calendarimporter_button", + navigationContext : container.getContextByName("calendar"), + handler : this.onImportButtonClick, + scope : this + } + }, + + /** + * Clickhandler for the button + */ + onImportButtonClick: function () { + Zarafa.core.data.UIFactory.openCreateRecord(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'], undefined, { + manager : Ext.WindowMgr + }); + }, + + /** + * Bid for the type of shared component + * and the given record. + * This will bid on calendar.dialogs.importevents + * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. + * @param {Ext.data.Record} record Optionally passed record. + * @return {Number} The bid for the shared component + */ + bidSharedComponent : function(type, record) + { + var bid = -1; + console.log(type); + console.log(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']); + switch(type) + { + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: + bid = 2; + break; + } + return bid; + }, + + /** + * Will return the reference to the shared component. + * Based on the type of component requested a component is returned. + * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. + * @param {Ext.data.Record} record Optionally passed record. + * @return {Ext.Component} Component + */ + getSharedComponent : function(type, record) + { + var component; + switch(type) + { + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: + component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel; + break; + } + + return component; + } +}); + + +/*############################################################################################################################ + * STARTUP + *############################################################################################################################*/ +Zarafa.onReady(function() { + if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) { + container.registerPlugin(new Zarafa.plugins.calendarimporter.ImportPlugin) + } +}); diff --git a/manifest.xml b/manifest.xml index 1598d21..52879fe 100644 --- a/manifest.xml +++ b/manifest.xml @@ -19,11 +19,16 @@ php/plugin.calendarimporter.php - js/calendarimporter.js - js/calendarimporter.js + js/plugin.calendarimporter.js + js/dialogs/ImportContentPanel.js + + js/plugin.calendarimporter.js + js/dialogs/ImportContentPanel.js resources/css/calendarimporter.css + + resources/css/calendarimporter.css