@@ -10,6 +10,7 @@ import { DisplayDocumentation } from "../templates"
1010import { AiOutlineUp , AiOutlineRight } from "react-icons/ai"
1111import { displayInternalProperties } from "../helpers/documentHelpers"
1212import { HiddenSubDocumentWidgets } from "./hiddenWidgets"
13+ import { getLinkedDescription } from "../components/DescriptionComponent"
1314
1415const CollapseMessage = ( { message, name, icon } ) => {
1516 return < >
@@ -115,7 +116,7 @@ function getExpanded(expanded, linked_to, frame) {
115116}
116117
117118export const TDBSubDocument = ( { extracted, expanded, order_by, comment, props, index, hideFieldLabel, linked_to, propertyDocumentation, id, label, reference, subDocumentData, setSubDocumentData, args } ) => {
118- const [ open , setOpen ] = useState ( args . mode === CONST . VIEW ? getExpanded ( expanded , linked_to , args . fullFrame ) : expanded ) ;
119+ const [ open , setOpen ] = useState ( args . mode === CONST . VIEW ? getExpanded ( expanded , linked_to , args . fullFrame ) : true ) ;
119120 //const [open, setOpen] = useState(true);
120121 let uiFrame = args . uiFrame , mode = args . mode
121122
@@ -145,7 +146,7 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
145146 className = "tdb__label__width"
146147 hideFieldLabel = { hideFieldLabel } />
147148 < Card bg = "secondary" className = { `tdb__subdocument__input ${ util . getBorder ( uiFrame , props . name , index ) } w-100` } key = { id } >
148- < Button variant = { "secondary" }
149+ { mode === CONST . VIEW && < > < Button variant = { "secondary" }
149150 className = { `text-start p-4` }
150151 data-testid = { `root_subdocument_${ props . name } _button` }
151152 name = { `root_subdocument_${ props . name } _button` }
@@ -154,8 +155,8 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
154155 aria-expanded = { open }
155156 >
156157 { /*<TDBLabel name={props.name} required={props.required} comment={comment}/>*/ }
157- { ! open && < CollapseMessage message = { `Click here to expand SubDocument` } name = { props . name } icon = { < AiOutlineRight className = "text-muted" /> } /> }
158- { open && < CollapseMessage message = { `Click here to collapse SubDocument` } name = { props . name } icon = { < AiOutlineUp className = "text-muted" /> } /> }
158+ { ! open && < CollapseMessage message = { `Click here to expand SubDocument` } name = { linked_to } icon = { < AiOutlineRight className = "text-muted" /> } /> }
159+ { open && < CollapseMessage message = { `Click here to collapse SubDocument` } name = { linked_to } icon = { < AiOutlineUp className = "text-muted" /> } /> }
159160 </ Button >
160161 < Collapse in = { open } >
161162 < div id = { `root_subdocument_${ props . name } ` } >
@@ -176,7 +177,30 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
176177 linked_to = { linked_to }
177178 args = { args } /> }
178179 </ div >
179- </ Collapse >
180+ </ Collapse > </ > }
181+ { mode !== CONST . VIEW && < >
182+ < Card . Header >
183+ { getLinkedDescription ( linked_to , `SubDocument` ) }
184+ </ Card . Header >
185+ < div id = { `root_subdocument_${ props . name } ` } >
186+ { subDocumentData && linked_to === subDocumentData [ CONST . TYPE ] && < SubDocumentProperties properties = { extracted . properties }
187+ //required={extracted.required}
188+ required = { props . required }
189+ //formData={props.formData}
190+ id = { id }
191+ index = { index }
192+ reference = { reference }
193+ order_by = { order_by }
194+ props = { props }
195+ subDocumentPropertyName = { props . name }
196+ propertyDocumentation = { propertyDocumentation }
197+ onChange = { props . onChange }
198+ subDocumentData = { subDocumentData }
199+ setSubDocumentData = { setSubDocumentData }
200+ linked_to = { linked_to }
201+ args = { args } /> }
202+ </ div >
203+ </ > }
180204 </ Card >
181205 </ Stack >
182206}
0 commit comments