mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 11:01:59 +00:00
数据目录 F2b / B8:确认含义还空着的码值时先说清楚——「确认本列推断」原本一键确认,「确认本表全部推断」和单项「确认」也一样,码值里有含义待填写时问一句「有 N 个码值的含义待填写,确认的是取值清单」,确认后这些码值仍显示「含义待填写」、还能填写;补检查脚本的断言
This commit is contained in:
@@ -2520,6 +2520,11 @@ export const CATALOG_UI_TEXT = {
|
||||
// ---- 剖析报告里关系的结论:按这次的实际变化说(原本就是已验证的不说「升为」)
|
||||
relationStillVerified: (coverage: string) => `仍为已验证,覆盖率 ${coverage}`,
|
||||
relationLowered: (reason: string) => `降为推断:${reason}`,
|
||||
// ---- 确认含义还空着的码值:确认的是取值清单,含义照旧待填写
|
||||
codesPendingConfirm: (n: number) => `有 ${formatNumber(n)} 个码值的含义待填写,确认的是取值清单`,
|
||||
codesPendingAfter: '确认后这些码值仍显示「含义待填写」,之后可以再填写',
|
||||
confirmColumnTitle: (col: string, n: number) => `确认列 ${col} 的 ${formatNumber(n)} 项推断?`,
|
||||
confirmCodesTitle: (where: string) => `确认${where}?`,
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -189,6 +189,13 @@ export function TableDetail({ sourceId, table, rows, drafted, fillCodes, onFillD
|
||||
const review = useCallback(async (t: ReviewTarget, action: CatalogReviewAction) => {
|
||||
const d = detailRef.current
|
||||
if (!d) return
|
||||
// 确认一份含义还空着的码值:先说清确认的是取值清单,含义照旧待填写
|
||||
if (action === 'confirm') {
|
||||
const blank = blankCodes(d.notes, (p) => p === t.path)
|
||||
if (blank.n && !(await confirmDialog({
|
||||
title: UT.confirmCodesTitle(t.where), consequences: [UT.codesPendingConfirm(blank.n), UT.codesPendingAfter], confirmLabel: CT.confirm,
|
||||
}))) return
|
||||
}
|
||||
const done = await write(t.path, () => api.dataCatalog.review(sourceId, table, { path: t.path, action, if_version: d.version }))
|
||||
if (done) setLive(action === 'reset' && t.source === 'human' ? CT.removed(t.where) : CT.reviewed[action](t.where))
|
||||
}, [sourceId, table, write])
|
||||
@@ -199,6 +206,12 @@ export function TableDetail({ sourceId, table, rows, drafted, fillCodes, onFillD
|
||||
const paths = new Set(COLUMN_FIELDS.map((f) => columnPath(col, f)))
|
||||
const { notes, n } = confirmProposed(d.notes, (p) => paths.has(p))
|
||||
if (!n) return
|
||||
// 一键确认本来不问;这一列的码值还有含义空着时先问一句:确认的是取值清单,含义照旧待填写
|
||||
const blank = blankCodes(d.notes, (p) => paths.has(p))
|
||||
if (blank.n && !(await confirmDialog({
|
||||
title: UT.confirmColumnTitle(col, n), consequences: [UT.codesPendingConfirm(blank.n), UT.codesPendingAfter, ...CT.confirmAllConsequences],
|
||||
confirmLabel: CT.confirmAllAction(n),
|
||||
}))) return
|
||||
const done = await write(`column:${col}`, () => api.dataCatalog.put(sourceId, table, notes, d.version))
|
||||
if (done) setLive(CT.confirmedN(n))
|
||||
}, [sourceId, table, write])
|
||||
@@ -313,8 +326,10 @@ export function TableDetail({ sourceId, table, rows, drafted, fillCodes, onFillD
|
||||
const confirmAll = async () => {
|
||||
const { notes: body, n } = confirmProposed(notes)
|
||||
if (!n) return
|
||||
const blank = blankCodes(notes)
|
||||
const ok = await confirmDialog({
|
||||
title: CT.confirmAllTitle(n, label ?? table), consequences: CT.confirmAllConsequences, confirmLabel: CT.confirmAllAction(n),
|
||||
title: CT.confirmAllTitle(n, label ?? table), confirmLabel: CT.confirmAllAction(n),
|
||||
consequences: blank.n ? [...CT.confirmAllConsequences, UT.codesPendingConfirm(blank.n), UT.codesPendingAfter] : CT.confirmAllConsequences,
|
||||
})
|
||||
if (!ok) return
|
||||
const done = await write('confirm-all', () => api.dataCatalog.put(sourceId, table, body, detail.version))
|
||||
@@ -502,6 +517,19 @@ export function TableDetail({ sourceId, table, rows, drafted, fillCodes, onFillD
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 要确认的推断码值里,含义还空着的码值有几个(数据剖析给的码值候选只有取值,含义等人填)。pick 挑审阅路径,
|
||||
* 不给就是整张表。确认的是「这一列只有这些取值」,含义照旧待填写——确认之前要说清楚
|
||||
*/
|
||||
function blankCodes(notes: CatalogDetail['notes'], pick: (path: string) => boolean = () => true): { n: number } {
|
||||
let n = 0
|
||||
for (const [col, items] of Object.entries(notes.columns ?? {})) {
|
||||
const codes = items?.codes
|
||||
if (codes && codes.status === 'proposed' && pick(columnPath(col, 'codes'))) n += pendingCodes(codes.value)
|
||||
}
|
||||
return { n }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 表级各项
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -986,6 +986,40 @@ await section('数据目录 · 批量确认', async () => {
|
||||
&& cb.notes.columns.amount.measure.status === 'confirmed' && cb.notes.columns.qty.label.status === 'proposed'
|
||||
&& cb.notes.label.status === 'proposed' && JSON.stringify(cb.notes.columns.amount.unit.value) === JSON.stringify(wideOld.columns.amount.unit.value))
|
||||
check('……这一行的按钮消失', await until(async () => (await page.locator('[data-confirm-column="amount"]').count()) === 0))
|
||||
|
||||
// 码值的含义还空着(数据剖析给的候选只有取值):各种确认都先说清确认的是取值清单,确认后照旧写「含义待填写」
|
||||
state.tables[S1].find((t) => t.name === 'visits').notes.columns.status.codes = item({ 1: '已入园', 9: '', 2: '' }, 'profile', 'proposed')
|
||||
await openDetail(page, S1, 'visits')
|
||||
const puts = () => count(sent, /^PUT |\/review$/)
|
||||
const put0 = puts()
|
||||
await page.locator('[data-catalog-confirm-all]').click()
|
||||
await confirmBox(page).waitFor()
|
||||
check('「确认本表全部推断」:码值含义还空着时后果里写明确认的是取值清单', (await consequences(page)).includes('有 2 个码值的含义待填写,确认的是取值清单'),
|
||||
(await consequences(page)).join(' | '))
|
||||
await confirmBox(page).getByRole('button', { name: '取消' }).click()
|
||||
await openMark(page, 'columns.status.codes')
|
||||
await panel(page).locator('[data-review-action="confirm"]').click()
|
||||
await confirmBox(page).waitFor()
|
||||
check('单项「确认」码值:同样先问', (await confirmBox(page).innerText()).includes('确认列 status 的码值?')
|
||||
&& (await consequences(page)).includes('有 2 个码值的含义待填写,确认的是取值清单'), (await confirmBox(page).innerText()).replace(/\s+/g, ' '))
|
||||
await confirmBox(page).getByRole('button', { name: '取消' }).click()
|
||||
await page.locator('[data-confirm-column="status"]').click()
|
||||
await confirmBox(page).waitFor()
|
||||
const blankCons = await consequences(page)
|
||||
check('「确认本列推断」原本一键确认,码值含义还空着时先问:有 2 个码值的含义待填写,确认的是取值清单',
|
||||
(await confirmBox(page).innerText()).includes('确认列 status 的 2 项推断?') && blankCons.includes('有 2 个码值的含义待填写,确认的是取值清单')
|
||||
&& blankCons.some((c) => c.includes('仍显示「含义待填写」')), blankCons.join(' | '))
|
||||
await confirmBox(page).getByRole('button', { name: '取消' }).click()
|
||||
check('……三处取消都没有提交', puts() === put0, String(puts() - put0))
|
||||
await page.locator('[data-confirm-column="status"]').click()
|
||||
await confirmBox(page).waitFor()
|
||||
await confirmBox(page).getByRole('button', { name: '确认 2 项' }).click()
|
||||
await until(async () => puts() === put0 + 1)
|
||||
const blankCell = page.locator('[data-column="status"] [data-cell="codes"]')
|
||||
check('……确认后码值记为已确认,空着的仍写「含义待填写」,还能填写', await until(async () => (await markStatus(page, 'columns.status.codes')) === 'confirmed')
|
||||
&& await blankCell.locator('[data-code-pending]').count() === 2 && await blankCell.locator('[data-codes-fill]').count() === 1
|
||||
&& JSON.stringify(lastBody(sent, /^PUT .*catalog\/visits$/)?.notes?.columns?.status?.codes?.value) === JSON.stringify({ 1: '已入园', 9: '', 2: '' }),
|
||||
(await blankCell.innerText()).replace(/\s+/g, ' '))
|
||||
check('只发了整份提交,没有别的写请求', writes(sent, /./).every((s) => /^PUT /.test(s.key)), JSON.stringify(writes(sent, /./).map((s) => s.key)))
|
||||
check('没有原生对话框', natives.length === 0, natives.join(' | '))
|
||||
check('没有运行时报错', errors.length === 0, errors[0] ?? '')
|
||||
|
||||
Reference in New Issue
Block a user