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

@ -129,6 +129,9 @@ use EGroupware\Api\Etemplate;
importexport_helper_functions::$dry_run = true;
$this->message .= '<b>' . lang('Import aborted') . ":</b><br />\n";
$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))
{
@ -149,6 +152,9 @@ use EGroupware\Api\Etemplate;
{
importexport_helper_functions::$dry_run = false;
$count = $plugin->import($file, $definition_obj);
// Close preview
EGroupware\Api\Json\Response::get()->call('app.importexport.closePreview');
}
}
else
@ -160,12 +166,12 @@ use EGroupware\Api\Etemplate;
{
$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
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;
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());
// TD gets the class too
preview.parent().show();
jQuery('.content', preview).empty();
jQuery('.content', preview).empty().text(this.egw.lang("Please wait..."));
preview
.removeClass("hideme")
.addClass('loading')
.show(100, jQuery.proxy(function()
{
@ -140,6 +141,14 @@ class ImportExportApp extends EgwApp
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
*
@ -148,11 +157,17 @@ class ImportExportApp extends EgwApp
*/
run_definition(action, selected)
{
if(!selected || selected.length != 1) return;
if(!selected || selected.length != 1)
{
return;
}
var id = selected[0].id || null;
var data = egw.dataGetUIDdata(id).data;
if(!data || !data.type) return;
if(!data || !data.type)
{
return;
}
egw.open_link(egw.link('/index.php', {
menuaction: 'importexport.importexport_' + data.type + '_ui.' + data.type + '_dialog',