Drop foreign key anchor in Relation view.
Signed-off-by: Ashutosh Dhundhara <ashutoshdhundhara@yahoo.com>
This commit is contained in:
parent
48fe645485
commit
1ed073f178
@ -40,6 +40,7 @@ $js_messages['strTruncateTableStrongWarning'] = __('You are about to TRUNCATE a
|
||||
$js_messages['strDeleteTrackingData'] = __('Delete tracking data for this table');
|
||||
$js_messages['strDeletingTrackingData'] = __('Deleting tracking data');
|
||||
$js_messages['strDroppingPrimaryKeyIndex'] = __('Dropping Primary Key/Index');
|
||||
$js_messages['strDroppingForeignKey'] = __('Dropping Foreign key.');
|
||||
$js_messages['strOperationTakesLongTime'] = __('This operation could take a long time. Proceed anyway?');
|
||||
$js_messages['strDropUserGroupWarning'] = __('Do you really want to delete user group "%s"?');
|
||||
$js_messages['strConfirmDeleteQBESearch'] = __('Do you really want to delete the search "%s"?');
|
||||
|
||||
@ -115,6 +115,7 @@ AJAX.registerTeardown('tbl_relation.js', function () {
|
||||
);
|
||||
$('body').off('click', 'a.add_foreign_key_field');
|
||||
$('body').off('click', 'a.add_foreign_key');
|
||||
$('a.drop_foreign_key_anchor.ajax').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('tbl_relation.js', function () {
|
||||
@ -190,4 +191,35 @@ AJAX.registerOnload('tbl_relation.js', function () {
|
||||
// Finally add the row.
|
||||
$new_row.insertAfter($prev_row);
|
||||
});
|
||||
|
||||
/**
|
||||
* Ajax Event handler for 'Drop Foreign key'
|
||||
*/
|
||||
$('a.drop_foreign_key_anchor.ajax').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var $anchor = $(this);
|
||||
|
||||
// Object containing reference to the current field's row
|
||||
var $curr_row = $anchor.parents('tr');
|
||||
|
||||
var question = escapeHtml(
|
||||
$curr_row.children('td')
|
||||
.children('.drop_foreign_key_msg')
|
||||
.val()
|
||||
);
|
||||
|
||||
$anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
|
||||
var $msg = PMA_ajaxShowMessage(PMA_messages.strDroppingForeignKey, false);
|
||||
$.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function (data) {
|
||||
if (data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
// Do nothing
|
||||
});
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + data.error, false);
|
||||
}
|
||||
}); // end $.get()
|
||||
}); // end $.PMA_confirm()
|
||||
}); //end Drop Foreign key
|
||||
});
|
||||
|
||||
@ -371,7 +371,8 @@ function PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db,
|
||||
. '<legend>' . __('Foreign key constraints') . '</legend>'
|
||||
. '<table id="foreign_keys" class="relationalTable">';
|
||||
|
||||
$html_output .= '<tr><th>' . __('Constraint properties') . '</th>'
|
||||
$html_output .= '<tr><th>' . __('Actions') . '</th>';
|
||||
$html_output .= '<th>' . __('Constraint properties') . '</th>'
|
||||
. '<th>'
|
||||
. __('Column')
|
||||
. PMA_Util::showHint(
|
||||
@ -428,6 +429,35 @@ function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i,
|
||||
$options_array, $tbl_storage_engine, $db
|
||||
) {
|
||||
$html_output = '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
|
||||
// Drop key anchor.
|
||||
$html_output .= '<td>';
|
||||
if (isset($one_key['constraint'])) {
|
||||
$drop_fk_query = 'ALTER TABLE ' . PMA_Util::backquote($GLOBALS['table'])
|
||||
. ' DROP FOREIGN KEY '
|
||||
. PMA_Util::backquote($one_key['constraint']) . ';';
|
||||
$this_params = $GLOBALS['url_params'];
|
||||
$this_params['goto'] = 'tbl_relation.php';
|
||||
$this_params['back'] = 'tbl_relation.php';
|
||||
$this_params['sql_query'] = $drop_fk_query;
|
||||
$this_params['message_to_show'] = sprintf(
|
||||
__('Foreign key constraint %s has been dropped'),
|
||||
$one_key['constraint']
|
||||
);
|
||||
$js_msg = PMA_jsFormat(
|
||||
'ALTER TABLE ' . $GLOBALS['table']
|
||||
. ' DROP FOREIGN KEY '
|
||||
. $one_key['constraint'] . ';'
|
||||
);
|
||||
|
||||
$html_output .= '<input type="hidden" class="drop_foreign_key_msg"'
|
||||
. ' value="' . $js_msg . '" />';
|
||||
$html_output .= ' <a class="drop_foreign_key_anchor';
|
||||
$html_output .= ' ajax';
|
||||
$html_output .= '" href="sql.php' . PMA_URL_getCommon($this_params)
|
||||
. '" >'
|
||||
. PMA_Util::getIcon('b_drop.png', __('Drop')) . '</a>';
|
||||
}
|
||||
$html_output .= '</td>';
|
||||
$html_output .= '<td>';
|
||||
$html_output .= '<span class="formelement clearfloat">';
|
||||
$constraint_name = isset($one_key['constraint'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user