@rss/common
Advanced tools
Comparing version 0.0.67 to 0.0.68
@@ -27,2 +27,3 @@ 'use strict'; | ||
var CARD_TYPE = require('../../constant/procedure/card-type.constant'); | ||
var DOCUMENT_STATUS = require('../../constant/procedure/document-status.constant'); | ||
@@ -158,6 +159,18 @@ | ||
copy.sections = copy.sections.map(function (section) { | ||
var cloneSection = Object.assign({}, section, { | ||
var cloneSection = _extends({}, section, { | ||
id: new ObjectId(), | ||
cards: section.cards.map(function (card) { | ||
return Object.assign({}, card, { id: new ObjectId(), attachments: [] }); | ||
if (card.type === CARD_TYPE.ACKNOWLEDGEMENT.type) { | ||
return _extends({}, card, { | ||
id: new ObjectId(), | ||
attachments: [], | ||
details: _extends({}, card.details, { | ||
signatures: [] | ||
}) | ||
}); | ||
} | ||
return _extends({}, card, { | ||
id: new ObjectId(), | ||
attachments: [] | ||
}); | ||
}) | ||
@@ -164,0 +177,0 @@ }); |
{ | ||
"name": "@rss/common", | ||
"version": "0.0.67", | ||
"version": "0.0.68", | ||
"description": "common constant, classes, & helper", | ||
@@ -5,0 +5,0 @@ "author": "Risk & Safety Solution", |
@@ -19,2 +19,3 @@ const ObjectId = require('bson').ObjectID; | ||
const CARD_TYPE = require('../../constant/procedure/card-type.constant'); | ||
const DOCUMENT_STATUS = require('../../constant/procedure/document-status.constant'); | ||
@@ -124,6 +125,24 @@ | ||
copy.sections = copy.sections.map((section) => { | ||
const cloneSection = Object.assign({}, section, { | ||
const cloneSection = { | ||
...section, | ||
id: new ObjectId(), | ||
cards: section.cards.map((card) => Object.assign({}, card, { id: new ObjectId(), attachments: [] })), | ||
}); | ||
cards: section.cards.map((card) => { | ||
if (card.type === CARD_TYPE.ACKNOWLEDGEMENT.type) { | ||
return { | ||
...card, | ||
id: new ObjectId(), | ||
attachments: [], | ||
details: { | ||
...card.details, | ||
signatures: [], | ||
}, | ||
}; | ||
} | ||
return { | ||
...card, | ||
id: new ObjectId(), | ||
attachments: [], | ||
}; | ||
}), | ||
}; | ||
return cloneSection; | ||
@@ -130,0 +149,0 @@ }); |
@@ -78,2 +78,64 @@ const Document = require('./document'); | ||
it('should clone a document with an acknowledgement card and remove signatures', () => { | ||
const document = new Document({ | ||
_id: '5b32afb68ec988000028ee4d', | ||
template: { | ||
_id: '5b084c570422b90000b89a2c', | ||
types: ['MEDICAL'], | ||
maxExpirationDays: null, | ||
tenantCode: ['ALL'], | ||
campusCode: ['ALL'], | ||
}, | ||
title: 'Title', | ||
description: 'this is a description', | ||
access: [], | ||
sections: [ | ||
{ | ||
id: '5acbe189bfb158000036760a', | ||
allowableCards: [], | ||
cards: [ | ||
{ | ||
id: '5834619518d49e2c51725e0d', | ||
type: 'ACKNOWLEDGEMENT', | ||
isRequired: true, | ||
allowAttachments: false, | ||
attachments: [], | ||
details: { | ||
acknowledgeLabel: 'Acknowledged by: ', | ||
prompt: | ||
'I have read and acknowledge the contents, requirements, and responsibilities outlined in this procedure.', | ||
signatures: [ | ||
{ | ||
date: '2018-08-30T17:09:51.408Z', | ||
person: { | ||
userId: 'VUN8MDN8dGFqaGFAdWNkYXZpcy5lZHU', | ||
firstName: 'Trevor', | ||
lastName: 'Jha', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
createdBy: { firstName: 'Ian' }, | ||
createdDate: new Date('2016-11-5T15:42:35.620Z'), | ||
lastModifiedBy: { firstName: 'Ian' }, | ||
lastModifiedDate: new Date('2016-11-22T15:42:35.620Z'), | ||
}); | ||
const newTitle = 'New Title'; | ||
const clonedDocument = Document.clone(document, { title: newTitle, description: 'some updated description' }); | ||
expect(clonedDocument._id.toString()).not.toEqual('5b32afb68ec988000028ee4d'); | ||
expect(clonedDocument.sections[0].id.toString()).not.toEqual('5acbe189bfb158000036760a'); | ||
expect(clonedDocument.sections[0].cards[0].id.toString()).not.toEqual('5834619518d49e2c51725e0d'); | ||
expect(clonedDocument.sections[0].cards[0].details.signatures).toHaveLength(0); | ||
expect(clonedDocument.createdBy).toBeNull(); | ||
expect(clonedDocument.lastModifiedBy).toBeNull(); | ||
expect(clonedDocument.template).toEqual(document.template); | ||
expect(clonedDocument.title).toEqual(newTitle); | ||
}); | ||
it('should create a new document from a template', () => { | ||
@@ -80,0 +142,0 @@ const template = { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252
13741
769469