n:m attribute–evidence guide lines from card right to field left.
Overlay draws all links for the selected attribute or evidence; optional binder context preserves unit tests without BinderProvider.
This commit is contained in:
parent
32c5a2ede4
commit
9dc4880ec1
4 changed files with 105 additions and 83 deletions
|
|
@ -277,7 +277,6 @@ export function FormRenderer({
|
|||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: 8,
|
||||
marginBottom: 8,
|
||||
flexWrap: "wrap",
|
||||
|
|
@ -303,53 +302,14 @@ export function FormRenderer({
|
|||
style={{
|
||||
flex: "1 1 100px",
|
||||
minWidth: 80,
|
||||
maxWidth: 160,
|
||||
fontSize: 12,
|
||||
padding: "4px 6px",
|
||||
border: "1px solid #ccc",
|
||||
borderRadius: 4,
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="add-field-button"
|
||||
onClick={() => {
|
||||
setAddLabel(`New attribute ${schema.fields.length + 1}`);
|
||||
setAddType("text");
|
||||
onRequestAddField?.();
|
||||
}}
|
||||
style={{
|
||||
fontSize: 11,
|
||||
padding: "4px 10px",
|
||||
border: "1px solid #888",
|
||||
borderRadius: 4,
|
||||
background: "white",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
Add attribute
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{showAddFieldForm && (
|
||||
<FieldDefinitionForm
|
||||
label={addLabel}
|
||||
type={addType}
|
||||
onChangeLabel={setAddLabel}
|
||||
onChangeType={setAddType}
|
||||
onSave={() =>
|
||||
onConfirmAddField?.({
|
||||
label: addLabel.trim(),
|
||||
type: addType,
|
||||
})
|
||||
}
|
||||
onCancel={() => onCancelAddField?.()}
|
||||
saveLabel="Add attribute"
|
||||
badge="New attribute"
|
||||
testidPrefix="field-add"
|
||||
/>
|
||||
)}
|
||||
|
||||
{visibleFields.length === 0 && schema.fields.length > 0 && (
|
||||
<p
|
||||
style={{ fontSize: 12, color: "#888", margin: "8px 0" }}
|
||||
|
|
@ -386,6 +346,48 @@ export function FormRenderer({
|
|||
onCancelEdit={() => onCancelFieldEdit?.()}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Add control lives below the list so existing attributes stay primary */}
|
||||
{showAddFieldForm ? (
|
||||
<FieldDefinitionForm
|
||||
label={addLabel}
|
||||
type={addType}
|
||||
onChangeLabel={setAddLabel}
|
||||
onChangeType={setAddType}
|
||||
onSave={() =>
|
||||
onConfirmAddField?.({
|
||||
label: addLabel.trim(),
|
||||
type: addType,
|
||||
})
|
||||
}
|
||||
onCancel={() => onCancelAddField?.()}
|
||||
saveLabel="Add attribute"
|
||||
badge="New attribute"
|
||||
testidPrefix="field-add"
|
||||
/>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
data-testid="add-field-button"
|
||||
onClick={() => {
|
||||
setAddLabel(`New attribute ${schema.fields.length + 1}`);
|
||||
setAddType("text");
|
||||
onRequestAddField?.();
|
||||
}}
|
||||
style={{
|
||||
fontSize: 11,
|
||||
padding: "6px 10px",
|
||||
border: "1px dashed #888",
|
||||
borderRadius: 4,
|
||||
background: "white",
|
||||
cursor: "pointer",
|
||||
width: "100%",
|
||||
marginTop: 4,
|
||||
}}
|
||||
>
|
||||
Add attribute
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue