@@ -10,6 +10,7 @@ import { DisplayDocumentation } from "../templates"
10
10
import { AiOutlineUp , AiOutlineRight } from "react-icons/ai"
11
11
import { displayInternalProperties } from "../helpers/documentHelpers"
12
12
import { HiddenSubDocumentWidgets } from "./hiddenWidgets"
13
+ import { getLinkedDescription } from "../components/DescriptionComponent"
13
14
14
15
const CollapseMessage = ( { message, name, icon } ) => {
15
16
return < >
@@ -115,7 +116,7 @@ function getExpanded(expanded, linked_to, frame) {
115
116
}
116
117
117
118
export 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 ) ;
119
120
//const [open, setOpen] = useState(true);
120
121
let uiFrame = args . uiFrame , mode = args . mode
121
122
@@ -145,7 +146,7 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
145
146
className = "tdb__label__width"
146
147
hideFieldLabel = { hideFieldLabel } />
147
148
< 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" }
149
150
className = { `text-start p-4` }
150
151
data-testid = { `root_subdocument_${ props . name } _button` }
151
152
name = { `root_subdocument_${ props . name } _button` }
@@ -154,8 +155,8 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
154
155
aria-expanded = { open }
155
156
>
156
157
{ /*<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" /> } /> }
159
160
</ Button >
160
161
< Collapse in = { open } >
161
162
< div id = { `root_subdocument_${ props . name } ` } >
@@ -176,7 +177,30 @@ export const TDBSubDocument = ({ extracted, expanded, order_by, comment, props,
176
177
linked_to = { linked_to }
177
178
args = { args } /> }
178
179
</ 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
+ </ > }
180
204
</ Card >
181
205
</ Stack >
182
206
}
0 commit comments