Spaces:
Running
Running
Commit ·
1626d14
1
Parent(s): 8be778a
fix: use _rawIndex for delete/validate to avoid index mismatch after filtering
Browse filesThe UI filters out consensus non-datasets, shifting display indices.
Now _rawIndex (original position in the unfiltered array) is used for
all API calls, so the correct entry gets deleted/validated.
- app/components/AnnotationPanel.js +2 -2
- app/page.js +12 -9
app/components/AnnotationPanel.js
CHANGED
|
@@ -31,7 +31,7 @@ export default function AnnotationPanel({
|
|
| 31 |
};
|
| 32 |
|
| 33 |
const submitValidation = (ds, idx, verdict) => {
|
| 34 |
-
onValidate(idx, {
|
| 35 |
human_validated: true,
|
| 36 |
human_verdict: verdict,
|
| 37 |
human_notes: validationNotes.trim() || null,
|
|
@@ -48,7 +48,7 @@ export default function AnnotationPanel({
|
|
| 48 |
};
|
| 49 |
|
| 50 |
const saveEditTag = (ds, idx) => {
|
| 51 |
-
onValidate(idx, { dataset_tag: editTag });
|
| 52 |
setEditingTagIdx(null);
|
| 53 |
setEditTag('');
|
| 54 |
};
|
|
|
|
| 31 |
};
|
| 32 |
|
| 33 |
const submitValidation = (ds, idx, verdict) => {
|
| 34 |
+
onValidate(ds._rawIndex ?? idx, {
|
| 35 |
human_validated: true,
|
| 36 |
human_verdict: verdict,
|
| 37 |
human_notes: validationNotes.trim() || null,
|
|
|
|
| 48 |
};
|
| 49 |
|
| 50 |
const saveEditTag = (ds, idx) => {
|
| 51 |
+
onValidate(ds._rawIndex ?? idx, { dataset_tag: editTag });
|
| 52 |
setEditingTagIdx(null);
|
| 53 |
setEditTag('');
|
| 54 |
};
|
app/page.js
CHANGED
|
@@ -266,9 +266,10 @@ export default function Home() {
|
|
| 266 |
|
| 267 |
// Delete dataset entry by index
|
| 268 |
const handleDeleteAnnotation = async (ds, idx) => {
|
|
|
|
| 269 |
try {
|
| 270 |
const res = await fetch(
|
| 271 |
-
`/api/validate?doc=${selectedDocIndex}&page=${currentPageNumber}&idx=${
|
| 272 |
{ method: 'DELETE' }
|
| 273 |
);
|
| 274 |
if (res.ok) {
|
|
@@ -310,14 +311,16 @@ export default function Home() {
|
|
| 310 |
}
|
| 311 |
};
|
| 312 |
|
| 313 |
-
// All datasets on the current page, excluding consensus non-datasets
|
| 314 |
-
//
|
| 315 |
-
const currentPageDatasets = (currentPageData?.datasets || [])
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
|
|
|
|
|
|
| 321 |
|
| 322 |
// Validate a dataset entry (approve/reject with notes)
|
| 323 |
const handleValidateDataset = async (datasetIdx, updates) => {
|
|
|
|
| 266 |
|
| 267 |
// Delete dataset entry by index
|
| 268 |
const handleDeleteAnnotation = async (ds, idx) => {
|
| 269 |
+
const rawIdx = ds._rawIndex ?? idx;
|
| 270 |
try {
|
| 271 |
const res = await fetch(
|
| 272 |
+
`/api/validate?doc=${selectedDocIndex}&page=${currentPageNumber}&idx=${rawIdx}`,
|
| 273 |
{ method: 'DELETE' }
|
| 274 |
);
|
| 275 |
if (res.ok) {
|
|
|
|
| 311 |
}
|
| 312 |
};
|
| 313 |
|
| 314 |
+
// All datasets on the current page, excluding consensus non-datasets.
|
| 315 |
+
// Preserve _rawIndex so delete/validate use the correct position in the file.
|
| 316 |
+
const currentPageDatasets = (currentPageData?.datasets || [])
|
| 317 |
+
.map((ds, i) => ({ ...ds, _rawIndex: i }))
|
| 318 |
+
.filter(ds => {
|
| 319 |
+
if (ds.dataset_tag === 'non-dataset' && ds.dataset_name?.judge_agrees === true) {
|
| 320 |
+
return false;
|
| 321 |
+
}
|
| 322 |
+
return true;
|
| 323 |
+
});
|
| 324 |
|
| 325 |
// Validate a dataset entry (approve/reject with notes)
|
| 326 |
const handleValidateDataset = async (datasetIdx, updates) => {
|