precise work with mongoid

This commit is contained in:
Jan Prochazka
2021-12-07 21:29:31 +01:00
parent c113266095
commit 6bd48ca29f
8 changed files with 25 additions and 34 deletions

View File

@@ -124,6 +124,8 @@
{:else}
<span class="null">({value.data.length} bytes)</span>
{/if}
{:else if value.$oid}
<span class="value">ObjectId("{value.$oid}")</span>
{:else if _.isPlainObject(value)}
<span class="null" title={JSON.stringify(value, undefined, 2)}>(JSON)</span>
{:else if _.isArray(value)}

View File

@@ -67,6 +67,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa
const value = row[uqName];
let text = value;
if (_.isArray(value)) text = `[${value.length} items]`;
else if (value?.$oid) text = `ObjectId("${value.$oid}")`;
const width = context.measureText(text).width + 8;
// console.log('colName', colName, text, width);
columnSizes.putSizeOverride(colIndex, width);

View File

@@ -4,7 +4,7 @@
showModal(EditJsonModal, {
json: rowData,
onSave: value => {
if (value._id != rowData._id) {
if (rowData._id && value._id != rowData._id) {
showModal(ErrorMessageModal, { message: '_id attribute cannot be changed' });
return false;
}

View File

@@ -71,6 +71,7 @@ export function extractRowCopiedValue(row, col) {
if (value === undefined) value = _.get(row, col);
if (value === null) return '(NULL)';
if (value === undefined) return '(NoField)';
if (value && value.$oid) return `ObjectId("${value.$oid}")`;
if (value && value.type == 'Buffer' && _.isArray(value.data)) return arrayToHexString(value.data);
if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value);
return value;