|
14 | 14 | <v-btn value="pedigree" :text="$t('formCheckboxSetupShowPedigree')" :prepend-icon="mdiFamilyTree" /> |
15 | 15 | </v-btn-toggle> |
16 | 16 |
|
17 | | - <v-textarea |
| 17 | + <QRScanInput |
| 18 | + v-model="areaInput" |
| 19 | + textarea |
18 | 20 | :label="$t('formLabelAddGermplasmName')" |
19 | 21 | :hint="$t('formDescriptionAddGermplasm')" |
20 | | - persistent-hint |
21 | | - v-model="areaInput" |
22 | | - > |
23 | | - <template #append-inner> |
24 | | - <v-btn :icon="mdiPlus" v-tooltip:top="$t('buttonAdd')" @click="addFromInput" /> |
25 | | - </template> |
26 | | - </v-textarea> |
| 22 | + :tooltip="$t('tooltipScanQRCodeAddGermplasm')" |
| 23 | + :formats="['qr_code', 'code_128', 'code_39', 'ean_8', 'ean_13']" |
| 24 | + /> |
27 | 25 | </div> |
| 26 | + |
| 27 | + <v-btn :prepend-icon="mdiPlus" color="primary" :disabled="areaInput === undefined || areaInput.trim().length === 0" class="mt-2" :text="$t('buttonAdd')" @click="addFromInput" /> |
28 | 28 | </template> |
29 | 29 | </v-card> |
30 | 30 |
|
|
42 | 42 | </v-virtual-scroll> |
43 | 43 |
|
44 | 44 | <div class=""> |
45 | | - <v-btn v-if="hasErrors || hasWarnings" @click="bottomSheetVisible = true" :text="$t('formFeedbackLayout', feedback.length)" :prepend-icon="hasErrors ? mdiAlertCircle : mdiAlert" :color="hasErrors ? 'error' : 'warning'" /> |
| 45 | + <v-btn v-if="hasErrors || hasWarnings" @click="bottomSheetVisible = true" :text="$t('formFeedbackLayout', feedback?.length || 0)" :prepend-icon="hasErrors ? mdiAlertCircle : mdiAlert" :color="hasErrors ? 'error' : 'warning'" /> |
46 | 46 | </div> |
47 | 47 | </template> |
48 | 48 |
|
|
82 | 82 | import emitter from 'tiny-emitter/instance' |
83 | 83 | import type { LayoutFeedback } from '@/components/setup/GermplasmLayoutTable.vue' |
84 | 84 | import { useI18n } from 'vue-i18n' |
| 85 | + import QRScanInput from '@/components/inputs/QRScanInput.vue' |
85 | 86 |
|
86 | 87 | const compProps = defineProps<{ |
87 | 88 | trial: TrialPlus |
|
93 | 94 | const newGermplasm = ref<CellMetadata[]>([]) |
94 | 95 | const visibleFields = ref<('treatment' | 'friendlyName' | 'pedigree' | 'barcode')[]>([]) |
95 | 96 | const areaInput = ref<string>() |
96 | | - const feedback = ref<LayoutFeedback[]>([]) |
| 97 | + const feedback = ref<LayoutFeedback[] | undefined>() |
97 | 98 | const bottomSheetVisible = ref(false) |
98 | 99 |
|
99 | 100 | let uniqueNames = new Set<string>() |
100 | 101 | let uniqueBarcodes = new Set<string>() |
101 | 102 |
|
102 | 103 | const hasErrors = computed(() => feedback.value && feedback.value.some(f => f.type === 'error')) |
103 | 104 | const hasWarnings = computed(() => feedback.value && feedback.value.some(f => f.type === 'warning')) |
104 | | - const canContinue = computed(() => canCheck.value && hasErrors.value === false) |
| 105 | + const canContinue = computed(() => canCheck.value && feedback.value && hasErrors.value === false) |
105 | 106 | const canCheck = computed(() => newGermplasm.value.length > 0) |
106 | 107 |
|
107 | 108 | function show () { |
108 | 109 | dialog.value = true |
109 | 110 | areaInput.value = undefined |
110 | | - feedback.value = [] |
| 111 | + feedback.value = undefined |
111 | 112 |
|
112 | 113 | getTrialData(compProps.trial.localId || '') |
113 | 114 | .then(data => { |
|
127 | 128 | function hide () { |
128 | 129 | newGermplasm.value = [] |
129 | 130 | areaInput.value = undefined |
130 | | - feedback.value = [] |
| 131 | + feedback.value = undefined |
131 | 132 | dialog.value = false |
132 | 133 | } |
133 | 134 | function check () { |
|
138 | 139 | const barcode = cell.barcode |
139 | 140 | if (barcode) { |
140 | 141 | if (barcodeSet.has(barcode)) { |
141 | | - feedback.value.push({ |
| 142 | + feedback.value?.push({ |
142 | 143 | type: 'error', |
143 | 144 | message: t('formFeedbackSetupDuplicateBarcode', { columnIndex: 1, rowIndex: index + 1, germplasm: cell.germplasm, rep: cell.rep, barcode: barcode }), |
144 | 145 | }) |
|
148 | 149 |
|
149 | 150 | const displayName = `${cell.germplasm}|${cell.rep}` |
150 | 151 | if (germplasmSet.has(displayName)) { |
151 | | - feedback.value.push({ |
| 152 | + feedback.value?.push({ |
152 | 153 | type: 'warning', |
153 | 154 | message: t('formFeedbackSetupDuplicateGermplasmRep', { columnIndex: 1, rowIndex: index + 1, germplasm: cell.germplasm, rep: cell.rep || 'N/A' }), |
154 | 155 | }) |
|
158 | 159 | }) |
159 | 160 | } |
160 | 161 | function save () { |
161 | | - if (!feedback.value.some(f => f.type === 'error')) { |
| 162 | + if (!feedback.value?.some(f => f.type === 'error')) { |
162 | 163 | addTrialGermplasm(compProps.trial.localId || '', newGermplasm.value) |
163 | 164 | .then(() => { |
164 | 165 | emitter.emit('trials-updated') |
|
0 commit comments