Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #300 from pangara/EPIC-1199
Browse files Browse the repository at this point in the history
EPIC-1199 Unable to create multiple Valued Components with the same name
  • Loading branch information
marklise authored Nov 10, 2017
2 parents b4e9792 + 2e92857 commit 81efd98
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
15 changes: 0 additions & 15 deletions modules/vcs/client/controllers/vc.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,8 @@ angular.module ('vcs')
m.type = obj.type;
VcModel.query({project: $scope.project})
.then(function(data) {
// Take the end of the string, assume it's a number,
// and increment accordingly.
var suffix = "-1";
if (data && data.length > 0) {
// get the last one and slice it
var existingCode = data[data.length-1].code.slice(-1);
existingCode++;
suffix = "-"+existingCode;
}
m.code = codeFromTitle(obj.name+"-"+m.project.code+suffix);
VcModel.saveCopy(m)
.then(function (saved) {
console.log("creating artifact for valued-component");
return ArtifactModel.getNew()
.then( function (f) {
f.valuedComponents.push(m);
Expand All @@ -130,7 +119,6 @@ angular.module ('vcs')
return ArtifactModel.saveCopy(f);
})
.then( function (art) {
console.log("created artifact of valued-component",art);
// Save the reference that this VC relates to. We will look to
// re-use this to build up the package of VC's later.
saved.artifact = art;
Expand Down Expand Up @@ -200,9 +188,6 @@ angular.module ('vcs')
});
};
this.ok = function () {
// console.log ('save clicked');
this.vc.code = codeFromTitle (this.vc.name);
// console.log ('new code = ', this.vc.code);
if (this.mode === 'add') {
VcModel.saveModel ().then (function (result) {
$modalInstance.close(result);
Expand Down
3 changes: 2 additions & 1 deletion modules/vcs/server/models/vc.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = require ('../../../core/server/controllers/core.schema.controll
__access : [ // read / write / delete are automatic
'publish',
'unPublish'],
__codename : 'unique',
name : { type: String, default: ''},
description : { type: String, default: ''},
title : { type:String, default:'', index:true },
type : { type:String, default:'', index:true },
topiccode : { type:String, default:'', index:true },
Expand Down

0 comments on commit 81efd98

Please sign in to comment.