This repository has been archived on 2020-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
angularjs-batarang/js/controllers/ModelCtrl.js

46 lines
993 B
JavaScript
Raw Normal View History

2012-07-02 21:09:51 +00:00
panelApp.controller('ModelCtrl', function ModelCtrl($scope, appContext) {
2012-07-02 21:09:51 +00:00
$scope.inspect = function () {
appContext.inspect(this.val.id);
};
$scope.edit = function () {
appContext.executeOnScope(this.val.id, function (scope, elt, args) {
scope[args.name] = args.value;
scope.$apply();
}, {
name: this.key,
value: JSON.parse(this.item)
});
};
$scope.roots = [];
2012-07-02 21:09:51 +00:00
var updateTree = function () {
var roots = appContext.getListOfRoots();
if (!roots) {
return;
}
$scope.tree = appContext.getModelTree($scope.selectedRoot);
2012-07-02 21:09:51 +00:00
$scope.roots.length = roots.length;
roots.forEach(function (item, i) {
$scope.roots[i] = {
label: item,
value: item
};
});
if (roots.length === 0) {
$scope.selectedRoot = null;
} else if (!$scope.selectedRoot) {
$scope.selectedRoot = $scope.roots[0].value;
}
$scope.$apply();
};
appContext.watchPoll(updateTree);
});