Skip to content

Commit f7b931c

Browse files
author
Vikas Agarwal
committed
Removes null values from phases key of project templates
1 parent 49249db commit f7b931c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/routes/projectTemplates/update.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ module.exports = [
6666
// Merge JSON fields
6767
entityToUpdate.scope = util.mergeJsonObjects(projectTemplate.scope, entityToUpdate.scope);
6868
entityToUpdate.phases = util.mergeJsonObjects(projectTemplate.phases, entityToUpdate.phases);
69+
// removes null phase templates
70+
entityToUpdate.phases = _.omitBy(entityToUpdate.phases, _.isNull)
6971

7072
return projectTemplate.update(entityToUpdate);
7173
})

src/util.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,11 @@ _.assignIn(util, {
379379
* @returns {Object} the merged object
380380
*/
381381
// eslint-disable-next-line consistent-return
382-
mergeJsonObjects: (targetObj, sourceObj) => _.mergeWith(targetObj, sourceObj, (target, source, key) => {
382+
mergeJsonObjects: (targetObj, sourceObj) => _.mergeWith(targetObj, sourceObj, (target, source) => {
383383
// Overwrite the array
384384
if (_.isArray(source)) {
385385
return source;
386386
}
387-
if (source === null) {
388-
_.unset(target, key);
389-
}
390387
}),
391388
});
392389

0 commit comments

Comments
 (0)