AC-1006 upgraded all js libraries to latest release. Fixed obvious broken things. Installed bower to make package installation/upgrade easier. Added less to Grunt build.

This commit is contained in:
Chris Houseknecht
2014-02-12 18:24:30 +00:00
committed by Chris Houseknecht
parent d25e712e21
commit e81d02885f
960 changed files with 112155 additions and 35865 deletions

View File

@@ -14,7 +14,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate,
ProjectStatus, FormatDate, Refresh, Wait, Stream, GetChoices, Empty) {
ClearScope('htmlTemplate');
ClearScope();
Wait('start');
@@ -23,63 +23,64 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
view = GenerateList,
base = $location.path().replace(/^\//, '').split('/')[0],
mode = (base === 'projects') ? 'edit' : 'select',
scope = view.inject(list, { mode: mode }),
url = (base === 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl,
choiceCount = 0;
view.inject(list, { mode: mode, scope: $scope });
$rootScope.flashMessage = null;
scope.projectLoading = true;
$scope.projectLoading = true;
if (mode === 'select') {
SelectionInit({
scope: scope,
scope: $scope,
list: list,
url: url,
returnToCaller: 1
});
}
if (scope.removePostRefresh) {
scope.removePostRefresh();
if ($scope.removePostRefresh) {
$scope.removePostRefresh();
}
scope.removePostRefresh = scope.$on('PostRefresh', function () {
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
// Cleanup after a delete
var j, i;
Wait('stop');
$('#prompt-modal').off();
if (scope.projects) {
for (i = 0; i < scope.projects.length; i++) {
if (scope.projects[i].status === 'ok') {
scope.projects[i].status = 'n/a';
if ($scope.projects) {
for (i = 0; i < $scope.projects.length; i++) {
if ($scope.projects[i].status === 'ok') {
$scope.projects[i].status = 'n/a';
}
switch (scope.projects[i].status) {
switch ($scope.projects[i].status) {
case 'n/a':
scope.projects[i].badge = 'none';
$scope.projects[i].badge = 'none';
break;
case 'updating':
case 'successful':
case 'ok':
scope.projects[i].badge = 'false';
$scope.projects[i].badge = 'false';
break;
case 'never updated':
case 'failed':
case 'missing':
scope.projects[i].badge = 'true';
$scope.projects[i].badge = 'true';
break;
}
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
FormatDate(new Date(scope.projects[i].last_updated)) : null;
$scope.projects[i].last_updated = ($scope.projects[i].last_updated !== null) ?
FormatDate(new Date($scope.projects[i].last_updated)) : null;
for (j = 0; j < scope.project_scm_type_options.length; j++) {
if (scope.project_scm_type_options[j].value === scope.projects[i].scm_type) {
scope.projects[i].scm_type = scope.project_scm_type_options[j].label;
if (scope.projects[i].scm_type === 'Manual') {
scope.projects[i].scm_update_tooltip = 'Manaul projects do not require an SCM update';
scope.projects[i].scm_type_class = 'btn-disabled';
for (j = 0; j < $scope.project_scm_type_options.length; j++) {
if ($scope.project_scm_type_options[j].value === $scope.projects[i].scm_type) {
$scope.projects[i].scm_type = $scope.project_scm_type_options[j].label;
if ($scope.projects[i].scm_type === 'Manual') {
$scope.projects[i].scm_update_tooltip = 'Manaul projects do not require an SCM update';
$scope.projects[i].scm_type_class = 'btn-disabled';
} else {
scope.projects[i].scm_update_tooltip = "Start an SCM update";
scope.projects[i].scm_type_class = "";
$scope.projects[i].scm_update_tooltip = "Start an SCM update";
$scope.projects[i].scm_type_class = "";
}
break;
}
@@ -88,14 +89,14 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
});
if (scope.removeChoicesHere) {
scope.removeChoicesHere();
if ($scope.removeChoicesHere) {
$scope.removeChoicesHere();
}
scope.removeChoicesHere = scope.$on('choicesCompleteProject', function () {
$scope.removeChoicesHere = $scope.$on('choicesCompleteProject', function () {
var opt;
list.fields.scm_type.searchOptions = scope.project_scm_type_options;
list.fields.status.searchOptions = scope.project_status_options;
list.fields.scm_type.searchOptions = $scope.project_scm_type_options;
list.fields.status.searchOptions = $scope.project_status_options;
if ($routeParams.scm_type && $routeParams.status) {
// Request coming from home page. User wants all errors for an scm_type
@@ -103,57 +104,57 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
SearchInit({
scope: scope,
scope: $scope,
set: 'projects',
list: list,
url: defaultUrl
});
PaginateInit({
scope: scope,
scope: $scope,
list: list,
url: defaultUrl
});
if ($routeParams.scm_type) {
scope[list.iterator + 'SearchField'] = 'scm_type';
scope[list.iterator + 'SelectShow'] = true;
scope[list.iterator + 'SearchSelectOpts'] = list.fields.scm_type.searchOptions;
scope[list.iterator + 'SearchFieldLabel'] = list.fields.scm_type.label.replace(/<br\>/g, ' ');
$scope[list.iterator + 'SearchField'] = 'scm_type';
$scope[list.iterator + 'SelectShow'] = true;
$scope[list.iterator + 'SearchSelectOpts'] = list.fields.scm_type.searchOptions;
$scope[list.iterator + 'SearchFieldLabel'] = list.fields.scm_type.label.replace(/<br\>/g, ' ');
for (opt in list.fields.scm_type.searchOptions) {
if (list.fields.scm_type.searchOptions[opt].value === $routeParams.scm_type) {
scope[list.iterator + 'SearchSelectValue'] = list.fields.scm_type.searchOptions[opt];
$scope[list.iterator + 'SearchSelectValue'] = list.fields.scm_type.searchOptions[opt];
break;
}
}
} else if ($routeParams.status) {
scope[list.iterator + 'SearchValue'] = $routeParams.status;
scope[list.iterator + 'SearchField'] = 'status';
scope[list.iterator + 'SelectShow'] = true;
scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label;
scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
$scope[list.iterator + 'SearchValue'] = $routeParams.status;
$scope[list.iterator + 'SearchField'] = 'status';
$scope[list.iterator + 'SelectShow'] = true;
$scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label;
$scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
for (opt in list.fields.status.searchOptions) {
if (list.fields.status.searchOptions[opt].value === $routeParams.status) {
scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
$scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
break;
}
}
}
scope.search(list.iterator);
$scope.search(list.iterator);
});
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReadyProject', function () {
$scope.removeChoicesReady = $scope.$on('choicesReadyProject', function () {
choiceCount++;
if (choiceCount === 2) {
scope.$emit('choicesCompleteProject');
$scope.$emit('choicesCompleteProject');
}
});
// Load options for status --used in search
GetChoices({
scope: scope,
scope: $scope,
url: defaultUrl,
field: 'status',
variable: 'project_status_options',
@@ -162,7 +163,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
// Load the list of options for Kind
GetChoices({
scope: scope,
scope: $scope,
url: defaultUrl,
field: 'scm_type',
variable: 'project_scm_type_options',
@@ -171,25 +172,25 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
LoadBreadCrumbs();
scope.showActivity = function () {
Stream({ scope: scope });
$scope.showActivity = function () {
Stream({ scope: $scope });
};
scope.addProject = function () {
$scope.addProject = function () {
$location.path($location.path() + '/add');
};
scope.editProject = function (id) {
$scope.editProject = function (id) {
$location.path($location.path() + '/' + id);
};
scope.showSCMStatus = function (id) {
$scope.showSCMStatus = function (id) {
// Refresh the project list
var i, statusCheckRemove = scope.$on('PostRefresh', function () {
var i, statusCheckRemove = $scope.$on('PostRefresh', function () {
var project;
for (i= 0; i < scope.projects.length; i++) {
if (scope.projects[i].id === id) {
project = scope.projects[i];
for (i= 0; i < $scope.projects.length; i++) {
if ($scope.projects[i].id === id) {
project = $scope.projects[i];
break;
}
}
@@ -218,10 +219,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
});
// Refresh the project list so we're looking at the latest data
scope.search(list.iterator, null, false, true);
$scope.search(list.iterator, null, false, true);
};
scope.deleteProject = function (id, name) {
$scope.deleteProject = function (id, name) {
var action = function () {
$('#prompt-modal').on('hiden.bs.modal', function () {
Wait('start');
@@ -231,14 +232,12 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
Rest.setUrl(url);
Rest.destroy()
.success(function () {
scope.search(list.iterator);
$scope.search(list.iterator);
})
.error(function (data, status) {
Wait('stop');
ProcessErrors(scope, data, status, null, {
hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
});
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
});
};
@@ -249,49 +248,49 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
});
};
if (scope.removeCancelUpdate) {
scope.removeCancelUpdate();
if ($scope.removeCancelUpdate) {
$scope.removeCancelUpdate();
}
scope.removeCancelUpdate = scope.$on('Cancel_Update', function (e, url) {
$scope.removeCancelUpdate = $scope.$on('Cancel_Update', function (e, url) {
// Cancel the project update process
Rest.setUrl(url);
Rest.post()
.success(function () {
Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task maanger.', 'alert-info');
scope.refresh();
$scope.refresh();
})
.error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
});
});
if (scope.removeCheckCancel) {
scope.removeCheckCancel();
if ($scope.removeCheckCancel) {
$scope.removeCheckCancel();
}
scope.removeCheckCancel = scope.$on('Check_Cancel', function (e, data) {
$scope.removeCheckCancel = $scope.$on('Check_Cancel', function (e, data) {
// Check that we 'can' cancel the update
var url = data.related.cancel;
Rest.setUrl(url);
Rest.get()
.success(function (data) {
if (data.can_cancel) {
scope.$emit('Cancel_Update', url);
$scope.$emit('Cancel_Update', url);
} else {
Alert('Cancel Not Allowed', 'Either you do not have access or the SCM update process completed. ' +
'Click the <em>Refresh</em> button to view the latest status.', 'alert-info');
}
})
.error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
});
});
scope.cancelUpdate = function (id, name) {
$scope.cancelUpdate = function (id, name) {
// Start the cancel process
var i, project, found = false;
for (i = 0; i < scope.projects.length; i++) {
if (scope.projects[i].id === id) {
project = scope.projects[i];
for (i = 0; i < $scope.projects.length; i++) {
if ($scope.projects[i].id === id) {
project = $scope.projects[i];
found = true;
break;
}
@@ -300,13 +299,11 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
Rest.setUrl(project.related.current_update);
Rest.get()
.success(function (data) {
scope.$emit('Check_Cancel', data);
$scope.$emit('Check_Cancel', data);
})
.error(function (data, status) {
ProcessErrors(scope, data, status, null, {
hdr: 'Error!',
msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status
});
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status });
});
} else {
Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + name + '. Click the <em>Refresh</em> ' +
@@ -314,33 +311,30 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
};
scope.refresh = function () {
$scope.refresh = function () {
Wait('start');
scope.projectLoading = false;
$scope.projectLoading = false;
Refresh({
scope: scope,
scope: $scope,
set: 'projects',
iterator: 'project',
url: scope.current_url
url: $scope.current_url
});
};
scope.SCMUpdate = function (project_id) {
$scope.SCMUpdate = function (project_id) {
var i;
for (i = 0; i < scope.projects.length; i++) {
if (scope.projects[i].id === project_id) {
if (scope.projects[i].scm_type === "Manual" || Empty(scope.projects[i].scm_type)) {
for (i = 0; i < $scope.projects.length; i++) {
if ($scope.projects[i].id === project_id) {
if ($scope.projects[i].scm_type === "Manual" || Empty($scope.projects[i].scm_type)) {
// Do not respond. Button appears greyed out as if it is disabled. Not disabled though, because we need mouse over event
// to work. So user can click, but we just won't do anything.
//Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
break;
} else if (scope.projects[i].status === 'updating') {
} else if ($scope.projects[i].status === 'updating') {
Alert('Update in Progress', 'The SCM update process is running. Use the Refresh button to monitor the status.', 'alert-info');
} else {
ProjectUpdate({
scope: scope,
project_id: project_id
});
ProjectUpdate({ scope: $scope, project_id: project_id });
}
}
}
@@ -353,47 +347,43 @@ ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routePara
];
function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors,
LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
CredentialList, GetChoices, DebugForm, Wait) {
ClearScope('tree-form');
ClearScope('htmlTemplate');
ClearScope();
// Inject dynamic view
var form = ProjectsForm,
generator = GenerateForm,
base = $location.path().replace(/^\//, '').split('/')[0],
defaultUrl = GetBasePath('projects'),
scope = generator.inject(form, { mode: 'add', related: false }),
master = {};
generator.inject(form, { mode: 'add', related: false, scope: $scope });
generator.reset();
LoadBreadCrumbs();
GetProjectPath({
scope: scope,
master: master
});
GetProjectPath({ scope: $scope, master: master });
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function () {
$scope.removeChoicesReady = $scope.$on('choicesReady', function () {
var i;
for (i = 0; i < scope.scm_type_options.length; i++) {
if (scope.scm_type_options[i].value === '') {
scope.scm_type = scope.scm_type_options[i];
for (i = 0; i < $scope.scm_type_options.length; i++) {
if ($scope.scm_type_options[i].value === '') {
$scope.scm_type = $scope.scm_type_options[i];
break;
}
}
scope.scmRequired = false;
master.scm_type = scope.scm_type;
$scope.scmRequired = false;
master.scm_type = $scope.scm_type;
});
// Load the list of options for Kind
GetChoices({
scope: scope,
scope: $scope,
url: defaultUrl,
field: 'scm_type',
variable: 'scm_type_options',
@@ -401,14 +391,14 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
});
LookUpInit({
scope: scope,
scope: $scope,
form: form,
list: OrganizationList,
field: 'organization'
});
LookUpInit({
scope: scope,
scope: $scope,
url: GetBasePath('credentials') + '?kind=scm',
form: form,
list: CredentialList,
@@ -416,26 +406,26 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
});
// Save
scope.formSave = function () {
$scope.formSave = function () {
var i, fld, url, data={};
generator.clearApiErrors();
data = {};
for (fld in form.fields) {
if (form.fields[fld].type === 'checkbox_group') {
for (i = 0; i < form.fields[fld].fields.length; i++) {
data[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
data[form.fields[fld].fields[i].name] = $scope[form.fields[fld].fields[i].name];
}
} else {
if (form.fields[fld].type !== 'alertblock') {
data[fld] = scope[fld];
data[fld] = $scope[fld];
}
}
}
data.scm_type = scope.scm_type.value;
if (scope.scm_type.value !== '') {
data.scm_type = $scope.scm_type.value;
if ($scope.scm_type.value !== '') {
delete data.local_path;
} else {
data.local_path = scope.local_path.value;
data.local_path = $scope.local_path.value;
}
url = (base === 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
@@ -445,7 +435,7 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
.success(function (data) {
var id = data.id,
url = GetBasePath('projects') + id + '/organizations/',
org = { id: scope.organization };
org = { id: $scope.organization };
Rest.setUrl(url);
Rest.post(org)
.success(function () {
@@ -458,39 +448,35 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
})
.error(function (data, status) {
Wait('stop');
ProcessErrors(scope, data, status, ProjectsForm, {
hdr: 'Error!',
msg: 'Failed to add organization to project. POST returned status: ' + status
});
ProcessErrors($scope, data, status, ProjectsForm, { hdr: 'Error!',
msg: 'Failed to add organization to project. POST returned status: ' + status });
});
})
.error(function (data, status) {
Wait('stop');
ProcessErrors(scope, data, status, ProjectsForm, {
hdr: 'Error!',
msg: 'Failed to create new project. POST returned status: ' + status
});
ProcessErrors($scope, data, status, ProjectsForm, { hdr: 'Error!',
msg: 'Failed to create new project. POST returned status: ' + status });
});
};
scope.scmChange = function () {
$scope.scmChange = function () {
// When an scm_type is set, path is not required
if (scope.scm_type) {
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
if ($scope.scm_type) {
$scope.pathRequired = ($scope.scm_type.value === '') ? true : false;
$scope.scmRequired = ($scope.scm_type.value !== '') ? true : false;
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
}
};
// Cancel
scope.formReset = function () {
$scope.formReset = function () {
var fld;
$rootScope.flashMessage = null;
generator.reset();
for (fld in master) {
scope.fld = master.fld;
$scope.fld = master.fld;
}
scope.scmChange();
$scope.scmChange();
};
}
@@ -511,59 +497,59 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
// Inject dynamic view
var form = ProjectsForm,
generator = GenerateForm,
scope = generator.inject(form, { mode: 'edit', related: true }),
defaultUrl = GetBasePath('projects') + $routeParams.id + '/',
base = $location.path().replace(/^\//, '').split('/')[0],
master = {},
id = $routeParams.id,
relatedSets = {};
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
generator.reset();
scope.project_local_paths = [];
scope.base_dir = '';
$scope.project_local_paths = [];
$scope.base_dir = '';
// After the project is loaded, retrieve each related set
if (scope.projectLoadedRemove) {
scope.projectLoadedRemove();
if ($scope.projectLoadedRemove) {
$scope.projectLoadedRemove();
}
scope.projectLoadedRemove = scope.$on('projectLoaded', function () {
$scope.projectLoadedRemove = $scope.$on('projectLoaded', function () {
var set, opts=[];
for (set in relatedSets) {
scope.search(relatedSets[set].iterator);
$scope.search(relatedSets[set].iterator);
}
if (Authorization.getUserInfo('is_superuser') === true) {
GetProjectPath({ scope: scope, master: master });
GetProjectPath({ scope: $scope, master: master });
} else {
opts.push({
label: scope.local_path,
value: scope.local_path
label: $scope.local_path,
value: $scope.local_path
});
scope.project_local_paths = opts;
scope.local_path = scope.project_local_paths[0];
scope.base_dir = 'You do not have access to view this property';
$scope.project_local_paths = opts;
$scope.local_path = $scope.project_local_paths[0];
$scope.base_dir = 'You do not have access to view this property';
}
LookUpInit({
url: GetBasePath('credentials') + '?kind=scm',
scope: scope,
scope: $scope,
form: form,
list: CredentialList,
field: 'credential'
});
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
$scope.pathRequired = ($scope.scm_type.value === '') ? true : false;
$scope.scmRequired = ($scope.scm_type.value !== '') ? true : false;
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
Wait('stop');
});
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function () {
$scope.removeChoicesReady = $scope.$on('choicesReady', function () {
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl);
Rest.get({ params: { id: id } })
@@ -573,18 +559,18 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
for (fld in form.fields) {
if (form.fields[fld].type === 'checkbox_group') {
for (i = 0; i < form.fields[fld].fields.length; i++) {
scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
$scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
}
} else {
if (data[fld]) {
scope[fld] = data[fld];
$scope[fld] = data[fld];
master[fld] = data[fld];
}
}
if (fld !== 'organization' && form.fields[fld].sourceModel &&
data.summary_fields && data.summary_fields[form.fields[fld].sourceModel]) {
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
$scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
@@ -602,38 +588,38 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
data.scm_type = (Empty(data.scm_type)) ? '' : data.scm_type;
for (i = 0; i < scope.scm_type_options.length; i++) {
if (scope.scm_type_options[i].value === data.scm_type) {
scope.scm_type = scope.scm_type_options[i];
for (i = 0; i < $scope.scm_type_options.length; i++) {
if ($scope.scm_type_options[i].value === data.scm_type) {
$scope.scm_type = $scope.scm_type_options[i];
break;
}
}
if (scope.scm_type.value !== '') {
scope.pathRequired = false;
scope.scmRequired = true;
if ($scope.scm_type.value !== '') {
$scope.pathRequired = false;
$scope.scmRequired = true;
} else {
scope.pathRequired = true;
scope.scmRequired = false;
$scope.pathRequired = true;
$scope.scmRequired = false;
}
master.scm_type = scope.scm_type;
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
master.scm_type = $scope.scm_type;
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
RelatedSearchInit({
scope: scope,
scope: $scope,
form: form,
relatedSets: relatedSets
});
RelatedPaginateInit({
scope: scope,
scope: $scope,
relatedSets: relatedSets
});
scope.$emit('projectLoaded');
$scope.$emit('projectLoaded');
})
.error(function (data, status) {
ProcessErrors(scope, data, status, form, {
ProcessErrors($scope, data, status, form, {
hdr: 'Error!',
msg: 'Failed to retrieve project: ' + id + '. GET status: ' + status
});
@@ -644,7 +630,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
Wait('start');
GetChoices({
url: GetBasePath('projects'),
scope: scope,
scope: $scope,
field: 'scm_type',
variable: 'scm_type_options',
callback: 'choicesReady'
@@ -652,7 +638,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
// Save changes to the parent
scope.formSave = function () {
$scope.formSave = function () {
var fld, i, params;
generator.clearApiErrors();
Wait('start');
@@ -661,20 +647,20 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
for (fld in form.fields) {
if (form.fields[fld].type === 'checkbox_group') {
for (i = 0; i < form.fields[fld].fields.length; i++) {
params[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
params[form.fields[fld].fields[i].name] = $scope[form.fields[fld].fields[i].name];
}
} else {
if (form.fields[fld].type !== 'alertblock') {
params[fld] = scope[fld];
params[fld] = $scope[fld];
}
}
}
params.scm_type = scope.scm_type.value;
if (scope.scm_type.value !== '') {
params.scm_type = $scope.scm_type.value;
if ($scope.scm_type.value !== '') {
delete params.local_path;
} else {
params.local_path = scope.local_path.value;
params.local_path = $scope.local_path.value;
}
Rest.setUrl(defaultUrl);
@@ -684,31 +670,28 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
ReturnToCaller();
})
.error(function (data, status) {
Wait('stop');
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
ProcessErrors($scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
});
};
scope.showActivity = function () {
Stream({
scope: scope
});
$scope.showActivity = function () {
Stream({ scope: $scope });
};
// Related set: Add button
scope.add = function (set) {
$scope.add = function (set) {
$rootScope.flashMessage = null;
$location.path('/' + base + '/' + $routeParams.id + '/' + set);
};
// Related set: Edit button
scope.edit = function (set, id) {
$scope.edit = function (set, id) {
$rootScope.flashMessage = null;
$location.path('/' + set + '/' + id);
};
// Related set: Delete button
scope['delete'] = function (set, itm_id, name, title) {
$scope['delete'] = function (set, itm_id, name, title) {
var action = function () {
var url = GetBasePath('projects') + id + '/' + set + '/';
$rootScope.flashMessage = null;
@@ -716,37 +699,37 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
Rest.post({ id: itm_id, disassociate: 1 })
.success(function () {
$('#prompt-modal').modal('hide');
scope.search(form.related[set].iterator);
$scope.search(form.related[set].iterator);
})
.error(function (data, status) {
$('#prompt-modal').modal('hide');
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
});
};
Prompt({
hdr: 'Delete',
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
body: 'Are you sure you want to remove ' + name + ' from ' + $scope.name + ' ' + title + '?',
action: action
});
};
scope.scmChange = function () {
if (scope.scm_type) {
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
$scope.scmChange = function () {
if ($scope.scm_type) {
$scope.pathRequired = ($scope.scm_type.value === '') ? true : false;
$scope.scmRequired = ($scope.scm_type.value !== '') ? true : false;
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
}
};
// Reset the form
scope.formReset = function () {
$scope.formReset = function () {
$rootScope.flashMessage = null;
generator.reset();
for (var fld in master) {
scope[fld] = master[fld];
$scope[fld] = master[fld];
}
scope.scmChange();
$scope.scmChange();
};
}