implement model based copy for projects

This commit is contained in:
Jake McDermott 2017-12-05 15:52:44 -05:00
parent e5fd483d06
commit 779385ddb6
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35
2 changed files with 24 additions and 0 deletions

View File

@ -154,6 +154,21 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
}
});
$scope.copyProject = project => {
Wait('start');
new Project('get', project.id)
.then(model => model.copy())
.then(({ id }) => {
const params = { project_id: id };
$state.go('projects.edit', params, { reload: true });
})
.catch(({ data, status }) => {
const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` };
ProcessErrors($scope, data, status, null, params);
})
.finally(() => Wait('stop'));
};
$scope.showSCMStatus = function(id) {
// Refresh the project list
var project = Find({ list: $scope.projects, key: 'id', val: id });

View File

@ -100,6 +100,15 @@ export default ['i18n', function(i18n) {
dataPlacement: 'top',
ngShow: "project.summary_fields.user_capabilities.schedule"
},
copy: {
label: i18n._('Copy'),
ngClick: 'copyProject(project)',
"class": 'btn-danger btn-xs',
awToolTip: i18n._('Copy project'),
dataPlacement: 'top',
// requires future api rbac changes
//ngShow: 'project.summary_fields.user_capabilities.copy'
},
edit: {
ngClick: "editProject(project.id)",
awToolTip: i18n._('Edit the project'),