Hi,
During the saving of an inline edit, I'm generating the update query with JavaScript on the client side, and posting it to tbl_replace.php, which prepares some variables for sql.php. sql.php then executes the update query, and generates an output in JSON, which is evaluated by jQuery at the client side. If the query has been successful, the values that were in the textarea/input fields, are taken as the new value for that field and the HTML is updated to that effect.
The above process creates a few problems for me. When the table being edited has a foreign key or transformed field, the javascript does not know what is the value to be displayed after a successful edit. For the foreign keys, I am generating the anchor at the server side in sql.php and adding it to the JSON output. However, the anchor is not being generated correctly, as the WHERE clause is missing. After the query has been executed, sql.php does not know the values of individual fields, and hence, I cannot generate the WHERE clause necessary for the anchor.
Similarly, for transformations, I don't have the value of the field, and hence, I cannot transform the new value to generate the HTML, which I can add to the JSON output.
In libraries/display_tbl.lib.php, the WHERE clause is generated on the fly for each field, as '= <field's value>', while the transformation is done in the function PMA_prepare_row_data().
The solution I have in mind for the transformation problem is to post an associative array to tbl_replace.php containing the field name and it's new value, which I'll use after the query has been executed and generate the HTML with this array. As for the first problem (foreign key's anchor), I've been stuck at it for some time and can't see a way out.
Could someone suggest a better solution?
Thanks!
Ninad Pundalik a écrit :
Hi,
Could someone suggest a better solution?
Thanks!
Ninad, I wanted to make some tests to answer you but there are merge conflicts in server_privileges.php and sql.php, leading to PHP parse errors.
Ninad Pundalik a écrit :
Hi,
During the saving of an inline edit, I'm generating the update query with JavaScript on the client side, and posting it to tbl_replace.php, which prepares some variables for sql.php. sql.php then executes the update query, and generates an output in JSON, which is evaluated by jQuery at the client side. If the query has been successful, the values that were in the textarea/input fields, are taken as the new value for that field and the HTML is updated to that effect.
(...) Ninad, while looking for a solution, I noticed another problem. When you generate the UPDATE query, it seems you are taking the column name from the displayed header and this is not correct as in my sample table, there are column comments (which are displayed in the header while browsing).
On 30/08/2010, Marc Delisle marc@infomarc.info wrote:
(...) Ninad, while looking for a solution, I noticed another problem. When you generate the UPDATE query, it seems you are taking the column name from the displayed header and this is not correct as in my sample table, there are column comments (which are displayed in the header while browsing).
Yes, I'm taking the column name from the header. I'll add comments to a table and see if I can further improve the code, so that it extracts only the field name and not the comments. If this is not easily possible, I might put the comments in a span by modifying the libraries/display_tbl.lib.php and tell jQuery to not read from that span.
Thanks for the heads up! :)
On 30/07/2010, Ninad Pundalik ninadsp16289@gmail.com wrote:
On 30/08/2010, Marc Delisle marc@infomarc.info wrote:
(...) Ninad, while looking for a solution, I noticed another problem. When you generate the UPDATE query, it seems you are taking the column name from the displayed header and this is not correct as in my sample table, there are column comments (which are displayed in the header while browsing).
Yes, I'm taking the column name from the header. I'll add comments to a table and see if I can further improve the code, so that it extracts only the field name and not the comments. If this is not easily possible, I might put the comments in a span by modifying the libraries/display_tbl.lib.php and tell jQuery to not read from that span.
The comments already are in a span. Fixed this in commit e47b213.
Hi,
In the function that extracts the name of the field (getFieldName in sql.js) from the table's header, I've put in an if condition that checks if the current text direction is LTR or RTL. I've tested the function for English (LTR). Could someone please confirm that it works for an RTL language? Here's what you could do to test it in Firebug:
0. Open up http://demo.phpmyadmin.net/gsoc-ninadsp/ . 1. Go to any page that shows results from a table. (Browse or make an SQL query on a table). 2. Browse the sql.js script in Firebug and set a breakpoint on line 31. That is the line where the field_name variable is trimmed. 3. Click on the Inline Edit anchor, and check the value of field_name at the breakpoint. If it is the same as the field's name, and the field has been truncated/transformed, the value of the field should be retrieved correctly from the server and put in the <textarea> element.
Thanks a lot for the help!
P.S.: As of revision 7acb4cb, a separate inline edit anchor is appended to each row after the table is loaded if javascript is enabled, so please do check the title text before clicking on the edit anchors seen there before clicking. Before the code is merged into master, I'd prefer to use a different icon for inline edit, so that this confusion does not happen.
Ninad Pundalik a écrit :
Hi,
In the function that extracts the name of the field (getFieldName in sql.js) from the table's header, I've put in an if condition that checks if the current text direction is LTR or RTL. I've tested the function for English (LTR). Could someone please confirm that it works for an RTL language? Here's what you could do to test it in Firebug:
- Open up http://demo.phpmyadmin.net/gsoc-ninadsp/ .
- Go to any page that shows results from a table. (Browse or make an
SQL query on a table). 2. Browse the sql.js script in Firebug and set a breakpoint on line 31. That is the line where the field_name variable is trimmed. 3. Click on the Inline Edit anchor, and check the value of field_name at the breakpoint. If it is the same as the field's name, and the field has been truncated/transformed, the value of the field should be retrieved correctly from the server and put in the <textarea> element.
Thanks a lot for the help!
P.S.: As of revision 7acb4cb, a separate inline edit anchor is appended to each row after the table is loaded if javascript is enabled, so please do check the title text before clicking on the edit anchors seen there before clicking. Before the code is merged into master, I'd prefer to use a different icon for inline edit, so that this confusion does not happen.
Hi Ninad, I tested with Hebrew and it works fine (I had columns with comments).
Hi Marc,
On 05/08/2010, Marc Delisle marc@infomarc.info wrote:
Hi Ninad, I tested with Hebrew and it works fine (I had columns with comments).
Thank you for testing it. I'm working on the support for image and application transformations now, and inline editing should be complete in a day or two, unless we encounter a major bug. :)