Merge pull request #1751 from madhuracj/bug4963
#4963 Improve/restore non-unique index row editing
This commit is contained in:
commit
7edd9524c0
@ -2374,6 +2374,16 @@ Design customization
|
||||
put when tables contents are displayed (you may have them displayed at
|
||||
the left side, right side, both sides or nowhere).
|
||||
|
||||
.. config:option:: $cfg['RowActionLinksWithoutUnique']
|
||||
|
||||
:type: boolean
|
||||
:default: false
|
||||
|
||||
Defines whether to show row links (Edit, Copy, Delete) and checkboxes
|
||||
for multiple row operations even when the selection does not have a unique key.
|
||||
Using row actions in the absence of a unique key may result in different/more
|
||||
rows being affected since there is no guaranteed way to select the exact row(s).
|
||||
|
||||
.. config:option:: $cfg['RememberSorting']
|
||||
|
||||
:type: boolean
|
||||
|
||||
@ -2680,6 +2680,14 @@ $cfg['LimitChars'] = 50;
|
||||
*/
|
||||
$cfg['RowActionLinks'] = 'left';
|
||||
|
||||
/**
|
||||
* Whether to show row links (Edit, Copy, Delete) and checkboxes for
|
||||
* multiple row operations even when the selection does not have a unique key.
|
||||
*
|
||||
* @global boolean $cfg['RowActionLinksWithoutUnique']
|
||||
*/
|
||||
$cfg['RowActionLinksWithoutUnique'] = false;
|
||||
|
||||
/**
|
||||
* Default sort order by primary key.
|
||||
* @global string $cfg['TablePrimaryKeyOrder']
|
||||
|
||||
@ -490,6 +490,8 @@ $strConfigNumRecentTables_name = __('Recently used tables');
|
||||
$strConfigNumFavoriteTables_name = __('Favorite tables');
|
||||
$strConfigRowActionLinks_desc = __('These are Edit, Copy and Delete links.');
|
||||
$strConfigRowActionLinks_name = __('Where to show the table row links');
|
||||
$strConfigRowActionLinksWithoutUnique_desc = __('Whether to show row links even in the absence of a unique key.');
|
||||
$strConfigRowActionLinksWithoutUnique_name = __('Show row links anyway');
|
||||
$strConfigNaturalOrder_desc
|
||||
= __('Use natural order for sorting table and database names.');
|
||||
$strConfigNaturalOrder_name = __('Natural order');
|
||||
|
||||
@ -218,6 +218,7 @@ $forms['Main_panel']['Browse'] = array(
|
||||
'RepeatCells',
|
||||
'LimitChars',
|
||||
'RowActionLinks',
|
||||
'RowActionLinksWithoutUnique',
|
||||
'TablePrimaryKeyOrder',
|
||||
'RememberSorting',
|
||||
'RelationalDisplay');
|
||||
|
||||
@ -125,6 +125,7 @@ $forms['Main_panel']['Browse'] = array(
|
||||
'RepeatCells',
|
||||
'LimitChars',
|
||||
'RowActionLinks',
|
||||
'RowActionLinksWithoutUnique',
|
||||
'TablePrimaryKeyOrder',
|
||||
'RememberSorting',
|
||||
'RelationalDisplay');
|
||||
|
||||
@ -1751,13 +1751,14 @@ function PMA_getHtmlForPreviousUpdateQuery($disp_query, $showSql, $sql_data,
|
||||
/**
|
||||
* To get the message if a column index is missing. If not will return null
|
||||
*
|
||||
* @param string $table current table
|
||||
* @param string $db current database
|
||||
* @param boolean $editable whether the results table can be editable or not
|
||||
* @param string $table current table
|
||||
* @param string $db current database
|
||||
* @param boolean $editable whether the results table can be editable or not
|
||||
* @param boolean $has_unique whether there is a unique key
|
||||
*
|
||||
* @return PMA_message $message
|
||||
*/
|
||||
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable)
|
||||
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $has_unique)
|
||||
{
|
||||
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
|
||||
$missing_unique_column_msg = PMA_message::notice(
|
||||
@ -1767,6 +1768,14 @@ function PMA_getMessageIfMissingColumnIndex($table, $db, $editable)
|
||||
. ' are not available.'
|
||||
)
|
||||
);
|
||||
} elseif (! empty($table) && ! $has_unique) {
|
||||
$missing_unique_column_msg = PMA_message::notice(
|
||||
__(
|
||||
'Current selection does not contain a unique column.'
|
||||
. ' Grid edit, Edit, Copy and Delete features may result in'
|
||||
. ' undesired behavior.'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$missing_unique_column_msg = null;
|
||||
}
|
||||
@ -1882,7 +1891,10 @@ function PMA_getQueryResponseForResultsReturned($result,
|
||||
|
||||
$just_one_table = PMA_resultSetHasJustOneTable($fields_meta);
|
||||
|
||||
$editable = ($has_unique || $updatableView) && $just_one_table;
|
||||
$editable = ($has_unique
|
||||
|| $GLOBALS['cfg']['RowActionLinksWithoutUnique']
|
||||
|| $updatableView)
|
||||
&& $just_one_table;
|
||||
|
||||
$displayParts = array(
|
||||
'edit_lnk' => $displayResultsObject::UPDATE_ROW,
|
||||
@ -1960,7 +1972,7 @@ function PMA_getQueryResponseForResultsReturned($result,
|
||||
);
|
||||
|
||||
$missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex(
|
||||
$table, $db, $editable
|
||||
$table, $db, $editable, $has_unique
|
||||
);
|
||||
|
||||
$bookmark_created_msg = PMA_getBookmarkCreatedMessage();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user