From 47f9f80e612f14017e7068b60d9eb74f9adfb0b7 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 5 Jul 2023 14:25:48 -0600 Subject: [PATCH] Importexport: Hide preview when import complete or aborted due to errors --- .../inc/class.importexport_import_ui.inc.php | 12 ++++++--- importexport/js/app.ts | 25 +++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index 7bcc5df561..2698ac652e 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -127,8 +127,11 @@ use EGroupware\Api\Etemplate; // Set this so plugin doesn't do any data changes $content['dry-run'] = true; importexport_helper_functions::$dry_run = true; - $this->message .= '' . lang('Import aborted').":
\n"; + $this->message .= '' . lang('Import aborted') . ":
\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 .= '' . lang('test only').":
\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) { diff --git a/importexport/js/app.ts b/importexport/js/app.ts index fbc44a4285..a9f5d42905 100644 --- a/importexport/js/app.ts +++ b/importexport/js/app.ts @@ -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,13 +157,19 @@ 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 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',{ + egw.open_link(egw.link('/index.php', { menuaction: 'importexport.importexport_' + data.type + '_ui.' + data.type + '_dialog', appname: data.application, definition: data.definition_id