diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-06-16 02:09:13 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-06-16 02:09:13 +0300 |
commit | bf2add8312324bda0af07d4256319752e2d37036 (patch) | |
tree | f092791257e6ff959f1abf9d8f5e0325e90da647 | |
parent | dbf52a93f7b1e596c8b7717fa3ea0a4bd59ab91e (diff) |
Fix preview SQL modal not working inside Index modal
- Fixes #17606
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
-rw-r--r-- | js/src/functions.js | 2 | ||||
-rw-r--r-- | js/src/navigation.js | 20 | ||||
-rw-r--r-- | libraries/classes/Controllers/Table/IndexesController.php | 1 | ||||
-rw-r--r-- | templates/footer.twig | 1 | ||||
-rw-r--r-- | templates/navigation/tree/node.twig | 4 | ||||
-rw-r--r-- | templates/table/index_form.twig | 7 | ||||
-rw-r--r-- | test/classes/FooterTest.php | 5 |
7 files changed, 15 insertions, 25 deletions
diff --git a/js/src/functions.js b/js/src/functions.js index ee563379f3..d2b3179e40 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -3438,7 +3438,7 @@ Functions.indexDialogModal = function (routeUrl, url, title, callbackSuccess, ca .insertAfter('#index_header'); var $editIndexDialog = $('#indexDialogModal'); if ($editIndexDialog.length > 0) { - $editIndexDialog.dialog('close'); + $editIndexDialog.modal('hide'); } $('div.no_indexes_defined').hide(); if (callbackSuccess) { diff --git a/js/src/navigation.js b/js/src/navigation.js index d89b1b1439..4562a3fd9c 100644 --- a/js/src/navigation.js +++ b/js/src/navigation.js @@ -444,26 +444,6 @@ $(function () { } ); - /** New index */ - $(document).on('click', '#pma_navigation_tree li.new_index a.ajax', function (event) { - event.preventDefault(); - var url = $(this).attr('href').substr( - $(this).attr('href').indexOf('?') + 1 - ) + CommonParams.get('arg_separator') + 'ajax_request=true'; - var title = Messages.strAddIndex; - Functions.indexEditorDialog(url, title); - }); - - /** Edit index */ - $(document).on('click', 'li.index a.ajax', function (event) { - event.preventDefault(); - var url = $(this).attr('href').substr( - $(this).attr('href').indexOf('?') + 1 - ) + CommonParams.get('arg_separator') + 'ajax_request=true'; - var title = Messages.strEditIndex; - Functions.indexEditorDialog(url, title); - }); - /** New view */ $(document).on('click', 'li.new_view a.ajax', function (event) { event.preventDefault(); diff --git a/libraries/classes/Controllers/Table/IndexesController.php b/libraries/classes/Controllers/Table/IndexesController.php index d5f9768e63..686bf0714e 100644 --- a/libraries/classes/Controllers/Table/IndexesController.php +++ b/libraries/classes/Controllers/Table/IndexesController.php @@ -147,6 +147,7 @@ class IndexesController extends AbstractController 'add_fields' => $add_fields, 'create_edit_table' => isset($_POST['create_edit_table']), 'default_sliders_state' => $GLOBALS['cfg']['InitialSlidersState'], + 'is_from_nav' => isset($_POST['is_from_nav']), ]); } } diff --git a/templates/footer.twig b/templates/footer.twig index 7949109ede..de9e8b2b35 100644 --- a/templates/footer.twig +++ b/templates/footer.twig @@ -1,4 +1,3 @@ -{{ include('modals/index_dialog_modal.twig') -}} {% if not is_ajax %} </div> {% endif %} diff --git a/templates/navigation/tree/node.twig b/templates/navigation/tree/node.twig index fc1fb00f23..060a26ebe7 100644 --- a/templates/navigation/tree/node.twig +++ b/templates/navigation/tree/node.twig @@ -35,6 +35,10 @@ {% if node_is_container %} <a class="hover_show_full" href="{{ url(text_link.route, text_link.params) }}">{{ node.name }}</a> + {% elseif 'index' in node.classes %} + <a class="hover_show_full" href="{{ url(text_link.route) }}" data-post="{{ get_common(text_link.params|merge({'is_from_nav': true})) }}" title="{{ text_link.title }}"> + {{- node.displayName ?? node.realName -}} + </a> {% else %} <a class="hover_show_full{{ text_link.is_ajax ? ' ajax' }}" href="{{ url(text_link.route, text_link.params) }}" title="{{ text_link.title }}"> {{- node.displayName ?? node.realName -}} diff --git a/templates/table/index_form.twig b/templates/table/index_form.twig index 1d0f9f7102..ac79ee9aed 100644 --- a/templates/table/index_form.twig +++ b/templates/table/index_form.twig @@ -5,6 +5,9 @@ class="ajax"> {{ get_hidden_inputs(form_params) }} + {% if is_from_nav %} + <input type="hidden" name="do_save_data" value="1"> + {% endif %} <fieldset class="pma-fieldset" id="index_edit_fields"> <div class="index_info"> @@ -237,6 +240,10 @@ </div> </fieldset> <fieldset class="pma-fieldset tblFooters"> + <button class="btn btn-primary" type="submit">{% trans 'Go' %}</button> <button class="btn btn-secondary" type="submit" id="preview_index_frm">{% trans 'Preview SQL' %}</button> </fieldset> </form> +{% if is_from_nav %} + {{ include('modals/preview_sql_modal.twig') }} +{% endif %} diff --git a/test/classes/FooterTest.php b/test/classes/FooterTest.php index 9e66a65955..679734704f 100644 --- a/test/classes/FooterTest.php +++ b/test/classes/FooterTest.php @@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests; use ArrayIterator; use PhpMyAdmin\ErrorHandler; use PhpMyAdmin\Footer; -use PhpMyAdmin\Template; use function json_encode; @@ -125,7 +124,7 @@ class FooterTest extends AbstractTestCase $footer = new Footer(); $footer->setAjax(true); $this->assertEquals( - (new Template())->render('modals/index_dialog_modal'), + '', $footer->getDisplay() ); } @@ -164,7 +163,7 @@ class FooterTest extends AbstractTestCase $footer = new Footer(); $footer->setMinimal(); $this->assertEquals( - (new Template())->render('modals/index_dialog_modal') . " </div>\n </body>\n</html>\n", + " </div>\n </body>\n</html>\n", $footer->getDisplay() ); } |