Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now supports creating items with tags #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define(["TFS/WorkItemTracking/Services", "TFS/WorkItemTracking/RestClient", "TFS
if (taskTemplate.fields.hasOwnProperty(key) == false) {
return false;
}
if (key.indexOf('System.Tags') >= 0) { //not supporting tags for now
if (key.indexOf('System.Tags-Remove') >= 0) { //removing tags not applicable
return false;
}
if (taskTemplate.fields[key].toLowerCase() == '@me') { //current identity is handled later
Expand All @@ -70,22 +70,29 @@ define(["TFS/WorkItemTracking/Services", "TFS/WorkItemTracking/RestClient", "TFS
}

function createWorkItemFromTemplate(currentWorkItem, taskTemplate, teamSettings) {
const workItemKeys = {
"System.Tags-Add": "System.Tags",
};

var workItem = [];

for (var key in taskTemplate.fields) {
//map template field to work item field
mappedKey = workItemKeys[key] || key;

if (IsPropertyValid(taskTemplate, key)) {
//if field value is empty copies value from parent
if (taskTemplate.fields[key] == '') {
if (currentWorkItem[key] != null) {
workItem.push({ "op": "add", "path": "/fields/" + key, "value": currentWorkItem[key] })
if (currentWorkItem[mappedKey] != null) {
workItem.push({ "op": "add", "path": "/fields/" + mappedKey, "value": currentWorkItem[key] })
}
}
else {
var fieldValue = taskTemplate.fields[key];
//check for references to parent fields - {fieldName}
fieldValue = replaceReferenceToParentField(fieldValue, currentWorkItem);

workItem.push({ "op": "add", "path": "/fields/" + key, "value": fieldValue })
workItem.push({ "op": "add", "path": "/fields/" + mappedKey, "value": fieldValue })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"Tasks"
],
"categories": [
"Plan and track"
"Azure Boards"
],
"content": {
"details": {
Expand Down