Add modular Sql.js to table sql and database sql and SqlQueryForm modified accordingly
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
This commit is contained in:
parent
661c9f74d4
commit
3ae93ad307
@ -24,9 +24,7 @@ PageSettings::showGroup('Sql');
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
|
||||
$scripts->addFile('sql.js');
|
||||
$scripts->addFile('sql');
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
|
||||
|
||||
@ -23,7 +23,9 @@ const files = {
|
||||
server_export: ['export'],
|
||||
server_import: ['import'],
|
||||
db_search: ['db_search', 'sql'],
|
||||
server_sql: ['sql']
|
||||
server_sql: ['sql'],
|
||||
tbl_sql: ['sql'],
|
||||
db_sql: ['sql']
|
||||
};
|
||||
|
||||
export default files;
|
||||
|
||||
49
js/src/functions/Sql/ForeignKey.js
Normal file
49
js/src/functions/Sql/ForeignKey.js
Normal file
@ -0,0 +1,49 @@
|
||||
import { PMA_getImage } from '../get_image';
|
||||
import PMA_commonParams from '../../variables/common_params';
|
||||
import { PMA_Messages as PMA_messages } from '../../variables/export_variables';
|
||||
/**
|
||||
* Get checkbox for foreign key checks
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
export function getForeignKeyCheckboxLoader () {
|
||||
var html = '';
|
||||
html += '<div>';
|
||||
html += '<div class="load-default-fk-check-value">';
|
||||
html += PMA_getImage('ajax_clock_small');
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
export function loadForeignKeyCheckbox () {
|
||||
// Load default foreign key check value
|
||||
var params = {
|
||||
'ajax_request': true,
|
||||
'server': PMA_commonParams.get('server'),
|
||||
'get_default_fk_check_value': true
|
||||
};
|
||||
$.get('sql.php', params, function (data) {
|
||||
var html = '<input type="hidden" name="fk_checks" value="0" />' +
|
||||
'<input type="checkbox" name="fk_checks" id="fk_checks"' +
|
||||
(data.default_fk_check_value ? ' checked="checked"' : '') + ' />' +
|
||||
'<label for="fk_checks">' + PMA_messages.strForeignKeyCheck + '</label>';
|
||||
$('.load-default-fk-check-value').replaceWith(html);
|
||||
});
|
||||
}
|
||||
|
||||
function getJSConfirmCommonParam (elem, params) {
|
||||
var $elem = $(elem);
|
||||
var sep = PMA_commonParams.get('arg_separator');
|
||||
if (params) {
|
||||
// Strip possible leading ?
|
||||
if (params.substring(0,1) === '?') {
|
||||
params = params.substr(1);
|
||||
}
|
||||
params += sep;
|
||||
} else {
|
||||
params = '';
|
||||
}
|
||||
params += 'is_js_confirmed=1' + sep + 'ajax_request=true' + sep + 'fk_checks=' + ($elem.find('#fk_checks').is(':checked') ? 1 : 0);
|
||||
return params;
|
||||
}
|
||||
@ -323,3 +323,49 @@ export function PMA_autosaveSQLSort (query) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts multiple fields.
|
||||
*
|
||||
*/
|
||||
export function insertValueQuery () {
|
||||
var myQuery = document.sqlform.sql_query;
|
||||
var myListBox = document.sqlform.dummy;
|
||||
|
||||
if (myListBox.options.length > 0) {
|
||||
sql_box_locked = true;
|
||||
var columnsList = '';
|
||||
var NbSelect = 0;
|
||||
for (var i = 0; i < myListBox.options.length; i++) {
|
||||
if (myListBox.options[i].selected) {
|
||||
NbSelect++;
|
||||
if (NbSelect > 1) {
|
||||
columnsList += ', ';
|
||||
}
|
||||
columnsList += myListBox.options[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
/* CodeMirror support */
|
||||
if (sqlQueryOptions.codemirror_editor) {
|
||||
sqlQueryOptions.codemirror_editor.replaceSelection(columnsList);
|
||||
sqlQueryOptions.codemirror_editor.focus();
|
||||
// IE support
|
||||
} else if (document.selection) {
|
||||
myQuery.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = columnsList;
|
||||
// MOZILLA/NETSCAPE support
|
||||
} else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart === '0') {
|
||||
var startPos = document.sqlform.sql_query.selectionStart;
|
||||
var endPos = document.sqlform.sql_query.selectionEnd;
|
||||
var SqlString = document.sqlform.sql_query.value;
|
||||
|
||||
myQuery.value = SqlString.substring(0, startPos) + columnsList + SqlString.substring(endPos, SqlString.length);
|
||||
myQuery.focus();
|
||||
} else {
|
||||
myQuery.value += columnsList;
|
||||
}
|
||||
sql_box_locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ import { printPreview } from './functions/Print';
|
||||
|
||||
import {
|
||||
setShowThisQuery, PMA_autosaveSQL, PMA_autosaveSQLSort, PMA_showThisQuery,
|
||||
checkSavedQuery, setQuery, checkSqlQuery, PMA_handleSimulateQueryButton
|
||||
checkSavedQuery, setQuery, checkSqlQuery, PMA_handleSimulateQueryButton, insertValueQuery
|
||||
} from './functions/Sql/SqlQuery';
|
||||
|
||||
/**
|
||||
@ -713,6 +713,22 @@ export function onload1 () {
|
||||
AJAX.source = $form;
|
||||
$.post($form.attr('action'), submitData, AJAX.responseHandler);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles double click table fields to insert into query
|
||||
*/
|
||||
$('#tablefields')
|
||||
.on('dblclick', function () {
|
||||
insertValueQuery();
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle click on insert or arrow button to insert table fields in query
|
||||
*/
|
||||
$('#tablefieldsSubmitLinkMode,#tablefieldsSubmitNonLinkMode')
|
||||
.on('click', function () {
|
||||
insertValueQuery();
|
||||
});
|
||||
} // end $()
|
||||
|
||||
/**
|
||||
|
||||
@ -278,7 +278,7 @@ class SqlQueryForm
|
||||
. '<label>' . __('Columns') . '</label>'
|
||||
. '<select id="tablefields" name="dummy" '
|
||||
. 'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" '
|
||||
. 'multiple="multiple" ondblclick="insertValueQuery()">';
|
||||
. 'multiple="multiple">';
|
||||
foreach ($columns_list as $field) {
|
||||
$html .= '<option value="'
|
||||
. Util::backquote(htmlspecialchars($field['Field']))
|
||||
@ -295,12 +295,11 @@ class SqlQueryForm
|
||||
. '<div id="tablefieldinsertbuttoncontainer">';
|
||||
if (Util::showIcons('ActionLinksMode')) {
|
||||
$html .= '<input type="button" class="button" name="insert"'
|
||||
. ' value="<<" onclick="insertValueQuery()"'
|
||||
. ' value="<<" id="tablefieldsSubmitLinkMode"'
|
||||
. ' title="' . __('Insert') . '" />';
|
||||
} else {
|
||||
$html .= '<input type="button" class="button" name="insert"'
|
||||
. ' value="' . __('Insert') . '"'
|
||||
. ' onclick="insertValueQuery()" />';
|
||||
. ' value="' . __('Insert') . '" id="tablefieldsSubmitNonLinkMode" />';
|
||||
}
|
||||
$html .= '</div>' . "\n"
|
||||
. '</div>' . "\n";
|
||||
|
||||
@ -24,9 +24,7 @@ PageSettings::showGroup('Sql');
|
||||
$response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
|
||||
$scripts->addFile('sql.js');
|
||||
$scripts->addFile('sql');
|
||||
|
||||
require 'libraries/tbl_common.inc.php';
|
||||
$url_query .= '&goto=tbl_sql.php&back=tbl_sql.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user