@rss/common
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -31,5 +31,6 @@ 'use strict'; | ||
count: null, | ||
hideNotes: false, | ||
notes: null, | ||
optionsId: null, | ||
selectedOptions: [], | ||
notes: null | ||
selectedOptions: [] | ||
}; | ||
@@ -48,2 +49,3 @@ | ||
this.details.countLabel = details.countLabel || null; | ||
this.details.hideNotes = 'hideNotes' in details ? details.hideNotes : false; | ||
this.details.optionsId = details.optionsId ? new ObjectId(details.optionsId) : null; | ||
@@ -76,2 +78,3 @@ this.details.selectedOptions = details.selectedOptions ? details.selectedOptions.map(function (opt) { | ||
count: { type: ['number', 'null'] }, | ||
hideNotes: { type: 'boolean' }, | ||
optionsId: { type: 'object' }, | ||
@@ -78,0 +81,0 @@ selectedOptions: { type: 'array', items: { $ref: 'card-option-value.schema.json' } }, |
@@ -32,3 +32,2 @@ 'use strict'; | ||
header: '', | ||
hideDescription: false, | ||
title: null, | ||
@@ -60,3 +59,2 @@ value: null | ||
this.details.header = details.header || ''; | ||
this.details.hideDescription = !!details.hideDescription; | ||
this.details.title = details.title || null; | ||
@@ -110,3 +108,2 @@ this.details.value = details.value || null; | ||
header: { type: 'string' }, | ||
hideDescription: { type: 'boolean' }, | ||
title: { type: ['string', 'null'] }, | ||
@@ -113,0 +110,0 @@ value: { type: ['string', 'null'] } |
@@ -30,4 +30,3 @@ 'use strict'; | ||
optionsId: null, | ||
questions: [], | ||
notes: null | ||
questions: [] | ||
}; | ||
@@ -49,3 +48,2 @@ | ||
}) : []; | ||
this.details.notes = details.notes || null; | ||
} | ||
@@ -69,4 +67,3 @@ }, { | ||
optionsId: { type: 'object' }, | ||
questions: { type: 'array', items: { $ref: 'card-label-value.schema.json' } }, | ||
notes: { type: ['string', 'null'] } | ||
questions: { type: 'array', items: { $ref: 'card-label-value.schema.json' } } | ||
} | ||
@@ -73,0 +70,0 @@ } |
{ | ||
"name": "@rss/common", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "common constant, classes, & helper", | ||
@@ -28,6 +28,12 @@ "author": "Risk & Safety Solution", | ||
"babel": { | ||
"presets": ["env"], | ||
"ignore": ["**/*.spec.js"], | ||
"plugins": ["transform-object-rest-spread"] | ||
"presets": [ | ||
"env" | ||
], | ||
"ignore": [ | ||
"**/*.spec.js" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
] | ||
} | ||
} |
@@ -33,2 +33,44 @@ const { createCardFactory } = require('./card-factory'); | ||
}); | ||
it('should create a condition card with children cards', () => { | ||
const card = createCardFactory('CONDITION', { | ||
details: { | ||
header: 'Equipments', | ||
conditions: { | ||
SIT: [ | ||
{ | ||
type: 'VALUE_UNIT', | ||
details: { | ||
unitOptions: ['Quantity'], | ||
countLabel: 'Sit to Stand device(s) Non Powered', | ||
valueDescription: 'Quantity', | ||
infoDescription: null, | ||
}, | ||
}, | ||
{ | ||
type: 'SELECT', | ||
isMovable: false, | ||
allowAttachments: false, | ||
details: { | ||
name: 'Asset Information', | ||
optionsId: '5acd4016cee0ae01aac5c62b', | ||
questions: [ | ||
{ | ||
label: 'Has RFID?', | ||
value: null, | ||
}, | ||
], | ||
notes: null, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
const validate = card.validate(); | ||
expect(validate.valid).toBeTruthy(); | ||
expect(card.details.conditions.SIT.length).toEqual(2); | ||
expect(card.details.conditions.SIT.map((c) => c.type)).toEqual(expect.arrayContaining(['VALUE_UNIT', 'SELECT'])); | ||
}); | ||
}); |
@@ -16,5 +16,6 @@ const ObjectId = require('bson').ObjectID; | ||
count: null, | ||
hideNotes: false, | ||
notes: null, | ||
optionsId: null, | ||
selectedOptions: [], | ||
notes: null, | ||
}; | ||
@@ -30,2 +31,3 @@ | ||
this.details.countLabel = details.countLabel || null; | ||
this.details.hideNotes = 'hideNotes' in details ? details.hideNotes : false; | ||
this.details.optionsId = details.optionsId ? new ObjectId(details.optionsId) : null; | ||
@@ -58,2 +60,3 @@ this.details.selectedOptions = details.selectedOptions | ||
count: { type: ['number', 'null'] }, | ||
hideNotes: { type: 'boolean' }, | ||
optionsId: { type: 'object' }, | ||
@@ -60,0 +63,0 @@ selectedOptions: { type: 'array', items: { $ref: 'card-option-value.schema.json' } }, |
@@ -15,3 +15,2 @@ const clone = require('clone'); | ||
header: '', | ||
hideDescription: false, | ||
title: null, | ||
@@ -38,3 +37,2 @@ value: null, | ||
this.details.header = details.header || ''; | ||
this.details.hideDescription = !!details.hideDescription; | ||
this.details.title = details.title || null; | ||
@@ -81,3 +79,2 @@ this.details.value = details.value || null; | ||
header: { type: 'string' }, | ||
hideDescription: { type: 'boolean' }, | ||
title: { type: ['string', 'null'] }, | ||
@@ -84,0 +81,0 @@ value: { type: ['string', 'null'] }, |
const Document = require('./document'); | ||
const TemplateReference = require('./template-reference'); | ||
const DOCUMENT_STATUS = require('../../constant/procedure/document-status.constant'); | ||
@@ -60,12 +59,2 @@ const ObjectId = require('bson').ObjectID; | ||
], | ||
group: { | ||
id: 'dee70836-ab40-4437-b055-2cfeaac666f1', | ||
name: 'Team Purple', | ||
owner: { | ||
userId: '', | ||
firstName: '', | ||
lastName: '', | ||
campusCode: '03', | ||
}, | ||
}, | ||
createdBy: { firstName: 'Ian' }, | ||
@@ -77,3 +66,4 @@ createdDate: new Date('2016-11-5T15:42:35.620Z'), | ||
const clonedDocument = Document.clone(document, { title: 'New Title', description: 'some updated description' }); | ||
const newTitle = 'New Title'; | ||
const clonedDocument = Document.clone(document, { title: newTitle, description: 'some updated description' }); | ||
@@ -85,52 +75,4 @@ expect(clonedDocument._id.toString()).not.toEqual('5808fa7fae73b626daa89192'); | ||
expect(clonedDocument.lastModifiedBy).toBeNull(); | ||
delete clonedDocument._id; | ||
delete clonedDocument.group; | ||
delete clonedDocument.createdBy; | ||
delete clonedDocument.createdDate; | ||
delete clonedDocument.lastModifiedBy; | ||
delete clonedDocument.sections[0].id; | ||
delete clonedDocument.sections[0].cards[0].id; | ||
expect(clonedDocument).toEqual({ | ||
template: { | ||
_id: new ObjectId('5808fa7fae73b626daa89192'), | ||
types: ['LOTO'], | ||
maxExpirationDays: null, | ||
tenantCode: ['ALL'], | ||
campusCode: ['ALL'], | ||
}, | ||
title: 'New Title', | ||
description: 'some updated description', | ||
access: [], | ||
expirationDate: null, | ||
status: DOCUMENT_STATUS.DRAFT, | ||
readyForUseBy: null, | ||
readyForUseDate: null, | ||
sections: [ | ||
{ | ||
allowableCards: [ | ||
{ | ||
allowAttachments: false, | ||
type: 'TEXT', | ||
}, | ||
], | ||
header: null, | ||
cards: [ | ||
{ | ||
type: 'TEXT', | ||
isEditable: true, | ||
isMovable: false, | ||
isRequired: false, | ||
allowAttachments: true, | ||
attachments: [], | ||
details: { | ||
text: 'some text', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
lastModifiedDate: null, | ||
}); | ||
expect(clonedDocument.template).toEqual(document.template); | ||
expect(clonedDocument.title).toEqual(newTitle); | ||
}); | ||
@@ -189,3 +131,3 @@ | ||
expect(doc).toEqual({ | ||
const newDocument = new Document({ | ||
title: 'TITLE', | ||
@@ -241,2 +183,5 @@ status: 'DRAFT', | ||
}); | ||
delete newDocument._id; | ||
delete newDocument.sections[0].id; | ||
expect(doc).toEqual(newDocument); | ||
}); | ||
@@ -243,0 +188,0 @@ |
@@ -16,3 +16,2 @@ const ObjectId = require('bson').ObjectID; | ||
questions: [], | ||
notes: null, | ||
}; | ||
@@ -29,3 +28,2 @@ | ||
this.details.questions = details.questions ? details.questions.map((opt) => new CardLabelValue(opt)) : []; | ||
this.details.notes = details.notes || null; | ||
} | ||
@@ -50,3 +48,2 @@ | ||
questions: { type: 'array', items: { $ref: 'card-label-value.schema.json' } }, | ||
notes: { type: ['string', 'null'] }, | ||
}, | ||
@@ -53,0 +50,0 @@ }, |
Sorry, the diff of this file is not supported yet
684786
11490