2013-11-01 23:04:43 +01:00
|
|
|
/**
|
|
|
|
* EGroupware - Import/Export - Javascript UI
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package importexport
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @copyright (c) 2013 Nathan Gray
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* JS for Import/Export
|
|
|
|
*
|
|
|
|
* @augments AppJS
|
|
|
|
*/
|
2013-11-04 21:54:23 +01:00
|
|
|
app.classes.importexport = AppJS.extend(
|
2013-11-01 23:04:43 +01:00
|
|
|
{
|
|
|
|
appname: 'importexport',
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @memberOf app.timesheet
|
|
|
|
*/
|
|
|
|
init: function()
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
destroy: function()
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
/**
|
|
|
|
* This function is called when the etemplate2 object is loaded
|
|
|
|
* and ready. If you must store a reference to the et2 object,
|
|
|
|
* make sure to clean it up in destroy().
|
|
|
|
*
|
|
|
|
* @param et2 etemplate2 Newly ready object
|
|
|
|
*/
|
|
|
|
et2_ready: function(et2)
|
|
|
|
{
|
|
|
|
// call parent
|
|
|
|
this._super.apply(this, arguments);
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2016-02-17 17:05:30 +01:00
|
|
|
if(this.et2.getWidgetById('export'))
|
2013-11-01 23:04:43 +01:00
|
|
|
{
|
2016-02-17 17:05:30 +01:00
|
|
|
if(!this.et2.getArrayMgr("content").getEntry("definition"))
|
|
|
|
{
|
|
|
|
// et2 doesn't understand a disabled button in the normal sense
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(this.et2.getWidgetById('export').getDOMNode()).attr('disabled','disabled');
|
|
|
|
jQuery(this.et2.getWidgetById('preview').getDOMNode()).attr('disabled','disabled');
|
2016-02-17 17:05:30 +01:00
|
|
|
}
|
|
|
|
if(!this.et2.getArrayMgr("content").getEntry("filter"))
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery('input[value="filter"]').parent().hide();
|
2016-02-17 17:05:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable / hide definition filter if not selected
|
|
|
|
if(this.et2.getArrayMgr("content").getEntry("selection") != 'filter')
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery('div.filters').hide();
|
2016-02-17 17:05:30 +01:00
|
|
|
}
|
2013-11-01 23:04:43 +01:00
|
|
|
}
|
|
|
|
},
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
export_preview: function(event, widget)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
var preview = jQuery(widget.getRoot().getWidgetById('preview_box').getDOMNode());
|
|
|
|
jQuery('.content',preview).empty()
|
2015-09-03 01:22:12 +02:00
|
|
|
.append('<div class="loading" style="width:100%;height:100%"></div>');
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
preview
|
|
|
|
.show(100, jQuery.proxy(function() {
|
|
|
|
widget.clicked = true;
|
|
|
|
widget.getInstanceManager().submit(false, true);
|
|
|
|
widget.clicked = false;
|
|
|
|
},this));
|
|
|
|
return false;
|
|
|
|
},
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
import_preview: function(event, widget)
|
|
|
|
{
|
|
|
|
var test = widget.getRoot().getWidgetById('dry-run');
|
2014-06-04 16:35:20 +02:00
|
|
|
if(test.getValue() == test.options.unselected_value) return true;
|
2013-11-04 21:54:23 +01:00
|
|
|
|
2013-11-01 23:04:43 +01:00
|
|
|
// Show preview
|
2016-06-02 16:51:15 +02:00
|
|
|
var preview = jQuery(widget.getRoot().getWidgetById('preview_box').getDOMNode());
|
|
|
|
jQuery('.content',preview).empty();
|
2013-11-01 23:04:43 +01:00
|
|
|
preview
|
|
|
|
.addClass('loading')
|
|
|
|
.show(100, jQuery.proxy(function() {
|
|
|
|
widget.clicked = true;
|
|
|
|
widget.getInstanceManager().submit(false, true);
|
2014-07-15 20:09:20 +02:00
|
|
|
widget.clicked = false;
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(widget.getRoot().getWidgetById('preview_box').getDOMNode())
|
2014-07-15 20:09:20 +02:00
|
|
|
.removeClass('loading');
|
2013-11-01 23:04:43 +01:00
|
|
|
},this));
|
|
|
|
return false;
|
2014-05-13 23:21:56 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a popup to run a given definition
|
|
|
|
*
|
|
|
|
* @param {egwAction} action
|
|
|
|
* @param {egwActionObject[]} selected
|
|
|
|
*/
|
|
|
|
run_definition: function(action, selected)
|
|
|
|
{
|
|
|
|
if(!selected || selected.length != 1) return;
|
|
|
|
|
|
|
|
var id = selected[0].id||null;
|
|
|
|
var data = egw.dataGetUIDdata(id).data;
|
|
|
|
if(!data || !data.type) return;
|
|
|
|
|
|
|
|
egw.open_link(egw.link('/index.php',{
|
|
|
|
menuaction: 'importexport.importexport_' + data.type + '_ui.' + data.type + '_dialog',
|
|
|
|
appname: data.application,
|
|
|
|
definition: data.definition_id
|
|
|
|
}), false, '850x440', app);
|
2014-07-15 20:09:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allowed users widget has been changed, if 'All users' or 'Just me'
|
|
|
|
* was selected, turn off any other options.
|
|
|
|
*/
|
|
|
|
allowed_users_change: function(node, widget)
|
|
|
|
{
|
|
|
|
var value = widget.getValue();
|
|
|
|
|
|
|
|
// Only 1 selected, no checking needed
|
2015-03-02 18:17:14 +01:00
|
|
|
if(value == null || value.length <= 1) return;
|
2014-07-15 20:09:20 +02:00
|
|
|
|
|
|
|
// Don't jump it to the top, it's weird
|
|
|
|
widget.selected_first = false;
|
|
|
|
|
|
|
|
var index = null;
|
|
|
|
var specials = ['','all']
|
|
|
|
for(var i = 0; i < specials.length; i++)
|
|
|
|
{
|
|
|
|
var special = specials[i];
|
|
|
|
if((index = value.indexOf(special)) >= 0)
|
|
|
|
{
|
|
|
|
if(window.event.target.value == special)
|
|
|
|
{
|
|
|
|
// Just clicked all/private, clear the others
|
|
|
|
value = [special];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Just added another, clear special
|
|
|
|
value.splice(index,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// A little highlight to call attention to the change
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery('input[value="'+special+'"]',node).parent().parent().effect('highlight',{},500);
|
2014-07-15 20:09:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(index >= 0)
|
|
|
|
{
|
|
|
|
widget.set_value(value);
|
|
|
|
}
|
2013-11-01 23:04:43 +01:00
|
|
|
}
|
|
|
|
});
|