Skip to content

Commit

Permalink
Dropped existing ajaxification of "Change column"
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent 2fdae84 commit 6f9354b
Showing 1 changed file with 0 additions and 110 deletions.
110 changes: 0 additions & 110 deletions js/tbl_structure.js
Expand Up @@ -163,41 +163,6 @@ $(function() {
}); // end $.PMA_confirm()
}); //end Drop Primary Key/Index

/**

This comment has been minimized.

Copy link
@lem9

lem9 Dec 7, 2012

Contributor

Rouslan,
what replaced this dropped code?

This comment has been minimized.

Copy link
@roccivic

roccivic Dec 7, 2012

Author Contributor

For the links, the functionality is now performed with the ajax page loader. For the multi submits, I'm not sure. The below code shows a really ugly dialog, so I wouldn't recommend using it anyway. I'm not too sure what's missing, but it should be relatively simple to integrate the multi submits with the ajax page loader if it's necessary.

This comment has been minimized.

Copy link
@lem9

This comment has been minimized.

Copy link
@roccivic

roccivic Dec 7, 2012

Author Contributor

I know, that bug was assigned to me for a while, I was looking for issues on the server side, but found nothing except for one (harmless) use of an uninitialised variable. So I gave up on it. You seem to be on the right track though :)

If the event handler is all that is missing, there you could submit a form that isn't attached to the DOM to trigger the ajax page loader.
This is what I'm thinking about (completely untested):

$('#fieldsForm.ajax')
.clone()
.removeClass('ajax')
.append('<input  />', { name:"ajax_request", value: 1})
.append('<input  />', { name:"submit_mult", value: "change"})
.submit()

This comment has been minimized.

Copy link
@lem9

lem9 Dec 7, 2012

Contributor

I don't follow: how a click on "With selected: Change" would be related to this?

This comment has been minimized.

Copy link
@roccivic

roccivic Dec 7, 2012

Author Contributor

Well, that click should open a new page, right? The code above will trigger a page load event in the ajax page loader by simulating the submission of a form. That will ultimately load a new page. Anyway, I'm not sure if this is the issue here.

Loading a url like below does not produce a change column form for me:
http://localhost/pma/tbl_structure.php?db=sakila&selected_fld[]=first_name&selected_fld[]=last_name&table=actor&table_type=table&token=4505de27fc04afaba72a0ef166d7b19d&mult_submit=change

This comment has been minimized.

Copy link
@lem9

lem9 Dec 7, 2012

Contributor

Last param should be submit_mult and not mult_submit.

This comment has been minimized.

Copy link
@roccivic

roccivic Dec 7, 2012

Author Contributor

Ok, with the correct parameter name it produces the famous "No change" message and throws that notice I was talking about:

Notice in ./libraries/mult_submits.inc.php#346
Undefined variable: mult_btn

Backtrace

./tbl_structure.php#78: include(./libraries/mult_submits.inc.php)

Looks like a server-side issue after all...

*Ajax event handler for multi column change
**/
$("#fieldsForm.ajax .mult_submit[value=change]").live('click', function(event){
event.preventDefault();

/*Check whether atleast one row is selected for change*/
if ($("#tablestructure tbody tr").hasClass("marked")) {
/*Define the action and $url variabls for the post method*/
var $form = $("#fieldsForm");
var action = $form.attr('action');
var url = $form.serialize()+"&ajax_request=true&submit_mult=change";
/*Calling for the changeColumns fucntion*/
changeColumns(action,url);
} else {
PMA_ajaxShowMessage(PMA_messages['strNoRowSelected']);
}
});

/**
*Ajax event handler for single column change
**/
$("#fieldsForm.ajax #tablestructure tbody tr td.edit a.ajax").live('click', function(event){
event.preventDefault();
/*Define the action and $url variabls for the post method*/
var action = "tbl_alter.php";
var url = $(this).attr('href');
if (url.substring(0, 13) == "tbl_alter.php") {
url = url.substring(14, url.length);
}
url = url + "&ajax_request=true";
/*Calling for the changeColumns fucntion*/
changeColumns(action,url);
});

/**
*Ajax event handler for index edit
**/
Expand Down Expand Up @@ -547,81 +512,6 @@ $(function() {
});
}); // end $()

/**
* Loads the append_fields_form to the Change dialog allowing users
* to change the columns
* @param string action Variable which parses the name of the
* destination file
* @param string $url Variable which parses the data for the
* post action
*/
function changeColumns(action,url)
{
/*Remove the hidden dialogs if there are*/
if ($('#change_column_dialog').length != 0) {
$('#change_column_dialog').remove();
}
if ($('#result_query').length != 0) {
$('#result_query').remove();
}
var $div = $('<div id="change_column_dialog"></div>');

/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
*/
var button_options = {};
// in the following function we need to use $(this)
button_options[PMA_messages['strCancel']] = function() {
$(this).dialog('close');
};

var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {
$(this).dialog('close');
};
var $msgbox = PMA_ajaxShowMessage();

$.get( action , url , function(data) {
//in the case of an error, show the error message returned.
if (data.success != undefined && data.success == false) {
$div
.append(data.error)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 230,
width: 900,
modal: true,
open: PMA_verifyColumnsProperties,
close: function() {
$(this).remove();
},
buttons : button_options_error
}); // end dialog options
} else {
$div
.append(data.message)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 600,
width: 900,
modal: true,
open: PMA_verifyColumnsProperties,
close: function() {
$(this).remove();
},
buttons : button_options
}); // end dialog options
$("#append_fields_form input[name=do_save_data]").addClass("ajax");
/*changed the z-index of the enum editor to allow the edit*/
$("#enum_editor").css("z-index", "1100");
$div = $("#change_column_dialog");
PMA_showHints($div);
}
PMA_ajaxRemoveMessage($msgbox);
}); // end $.get()
}

/**
* jQuery coding for 'Change Table' and 'Add Column'. Used on tbl_structure.php *
* Attach Ajax Event handlers for Change Table
Expand Down

0 comments on commit 6f9354b

Please sign in to comment.