From 8a5d0c3b13367b9eaa7098a41c9c34e330f66338 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 15 Oct 2017 13:45:35 -0600 Subject: [PATCH] Correct row numbers displayed in the import result form (#3136) * Add support for a source index offset Improves the reporting of errors in the importing process by getting the correct offset for the displayed row where the error took place. * Add the source index offset to the row number Refs https://github.com/octobercms/october/commit/ce6df84b04a6961a0cb31abdb95af2bd5558773b --- .../backend/behaviors/ImportExportController.php | 13 +++++++++++++ .../partials/_import_result_form.htm | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 3cba09ca1..6b371f68b 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -210,6 +210,8 @@ class ImportExportController extends ControllerBehavior catch (Exception $ex) { $this->controller->handleError($ex); } + + $this->vars['sourceIndexOffset'] = $this->getImportSourceIndexOffset($importOptions['firstRowTitles']); return $this->importExportMakePartial('import_result_form'); } @@ -332,6 +334,17 @@ class ImportExportController extends ControllerBehavior return $firstRow; } + + /** + * Get the index offset to add to the reported row number in status messages + * + * @param bool $firstRowTitles Whether or not the first row contains column titles + * @return int $offset + */ + protected function getImportSourceIndexOffset($firstRowTitles) + { + return $firstRowTitles ? 2 : 1; + } protected function makeImportUploadFormWidget() { diff --git a/modules/backend/behaviors/importexportcontroller/partials/_import_result_form.htm b/modules/backend/behaviors/importexportcontroller/partials/_import_result_form.htm index 6a3cd1c40..c67f7cdd3 100644 --- a/modules/backend/behaviors/importexportcontroller/partials/_import_result_form.htm +++ b/modules/backend/behaviors/importexportcontroller/partials/_import_result_form.htm @@ -61,7 +61,7 @@