Importexport: Hide preview when import complete or aborted due to errors

This commit is contained in:
nathan 2023-07-05 14:25:48 -06:00
parent 6ace2c1fbc
commit 47f9f80e61
2 changed files with 29 additions and 8 deletions

View File

@ -127,8 +127,11 @@ use EGroupware\Api\Etemplate;
// Set this so plugin doesn't do any data changes // Set this so plugin doesn't do any data changes
$content['dry-run'] = true; $content['dry-run'] = true;
importexport_helper_functions::$dry_run = true; importexport_helper_functions::$dry_run = true;
$this->message .= '<b>' . lang('Import aborted').":</b><br />\n"; $this->message .= '<b>' . lang('Import aborted') . ":</b><br />\n";
$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
// Close preview
EGroupware\Api\Json\Response::get()->call('app.importexport.closePreview');
} }
if(count($check_message)) if(count($check_message))
{ {
@ -149,6 +152,9 @@ use EGroupware\Api\Etemplate;
{ {
importexport_helper_functions::$dry_run = false; importexport_helper_functions::$dry_run = false;
$count = $plugin->import($file, $definition_obj); $count = $plugin->import($file, $definition_obj);
// Close preview
EGroupware\Api\Json\Response::get()->call('app.importexport.closePreview');
} }
} }
else else
@ -160,12 +166,12 @@ use EGroupware\Api\Etemplate;
{ {
$this->message .= '<b>' . lang('test only').":</b><br />\n"; $this->message .= '<b>' . lang('test only').":</b><br />\n";
} }
$this->message .= lang('%1 records processed', $count); $this->message .= lang('%1 records processed', $count ?? 0);
// Refresh opening window // Refresh opening window
if(!$content['dry-run']) if(!$content['dry-run'])
{ {
Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); Framework::refresh_opener(lang('%1 records processed', $count ?? 0), $appname, null, null, $appname);
} }
$total_processed = 0; $total_processed = 0;
foreach($plugin->get_results() as $action => $a_count) { foreach($plugin->get_results() as $action => $a_count) {

View File

@ -126,8 +126,9 @@ class ImportExportApp extends EgwApp
var preview = jQuery(widget.getRoot().getWidgetById('preview_box').getDOMNode()); var preview = jQuery(widget.getRoot().getWidgetById('preview_box').getDOMNode());
// TD gets the class too // TD gets the class too
preview.parent().show(); preview.parent().show();
jQuery('.content', preview).empty(); jQuery('.content', preview).empty().text(this.egw.lang("Please wait..."));
preview preview
.removeClass("hideme")
.addClass('loading') .addClass('loading')
.show(100, jQuery.proxy(function() .show(100, jQuery.proxy(function()
{ {
@ -140,6 +141,14 @@ class ImportExportApp extends EgwApp
return false; return false;
} }
closePreview()
{
const preview = jQuery(this.et2.getWidgetById("preview_box"));
// TD gets the class too
preview.parent().hide();
}
/** /**
* Open a popup to run a given definition * Open a popup to run a given definition
* *
@ -148,13 +157,19 @@ class ImportExportApp extends EgwApp
*/ */
run_definition(action, selected) run_definition(action, selected)
{ {
if(!selected || selected.length != 1) return; if(!selected || selected.length != 1)
{
return;
}
var id = selected[0].id||null; var id = selected[0].id || null;
var data = egw.dataGetUIDdata(id).data; var data = egw.dataGetUIDdata(id).data;
if(!data || !data.type) return; if(!data || !data.type)
{
return;
}
egw.open_link(egw.link('/index.php',{ egw.open_link(egw.link('/index.php', {
menuaction: 'importexport.importexport_' + data.type + '_ui.' + data.type + '_dialog', menuaction: 'importexport.importexport_' + data.type + '_ui.' + data.type + '_dialog',
appname: data.application, appname: data.application,
definition: data.definition_id definition: data.definition_id