Skip to content

Commit 3882b4e

Browse files
authored
Merge pull request #52 from OpenConceptLab/issues#2589
OpenConceptLab/ocl_issues#2589 | Auto Match all rows
2 parents 6ecbe91 + 115479c commit 3882b4e

7 files changed

Lines changed: 86 additions & 23 deletions

File tree

src/components/map-projects/AutoMatchDialog.jsx

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,50 @@ const AutoMatchDialog = ({
4848
}) => {
4949
const { t } = useTranslation()
5050
const [algos, setAlgos] = React.useState(true)
51+
const [confirmAllIncludingApproved, setConfirmAllIncludingApproved] = React.useState(false)
5152
const allRowsCount = rowStatuses.unmapped.length + rowStatuses.readyForReview.length
53+
const totalRows = rowStatuses.unmapped.length + rowStatuses.readyForReview.length + rowStatuses.reviewed.length
5254
const rowsInSelectedScope = {
5355
unmapped: rowStatuses.unmapped.length,
5456
all: allRowsCount,
57+
allIncludingApproved: totalRows,
5558
selected: selectedRowCount
5659
}
5760
const rowsToMatchCount = rowsInSelectedScope[autoMatchScope] || 0
58-
const totalRows = rowStatuses.unmapped.length + rowStatuses.readyForReview.length + rowStatuses.reviewed.length
5961
const hasSelectedRows = selectedRowCount > 0
6062
const hasUnmappedRows = rowStatuses.unmapped.length > 0
63+
const hasApprovedRows = rowStatuses.reviewed.length > 0
64+
const isAllIncludingApproved = autoMatchScope === 'allIncludingApproved'
6165

6266
React.useEffect(() => {
6367
if (autoMatchScope === 'unmapped' && !hasUnmappedRows) {
6468
setAutoMatchScope('all')
6569
}
66-
}, [autoMatchScope, hasUnmappedRows, setAutoMatchScope])
70+
if (autoMatchScope === 'allIncludingApproved' && !hasApprovedRows) {
71+
setAutoMatchScope('all')
72+
}
73+
}, [autoMatchScope, hasApprovedRows, hasUnmappedRows, setAutoMatchScope])
74+
75+
React.useEffect(() => {
76+
if(!open || !isAllIncludingApproved)
77+
setConfirmAllIncludingApproved(false)
78+
}, [isAllIncludingApproved, open])
6779

6880
const scopeOptions = [
81+
{
82+
value: 'selected',
83+
disabled: !hasSelectedRows,
84+
label: `${t('map_project.selected_rows')} (${selectedRowCount.toLocaleString()})`,
85+
helperText: hasSelectedRows ?
86+
t('map_project.auto_match_selected_rows_note', {count: selectedRowCount.toLocaleString()}) :
87+
t('map_project.auto_match_selected_rows_note_no_count')
88+
},
89+
{
90+
value: 'unmapped',
91+
disabled: !hasUnmappedRows,
92+
label: `${t('map_project.unmapped_only')} (${rowStatuses.unmapped.length.toLocaleString()})`,
93+
helperText: t('map_project.auto_match_unmapped_only_note')
94+
},
6995
{
7096
value: 'all',
7197
disabled: false,
@@ -76,24 +102,21 @@ const AutoMatchDialog = ({
76102
})
77103
},
78104
{
79-
value: 'unmapped',
80-
disabled: !hasUnmappedRows,
81-
label: `${t('map_project.unmapped_only')} (${rowStatuses.unmapped.length.toLocaleString()})`,
82-
helperText: rowStatuses.unmapped.length > 0 ?
83-
t('map_project.auto_match_unmapped_only_note', {count: rowStatuses.unmapped.length.toLocaleString()}) :
84-
t('map_project.auto_match_unmapped_only_note_no_count')
85-
},
86-
{
87-
value: 'selected',
88-
disabled: !hasSelectedRows,
89-
label: `${t('map_project.selected_rows')} (${selectedRowCount.toLocaleString()})`,
90-
helperText: hasSelectedRows ?
91-
t('map_project.auto_match_selected_rows_note', {count: selectedRowCount.toLocaleString()}) :
92-
t('map_project.auto_match_selected_rows_note_no_count')
105+
value: 'allIncludingApproved',
106+
disabled: !hasApprovedRows,
107+
label: `${t('map_project.all_including_approved')} (${totalRows.toLocaleString()})`,
108+
helperText: t('map_project.auto_match_all_including_approved_note', {
109+
approvedCount: rowStatuses.reviewed.length.toLocaleString(),
110+
proposedCount: rowStatuses.readyForReview.length.toLocaleString()
111+
})
93112
}
94113
]
95114

96-
const isDisabled = !repoVersion?.version_url || rowsToMatchCount === 0 || (!algos && !autoRunAIAnalysis)
115+
const isDisabled =
116+
!repoVersion?.version_url ||
117+
rowsToMatchCount === 0 ||
118+
(!algos && !autoRunAIAnalysis) ||
119+
(isAllIncludingApproved && !confirmAllIncludingApproved)
97120

98121
return (
99122
<Dialog
@@ -145,6 +168,21 @@ const AutoMatchDialog = ({
145168
{option.helperText}
146169
</FormHelperText>
147170
}
171+
{
172+
autoMatchScope === option.value && option.value === 'allIncludingApproved' &&
173+
<FormControlLabel
174+
sx={{marginLeft: '24px', marginTop: '4px'}}
175+
control={
176+
<Checkbox
177+
checked={confirmAllIncludingApproved}
178+
onChange={event => setConfirmAllIncludingApproved(event.target.checked)}
179+
/>
180+
}
181+
label={t('map_project.auto_match_all_including_approved_confirm', {
182+
approvedCount: rowStatuses.reviewed.length.toLocaleString()
183+
})}
184+
/>
185+
}
148186
</div>
149187
))
150188
}

src/components/map-projects/MapProject.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,7 @@ const MapProject = () => {
17291729
const selectedRowIndexes = getSelectedRowIndexes(rows)
17301730
const isAutoMatchUnmappedOnly = autoMatchScope === 'unmapped'
17311731
const isAutoMatchAllRows = autoMatchScope === 'all'
1732+
const isAutoMatchAllIncludingApproved = autoMatchScope === 'allIncludingApproved'
17321733
const isAutoMatchSelectedRows = autoMatchScope === 'selected'
17331734
const selectedRowsLogExtras = isAutoMatchSelectedRows ? {
17341735
selected_rows_count: selectedRowIndexes.length,
@@ -1874,6 +1875,8 @@ const MapProject = () => {
18741875
subActions.push('reranker')
18751876
if(isAutoMatchUnmappedOnly)
18761877
subActions.push('unmatched_only')
1878+
if(isAutoMatchAllIncludingApproved)
1879+
subActions.push('including_approved')
18771880
if(isAutoMatchSelectedRows)
18781881
subActions.push('selected_rows')
18791882
if(inAIAssistantGroup && autoRunAIAnalysis)
@@ -1895,6 +1898,8 @@ const MapProject = () => {
18951898

18961899
if(isAutoMatchAllRows)
18971900
setRowStatuses(prev => ({...prev, readyForReview: []}))
1901+
if(isAutoMatchAllIncludingApproved)
1902+
setRowStatuses(prev => ({...prev, readyForReview: [], reviewed: []}))
18981903
if(isAutoMatchSelectedRows)
18991904
setRowStatuses(prev => ({
19001905
...prev,

src/components/map-projects/__tests__/autoMatchRows.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ test('getRowsToProcess: all scope excludes reviewed rows and keeps unmapped plus
4343
assert.deepEqual(result.map(row => row.__index), [0, 1, 2])
4444
})
4545

46+
test('getRowsToProcess: allIncludingApproved scope includes every row', () => {
47+
const result = getRowsToProcess(
48+
rows,
49+
{ unmapped: [0, 2], readyForReview: [1], reviewed: [3] },
50+
'allIncludingApproved',
51+
[3]
52+
)
53+
54+
assert.deepEqual(result.map(row => row.__index), [0, 1, 2, 3])
55+
})
56+
4657
test('getRowsToProcess: selected scope preserves table row order, not selection order', () => {
4758
const result = getRowsToProcess(
4859
rows,

src/components/map-projects/autoMatchRows.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ export const getRowsToProcess = (rows, rowStatuses, autoMatchScope, selectedRowI
1212
if(autoMatchScope === 'selected')
1313
return rows.filter(row => selectedIndexSet.has(row.__index))
1414

15+
if(autoMatchScope === 'allIncludingApproved')
16+
return rows
17+
1518
return rows.filter(row => !reviewedIndexes.has(row.__index))
1619
}

src/i18n/locales/en/translations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,11 @@
515515
"loading_project": "Loading project...",
516516
"stopping_gracefully": "Stopping gracefully...",
517517
"stop_processing": "Stop Processing",
518-
"auto_match_unmapped_only_note": "Note: Skip {{count}} input rows that are already proposed",
519-
"auto_match_unmapped_only_note_no_count": "Note: Skip input rows that are already proposed",
518+
"auto_match_unmapped_only_note": "Note: Only unmapped rows will be matched.",
520519
"auto_match_note": "Note: This will not affect {{approvedCount}} approved input rows but will override {{proposedCount}} proposed input rows",
521520
"auto_match_note_no_counts": "Note: This will not affect approved input rows but will override proposed input rows",
521+
"auto_match_all_including_approved_note": "Warning: This will re-run every input row from scratch and overwrite {{approvedCount}} approved and {{proposedCount}} proposed decisions.",
522+
"auto_match_all_including_approved_confirm": "I understand that {{approvedCount}} approved decisions will be overwritten",
522523
"auto_match_selected_rows_note": "Note: This will run Auto Match for {{count}} selected input rows",
523524
"auto_match_selected_rows_note_no_count": "Note: Select rows in the left panel to enable this option",
524525
"run_ai_analysis": "Run AI Analysis",
@@ -634,6 +635,7 @@
634635
"full_project_export": "Full Project Export",
635636
"select_an_algo": "Select an algorithm",
636637
"selected_rows": "Selected Rows",
638+
"all_including_approved": "All (incl. Approved)",
637639
"unmapped_and_proposed": "Unmapped & Proposed",
638640
"rows_to_match": "Rows to Match",
639641
"out_of": "out of",

src/i18n/locales/es/translations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,11 @@
482482
"loading_project": "Cargando proyecto...",
483483
"stopping_gracefully": "Deteniendo suavemente...",
484484
"stop_processing": "Detener Procesamiento",
485-
"auto_match_unmapped_only_note": "Nota: Omitir {{count}} filas de entrada que ya están propuestas",
486-
"auto_match_unmapped_only_note_no_count": "Nota: Omitir filas de entrada que ya están propuestas",
485+
"auto_match_unmapped_only_note": "Nota: Solo se emparejarán las filas no mapeadas.",
487486
"auto_match_note": "Nota: Esto no afectará {{approvedCount}} filas de entrada aprobadas pero sobrescribirá {{proposedCount}} filas de entrada propuestas",
488487
"auto_match_note_no_counts": "Nota: Esto no afectará las filas de entrada aprobadas pero sobrescribirá las filas de entrada propuestas",
488+
"auto_match_all_including_approved_note": "Advertencia: Esto volverá a ejecutar cada fila de entrada desde cero y sobrescribirá {{approvedCount}} decisiones aprobadas y {{proposedCount}} propuestas.",
489+
"auto_match_all_including_approved_confirm": "Entiendo que se sobrescribirán {{approvedCount}} decisiones aprobadas",
489490
"auto_match_selected_rows_note": "Nota: Esto ejecutará Auto Match para {{count}} fila(s) seleccionada(s)",
490491
"auto_match_selected_rows_note_no_count": "Nota: Seleccione filas en el panel izquierdo para habilitar esta opción",
491492
"run_ai_analysis": "Ejecutar Análisis de IA",
@@ -611,6 +612,7 @@
611612
"full_project_export": "Exportación completa del proyecto",
612613
"select_an_algo": "Seleccione un algoritmo",
613614
"selected_rows": "Filas seleccionadas",
615+
"all_including_approved": "Todas (incl. aprobadas)",
614616
"unmapped_and_proposed": "No mapeadas y propuestas",
615617
"rows_to_match": "Filas para coincidir",
616618
"out_of": "de",

src/i18n/locales/zh/translations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,11 @@
507507
"loading_project": "正在加载项目...",
508508
"stopping_gracefully": "正在优雅地停止...",
509509
"stop_processing": "停止处理",
510-
"auto_match_unmapped_only_note": "注意:跳过 {{count}} 个已提议的输入行",
511-
"auto_match_unmapped_only_note_no_count": "注意:跳过已提议的输入行",
510+
"auto_match_unmapped_only_note": "注意:只会匹配未映射的输入行。",
512511
"auto_match_note": "注意:这不会影响 {{approvedCount}} 个已批准的输入行,但会覆盖 {{proposedCount}} 个已提议的输入行",
513512
"auto_match_note_no_counts": "注意:这不会影响已批准的输入行,但会覆盖已提议的输入行",
513+
"auto_match_all_including_approved_note": "警告:这将从头重新运行每一条输入行,并覆盖 {{approvedCount}} 个已批准和 {{proposedCount}} 个已提议的决策。",
514+
"auto_match_all_including_approved_confirm": "我明白将覆盖 {{approvedCount}} 个已批准的决策",
514515
"auto_match_selected_rows_note": "注意:这将对 {{count}} 个已选输入行运行自动匹配",
515516
"auto_match_selected_rows_note_no_count": "注意:请在左侧面板选择行以启用此选项",
516517
"run_ai_analysis": "运行 AI 分析",
@@ -636,6 +637,7 @@
636637
"full_project_export": "完整项目导出",
637638
"select_an_algo": "选择算法",
638639
"selected_rows": "已选行",
640+
"all_including_approved": "全部(含已批准)",
639641
"unmapped_and_proposed": "未映射和已提议",
640642
"rows_to_match": "要匹配的行",
641643
"out_of": "",

0 commit comments

Comments
 (0)