fix(panel/scopes): disallow editing special scope properties

test-unit-sauce
Brian Ford 10 years ago
parent 239c560c74
commit 3a999ad92a

@ -3,6 +3,17 @@ angular.module('batarang.json-tree', []).
var BAT_JSON_TREE_TEMPLATE = '<div class="properties-tree"></div>';
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(
'<span contentEditable="true" class="console-formatted-' + (typeof val) + '">' +
val +
'</span>');
// 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(
'<span class="console-formatted-' + (typeof val) + '">' +
val +
'</span>');
} else {
childElt = angular.element(
'<span contentEditable="true" class="console-formatted-' + (typeof val) + '">' +
val +
'</span>');
// TODO: test this
childElt.on('blur', function () {
scope.batAssign({
path: fullPath,
value: childElt.text()
});
});
})
}
}
parentElt.append(childElt);