@rss/common
Advanced tools
Comparing version 0.0.84 to 0.0.86
@@ -124,2 +124,588 @@ 'use strict'; | ||
}] | ||
}; | ||
}; | ||
module.exports.deeplynestedQuestion = { | ||
type: 'group', | ||
key: 'cell_lines', | ||
parentType: ['Animal Primary Cells', 'Human Primary Cells', 'Established Cell Lines'], | ||
questions: [{ | ||
type: 'radio', | ||
key: 'source_organism', | ||
label: 'Source organism: ', | ||
required: true, | ||
options: [{ label: 'Humans', value: 'Humans_source_organism' }, { label: 'Vertebrate', value: 'Vertebrate_animals_source_organism' }, { label: 'Invertebrates', value: 'Invertebrates_source_organism' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'source_organism_human', | ||
parentKey: 'source_organism', | ||
parentValue: 'Humans_source_organism', | ||
label: '', | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'human_cells_tissues_body_fluids', | ||
label: '', | ||
required: true, | ||
options: [{ label: 'Cells', value: 'human_cells' }, { label: 'Tissues', value: 'human_tissues' }, { label: 'Body fluids', value: 'human_body_fluids' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'human_if_cells', | ||
parentKey: 'human_cells_tissues_body_fluids', | ||
parentValue: 'human_cells', | ||
label: '', | ||
questions: [{ | ||
type: 'radio', | ||
key: 'Primary_cells_human', | ||
label: 'Primary or established cells: ', | ||
required: true, | ||
options: [{ label: 'Primary cells', value: 'Primary_cells' }, { label: 'Established cell lines', value: 'Established_cell_lines' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'source_organism_human_number', | ||
parentKey: 'Primary_cells_human', | ||
parentValue: 'Primary_cells', | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'source_organism_human_IRB_text', | ||
label: 'Indicate the IRB protocol number for primary cells: ', | ||
inputType: 'text', | ||
required: 'true' | ||
}] | ||
}] | ||
}, { | ||
type: 'dependent', | ||
parentKey: 'human_cells_tissues_body_fluids', | ||
parentValue: ['human_tissues', 'human_body_fluids'], | ||
label: '', | ||
key: 'human_cells_tissues_body_fluids_dependent', | ||
questions: [{ | ||
type: 'input', | ||
key: 'source_organism_human_IACUC_text', | ||
label: 'Institutional Review Board (IRB) protocol number for tissues and/or body fluids: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}] | ||
}, { | ||
type: 'dependent', | ||
key: 'source_organism_vertebrate', | ||
parentKey: 'source_organism', | ||
parentValue: 'Vertebrate_animals_source_organism', | ||
label: '', | ||
questions: [{ type: 'input', key: 'vertebrate_animals_name', label: 'Vertebrate name: ', inputType: 'text' }, { | ||
type: 'checkbox', | ||
key: 'vertebrate_cells_tissues_body_fluids', | ||
label: '', | ||
required: true, | ||
options: [{ label: 'Cells', value: 'vertebrate_cells' }, { label: 'Tissues', value: 'vertebrate_tissues' }, { label: 'Body fluids', value: 'vertebrate_body_fluids' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'vertebrate_if_cells', | ||
parentKey: 'vertebrate_cells_tissues_body_fluids', | ||
parentValue: 'vertebrate_cells', | ||
label: '', | ||
questions: [{ | ||
type: 'radio', | ||
key: 'Primary_cells_vertebrate_animals', | ||
label: 'Primary or established cells: ', | ||
required: true, | ||
options: [{ label: 'Primary cells', value: 'Primary_cells' }, { label: 'Established cell lines', value: 'Established_cell_lines' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'source_organism_vertebrate_number', | ||
parentKey: 'Primary_cells_vertebrate_animals', | ||
parentValue: 'Primary_cells', | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'source_organism_vertebrate_IACUC_text', | ||
label: 'Indicate the Institutional Animal Care and Use Committee (IACUC) protocol number for primary cells: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}] | ||
}, { | ||
type: 'dependent', | ||
parentKey: 'vertebrate_cells_tissues_body_fluids', | ||
parentValue: ['vertebrate_tissues', 'vertebrate_body_fluids'], | ||
label: '', | ||
key: 'vertebrate_cells_tissues_body_fluids_dependent', | ||
questions: [{ | ||
type: 'input', | ||
key: 'source_organism_vertebrate_IACUC_text', | ||
label: 'Indicate the Institutional Animal Care and Use Committee (IACUC) protocol number for tissues and body fluids: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}] | ||
}, { | ||
type: 'dependent', | ||
key: 'source_organism_invertebrates', | ||
parentKey: 'source_organism', | ||
parentValue: 'Invertebrates_source_organism', | ||
label: '', | ||
questions: [{ type: 'input', key: 'invertebrate_animals_name', label: 'Invertebrate name: ', inputType: 'text' }] | ||
}, { | ||
type: 'input', | ||
key: 'provider_of_materials', | ||
label: 'Provider of materials: ', | ||
inputType: 'text', | ||
required: true | ||
}, { | ||
type: 'radio', | ||
key: 'is_this_material_known_to_contain_pathogens', | ||
label: 'Is this material known to contain pathogens?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'is_this_material_known_to_contain_pathogens_yes', | ||
parentKey: 'is_this_material_known_to_contain_pathogens', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [{ type: 'input', key: 'pathogen_name_text', label: 'Which pathogens?', inputType: 'text' }] | ||
}, { | ||
type: 'radio', | ||
key: 'will_this_cell_line_be_used_or_put_in_storage_only', | ||
label: 'Will this material be used or put in storage only?', | ||
options: [{ label: 'Used', value: 'Used' }, { label: 'Storage only', value: 'storage_only' }], | ||
required: true | ||
}, { | ||
type: 'dependent', | ||
key: 'this_cell_line_used_or_put_in_storage_used_dependent', | ||
parentKey: 'will_this_cell_line_be_used_or_put_in_storage_only', | ||
parentValue: 'Used', | ||
label: '', | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'hazardous_procedures', | ||
label: 'Select the procedures that apply: ', | ||
options: [{ id: 27, label: 'Animal Work', value: 'Animal_Work' }, { label: 'Blending', value: 'Blending' }, { label: 'Centrifugation, Ultra-centrifugation', value: 'Centrifugation,_Ultra-centrifugation' }, { label: 'Dissections', value: 'Dissections' }, { label: 'Electroporation', value: 'Electroporation' }, { label: 'Flow cytometry', value: 'Flow_cytometry' }, { label: 'Handling infected organisms or tissues', value: 'Handling_infected_organisms_or_tissues' }, { label: 'Homogenization', value: 'Homogenization' }, { label: 'Injection', value: 'Injection' }, { | ||
label: 'Large-scale culture (e.g., >10L in one vessel)', | ||
value: 'Large-scale_culture_(e.g.,_>10L_in_one_vessel)' | ||
}, { label: 'Lyophilization', value: 'Lyophilization' }, { label: 'Necropsy', value: 'Necropsy' }, { label: 'Pipetting', value: 'Pipetting' }, { label: 'Pumping in closed system', value: 'Pumping_in_closed_system' }, { label: 'Shaking culture', value: 'Shaking_culture' }, { label: 'Sharps use', value: 'Sharps_use' }, { label: 'Sonication', value: 'Sonication' }, { label: 'Streak plating', value: 'Streak_plating' }, { label: 'Trapping or handling wild animals', value: 'Trapping_or_handling_wild_animals' }, { label: 'Vortexing', value: 'Vortexing' }, { id: 21, label: 'Other', value: 'Other' }], | ||
required: true | ||
}, { | ||
type: 'radio', | ||
key: 'will_this_cell_line_be_genetically_modified', | ||
label: 'Will this material be genetically modified?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'will_this_cell_line_be_genetically_modified_dependent', | ||
parentKey: 'will_this_cell_line_be_genetically_modified', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [{ | ||
type: 'radio', | ||
key: 'will_greater_than_10_liters', | ||
label: 'Will greater than 10 liters (per container) of this material be cultured at any given time?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }], | ||
required: true | ||
}, { | ||
type: 'checkbox', | ||
key: 'genetically_modified_checkbox', | ||
label: '', | ||
options: [{ | ||
label: 'I received this material genetically modified. ', | ||
value: 'received_this_material_genetically_modified' | ||
}, { | ||
label: 'I will genetically modify this material in the lab', | ||
value: 'will_genetically_modify_this_material' | ||
}] | ||
}] | ||
}, { | ||
type: 'checkbox', | ||
key: 'this_cell_line_will_be_added_to_the_following_whole_organisms', | ||
label: 'This material will be added to the following whole organisms: ', | ||
options: [{ label: 'Vertebrate animals ', value: 'Vertebrate_animals' }, { label: 'Invertebrate animals', value: 'Invertebrate_animals' }, { label: 'Plants', value: 'Plants' }, { label: 'Not applicable', value: 'Not_applicable' }] | ||
}] | ||
}] | ||
}; | ||
module.exports.requiredthSecondLevelNestedAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [{ label: 'Body fluids', value: 'human_body_fluids' }, { label: 'Cells', value: 'human_cells' }], | ||
human_cells_tissues_body_fluids_dependent: { source_organism_human_IACUC_text: '' }, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: 'third level require answer' } | ||
} | ||
} | ||
} | ||
}; | ||
module.exports.requiredThirdLevelNestedAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [{ label: 'Body fluids', value: 'human_body_fluids' }, { label: 'Cells', value: 'human_cells' }], | ||
human_cells_tissues_body_fluids_dependent: { | ||
source_organism_human_IACUC_text: 'seond level nested required answer' | ||
}, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: '' } | ||
} | ||
} | ||
} | ||
}; | ||
module.exports.sharedParentSecondAndThirdLevelAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [{ label: 'Body fluids', value: 'human_body_fluids' }, { label: 'Cells', value: 'human_cells' }], | ||
human_cells_tissues_body_fluids_dependent: { | ||
source_organism_human_IACUC_text: 'seond level nested required answer' | ||
}, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: 'third level' } | ||
} | ||
} | ||
} | ||
}; | ||
module.exports.multpleNestedQuestionWithSharedParents = { | ||
type: 'group', | ||
key: 'nucleic_acids', | ||
parentType: ['Nucleic Acids'], | ||
questions: [{ | ||
type: 'dropdown', | ||
key: 'nucleic_acid_category', | ||
label: 'Select the nucleic acid category: ', | ||
required: true, | ||
options: [{ label: 'Non-hazardous nucleic acids', value: 'Non_hazardous_nucleic_acids' }, { label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, { label: 'Drug resistance', value: 'Drug_resistance' }, { label: 'Gene drive', value: 'Gene_drive' }, { label: 'Immune modulating', value: 'Immune_modulating' }, { label: 'Oncogene', value: 'Oncogene' }, { label: 'Plasmid vector', value: 'Plasmid_vector' }, { label: 'Suppress gene function', value: 'Suppress_gene_function' }, { label: 'Toxin', value: 'Toxin' }, { label: 'Virulence factor', value: 'Virulence_factor' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'non_hazardous_nucleic_acids_dependent_1', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: 'Non_hazardous_nucleic_acids', | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'identify_non_hazardous_genes', | ||
label: 'Identify all non-hazardous genes. In some cases, you can add a category of genes or gene products (e.g., G proteins, heat shock proteins, etc.): ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}, { | ||
type: 'dependent', | ||
key: 'non_hazardous_nucleic_acids_dependent_2', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: ['CRISPR_Cas9'], | ||
label: '', | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'CRISPR_application', | ||
label: 'Select all that apply: ', | ||
inputType: 'text', | ||
required: true, | ||
options: [{ label: 'Off-targeting effects', value: 'Off_target_effects' }, { label: 'Delivery system used', value: 'delivered_system_used' }, { label: 'Permanent or heritable modification', value: 'permanent_heritable_modification' }, { label: 'Multiple genes being targeted in one construct', value: 'multiple_gene_one_construct' }, { | ||
label: 'Potential risks to personnel for exposure to material or the resulting modified organism', | ||
value: 'potential_risks_exposure' | ||
}, { label: 'Researcher knowledge and experience', value: 'researcher_knowledge_exp' }] | ||
}, { | ||
type: 'input', | ||
key: 'CRISPR_Clarification', | ||
label: 'Use this space to expand on or clarify any of the items checked above: ', | ||
inputType: 'text' | ||
}] | ||
}, { | ||
type: 'dependent', | ||
key: 'hazardous_nucleic_acids_dependent', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: ['Drug_resistance', 'Gene_drive', 'Immune_modulating', 'Oncogene', 'Plasmid_vector', 'Suppress_gene_function', 'Toxin', 'Virulence_factor'], | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'Nucleic_acid_gene_name: ', | ||
label: 'Nucleic acid (gene) name: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}, { | ||
type: 'input', | ||
key: 'describe_the_gene_function', | ||
label: 'Describe the gene function: ', | ||
inputType: 'text', | ||
required: true | ||
}, { | ||
type: 'radio', | ||
key: 'Will_this_nucleic_acid_be_added_to_other_organisms', | ||
label: 'Will this nucleic acid be added to other organisms?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'Will_this_nucleic_acid_be_added_to_other_organisms_yes', | ||
parentKey: 'Will_this_nucleic_acid_be_added_to_other_organisms', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'Indicate_the_other_organisms: ', | ||
label: 'Indicate the other organisms: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}] | ||
}; | ||
module.exports.nestedRequiredAnswerTextBox = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'Drug resistance', value: 'Drug_resistance' } | ||
} | ||
}; | ||
module.exports.nestedRequiredAnswerCheckBoxes = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': '' } | ||
} | ||
}; | ||
module.exports.minimumNestedRequiredAnswer = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': '' }, | ||
non_hazardous_nucleic_acids_dependent_2: { | ||
CRISPR_application: [{ label: 'Permanent or heritable modification', value: 'permanent_heritable_modification' }] | ||
} | ||
} | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsQuestion = { | ||
type: 'dependent', | ||
key: 'types_materials_transported_followup1', | ||
parentKey: 'types_materials_transported', | ||
parentValue: ['infectious_agents', 'transgenic_microorganisms', 'human_source_materials', 'non_human_primate_source_materials', 'materials_not_endemic', 'transgenic_animals', 'transgenic_plants'], | ||
label: '', | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'ways_materials_transported_followup_materials', | ||
label: 'We will transport materials: ', | ||
options: [{ label: 'Within a facility (between rooms)', value: 'within_a_facility' }, { label: 'Between facilities', value: 'between_facilities' }, { label: 'Other', value: 'ways_materials_transported_other' }], | ||
required: true | ||
}, { | ||
type: 'dependent', | ||
key: 'followup_ways_materials_transported_other', | ||
parentKey: 'ways_materials_transported_followup_materials', | ||
parentValue: 'ways_materials_transported_other', | ||
questions: [{ type: 'input', key: 'transport_ways_other_followup', label: 'Explain: ', inputType: 'text' }] | ||
}, { | ||
type: 'checkbox', | ||
key: 'types_materials_transported_followup_ways', | ||
label: 'Materials will be transported in the following way(s): ', | ||
options: [{ label: 'University/commercial vehicle', value: 'university_commercial_vehicle' }, { label: 'Personal vehicle', value: 'personal_vehicle' }, { label: 'Walking', value: 'walking' }, { label: 'Bicycle', value: 'bicycle' }, { label: 'Cart', value: 'cart' }, { label: 'Other', value: 'folloup_materials_transported_other' }] | ||
}, { | ||
type: 'dependent', | ||
key: 'followup_transported_other_yes', | ||
parentKey: 'types_materials_transported_followup_ways', | ||
parentValue: 'folloup_materials_transported_other', | ||
questions: [{ type: 'input', key: 'transport_ways_other_followup', label: 'Explain: ', inputType: 'text' }] | ||
}, { | ||
type: 'label', | ||
key: 'transport_ways_containment', | ||
label: 'Transport of material requires closed primary containment inside a hard-sided, leak-proof, lidded, and sanitizable secondary container that is labeled with contact information and relevant hazard symbols. Sufficient absorbent materials will be placed inside the secondary container.' | ||
}, { | ||
type: 'group', | ||
key: 'materials_transport_contained_group', | ||
label: 'Describe how materials will be contained during transport: ', | ||
questions: [{ | ||
type: 'input', | ||
key: 'materials_transport_contained_primary', | ||
label: 'Primary containment (e.g., tube, plate or culture flask)', | ||
inputType: 'text' | ||
}, { | ||
type: 'input', | ||
key: 'materials_transport_contained_secondary', | ||
label: 'Secondary containment (e.g., hard-sided, leak-proof, lidded or labeled container lined with absorbent material)', | ||
inputType: 'text' | ||
}, { | ||
type: 'input', | ||
key: 'materials_transport_contained_additional', | ||
label: 'Additional Containment', | ||
inputType: 'text' | ||
}, { type: 'input', key: 'materials_transport_contained_other', label: 'Other', inputType: 'text' }] | ||
}] | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswer = { | ||
types_materials_transported: [{ label: 'Not applicable.', value: 'not_applicable' }, { label: 'Human source materials', value: 'human_source_materials' }], | ||
types_materials_transported_followup1: { | ||
ways_materials_transported_followup_materials: [{ label: 'Within a facility (between rooms)', value: 'within_a_facility' }] | ||
} | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswerComplete = { | ||
types_materials_transported: [{ label: 'Human source materials', value: 'human_source_materials' }, { label: 'Transgenic animals', value: 'transgenic_animals' }], | ||
types_materials_transported_followup1: { | ||
ways_materials_transported_followup_materials: [{ label: 'Between facilities', value: 'between_facilities' }], | ||
types_materials_transported_followup_ways: [{ label: 'Bicycle', value: 'bicycle' }], | ||
materials_transport_contained_group: { materials_transport_contained_additional: 'test Additional Containment' } | ||
} | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswerIncomplete = { | ||
types_materials_transported: [{ label: 'Not applicable.', value: 'not_applicable' }, { label: 'Human source materials', value: 'human_source_materials' }] | ||
}; | ||
module.exports.answerHasMatchedParentQuestion = { | ||
type: 'dependent', | ||
key: 'transported_between_location_yes', | ||
parentKey: 'transported_between_location', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'provide_statement', | ||
label: 'Provide statement: ', | ||
options: [] | ||
}] | ||
}; | ||
module.exports.answerHasMatchedParentAnswer = { | ||
materials_transport_checkes: { types_materials_transported: [{ label: 'Not applicable.', value: 'not_applicable' }] }, | ||
transported_between_location: 'Yes' | ||
}; | ||
module.exports.singleAnswerHasMatchedParntsQuestion = { | ||
type: 'dependent', | ||
key: 'hazardous_nucleic_acids_dependent', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: ['Drug_resistance', 'Gene_drive', 'Immune_modulating', 'Oncogene', 'Plasmid_vector', 'Suppress_gene_function', 'Toxin', 'Virulence_factor'], | ||
label: '', | ||
questions: [{ | ||
type: 'input', | ||
key: 'Nucleic_acid_gene_name: ', | ||
label: 'Nucleic acid (gene) name: ', | ||
inputType: 'text', | ||
required: true | ||
}] | ||
}; | ||
module.exports.singleAnswerHasMatchedParntsAnswer = { | ||
nucleic_acid_category: { label: 'Drug resistance', value: 'Drug_resistance' }, | ||
describe_the_gene_function: 'function is test test ', | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': 'answer is test test' } | ||
}; | ||
module.exports.addAnotherQuestion = { | ||
type: 'addanother', | ||
key: 'biological_safety_cabinets_used_add_another', | ||
label: '', | ||
required: true, | ||
questions: [{ | ||
type: 'group', | ||
key: 'safety_cabinet_add_another_question_group', | ||
required: true, | ||
questions: [{ | ||
type: 'checkbox', | ||
key: 'exhaust_type', | ||
label: 'Exhaust type', | ||
options: [{ label: 'Recirculating', value: 'Recirculating' }, { label: 'Canopy', value: 'Canopy' }, { label: 'Hard ducted', value: 'Hard_ducted' }], | ||
required: true | ||
}, { type: 'input', key: 'location', label: 'Location: ', inputType: 'text', required: true }, { | ||
type: 'input', | ||
key: 'biosafety_cabinet_shared_pi', | ||
label: 'If this biosafety cabinet will be shared with other PIs, indicate who the PIs will be.' | ||
}, { | ||
type: 'textarea', | ||
key: 'procedures_performed', | ||
label: 'Describe procedures that will be performed in the biological safety cabinet (e.g., tissue culture work, necropsy of animals with infectious agents): ', | ||
rows: 5, | ||
rowsMax: 10, | ||
required: true | ||
}] | ||
}] | ||
}; | ||
module.exports.addAnotherAnswerValid = [{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text' | ||
} | ||
} | ||
}, { | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Canopy', value: 'Canopy' }, { label: 'Recirculating', value: 'Recirculating' }, { label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'add another location 2 test', | ||
procedures_performed: 'add another 2 procdures text text', | ||
biosafety_cabinet_shared_pi: 'option text test' | ||
} | ||
} | ||
}]; | ||
module.exports.addAnotherAnswerSomeIncomplete = [{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text' | ||
} | ||
} | ||
}, { | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [], | ||
location: '', | ||
procedures_performed: '', | ||
biosafety_cabinet_shared_pi: 'option text test' | ||
} | ||
} | ||
}]; | ||
module.exports.addAnotherAnswerSomeInvalid = [{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text' | ||
} | ||
} | ||
}, { | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Recirculating', value: 'Recirculating' }], | ||
location: 'location 2', | ||
procedures_performed: '', | ||
biosafety_cabinet_shared_pi: 'option text test' | ||
} | ||
} | ||
}]; | ||
module.exports.addAnotherAnswerPartialIncomplete = [{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text' | ||
} | ||
} | ||
}, { | ||
id: '5bbe2dc61c9d440000ccbbd5', | ||
item: { | ||
safety_cabinet_add_another_question_group: { exhaust_type: [{ label: 'Recirculating', value: 'Recirculating' }] } | ||
} | ||
}]; |
@@ -5,52 +5,107 @@ 'use strict'; | ||
var hasError = function hasError(question, answer) { | ||
if (!question.required && question.type !== 'group') return false; | ||
var Helper = { | ||
hasError: function hasError(question, answer) { | ||
if (!question.required && question.type !== 'group') return false; | ||
if (!answer && question.required) { | ||
return true; | ||
} | ||
if (!answer && question.required) { | ||
return true; | ||
} | ||
var questionAnswer = answer[question.key]; | ||
if (questionAnswer && !questionAnswer) { | ||
return true; | ||
} | ||
switch (question.type) { | ||
case FqType.RADIO: | ||
return answer && !answer; | ||
case FqType.CHECKBOX: | ||
case FqType.ATTACHMENT: | ||
return answer && !answer.length; // TODO Validate responses are in question options | ||
case FqType.DROPDOWN: | ||
return questionAnswer && !questionAnswer.length; | ||
case FqType.GROUP: | ||
return module.exports.hasGroupError(question, questionAnswer); | ||
case 'people': | ||
case 'location': | ||
case 'agent': | ||
return answer && !answer.length; | ||
default: | ||
return question.required && !answer; | ||
} | ||
}; | ||
var questionAnswer = answer && answer[question.key]; | ||
var hasGroupError = function hasGroupError(questionGroup, answers) { | ||
return questionGroup.questions.some(function (q) { | ||
if (answers) { | ||
if (q.type === FqType.GROUP) { | ||
return hasGroupError(q, answers[q.key]); | ||
} | ||
if (q.type === FqType.DEPENDENT) { | ||
if (answers[q.parentKey] === q.parentValue) { | ||
return hasGroupError(q, answers[q.key]); | ||
} else if (Array.isArray(answers[q.parentKey])) { | ||
return hasGroupError(q, answers[q.key]); | ||
switch (question.type) { | ||
case FqType.RADIO: | ||
return answer && !answer; | ||
case FqType.CHECKBOX: | ||
return answer && !answer.length; | ||
case FqType.DROPDOWN: | ||
return questionAnswer && !questionAnswer.length; | ||
case FqType.GROUP: | ||
return Helper.hasGroupError(question, questionAnswer); | ||
case FqType.ADD_ANOTHER: | ||
return Helper.hasAddAnotherError(question, answer); | ||
case 'people': | ||
case 'location': | ||
case 'agent': | ||
case FqType.ATTACHMENT: | ||
return answer && !Object.keys(answer).filter(function (key) { | ||
return answer[key]; | ||
}).length; | ||
default: | ||
return question.required && !answer; | ||
} | ||
}, | ||
hasAddAnotherError: function hasAddAnotherError(question, answers) { | ||
return question.questions.some(function (q) { | ||
return answers.some(function (ans) { | ||
return Helper.hasGroupError(q, ans.item[q.key]); | ||
}); | ||
}); | ||
}, | ||
hasGroupError: function hasGroupError(questionGroup, answers) { | ||
return questionGroup.questions.some(function (q) { | ||
if (answers) { | ||
if (q.type === FqType.GROUP) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
} | ||
return false; | ||
if (q.type === FqType.DEPENDENT) { | ||
return Helper.hasDependentError(q, answers); | ||
} | ||
return q.required && Helper.hasError(q, answers[q.key]); | ||
} | ||
return q.required && hasError(q, answers[q.key]); | ||
return q.required; | ||
}); | ||
}, | ||
hasDependentError: function hasDependentError(q, answers) { | ||
if (Array.isArray(q.parentValue)) { | ||
// eslint-disable-next-line | ||
if (Helper._multipleAnswersHaveMatchedParents(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else if (Helper._singleAnswerHasMatchedParnts(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
} | ||
} else { | ||
// eslint-disable-next-line | ||
if (Helper._answerHasMatchedParent(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else if (Helper._multipleAnswersHaveMatchedParent(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else { | ||
return Helper.hasError(q, answers); | ||
} | ||
} | ||
return q.required; | ||
}); | ||
return false; | ||
}, | ||
_multipleAnswersHaveMatchedParent: function _multipleAnswersHaveMatchedParent(q, answers) { | ||
return Array.isArray(answers[q.parentKey]) && answers[q.parentKey].some(function (ans) { | ||
return ans.value === q.parentValue; | ||
}); | ||
}, | ||
_multipleAnswersHaveMatchedParents: function _multipleAnswersHaveMatchedParents(q, answers) { | ||
return Array.isArray(answers[q.parentKey]) && answers[q.parentKey].some(function (ans) { | ||
return q.parentValue.some(function (pValue) { | ||
return ans.value === pValue; | ||
}); | ||
}); | ||
}, | ||
_answerHasMatchedParent: function _answerHasMatchedParent(q, answers) { | ||
return answers[q.parentKey] && (answers[q.parentKey].value === q.parentValue || answers[q.parentKey] === q.parentValue); | ||
}, | ||
_singleAnswerHasMatchedParnts: function _singleAnswerHasMatchedParnts(q, answers) { | ||
return q.parentValue.some(function (pValue) { | ||
return pValue === answers[q.parentKey].value; | ||
}); | ||
} | ||
}; | ||
module.exports = { hasError: hasError, hasGroupError: hasGroupError }; | ||
module.exports = Helper; |
{ | ||
"name": "@rss/common", | ||
"version": "0.0.84", | ||
"version": "0.0.86", | ||
"description": "common constant, classes, & helper", | ||
@@ -5,0 +5,0 @@ "author": "Risk & Safety Solution", |
@@ -150,1 +150,817 @@ module.exports.inputQuestion = { | ||
}; | ||
module.exports.deeplynestedQuestion = { | ||
type: 'group', | ||
key: 'cell_lines', | ||
parentType: ['Animal Primary Cells', 'Human Primary Cells', 'Established Cell Lines'], | ||
questions: [ | ||
{ | ||
type: 'radio', | ||
key: 'source_organism', | ||
label: 'Source organism: ', | ||
required: true, | ||
options: [ | ||
{ label: 'Humans', value: 'Humans_source_organism' }, | ||
{ label: 'Vertebrate', value: 'Vertebrate_animals_source_organism' }, | ||
{ label: 'Invertebrates', value: 'Invertebrates_source_organism' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'source_organism_human', | ||
parentKey: 'source_organism', | ||
parentValue: 'Humans_source_organism', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'human_cells_tissues_body_fluids', | ||
label: '', | ||
required: true, | ||
options: [ | ||
{ label: 'Cells', value: 'human_cells' }, | ||
{ label: 'Tissues', value: 'human_tissues' }, | ||
{ label: 'Body fluids', value: 'human_body_fluids' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'human_if_cells', | ||
parentKey: 'human_cells_tissues_body_fluids', | ||
parentValue: 'human_cells', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'radio', | ||
key: 'Primary_cells_human', | ||
label: 'Primary or established cells: ', | ||
required: true, | ||
options: [ | ||
{ label: 'Primary cells', value: 'Primary_cells' }, | ||
{ label: 'Established cell lines', value: 'Established_cell_lines' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'source_organism_human_number', | ||
parentKey: 'Primary_cells_human', | ||
parentValue: 'Primary_cells', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'source_organism_human_IRB_text', | ||
label: 'Indicate the IRB protocol number for primary cells: ', | ||
inputType: 'text', | ||
required: 'true', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
parentKey: 'human_cells_tissues_body_fluids', | ||
parentValue: ['human_tissues', 'human_body_fluids'], | ||
label: '', | ||
key: 'human_cells_tissues_body_fluids_dependent', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'source_organism_human_IACUC_text', | ||
label: 'Institutional Review Board (IRB) protocol number for tissues and/or body fluids: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'source_organism_vertebrate', | ||
parentKey: 'source_organism', | ||
parentValue: 'Vertebrate_animals_source_organism', | ||
label: '', | ||
questions: [ | ||
{ type: 'input', key: 'vertebrate_animals_name', label: 'Vertebrate name: ', inputType: 'text' }, | ||
{ | ||
type: 'checkbox', | ||
key: 'vertebrate_cells_tissues_body_fluids', | ||
label: '', | ||
required: true, | ||
options: [ | ||
{ label: 'Cells', value: 'vertebrate_cells' }, | ||
{ label: 'Tissues', value: 'vertebrate_tissues' }, | ||
{ label: 'Body fluids', value: 'vertebrate_body_fluids' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'vertebrate_if_cells', | ||
parentKey: 'vertebrate_cells_tissues_body_fluids', | ||
parentValue: 'vertebrate_cells', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'radio', | ||
key: 'Primary_cells_vertebrate_animals', | ||
label: 'Primary or established cells: ', | ||
required: true, | ||
options: [ | ||
{ label: 'Primary cells', value: 'Primary_cells' }, | ||
{ label: 'Established cell lines', value: 'Established_cell_lines' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'source_organism_vertebrate_number', | ||
parentKey: 'Primary_cells_vertebrate_animals', | ||
parentValue: 'Primary_cells', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'source_organism_vertebrate_IACUC_text', | ||
label: | ||
'Indicate the Institutional Animal Care and Use Committee (IACUC) protocol number for primary cells: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
parentKey: 'vertebrate_cells_tissues_body_fluids', | ||
parentValue: ['vertebrate_tissues', 'vertebrate_body_fluids'], | ||
label: '', | ||
key: 'vertebrate_cells_tissues_body_fluids_dependent', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'source_organism_vertebrate_IACUC_text', | ||
label: | ||
'Indicate the Institutional Animal Care and Use Committee (IACUC) protocol number for tissues and body fluids: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'source_organism_invertebrates', | ||
parentKey: 'source_organism', | ||
parentValue: 'Invertebrates_source_organism', | ||
label: '', | ||
questions: [{ type: 'input', key: 'invertebrate_animals_name', label: 'Invertebrate name: ', inputType: 'text' }], | ||
}, | ||
{ | ||
type: 'input', | ||
key: 'provider_of_materials', | ||
label: 'Provider of materials: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
{ | ||
type: 'radio', | ||
key: 'is_this_material_known_to_contain_pathogens', | ||
label: 'Is this material known to contain pathogens?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'is_this_material_known_to_contain_pathogens_yes', | ||
parentKey: 'is_this_material_known_to_contain_pathogens', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [{ type: 'input', key: 'pathogen_name_text', label: 'Which pathogens?', inputType: 'text' }], | ||
}, | ||
{ | ||
type: 'radio', | ||
key: 'will_this_cell_line_be_used_or_put_in_storage_only', | ||
label: 'Will this material be used or put in storage only?', | ||
options: [{ label: 'Used', value: 'Used' }, { label: 'Storage only', value: 'storage_only' }], | ||
required: true, | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'this_cell_line_used_or_put_in_storage_used_dependent', | ||
parentKey: 'will_this_cell_line_be_used_or_put_in_storage_only', | ||
parentValue: 'Used', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'hazardous_procedures', | ||
label: 'Select the procedures that apply: ', | ||
options: [ | ||
{ id: 27, label: 'Animal Work', value: 'Animal_Work' }, | ||
{ label: 'Blending', value: 'Blending' }, | ||
{ label: 'Centrifugation, Ultra-centrifugation', value: 'Centrifugation,_Ultra-centrifugation' }, | ||
{ label: 'Dissections', value: 'Dissections' }, | ||
{ label: 'Electroporation', value: 'Electroporation' }, | ||
{ label: 'Flow cytometry', value: 'Flow_cytometry' }, | ||
{ label: 'Handling infected organisms or tissues', value: 'Handling_infected_organisms_or_tissues' }, | ||
{ label: 'Homogenization', value: 'Homogenization' }, | ||
{ label: 'Injection', value: 'Injection' }, | ||
{ | ||
label: 'Large-scale culture (e.g., >10L in one vessel)', | ||
value: 'Large-scale_culture_(e.g.,_>10L_in_one_vessel)', | ||
}, | ||
{ label: 'Lyophilization', value: 'Lyophilization' }, | ||
{ label: 'Necropsy', value: 'Necropsy' }, | ||
{ label: 'Pipetting', value: 'Pipetting' }, | ||
{ label: 'Pumping in closed system', value: 'Pumping_in_closed_system' }, | ||
{ label: 'Shaking culture', value: 'Shaking_culture' }, | ||
{ label: 'Sharps use', value: 'Sharps_use' }, | ||
{ label: 'Sonication', value: 'Sonication' }, | ||
{ label: 'Streak plating', value: 'Streak_plating' }, | ||
{ label: 'Trapping or handling wild animals', value: 'Trapping_or_handling_wild_animals' }, | ||
{ label: 'Vortexing', value: 'Vortexing' }, | ||
{ id: 21, label: 'Other', value: 'Other' }, | ||
], | ||
required: true, | ||
}, | ||
{ | ||
type: 'radio', | ||
key: 'will_this_cell_line_be_genetically_modified', | ||
label: 'Will this material be genetically modified?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'will_this_cell_line_be_genetically_modified_dependent', | ||
parentKey: 'will_this_cell_line_be_genetically_modified', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'radio', | ||
key: 'will_greater_than_10_liters', | ||
label: 'Will greater than 10 liters (per container) of this material be cultured at any given time?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }], | ||
required: true, | ||
}, | ||
{ | ||
type: 'checkbox', | ||
key: 'genetically_modified_checkbox', | ||
label: '', | ||
options: [ | ||
{ | ||
label: 'I received this material genetically modified. ', | ||
value: 'received_this_material_genetically_modified', | ||
}, | ||
{ | ||
label: 'I will genetically modify this material in the lab', | ||
value: 'will_genetically_modify_this_material', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'checkbox', | ||
key: 'this_cell_line_will_be_added_to_the_following_whole_organisms', | ||
label: 'This material will be added to the following whole organisms: ', | ||
options: [ | ||
{ label: 'Vertebrate animals ', value: 'Vertebrate_animals' }, | ||
{ label: 'Invertebrate animals', value: 'Invertebrate_animals' }, | ||
{ label: 'Plants', value: 'Plants' }, | ||
{ label: 'Not applicable', value: 'Not_applicable' }, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
module.exports.requiredthSecondLevelNestedAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [ | ||
{ label: 'Body fluids', value: 'human_body_fluids' }, | ||
{ label: 'Cells', value: 'human_cells' }, | ||
], | ||
human_cells_tissues_body_fluids_dependent: { source_organism_human_IACUC_text: '' }, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: 'third level require answer' }, | ||
}, | ||
}, | ||
}, | ||
}; | ||
module.exports.requiredThirdLevelNestedAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [ | ||
{ label: 'Body fluids', value: 'human_body_fluids' }, | ||
{ label: 'Cells', value: 'human_cells' }, | ||
], | ||
human_cells_tissues_body_fluids_dependent: { | ||
source_organism_human_IACUC_text: 'seond level nested required answer', | ||
}, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: '' }, | ||
}, | ||
}, | ||
}, | ||
}; | ||
module.exports.sharedParentSecondAndThirdLevelAnswer = { | ||
cell_lines: { | ||
source_organism: 'Humans_source_organism', | ||
provider_of_materials: 'first level require answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
source_organism_human: { | ||
human_cells_tissues_body_fluids: [ | ||
{ label: 'Body fluids', value: 'human_body_fluids' }, | ||
{ label: 'Cells', value: 'human_cells' }, | ||
], | ||
human_cells_tissues_body_fluids_dependent: { | ||
source_organism_human_IACUC_text: 'seond level nested required answer', | ||
}, | ||
human_if_cells: { | ||
Primary_cells_human: 'Primary_cells', | ||
source_organism_human_number: { source_organism_human_IRB_text: 'third level' }, | ||
}, | ||
}, | ||
}, | ||
}; | ||
module.exports.multpleNestedQuestionWithSharedParents = { | ||
type: 'group', | ||
key: 'nucleic_acids', | ||
parentType: ['Nucleic Acids'], | ||
questions: [ | ||
{ | ||
type: 'dropdown', | ||
key: 'nucleic_acid_category', | ||
label: 'Select the nucleic acid category: ', | ||
required: true, | ||
options: [ | ||
{ label: 'Non-hazardous nucleic acids', value: 'Non_hazardous_nucleic_acids' }, | ||
{ label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, | ||
{ label: 'Drug resistance', value: 'Drug_resistance' }, | ||
{ label: 'Gene drive', value: 'Gene_drive' }, | ||
{ label: 'Immune modulating', value: 'Immune_modulating' }, | ||
{ label: 'Oncogene', value: 'Oncogene' }, | ||
{ label: 'Plasmid vector', value: 'Plasmid_vector' }, | ||
{ label: 'Suppress gene function', value: 'Suppress_gene_function' }, | ||
{ label: 'Toxin', value: 'Toxin' }, | ||
{ label: 'Virulence factor', value: 'Virulence_factor' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'non_hazardous_nucleic_acids_dependent_1', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: 'Non_hazardous_nucleic_acids', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'identify_non_hazardous_genes', | ||
label: | ||
'Identify all non-hazardous genes. In some cases, you can add a category of genes or gene products (e.g., G proteins, heat shock proteins, etc.): ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'non_hazardous_nucleic_acids_dependent_2', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: ['CRISPR_Cas9'], | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'CRISPR_application', | ||
label: 'Select all that apply: ', | ||
inputType: 'text', | ||
required: true, | ||
options: [ | ||
{ label: 'Off-targeting effects', value: 'Off_target_effects' }, | ||
{ label: 'Delivery system used', value: 'delivered_system_used' }, | ||
{ label: 'Permanent or heritable modification', value: 'permanent_heritable_modification' }, | ||
{ label: 'Multiple genes being targeted in one construct', value: 'multiple_gene_one_construct' }, | ||
{ | ||
label: 'Potential risks to personnel for exposure to material or the resulting modified organism', | ||
value: 'potential_risks_exposure', | ||
}, | ||
{ label: 'Researcher knowledge and experience', value: 'researcher_knowledge_exp' }, | ||
], | ||
}, | ||
{ | ||
type: 'input', | ||
key: 'CRISPR_Clarification', | ||
label: 'Use this space to expand on or clarify any of the items checked above: ', | ||
inputType: 'text', | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'hazardous_nucleic_acids_dependent', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: [ | ||
'Drug_resistance', | ||
'Gene_drive', | ||
'Immune_modulating', | ||
'Oncogene', | ||
'Plasmid_vector', | ||
'Suppress_gene_function', | ||
'Toxin', | ||
'Virulence_factor', | ||
], | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'Nucleic_acid_gene_name: ', | ||
label: 'Nucleic acid (gene) name: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'input', | ||
key: 'describe_the_gene_function', | ||
label: 'Describe the gene function: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
{ | ||
type: 'radio', | ||
key: 'Will_this_nucleic_acid_be_added_to_other_organisms', | ||
label: 'Will this nucleic acid be added to other organisms?', | ||
options: [{ label: 'Yes', value: 'Yes' }, { label: 'No', value: 'No' }], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'Will_this_nucleic_acid_be_added_to_other_organisms_yes', | ||
parentKey: 'Will_this_nucleic_acid_be_added_to_other_organisms', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'Indicate_the_other_organisms: ', | ||
label: 'Indicate the other organisms: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
module.exports.nestedRequiredAnswerTextBox = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'Drug resistance', value: 'Drug_resistance' }, | ||
}, | ||
}; | ||
module.exports.nestedRequiredAnswerCheckBoxes = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': '' }, | ||
}, | ||
}; | ||
module.exports.minimumNestedRequiredAnswer = { | ||
nucleic_acids: { | ||
describe_the_gene_function: 'first level required question', | ||
nucleic_acid_category: { label: 'CRISPR/Cas9', value: 'CRISPR_Cas9' }, | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': '' }, | ||
non_hazardous_nucleic_acids_dependent_2: { | ||
CRISPR_application: [{ label: 'Permanent or heritable modification', value: 'permanent_heritable_modification' }], | ||
}, | ||
}, | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsQuestion = { | ||
type: 'dependent', | ||
key: 'types_materials_transported_followup1', | ||
parentKey: 'types_materials_transported', | ||
parentValue: [ | ||
'infectious_agents', | ||
'transgenic_microorganisms', | ||
'human_source_materials', | ||
'non_human_primate_source_materials', | ||
'materials_not_endemic', | ||
'transgenic_animals', | ||
'transgenic_plants', | ||
], | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'ways_materials_transported_followup_materials', | ||
label: 'We will transport materials: ', | ||
options: [ | ||
{ label: 'Within a facility (between rooms)', value: 'within_a_facility' }, | ||
{ label: 'Between facilities', value: 'between_facilities' }, | ||
{ label: 'Other', value: 'ways_materials_transported_other' }, | ||
], | ||
required: true, | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'followup_ways_materials_transported_other', | ||
parentKey: 'ways_materials_transported_followup_materials', | ||
parentValue: 'ways_materials_transported_other', | ||
questions: [{ type: 'input', key: 'transport_ways_other_followup', label: 'Explain: ', inputType: 'text' }], | ||
}, | ||
{ | ||
type: 'checkbox', | ||
key: 'types_materials_transported_followup_ways', | ||
label: 'Materials will be transported in the following way(s): ', | ||
options: [ | ||
{ label: 'University/commercial vehicle', value: 'university_commercial_vehicle' }, | ||
{ label: 'Personal vehicle', value: 'personal_vehicle' }, | ||
{ label: 'Walking', value: 'walking' }, | ||
{ label: 'Bicycle', value: 'bicycle' }, | ||
{ label: 'Cart', value: 'cart' }, | ||
{ label: 'Other', value: 'folloup_materials_transported_other' }, | ||
], | ||
}, | ||
{ | ||
type: 'dependent', | ||
key: 'followup_transported_other_yes', | ||
parentKey: 'types_materials_transported_followup_ways', | ||
parentValue: 'folloup_materials_transported_other', | ||
questions: [{ type: 'input', key: 'transport_ways_other_followup', label: 'Explain: ', inputType: 'text' }], | ||
}, | ||
{ | ||
type: 'label', | ||
key: 'transport_ways_containment', | ||
label: | ||
'Transport of material requires closed primary containment inside a hard-sided, leak-proof, lidded, and sanitizable secondary container that is labeled with contact information and relevant hazard symbols. Sufficient absorbent materials will be placed inside the secondary container.', | ||
}, | ||
{ | ||
type: 'group', | ||
key: 'materials_transport_contained_group', | ||
label: 'Describe how materials will be contained during transport: ', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'materials_transport_contained_primary', | ||
label: 'Primary containment (e.g., tube, plate or culture flask)', | ||
inputType: 'text', | ||
}, | ||
{ | ||
type: 'input', | ||
key: 'materials_transport_contained_secondary', | ||
label: | ||
'Secondary containment (e.g., hard-sided, leak-proof, lidded or labeled container lined with absorbent material)', | ||
inputType: 'text', | ||
}, | ||
{ | ||
type: 'input', | ||
key: 'materials_transport_contained_additional', | ||
label: 'Additional Containment', | ||
inputType: 'text', | ||
}, | ||
{ type: 'input', key: 'materials_transport_contained_other', label: 'Other', inputType: 'text' }, | ||
], | ||
}, | ||
], | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswer = { | ||
types_materials_transported: [ | ||
{ label: 'Not applicable.', value: 'not_applicable' }, | ||
{ label: 'Human source materials', value: 'human_source_materials' }, | ||
], | ||
types_materials_transported_followup1: { | ||
ways_materials_transported_followup_materials: [ | ||
{ label: 'Within a facility (between rooms)', value: 'within_a_facility' }, | ||
], | ||
}, | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswerComplete = { | ||
types_materials_transported: [ | ||
{ label: 'Human source materials', value: 'human_source_materials' }, | ||
{ label: 'Transgenic animals', value: 'transgenic_animals' }, | ||
], | ||
types_materials_transported_followup1: { | ||
ways_materials_transported_followup_materials: [{ label: 'Between facilities', value: 'between_facilities' }], | ||
types_materials_transported_followup_ways: [{ label: 'Bicycle', value: 'bicycle' }], | ||
materials_transport_contained_group: { materials_transport_contained_additional: 'test Additional Containment' }, | ||
}, | ||
}; | ||
module.exports.multipleAnswersHaveMatchedParentsAnswerIncomplete = { | ||
types_materials_transported: [ | ||
{ label: 'Not applicable.', value: 'not_applicable' }, | ||
{ label: 'Human source materials', value: 'human_source_materials' }, | ||
], | ||
}; | ||
module.exports.answerHasMatchedParentQuestion = { | ||
type: 'dependent', | ||
key: 'transported_between_location_yes', | ||
parentKey: 'transported_between_location', | ||
parentValue: 'Yes', | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'provide_statement', | ||
label: 'Provide statement: ', | ||
options: [], | ||
}, | ||
], | ||
}; | ||
module.exports.answerHasMatchedParentAnswer = { | ||
materials_transport_checkes: { types_materials_transported: [{ label: 'Not applicable.', value: 'not_applicable' }] }, | ||
transported_between_location: 'Yes', | ||
}; | ||
module.exports.singleAnswerHasMatchedParntsQuestion = { | ||
type: 'dependent', | ||
key: 'hazardous_nucleic_acids_dependent', | ||
parentKey: 'nucleic_acid_category', | ||
parentValue: [ | ||
'Drug_resistance', | ||
'Gene_drive', | ||
'Immune_modulating', | ||
'Oncogene', | ||
'Plasmid_vector', | ||
'Suppress_gene_function', | ||
'Toxin', | ||
'Virulence_factor', | ||
], | ||
label: '', | ||
questions: [ | ||
{ | ||
type: 'input', | ||
key: 'Nucleic_acid_gene_name: ', | ||
label: 'Nucleic acid (gene) name: ', | ||
inputType: 'text', | ||
required: true, | ||
}, | ||
], | ||
}; | ||
module.exports.singleAnswerHasMatchedParntsAnswer = { | ||
nucleic_acid_category: { label: 'Drug resistance', value: 'Drug_resistance' }, | ||
describe_the_gene_function: 'function is test test ', | ||
hazardous_nucleic_acids_dependent: { 'Nucleic_acid_gene_name: ': 'answer is test test' }, | ||
}; | ||
module.exports.addAnotherQuestion = { | ||
type: 'addanother', | ||
key: 'biological_safety_cabinets_used_add_another', | ||
label: '', | ||
required: true, | ||
questions: [ | ||
{ | ||
type: 'group', | ||
key: 'safety_cabinet_add_another_question_group', | ||
required: true, | ||
questions: [ | ||
{ | ||
type: 'checkbox', | ||
key: 'exhaust_type', | ||
label: 'Exhaust type', | ||
options: [ | ||
{ label: 'Recirculating', value: 'Recirculating' }, | ||
{ label: 'Canopy', value: 'Canopy' }, | ||
{ label: 'Hard ducted', value: 'Hard_ducted' }, | ||
], | ||
required: true, | ||
}, | ||
{ type: 'input', key: 'location', label: 'Location: ', inputType: 'text', required: true }, | ||
{ | ||
type: 'input', | ||
key: 'biosafety_cabinet_shared_pi', | ||
label: 'If this biosafety cabinet will be shared with other PIs, indicate who the PIs will be.', | ||
}, | ||
{ | ||
type: 'textarea', | ||
key: 'procedures_performed', | ||
label: | ||
'Describe procedures that will be performed in the biological safety cabinet (e.g., tissue culture work, necropsy of animals with infectious agents): ', | ||
rows: 5, | ||
rowsMax: 10, | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
module.exports.addAnotherAnswerValid = [ | ||
{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text', | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [ | ||
{ label: 'Canopy', value: 'Canopy' }, | ||
{ label: 'Recirculating', value: 'Recirculating' }, | ||
{ label: 'Hard ducted', value: 'Hard_ducted' }, | ||
], | ||
location: 'add another location 2 test', | ||
procedures_performed: 'add another 2 procdures text text', | ||
biosafety_cabinet_shared_pi: 'option text test', | ||
}, | ||
}, | ||
}, | ||
]; | ||
module.exports.addAnotherAnswerSomeIncomplete = [ | ||
{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text', | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [], | ||
location: '', | ||
procedures_performed: '', | ||
biosafety_cabinet_shared_pi: 'option text test', | ||
}, | ||
}, | ||
}, | ||
]; | ||
module.exports.addAnotherAnswerSomeInvalid = [ | ||
{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text', | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '5bbe29d71c9d440000d5657b', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Recirculating', value: 'Recirculating' }], | ||
location: 'location 2', | ||
procedures_performed: '', | ||
biosafety_cabinet_shared_pi: 'option text test', | ||
}, | ||
}, | ||
}, | ||
]; | ||
module.exports.addAnotherAnswerPartialIncomplete = [ | ||
{ | ||
id: '5bbe29a51c9d440000d5657a', | ||
item: { | ||
safety_cabinet_add_another_question_group: { | ||
exhaust_type: [{ label: 'Hard ducted', value: 'Hard_ducted' }], | ||
location: 'location test', | ||
procedures_performed: 'procedures test text', | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '5bbe2dc61c9d440000ccbbd5', | ||
item: { | ||
safety_cabinet_add_another_question_group: { exhaust_type: [{ label: 'Recirculating', value: 'Recirculating' }] }, | ||
}, | ||
}, | ||
]; |
const FqType = require('../../constant/flexible-questionnaire/fq-type.constant'); | ||
const hasError = (question, answer) => { | ||
if (!question.required && question.type !== 'group') return false; | ||
const Helper = { | ||
hasError: (question, answer) => { | ||
if (!question.required && question.type !== 'group') return false; | ||
if (!answer && question.required) { | ||
return true; | ||
} | ||
if (!answer && question.required) { | ||
return true; | ||
} | ||
const questionAnswer = answer[question.key]; | ||
if (questionAnswer && !questionAnswer) { | ||
return true; | ||
} | ||
switch (question.type) { | ||
case FqType.RADIO: | ||
return answer && !answer; | ||
case FqType.CHECKBOX: | ||
case FqType.ATTACHMENT: | ||
return answer && !answer.length; // TODO Validate responses are in question options | ||
case FqType.DROPDOWN: | ||
return questionAnswer && !questionAnswer.length; | ||
case FqType.GROUP: | ||
return module.exports.hasGroupError(question, questionAnswer); | ||
case 'people': | ||
case 'location': | ||
case 'agent': | ||
return answer && !answer.length; | ||
default: | ||
return question.required && !answer; | ||
} | ||
}; | ||
const questionAnswer = answer && answer[question.key]; | ||
const hasGroupError = (questionGroup, answers) => | ||
questionGroup.questions.some((q) => { | ||
if (answers) { | ||
if (q.type === FqType.GROUP) { | ||
return hasGroupError(q, answers[q.key]); | ||
} | ||
if (q.type === FqType.DEPENDENT) { | ||
if (answers[q.parentKey] === q.parentValue) { | ||
return hasGroupError(q, answers[q.key]); | ||
} else if (Array.isArray(answers[q.parentKey])) { | ||
return hasGroupError(q, answers[q.key]); | ||
switch (question.type) { | ||
case FqType.RADIO: | ||
return answer && !answer; | ||
case FqType.CHECKBOX: | ||
return answer && !answer.length; | ||
case FqType.DROPDOWN: | ||
return questionAnswer && !questionAnswer.length; | ||
case FqType.GROUP: | ||
return Helper.hasGroupError(question, questionAnswer); | ||
case FqType.ADD_ANOTHER: | ||
return Helper.hasAddAnotherError(question, answer); | ||
case 'people': | ||
case 'location': | ||
case 'agent': | ||
case FqType.ATTACHMENT: | ||
return answer && !Object.keys(answer).filter((key) => answer[key]).length; | ||
default: | ||
return question.required && !answer; | ||
} | ||
}, | ||
hasAddAnotherError: (question, answers) => | ||
question.questions.some((q) => answers.some((ans) => Helper.hasGroupError(q, ans.item[q.key]))), | ||
hasGroupError: (questionGroup, answers) => | ||
questionGroup.questions.some((q) => { | ||
if (answers) { | ||
if (q.type === FqType.GROUP) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
} | ||
return false; | ||
if (q.type === FqType.DEPENDENT) { | ||
return Helper.hasDependentError(q, answers); | ||
} | ||
return q.required && Helper.hasError(q, answers[q.key]); | ||
} | ||
return q.required && hasError(q, answers[q.key]); | ||
return q.required; | ||
}), | ||
hasDependentError: (q, answers) => { | ||
if (Array.isArray(q.parentValue)) { | ||
// eslint-disable-next-line | ||
if (Helper._multipleAnswersHaveMatchedParents(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else if (Helper._singleAnswerHasMatchedParnts(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
} | ||
} else { | ||
// eslint-disable-next-line | ||
if (Helper._answerHasMatchedParent(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else if (Helper._multipleAnswersHaveMatchedParent(q, answers)) { | ||
return Helper.hasGroupError(q, answers[q.key]); | ||
// eslint-disable-next-line | ||
} else { | ||
return Helper.hasError(q, answers); | ||
} | ||
} | ||
return q.required; | ||
}); | ||
return false; | ||
}, | ||
module.exports = { hasError, hasGroupError }; | ||
_multipleAnswersHaveMatchedParent: (q, answers) => | ||
Array.isArray(answers[q.parentKey]) && answers[q.parentKey].some((ans) => ans.value === q.parentValue), | ||
_multipleAnswersHaveMatchedParents: (q, answers) => | ||
Array.isArray(answers[q.parentKey]) && | ||
answers[q.parentKey].some((ans) => q.parentValue.some((pValue) => ans.value === pValue)), | ||
_answerHasMatchedParent: (q, answers) => | ||
answers[q.parentKey] && (answers[q.parentKey].value === q.parentValue || answers[q.parentKey] === q.parentValue), | ||
_singleAnswerHasMatchedParnts: (q, answers) => q.parentValue.some((pValue) => pValue === answers[q.parentKey].value), | ||
}; | ||
module.exports = Helper; |
@@ -1,2 +0,2 @@ | ||
const helper = require('./fq-helper'); | ||
const Helper = require('./fq-helper'); | ||
const data = require('./fq-helper-test-data'); | ||
@@ -8,3 +8,3 @@ | ||
expect(helper.hasError(data.inputQuestion, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.inputQuestion, answer)).toBeFalsy(); | ||
}); | ||
@@ -15,3 +15,3 @@ | ||
expect(helper.hasError(data.inputQuestion, answer)).toBeTruthy(); | ||
expect(Helper.hasError(data.inputQuestion, answer)).toBeTruthy(); | ||
}); | ||
@@ -22,3 +22,3 @@ | ||
expect(helper.hasError(data.textAreaQuestion, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.textAreaQuestion, answer)).toBeFalsy(); | ||
}); | ||
@@ -34,3 +34,3 @@ | ||
expect(helper.hasError(data.checkboxQuestion, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.checkboxQuestion, answer)).toBeFalsy(); | ||
}); | ||
@@ -43,3 +43,3 @@ | ||
expect(helper.hasError(data.checkboxQuestion, answer)).toBeTruthy(); | ||
expect(Helper.hasError(data.checkboxQuestion, answer)).toBeTruthy(); | ||
}); | ||
@@ -51,3 +51,3 @@ | ||
}; | ||
expect(helper.hasError(data.radioQuestion, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.radioQuestion, answer)).toBeFalsy(); | ||
}); | ||
@@ -65,3 +65,3 @@ | ||
expect(helper.hasError(data.dropdownQuestion, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.dropdownQuestion, answer)).toBeFalsy(); | ||
}); | ||
@@ -82,3 +82,3 @@ | ||
expect(helper.hasError(data.groupQuestion, answer)).toBeTruthy(); | ||
expect(Helper.hasError(data.groupQuestion, answer)).toBeTruthy(); | ||
}); | ||
@@ -99,3 +99,3 @@ | ||
expect(helper.hasError(data.peopleGroup, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.peopleGroup, answer)).toBeFalsy(); | ||
}); | ||
@@ -120,3 +120,3 @@ | ||
expect(helper.hasError(data.peopleGroup, answer)).toBeTruthy(); | ||
expect(Helper.hasError(data.peopleGroup, answer)).toBeTruthy(); | ||
}); | ||
@@ -131,3 +131,3 @@ | ||
expect(helper.hasError(data.peopleGroup, answer)).toBeTruthy(); | ||
expect(Helper.hasError(data.peopleGroup, answer)).toBeTruthy(); | ||
}); | ||
@@ -156,4 +156,134 @@ | ||
expect(helper.hasError(data.peopleGroup, answer)).toBeFalsy(); | ||
expect(Helper.hasError(data.peopleGroup, answer)).toBeFalsy(); | ||
}); | ||
it('should validate second level nested question for the child of multiple parent questions ', () => { | ||
expect(Helper.hasError(data.deeplynestedQuestion, data.requiredthSecondLevelNestedAnswer)).toBeTruthy(); | ||
}); | ||
it('should validate third level nested questions for the child of multiple parent questions ', () => { | ||
expect(Helper.hasError(data.deeplynestedQuestion, data.requiredThirdLevelNestedAnswer)).toBeTruthy(); | ||
}); | ||
it('should validate multiple nested questions for the child of multiple parent questions ', () => { | ||
expect(Helper.hasError(data.deeplynestedQuestion, data.sharedParentSecondAndThirdLevelAnswer)).toBeFalsy(); | ||
}); | ||
it('should validate required nested questions if and only if required parent questions are selected', () => { | ||
const minimumRequiredAnswer = { | ||
cell_lines: { | ||
source_organism: 'Invertebrates_source_organism', | ||
provider_of_materials: 'first level nested required answer', | ||
will_this_cell_line_be_used_or_put_in_storage_only: 'storage_only', | ||
}, | ||
}; | ||
expect(Helper.hasError(data.deeplynestedQuestion, minimumRequiredAnswer)).toBeFalsy(); | ||
}); | ||
it('should validate nested textbox questions for the child of multiple parent questions ', () => { | ||
expect(Helper.hasError(data.multpleNestedQuestionWithSharedParents, data.nestedRequiredAnswerTextBox)).toBeTruthy(); | ||
}); | ||
it('should validate checkbox nested questions for the child of multiple parent questions ', () => { | ||
expect( | ||
Helper.hasError(data.multpleNestedQuestionWithSharedParents, data.nestedRequiredAnswerCheckBoxes), | ||
).toBeTruthy(); | ||
}); | ||
it('should validate nested questions for the child of multiple parent questions ', () => { | ||
expect(Helper.hasError(data.multpleNestedQuestionWithSharedParents, data.minimumNestedRequiredAnswer)).toBeFalsy(); | ||
}); | ||
it('should check whether multiple answers that have matched parents with multiple value ', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper._multipleAnswersHaveMatchedParents( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswer, | ||
), | ||
).toBeTruthy(); | ||
}); | ||
it('should have at least one answer that have matched parents with multiple value ', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper.hasDependentError( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswerIncomplete, | ||
), | ||
).toBeTruthy(); | ||
}); | ||
it('should have at least one answer that have matched parents with multiple value ', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper.hasDependentError( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswer, | ||
), | ||
).toBeFalsy(); | ||
}); | ||
it('should validate multiple answer that have matched parents with multiple value ', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper.hasDependentError( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswerComplete, | ||
), | ||
).toBeFalsy(); | ||
}); | ||
it('should check whether multiple answers that have matched parents with multiple value ', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper._multipleAnswersHaveMatchedParents( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswer, | ||
), | ||
).toBeTruthy(); | ||
}); | ||
it('should check whether parent value is a single value that matched the answer', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper._answerHasMatchedParent(data.answerHasMatchedParentQuestion, data.answerHasMatchedParentAnswer), | ||
).toBeTruthy(); | ||
}); | ||
it('should check when parent value is not a single value that matched the answer', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper._answerHasMatchedParent( | ||
data.multipleAnswersHaveMatchedParentsQuestion, | ||
data.multipleAnswersHaveMatchedParentsAnswer, | ||
), | ||
).toBeFalsy(); | ||
}); | ||
it('should check single answer has a matched parnts value', () => { | ||
expect( | ||
// eslint-disable-next-line | ||
Helper._singleAnswerHasMatchedParnts( | ||
data.singleAnswerHasMatchedParntsQuestion, | ||
data.singleAnswerHasMatchedParntsAnswer, | ||
), | ||
).toBeTruthy(); | ||
}); | ||
it('should validate every responses of addanother question type', () => { | ||
expect(Helper.hasAddAnotherError(data.addAnotherQuestion, data.addAnotherAnswerValid)).toBeFalsy(); | ||
}); | ||
it('should validate against incomplete responses in each of addanother question type', () => { | ||
expect(Helper.hasAddAnotherError(data.addAnotherQuestion, data.addAnotherAnswerSomeIncomplete)).toBeTruthy(); | ||
}); | ||
it('should validate against invalid responses in each question within addanother question type', () => { | ||
expect(Helper.hasAddAnotherError(data.addAnotherQuestion, data.addAnotherAnswerSomeInvalid)).toBeTruthy(); | ||
}); | ||
it('should validate against partial incomplete responses within addanother question type', () => { | ||
expect(Helper.hasAddAnotherError(data.addAnotherQuestion, data.addAnotherAnswerPartialIncomplete)).toBeTruthy(); | ||
}); | ||
}); |
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
15525
572235
261