Commit 60d7b42c authored by drigle's avatar drigle

fix: enable reference editing in detail drawer

parent 190e6b24
......@@ -568,6 +568,7 @@ export default function ReferenceSearchSelect({
<XinyuanAutocomplete
{...selectionProps}
aria-label={placeholder}
allowsEmptyCollection
emptyText="无匹配结果"
errorText={error}
inputValue={query}
......
......@@ -32,6 +32,7 @@ function toSelectionKey(value) {
export default function XinyuanAutocomplete({
'aria-label': ariaLabel,
allowsEmptyCollection = false,
className,
emptyText = '暂无可选项',
errorText = '',
......@@ -119,6 +120,7 @@ export default function XinyuanAutocomplete({
<Autocomplete
{...rootSelectionProps}
aria-label={ariaLabel || placeholder}
allowsEmptyCollection={allowsEmptyCollection}
className={className}
fullWidth={fullWidth}
isDisabled={isDisabled}
......
......@@ -40,6 +40,7 @@ export default function SubjectViewContent({
editSessionId,
mode = 'view',
onFieldChange,
onFieldUpdate,
onPendingLocalMaterialChange,
onFieldValidation,
readonly,
......@@ -106,6 +107,9 @@ export default function SubjectViewContent({
editSessionId,
)
}
onSave={onFieldUpdate
? (newValue) => onFieldUpdate(field.field, newValue, field.fieldDef)
: undefined}
onValidationChange={onFieldValidation}
onPendingLocalMaterialChange={onPendingLocalMaterialChange}
readonly={readonly}
......
......@@ -594,8 +594,16 @@ export default function TailwindEditableField({
const textPlaceholder = getTextPlaceholder(placeholder, fieldDef);
const fieldLabel = String(fieldDef?.label || fieldDef?.name || '字段').trim();
const selectPlaceholder = `请选择${fieldLabel}`;
if (mode === 'view' || (mode === 'edit' && (readonly || disabled))) {
const canInlineEditReference =
mode === 'view' &&
isReferenceFieldType(fieldType) &&
canEdit &&
typeof onSave === 'function';
if (
(mode === 'view' && !canInlineEditReference) ||
(mode === 'edit' && (readonly || disabled))
) {
return <ReadonlyFieldValue value={value} fieldDef={fieldDef} />;
}
......
......@@ -458,6 +458,11 @@ const RecordDetailDrawer = (props, ref) => {
}
};
const handleInlineFieldUpdate = async (fieldPath, newValue, fieldDef) => {
await handleFieldUpdate(fieldPath, newValue, fieldDef);
onDataChange?.(true);
};
return (
<Modal.Root>
<Modal.Trigger aria-hidden="true" className="sr-only" tabIndex={-1} />
......@@ -585,6 +590,7 @@ const RecordDetailDrawer = (props, ref) => {
editSessionId={editSessionRef.current}
mode={isEditing ? 'edit' : 'view'}
onFieldChange={handleDraftFieldChange}
onFieldUpdate={handleInlineFieldUpdate}
onFieldValidation={handleFieldValidation}
onPendingLocalMaterialChange={handlePendingLocalMaterialChange}
readonly={effectiveReadonly}
......
......@@ -37,7 +37,10 @@
7. 详情弹窗按符合条件的 detail 视图显示字段,并支持字段内联维护;当前 Detail View 的
`settings.shortTitle === true` 时隐藏记录标题和 `title` 字段,但始终保留“记录详情”功能标题和
Modal 可访问名称。标题、阶段 Tabs 和顶部业务操作固定在 Header,字段内容只在 Body 内纵向
滚动,滚动内容不得穿过或遮挡阶段 Tabs。
滚动,滚动内容不得穿过或遮挡阶段 Tabs。查看态的 `reference`、`document`、`view`、
`template`、`task`、`tag`、`group`、`category` 字段显示关联记录表,并在字段具备编辑权限时
提供“编辑关联记录”入口;保存时只向 `metadata` 写入目标记录 `_id`(多值字段写入 `_id[]`)。
引用目标缺少 Subject、加载失败或保存失败时在字段附近保留可读错误反馈,不丢失当前编辑值。
8. 列表页不展示前端写死的项目总数、完成率等摘要卡片,仅展示由服务端 Subject/View 配置驱动的视图、筛选和表格内容;项目统计统一在驾驶舱查看。
9. 业务列表、动态表单数据表和关联记录表中的长文本最多展示两行,内容始终限制在所属列内;超出内容通过 HeroUI Tooltip 或项目详情查看,避免遮挡相邻列或由单条长文本过度拉高整行。弹窗内只读关联记录表按实际数据行高度收缩,不提供无业务价值的列宽拖拽。
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment