未验证 提交 29026caa 编写于 作者: S sercan

fixes #498

上级 62860f87
import { SessionManager } from '/client/imports/modules';
import { ExtendedJSON, SessionManager } from '/client/imports/modules';
import { ReactivityProvider } from '/client/imports/facades';
import $ from 'jquery';
import Helper from '/client/imports/helpers/helper';
import { QueryRender } from '../../ui/querying';
import { QueryRender } from '/client/imports/ui/querying';
import { _ } from 'meteor/underscore';
const CodeMirror = require('codemirror');
const JSONEditor = require('jsoneditor');
......@@ -52,29 +53,24 @@ const quoteAttr = function (s) {
const convertObjectToGridRow = function (obj, allKeys) {
let html = '<tr>';
allKeys.forEach((key) => {
let val = obj[key];
if (typeof val === 'undefined') val = '';
if (val !== null && typeof val === 'object') {
const valKeys = Object.keys(val);
if (valKeys.length === 1 && valKeys[0] === '$date') {
val = val.$date;
} else {
val = JSON.stringify(val);
}
}
val = `${val}`;
if (val.length > 50) {
html += `<td title="${quoteAttr(val)}">${val.substr(0, 47)}...</td>`;
} else {
html += `<td>${val}</td>`;
}
if (val !== null && typeof val === 'object') val = JSON.stringify(val);
val = `${_.escape(val)}`;
if (val.length > 100) html += `<td title="${quoteAttr(val)}">${val.substr(0, 97)}...</td>`;
else html += `<td>${val}</td>`;
});
html += '</tr>';
return html;
};
const displayJsonEditorModal = function (sData) {
let dataToSet = ExtendedJSON.convertAndCheckJSON(_.unescape(sData));
dataToSet = dataToSet.ERROR ? _.unescape(sData) : dataToSet;
let modal = $('#json-editor-modal');
if (modal.length === 0) {
modal = $('<div class="modal fade" id="json-editor-modal" tabindex="-1" role="dialog">'
......@@ -100,7 +96,7 @@ const displayJsonEditorModal = function (sData) {
});
}
modal.modal();
$('#json-editor-modal-data').data('jsoneditor').set(JSON.parse(sData));
$('#json-editor-modal-data').data('jsoneditor').set(dataToSet);
};
const doCodeMirrorResizable = function (codeMirror) {
......
......@@ -651,5 +651,6 @@
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending",
"view_on": "View On"
"view_on": "View On",
"not_valid_field": "Not a valid json field: __error__"
}
......@@ -652,5 +652,6 @@
"sortAscending": ": yükselen şekilde sıralamayı aktive et",
"sortDescending": ": alçalan şekilde sıralamayı aktive et",
"view_on": "Bağlı Collection"
"view_on": "Bağlı Collection",
"not_valid_field": "Alan JSON değil: __error__"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册