diff --git a/panel/components/json-tree/json-tree.js b/panel/components/json-tree/json-tree.js index 3f6e583..994d965 100644 --- a/panel/components/json-tree/json-tree.js +++ b/panel/components/json-tree/json-tree.js @@ -3,6 +3,17 @@ angular.module('batarang.json-tree', []). var BAT_JSON_TREE_TEMPLATE = '
'; +var BAT_JSON_TREE_UNEDITABLE = [ + '$id', + + // managed by ngRepeat + '$first', + '$last', + '$index', + '$even', + '$odd' +]; + /* * TODO: remove dependency on inspectedApp service */ @@ -89,18 +100,28 @@ function batJsonTreeDirective() { if (typeof val === 'string') { val = '"' + val + '"'; } - childElt = angular.element( - '' + - val + - ''); // TODO: test this - childElt.on('blur', function () { - scope.batAssign({ - path: fullPath, - value: childElt.text() + // some properties (like $id) shouldn't be edited + if (BAT_JSON_TREE_UNEDITABLE.indexOf(fullPath) > -1) { + childElt = angular.element( + '' + + val + + ''); + } else { + childElt = angular.element( + '' + + val + + ''); + + // TODO: test this + childElt.on('blur', function () { + scope.batAssign({ + path: fullPath, + value: childElt.text() + }); }); - }) + } } parentElt.append(childElt);