Skip to content

Commit

Permalink
Merged PR 258: Moving items to the default row should be done by clea…
Browse files Browse the repository at this point in the history
…ring the field. Also, if

Moving items to the default row should be done by clearing the field. Also, if the source and target board both contain a row with the same name, we'll keep items in that row. Fixes bug #13618

Related work items: #13618
  • Loading branch information
Kees Verhaar authored and chrismason committed Oct 11, 2017
2 parents 2656a8d + 96fc811 commit 7a9b2e6
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ export class BoardConfiguration {

let uniqueNameifier = Date.now().toString() + "-";

let newRows = await this._applyNewRows(oldBoard.rows, backlogSettingToApply.rows, uniqueNameifier, backlogSettingToApply.boardName, context, workClient);
let newDefaultRow = this._getDefaultRow(newRows);
let newRows: WorkContracts.BoardRow[] = await this._applyNewRows(oldBoard.rows, backlogSettingToApply.rows, uniqueNameifier, backlogSettingToApply.boardName, context, workClient);
let newDefaultRow: WorkContracts.BoardRow = this._getDefaultRow(newRows);
let newDefaultRowName: string = null;
if (newDefaultRow) {
newDefaultRowName = newDefaultRow.name;
Expand Down Expand Up @@ -449,11 +449,22 @@ export class BoardConfiguration {
"value": newColumnFieldValue
}
];
if (newDefaultRowName && newDefaultRowName.length > 0) {

// If the target board has a row name that is exactly the same as a row in the source board, we update work items to stay in that row.
// Otherwise, we'll move them to the default row. This way we avoid having to do a complete mapping exercise, while still having some intelligent behavior.
let currentRowValue: string = wit.fields[boardRowField];
let shouldUpdateRowName: boolean = currentRowValue != null && newRows.filter(r => r.name === uniqueNameifier + currentRowValue).length > 0;
if (shouldUpdateRowName) {
patch.push({
"op": "replace",
"path": `/fields/${boardRowField}`,
"value": newDefaultRowName
"value": `${uniqueNameifier}${currentRowValue}`
});
} else {
patch.push({
"op": "remove",
"path": `/fields/${boardRowField}`,
"value": null
});
}
console.log("Updating work item from column: " + witColumn + " to column: " + JSON.stringify(patch));
Expand Down

0 comments on commit 7a9b2e6

Please sign in to comment.