|
| 1 | +import _ from 'lodash' |
| 2 | +// import NumberText from '../../components/NumberText/NumberText' |
| 3 | +import { findProduct } from '../projectWizard' |
| 4 | + |
| 5 | + |
| 6 | +const isFileRequired = (project, subSections) => { |
| 7 | + const subSection = _.find(subSections, (s) => s.type === 'questions') |
| 8 | + const fields = _.filter(subSection.questions, q => q.type.indexOf('see-attached') > -1) |
| 9 | + // iterate over all seeAttached type fields to check |
| 10 | + // if any see attached is checked. |
| 11 | + return _.some(_.map( |
| 12 | + _.map(fields, 'fieldName'), |
| 13 | + fn => _.get(project, `${fn}.seeAttached`) |
| 14 | + )) |
| 15 | +} |
| 16 | + |
| 17 | +const sections = [ |
| 18 | + { |
| 19 | + id: 'appDefinition', |
| 20 | + title: (project, showProduct) => { |
| 21 | + const product = _.get(project, 'details.products[0]') |
| 22 | + if (showProduct && product) { |
| 23 | + const prd = findProduct(product) |
| 24 | + if (prd) return prd.name |
| 25 | + } |
| 26 | + return 'Definition' |
| 27 | + }, |
| 28 | + required: true, |
| 29 | + description: 'Please answer a few basic questions about your project. You can also provide the needed information in a supporting document--add a link in the notes section or upload it below.', |
| 30 | + subSections: [ |
| 31 | + { |
| 32 | + id: 'projectName', |
| 33 | + required: true, |
| 34 | + validationError: 'Please provide a name to your project', |
| 35 | + fieldName: 'name', |
| 36 | + description: '', |
| 37 | + title: 'Project Name', |
| 38 | + type: 'project-name' |
| 39 | + }, |
| 40 | + { |
| 41 | + id: 'questions', |
| 42 | + required: true, |
| 43 | + hideTitle: true, |
| 44 | + title: 'Questions', |
| 45 | + description: '', |
| 46 | + type: 'questions', |
| 47 | + questions: [ |
| 48 | + { |
| 49 | + id: 'projectInfo', |
| 50 | + fieldName: 'description', |
| 51 | + // required is not needed if we specifiy validations |
| 52 | + // required: true, |
| 53 | + validations: 'isRequired,minLength:160', |
| 54 | + validationErrors: { |
| 55 | + isRequired: 'Please provide your objectives', |
| 56 | + minLength: 'Please enter at least 160 characters' |
| 57 | + }, |
| 58 | + description: 'Brief Description of your objectives', |
| 59 | + title: 'Objectives', |
| 60 | + type: 'textbox' |
| 61 | + } |
| 62 | + |
| 63 | + ] |
| 64 | + } |
| 65 | + |
| 66 | + ] |
| 67 | + }, |
| 68 | + |
| 69 | + { |
| 70 | + id: 'files', |
| 71 | + required: isFileRequired, |
| 72 | + title: (project) => `Project Files (${_.get(project, 'attachments', []).length})` || 'Files', |
| 73 | + description: '', |
| 74 | + type: 'files', |
| 75 | + fieldName: 'attachments' |
| 76 | + } |
| 77 | +] |
| 78 | + |
| 79 | +export default sections |
| 80 | + |
| 81 | +export const basicSections = [ |
| 82 | + { |
| 83 | + id: 'appDefinition', |
| 84 | + title: '', |
| 85 | + required: true, |
| 86 | + description: 'Please answer a few basic questions about your project and, as an option, add links to supporting documents in the “Notes” section. If you have any files to upload, you’ll be able to do so later.', |
| 87 | + subSections: [ |
| 88 | + { |
| 89 | + id: 'projectName', |
| 90 | + required: true, |
| 91 | + validationError: 'Please provide a name to your project', |
| 92 | + fieldName: 'name', |
| 93 | + description: '', |
| 94 | + title: 'Project Name', |
| 95 | + type: 'project-name' |
| 96 | + }, |
| 97 | + { |
| 98 | + id: 'questions', |
| 99 | + required: true, |
| 100 | + hideTitle: true, |
| 101 | + title: 'Questions', |
| 102 | + description: '', |
| 103 | + type: 'questions', |
| 104 | + questions: [ |
| 105 | + { |
| 106 | + id: 'projectInfo', |
| 107 | + fieldName: 'description', |
| 108 | + // required is not needed if we specifiy validations |
| 109 | + // required: true, |
| 110 | + validations: 'isRequired,minLength:160', |
| 111 | + validationErrors: { |
| 112 | + isRequired: 'Please provide your objectives', |
| 113 | + minLength: 'Please enter at least 160 characters' |
| 114 | + }, |
| 115 | + description: 'Brief Description of your objectives', |
| 116 | + title: 'Objectives', |
| 117 | + type: 'textbox' |
| 118 | + }, |
| 119 | + |
| 120 | + { |
| 121 | + icon: 'question', |
| 122 | + title: 'Do you have ground truth defined?', |
| 123 | + description: '', |
| 124 | + |
| 125 | + fieldName: 'details.vision.groundtruth', |
| 126 | + type: 'radio-group', |
| 127 | + options: [ |
| 128 | + {value: 'true', label: 'Yes'}, |
| 129 | + {value: 'false', label: 'No'} |
| 130 | + ], |
| 131 | + required: true, |
| 132 | + validationError: 'Please select one' |
| 133 | + }, |
| 134 | + { |
| 135 | + icon: 'question', |
| 136 | + title: 'Describe your ground truth?', |
| 137 | + description: '(if applicable)', |
| 138 | + type: 'textbox', |
| 139 | + fieldName: 'details.vision.groundtruthDesc' |
| 140 | + }, |
| 141 | + { |
| 142 | + icon: 'question', |
| 143 | + title: 'Describe your data set', |
| 144 | + description: '(if applicable)', |
| 145 | + type: 'textbox', |
| 146 | + fieldName: 'details.vision.dataDesc' |
| 147 | + } |
| 148 | + |
| 149 | + ] |
| 150 | + }, |
| 151 | + { |
| 152 | + id: 'notes', |
| 153 | + fieldName: 'details.appDefinition.notes', |
| 154 | + title: 'Additional Notes', |
| 155 | + description: 'Please detail any other additional information', |
| 156 | + type: 'notes' |
| 157 | + } |
| 158 | + ] |
| 159 | + } |
| 160 | +] |
0 commit comments