Skip to content

Commit

Permalink
Fix #17398 - Fixing clicking on JSON columns triggers update query
Browse files Browse the repository at this point in the history
it also fixes the issue where the JSON columns are saved with spaces
and new lines, after being updated from the UI.

Fixes: #17398
Signed-off-by: iifawzi <iifawzie@gmail.com>
  • Loading branch information
iifawzi committed Jan 14, 2023
1 parent f7d9321 commit b60d145
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions js/src/makegrid.js
Expand Up @@ -1274,7 +1274,12 @@ var makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGrid
fieldsType.push('hex');
}
fieldsNull.push('');
fields.push($thisField.data('value'));

if ($thisField.attr('data-type') !== 'json') {
fields.push($thisField.data('value'));
} else {
fields.push(JSON.stringify(JSON.parse($thisField.data('value'))));
}

var cellIndex = $thisField.index('.to_be_saved');
if ($thisField.is(':not(.relation, .enum, .set, .bit)')) {
Expand Down Expand Up @@ -1510,7 +1515,15 @@ var makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGrid
} else {
thisFieldParams[fieldName] = $(g.cEdit).find('.edit_box').val();
}
if (g.wasEditedCellNull || thisFieldParams[fieldName] !== Functions.getCellValue(g.currentEditCell)) {

var isValueUpdated;
if ($thisField.attr('data-type') !== 'json') {
isValueUpdated = thisFieldParams[fieldName] !== Functions.getCellValue(g.currentEditCell);
} else {
isValueUpdated = JSON.stringify(JSON.parse(thisFieldParams[fieldName])) !== JSON.stringify(JSON.parse(Functions.getCellValue(g.currentEditCell)));
}

if (g.wasEditedCellNull || isValueUpdated) {
needToPost = true;
}
}
Expand Down

0 comments on commit b60d145

Please sign in to comment.