Skip to content

Commit

Permalink
Merge pull request #17608 from MauricioFauth/sidebar-index-links
Browse files Browse the repository at this point in the history
Fix preview SQL modal not working inside Index modal
Fixes #17606
  • Loading branch information
MauricioFauth committed Jun 16, 2022
2 parents dbf52a9 + bf2add8 commit b6ba539
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion js/src/functions.js
Expand Up @@ -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) {
Expand Down
20 changes: 0 additions & 20 deletions js/src/navigation.js
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions libraries/classes/Controllers/Table/IndexesController.php
Expand Up @@ -147,6 +147,7 @@ private function displayForm(Index $index): void
'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']),
]);
}
}
1 change: 0 additions & 1 deletion templates/footer.twig
@@ -1,4 +1,3 @@
{{ include('modals/index_dialog_modal.twig') -}}
{% if not is_ajax %}
</div>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions templates/navigation/tree/node.twig
Expand Up @@ -35,6 +35,10 @@

{% if node_is_container %}
&nbsp;<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 -}}
Expand Down
7 changes: 7 additions & 0 deletions templates/table/index_form.twig
Expand Up @@ -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">
Expand Down Expand Up @@ -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 %}
5 changes: 2 additions & 3 deletions test/classes/FooterTest.php
Expand Up @@ -7,7 +7,6 @@
use ArrayIterator;
use PhpMyAdmin\ErrorHandler;
use PhpMyAdmin\Footer;
use PhpMyAdmin\Template;

use function json_encode;

Expand Down Expand Up @@ -125,7 +124,7 @@ public function testAjax(): void
$footer = new Footer();
$footer->setAjax(true);
$this->assertEquals(
(new Template())->render('modals/index_dialog_modal'),
'',
$footer->getDisplay()
);
}
Expand Down Expand Up @@ -164,7 +163,7 @@ public function testMinimal(): void
$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()
);
}
Expand Down

0 comments on commit b6ba539

Please sign in to comment.