From 157c072c3ccb8a2cfebeed5d19f784ae8ffc234a Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 25 Aug 2021 17:47:33 +0200 Subject: [PATCH] Fix #16693 - Show the new column and the table structure on the same page Signed-off-by: William Desportes --- js/src/table/structure.js | 16 ++++++++++++++-- .../Controllers/Table/AddFieldController.php | 10 ++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/js/src/table/structure.js b/js/src/table/structure.js index c8ebbd8a0c..7539b7c27c 100644 --- a/js/src/table/structure.js +++ b/js/src/table/structure.js @@ -91,12 +91,24 @@ AJAX.registerOnload('table/structure.js', function () { .show(); Functions.highlightSql($('#page_content')); $('.result_query .alert-primary').remove(); - reloadFieldForm(); + if (typeof data.structure_refresh_route !== 'string') { + // Do not reload the form when the code below freshly filled it + reloadFieldForm(); + } $form.remove(); Functions.ajaxRemoveMessage($msg); Functions.initSlider(); Navigation.reload(); - CommonActions.refreshMain('index.php?route=/table/structure'); + if (typeof data.structure_refresh_route === 'string') { + // Fetch the table structure right after adding a new column + $.get(data.structure_refresh_route, function (data) { + if (typeof data.success !== 'undefined' && data.success === true) { + $('#page_content').append(data.message).show(); + } + }); + } else { + CommonActions.refreshMain('index.php?route=/table/structure'); + } } else { Functions.ajaxShowMessage(data.error, false); } diff --git a/libraries/classes/Controllers/Table/AddFieldController.php b/libraries/classes/Controllers/Table/AddFieldController.php index 37eef993cf..6420b2cc03 100644 --- a/libraries/classes/Controllers/Table/AddFieldController.php +++ b/libraries/classes/Controllers/Table/AddFieldController.php @@ -159,6 +159,16 @@ class AddFieldController extends AbstractController Generator::getMessage($message, $sql_query, 'success') ); + // Give an URL to call and use to appends the structure after the success message + $this->response->addJSON( + 'structure_refresh_route', + Url::getFromRoute('/table/structure', [ + 'db' => $db, + 'table' => $table, + 'ajax_request' => '1', + ]) + ); + return; }