Cleanup export JS code
This commit is contained in:
@@ -34,6 +34,59 @@ Ext.namespace('Zarafa.plugins.calendarimporter.data');
|
||||
* @singleton
|
||||
*/
|
||||
Zarafa.plugins.calendarimporter.data.Actions = {
|
||||
/**
|
||||
* Generates a request to download the selected records as vCard.
|
||||
*
|
||||
* @param storeId
|
||||
* @param recordIds
|
||||
*/
|
||||
exportToICS: function (storeId, recordIds, recordFolder) {
|
||||
if((typeof recordIds != "undefined" && recordIds.length < 1) || (typeof recordFolder != "undefined" && recordFolder.get('content_count') < 1)) {
|
||||
Zarafa.common.dialogs.MessageBox.show({
|
||||
title: dgettext('plugin_calendarimporter', 'Error'),
|
||||
msg: dgettext('plugin_calendarimporter', 'No events found. Export skipped!'),
|
||||
icon: Zarafa.common.dialogs.MessageBox.ERROR,
|
||||
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||
});
|
||||
} else {
|
||||
|
||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS
|
||||
});
|
||||
|
||||
var recordcount = 0;
|
||||
var exportPayload = {
|
||||
storeid: storeId,
|
||||
records: undefined,
|
||||
folder: undefined
|
||||
};
|
||||
|
||||
if(typeof recordIds != "undefined") {
|
||||
exportPayload.records = recordIds;
|
||||
recordcount = recordIds.length;
|
||||
}
|
||||
|
||||
if(typeof recordFolder != "undefined") {
|
||||
exportPayload.folder = recordFolder.get("entryid");
|
||||
recordcount = recordFolder.get('content_count');
|
||||
}
|
||||
|
||||
// Notify user
|
||||
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
|
||||
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Calendar Export'), String.format(dgettext('plugin_calendarimporter', 'Exporting {0} events. Please wait...'), recordcount));
|
||||
|
||||
|
||||
|
||||
// request attachment preperation
|
||||
container.getRequest().singleRequest(
|
||||
'calendarmodule',
|
||||
'export',
|
||||
exportPayload,
|
||||
responseHandler
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the export request.
|
||||
* @param {Object} response
|
||||
|
@@ -95,26 +95,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
recordIds.push(btn.records[i].get("entryid"));
|
||||
}
|
||||
|
||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS,
|
||||
scope: this
|
||||
});
|
||||
|
||||
// Notify user
|
||||
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
|
||||
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Calendar Export'), String.format(dgettext('plugin_calendarimporter', 'Exporting {0} events. Please wait...'), recordIds.length));
|
||||
|
||||
|
||||
// request attachment preperation
|
||||
container.getRequest().singleRequest(
|
||||
'calendarmodule',
|
||||
'export',
|
||||
{
|
||||
storeid: btn.records[0].get("store_entryid"),
|
||||
records: recordIds
|
||||
},
|
||||
responseHandler
|
||||
);
|
||||
Zarafa.plugins.calendarimporter.data.Actions.exportToICS(btn.records[0].get("store_entryid"), recordIds, undefined);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -94,25 +94,7 @@ Zarafa.plugins.calendarimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.
|
||||
* @private
|
||||
*/
|
||||
onContextItemExport: function () {
|
||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS,
|
||||
scope: this
|
||||
});
|
||||
|
||||
// Notify user
|
||||
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
|
||||
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Calendar Export'), String.format(dgettext('plugin_calendarimporter', 'Exporting {0} events. Please wait...'), this.records.get('content_count')));
|
||||
|
||||
// request attachment preperation
|
||||
container.getRequest().singleRequest(
|
||||
'calendarmodule',
|
||||
'export',
|
||||
{
|
||||
storeid: this.records.get("store_entryid"),
|
||||
folder: this.records.get("entryid")
|
||||
},
|
||||
responseHandler
|
||||
);
|
||||
Zarafa.plugins.calendarimporter.data.Actions.exportToICS(this.records.get("store_entryid"), undefined, this.records);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user