in synergy/client/app/js/controllers.js [2109:2221]
$scope.fetch = function (useCache) {
if (self.simpleName.length > 0) {
loadSpecificationFromAlias();
return;
}
if (window.location.href.indexOf("/title/") > -1) {// shouldn't be, caused by some issue in .htaccess
$location.path("");
return;
}
switch (getAction()) {
case "create":
versionsHttp.get($scope, true, function (data) {
$scope.versions = data;
$scope.version = data[0].name || "";
$scope.refreshCodemirror = true;
}, $scope.generalHttpFactoryError);
projectsHttp.getAll($scope, function (data) {
$scope.projects = data;
$scope.project = $scope.projects[0];
}, $scope.generalHttpFactoryError);
break;
case "1":
if ($scope.id < 0) {
return;
}
if (specificationCache.getCurrentSpecificationId() === parseInt($scope.id, 10)) {
displaySimpleSpecification(specificationCache.getCurrentSpecification());
} else {
specificationCache.resetCurrentSpecification();
specificationHttp.get($scope, useCache, $scope.id, function (data) {
displaySimpleSpecification(data);
}, $scope.generalHttpFactoryError);
}
break;
case "2":
if ($scope.id < 0) {
return;
}
specificationHttp.getFull($scope, useCache, $scope.id, function (data) {
$scope.specification = data;
setProject(data);
specificationDurationCache.All = data.estimation;
specificationCache.setCurrentSpecification(data, $scope.project);
getRemovalUsers();
$scope.labels = getLabels(data);
$scope.newname = data.title;
resolveContinuousJobs(data.ext.continuous_integration);
$scope.$emit("updateBreadcrumbs", {link: "specification/" + $scope.id + "/v/2", title: data.title});
try {
if (data.controls.length > 0) {
$scope.rights = 1;
}
} catch (e) {
}
}, $scope.generalHttpFactoryError);
break;
default : // edit
if ($scope.id < 0) {
return;
}
if (typeof $scope.SYNERGY.session.session_id === "undefined" || $scope.SYNERGY.session.session_id.length < 1) {
break;
}
specificationHttp.get($scope, false, $scope.id, function (data) {
self.originalSimpleName = data.simpleName;
setProject(data);
$scope.refreshCodemirror = true;
if (SynergyUtils.definedNotNull(data.ext.continuous_integration)) {
for (var j = 0, max = data.ext.continuous_integration.length; j < max; j++) {
data.ext.continuous_integration[j].jobUrl = data.ext.continuous_integration[j].jobUrl.substring(0, data.ext.continuous_integration[j].jobUrl.indexOf("/lastCompletedBuild"));
}
}
$scope.$emit("updateBreadcrumbs", {link: "specification/" + $scope.id, title: data.title});
try {
if (data.controls.length > 0) {
$scope.rights = 1;
}
} catch (e) {
}
$scope.specification = data;
$scope.specification.originalOwner = data.owner;
projectsHttp.getAll($scope, function (data) {
var defaultProject = true;
for (var p = 0, maxp = data.length; p < maxp; p++) {
if (data[p].name === $scope.project.name) {
$scope.project.id = data[p].id;
defaultProject = false;
break;
}
}
if (defaultProject) {
data.push($scope.project);
}
$scope.projects = data;
}, $scope.generalHttpFactoryError);
usersHttp.getAll($scope, function (data) {
$scope.users = data.users;
}, $scope.generalHttpFactoryError);
}, $scope.generalHttpFactoryError);
break;
}
};