mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix JSON type rendering. Fixes #1404
This commit is contained in:
parent
d4c3b1bcff
commit
3ee8861d44
@ -904,6 +904,40 @@
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* JSONBCell Formatter.
|
||||
*/
|
||||
var JSONBCellFormatter = Backgrid.Extension.JSONBCellFormatter =
|
||||
function () {};
|
||||
_.extend(JSONBCellFormatter.prototype, {
|
||||
fromRaw: function (rawData, model) {
|
||||
// json data
|
||||
if(_.isArray(rawData)) {
|
||||
var converted_data = '';
|
||||
converted_data = _.map(rawData, function(data) {
|
||||
return JSON.stringify(JSON.stringify(data));
|
||||
});
|
||||
return '{' + converted_data.join() + '}';
|
||||
} else if(_.isObject(rawData)) {
|
||||
return JSON.stringify(rawData);
|
||||
} else {
|
||||
return rawData;
|
||||
}
|
||||
},
|
||||
toRaw: function (formattedData, model) {
|
||||
return formattedData;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* JSONBCell for backgrid.
|
||||
*/
|
||||
var JSONBCell = Backgrid.Extension.JSONBCell =
|
||||
Backgrid.StringCell.extend({
|
||||
className: "jsonb-cell",
|
||||
formatter: JSONBCellFormatter
|
||||
});
|
||||
|
||||
return Backgrid;
|
||||
|
||||
}));
|
||||
|
@ -1555,6 +1555,12 @@ define(
|
||||
case "timestamp with time zone":
|
||||
col_cell = 'datetime';
|
||||
break;
|
||||
case "json":
|
||||
case "json[]":
|
||||
case "jsonb":
|
||||
case "jsonb[]":
|
||||
col_cell = Backgrid.Extension.JSONBCell;
|
||||
break;
|
||||
default:
|
||||
col_cell = 'string';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user