Skip to content

Commit

Permalink
Move input.sqlbutton event listener to sql.js file
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Jun 19, 2022
1 parent b9fa83c commit f5d738d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 0 additions & 8 deletions js/src/functions.js
Expand Up @@ -1395,14 +1395,12 @@ AJAX.registerTeardown('functions.js', function () {
$(document).off('click', 'a.inline_edit_sql');
$(document).off('click', 'input#sql_query_edit_save');
$(document).off('click', 'input#sql_query_edit_discard');
$('input.sqlbutton').off('click');
if (codeMirrorEditor) {
codeMirrorEditor.off('blur');
} else {
$(document).off('blur', '#sqlquery');
}
$(document).off('change', '#parameterized');
$(document).off('click', 'input.sqlbutton');
$('#sqlquery').off('keydown');
$('#sql_query_edit').off('keydown');

Expand Down Expand Up @@ -1484,12 +1482,6 @@ AJAX.registerOnload('functions.js', function () {
$divEditor.remove();
});

$(document).on('click', 'input.sqlbutton', function (evt) {
Functions.insertQuery(evt.target.id);
Functions.handleSimulateQueryButton();
return false;
});

$(document).on('change', '#parameterized', Functions.updateQueryParameters);

var $inputUsername = $('#input_username');
Expand Down
9 changes: 8 additions & 1 deletion js/src/sql.js
Expand Up @@ -214,6 +214,7 @@ AJAX.registerTeardown('sql.js', function () {
$(document).off('submit', '.maxRowsForm');
$(document).off('click', '#view_as');
$(document).off('click', '#sqlquery');
$(document).off('click', 'input.sqlbutton');
});

/**
Expand Down Expand Up @@ -851,7 +852,13 @@ AJAX.registerOnload('sql.js', function () {
Functions.selectContent(this);
}
});
}); // end $()

$(document).on('click', 'input.sqlbutton', function (evt) {
Functions.insertQuery(evt.target.id);
Functions.handleSimulateQueryButton();
return false;
});
});

/**
* Starting from some th, change the class of all td under it.
Expand Down
1 change: 1 addition & 0 deletions libraries/classes/Controllers/Table/TrackingController.php
Expand Up @@ -194,6 +194,7 @@ public function __invoke(): void

$sqlDump = '';
if (isset($_POST['report_export']) && $_POST['export_type'] === 'sqldump') {
$this->addScriptFiles(['sql.js']);
$sqlDump = $this->tracking->exportAsSqlDump($GLOBALS['db'], $GLOBALS['table'], $GLOBALS['entries']);
}

Expand Down
2 changes: 2 additions & 0 deletions libraries/classes/Controllers/View/CreateController.php
Expand Up @@ -281,6 +281,8 @@ public function __invoke(ServerRequest $request): void
$GLOBALS['urlParams']['db'] = $GLOBALS['db'];
$GLOBALS['urlParams']['reload'] = 1;

$this->addScriptFiles(['sql.js']);

echo $this->template->render('view_create', [
'ajax_dialog' => isset($_POST['ajax_dialog']),
'text_dir' => $GLOBALS['text_dir'],
Expand Down

0 comments on commit f5d738d

Please sign in to comment.