Modular code for tbl_find_replace.php

Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
This commit is contained in:
Piyush Vijay 2018-08-09 03:25:50 +05:30
parent 65a54b8d74
commit 0ce9714c19
3 changed files with 54 additions and 3 deletions

View File

@ -43,7 +43,7 @@ const PhpToJsFileMapping = {
tbl_change: ['sql', 'tbl_change'],
tbl_select: ['sql', 'tbl_change', 'tbl_select'],
tbl_zoom_select: ['sql', 'tbl_change'],
tbl_find_replace: ['']
tbl_find_replace: ['tbl_find_replace']
};
const JsFileList = [
@ -81,7 +81,8 @@ const JsFileList = [
'tbl_operations',
'tbl_tracking',
'tbl_change',
'tbl_select'
'tbl_select',
'tbl_find_replace'
];
export {

View File

@ -0,0 +1,50 @@
import { PMA_Messages as PMA_messages } from './variables/export_variables';
import { PMA_prepareForAjaxRequest } from './functions/AjaxRequest';
import { PMA_ajaxRemoveMessage, PMA_ajaxShowMessage } from './utils/show_ajax_messages';
/**
* Unbind all event handlers before tearing down a page
*/
export function teardownTblFindReplace () {
$('#find_replace_form').off('submit');
$('#toggle_find').off('click');
}
/**
* Bind events
*/
export function onloadTblFindReplace () {
$('<div id="toggle_find_div"><a id="toggle_find"></a></div>')
.insertAfter('#find_replace_form')
.hide();
$('#toggle_find')
.html(PMA_messages.strHideFindNReplaceCriteria)
.on('click', function () {
var $link = $(this);
$('#find_replace_form').slideToggle();
if ($link.text() === PMA_messages.strHideFindNReplaceCriteria) {
$link.text(PMA_messages.strShowFindNReplaceCriteria);
} else {
$link.text(PMA_messages.strHideFindNReplaceCriteria);
}
return false;
});
$('#find_replace_form').submit(function (e) {
e.preventDefault();
var findReplaceForm = $('#find_replace_form');
PMA_prepareForAjaxRequest(findReplaceForm);
var $msgbox = PMA_ajaxShowMessage();
$.post(findReplaceForm.attr('action'), findReplaceForm.serialize(), function (data) {
PMA_ajaxRemoveMessage($msgbox);
if (data.success === true) {
$('#toggle_find_div').show();
$('#toggle_find').trigger('click');
$('#sqlqueryresultsouter').html(data.preview);
} else {
$('#sqlqueryresultsouter').html(data.error);
}
});
});
}

View File

@ -197,7 +197,7 @@ class TableSearchController extends TableController
$this->response
->getHeader()
->getScripts()
->addFile('tbl_find_replace.js');
->addFile('tbl_find_replace');
if (isset($_POST['replace'])) {
$this->replaceAction();