Grid edit: add truncated support for TEXT data type
This commit is contained in:
parent
5faaa14bd7
commit
4c30640024
@ -2953,8 +2953,8 @@ function PMA_createqTip($elements, content, options) {
|
||||
function PMA_getCellValue(td) {
|
||||
if ($(td).is('.null')) {
|
||||
return '';
|
||||
} else if ($(td).is(':not(.truncated, .transformed, .relation, .enum, .set, .null)')) {
|
||||
return $(td).find('span').html().replace(/<br>/g, "\n");
|
||||
} else if ($(td).is(':not(.transformed, .relation, .enum, .set, .null)')) {
|
||||
return unescape($(td).find('span').html()).replace(/<br>/g, "\n");
|
||||
} else {
|
||||
return $(td).text();
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
cellEditHint: '', // hint shown when doing grid edit
|
||||
gotoLinkText: 'Go to link', // "Go to link" text
|
||||
wasEditedCellNull: false, // true if last value of the edited cell was NULL
|
||||
maxTruncatedLen: 0, // number of characters that can be displayed in a cell
|
||||
|
||||
// functions
|
||||
dragStartRsz: function(e, obj) { // start column resize
|
||||
@ -482,6 +483,7 @@
|
||||
|
||||
g.isCellEditActive = false;
|
||||
g.currentEditCell = cell;
|
||||
$(g.cEdit).find('input[type=text]').focus();
|
||||
}
|
||||
} else {
|
||||
g.hideEditCell();
|
||||
@ -538,6 +540,10 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if ($this_field.is('.truncated')) {
|
||||
if (new_html.length > g.maxTruncatedLen) {
|
||||
new_html = new_html.substring(0, g.maxTruncatedLen) + '...';
|
||||
}
|
||||
}
|
||||
// replace '\n' with <br>
|
||||
new_html = new_html.replace(/\n/g, '<br />');
|
||||
@ -784,6 +790,9 @@
|
||||
}, function(data) {
|
||||
$editArea.removeClass('edit_area_loading');
|
||||
if(data.success == true) {
|
||||
// get the truncated data length
|
||||
g.maxTruncatedLen = PMA_getCellValue(g.currentEditCell).length - 3;
|
||||
|
||||
$(g.cEdit).find('input[type=text]').val(data.value);
|
||||
$editArea.append('<textarea>'+data.value+'</textarea>');
|
||||
$editArea.find('textarea').live('keyup', function(e) {
|
||||
@ -1244,7 +1253,6 @@
|
||||
e.stopPropagation();
|
||||
} else {
|
||||
g.showEditCell(this);
|
||||
$(g.cEdit).find('input[type=text]').focus();
|
||||
e.stopPropagation();
|
||||
}
|
||||
// prevent default action when clicking on "link" in a table
|
||||
|
||||
@ -1480,10 +1480,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
// TEXT fields type so we have to ensure it's really a BLOB
|
||||
$field_flags = PMA_DBI_field_flags($dt_result, $i);
|
||||
|
||||
// remove 'inline_edit' from $class as we can't edit binary data.
|
||||
$class = str_replace('inline_edit', '', $class);
|
||||
|
||||
if (stristr($field_flags, 'BINARY')) {
|
||||
// remove 'inline_edit' from $class as we can't edit binary data.
|
||||
$class = str_replace('inline_edit', '', $class);
|
||||
|
||||
if (! isset($row[$i]) || is_null($row[$i])) {
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
|
||||
} else {
|
||||
@ -1512,7 +1512,11 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
// characters for tabulations and <cr>/<lf>
|
||||
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
|
||||
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
|
||||
if ($is_field_truncated) {
|
||||
$class .= ' truncated';
|
||||
}
|
||||
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
|
||||
} else {
|
||||
$vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user