Thilanka Kaushalya a écrit :
Hi Marc,
what will be your strategy on this (about avoiding code duplication)?
I was able to do the first part of ajaxify the insert option in the db->structure. I basically used db_structure.php and db_structure.js files for this modification.
In db_structure.js file I have used the two action to handle this.
- $("td.insert_table a.ajax").live('click',function(event){})
- $("#insertForm .insertRowTable input[value=Go], #buttonYes ").live('click', function(event) {})
In first event I used to pop up a dialog which carries the "insert table" form and I don't think it need any modification. Then the second event handles the action after clicking the "Go" buttons at the "InsertRowTable" tables and the "Go" button at the "actions_panel". Currently I'm using the same action logic for both button clicks because I cannot clearly identify the importance of options in the "actions_panel" at this pop up dialog box. Please clarify me on this issue.
In actions_panel (when called in this Ajax context), the possibility of inserting more than one row (insert another new row) is the most interesting option.
Is this a problem to leave all the options? for example, a space problem in the popup?
Currently after inserting to a table using this ajax form, the "Rows" column in the "tablesForm" does not get update. I tried to a get a similar approach in my last task for that by collecting the echos of "tablesForm" in the db_structure.php to a variable and then send it via PMA_ajaxResponse() method. But since db_structure.php uses PMA_TableHeader() method to echo the headers of the table it is difficult to do that. So what do you prefer in this situation.
Many things can happen in an insert: it may fail, or maybe the user inserted more than one row. So we cannot just increment the number of rows by one, using the previous number.
It would be acceptable to count again the number of rows with PMA_Table::countRecords().
Please help me on these issues. Thank you.
Regards, Thilanka.
It would be easier to test your actual code; please push it.