(function () { 'use strict'; var app = angular.module('frameworksModule'); // A controller for frameworks and competency trees that are used app.controller('competencyTreeController', ['$scope', 'userDataContext', function ($scope, userDataContext) { // Data for the users frameworks getFrameworks(); $scope.frameworks = {}; $scope.competencies = []; // Get all frameworks for the user function getFrameworks() { return userDataContext.getAllMyFrameworkAssignmentDeployments().then(function (frameworks) { if (frameworks.length > 0) { $scope.frameworks = frameworks; var id = frameworks[0].assignmentDeployed.id; if (typeof $scope.setFramework == "function") { $scope.setFramework(id); } else { this.setFrameworkAndGetCompetencies(id); } } }); } // Set the framework, without getting competencies this.setFrameworkId = function (id) { $scope.selectedFramework = id; } // Set the framework, getting competencies this.setFrameworkAndGetCompetencies = function (id) { this.setFrameworkId(id); return this.getFrameworkCompetencies(id); } // Get all competencies for the selected framework this.getFrameworkCompetencies = function (frameworkAssignmentId) { return userDataContext.getFrameworkEvidenceSummary(frameworkAssignmentId).then(function (data) { $scope.competencies = data.branches; return data; }); } }]); })();