Skip to content

Commit

Permalink
feat(ViewCreator): default to resolve target if it's a reference
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed Oct 27, 2023
1 parent d056deb commit 8c385c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"uiRecipes": [
{
"name": "Form",
"name": "Edit",
"type": "CORE:UiRecipe",
"plugin": "@development-framework/dm-core-plugins/form"
},
Expand Down
11 changes: 7 additions & 4 deletions packages/dm-core/src/components/ViewCreator/ViewCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
const [isLoading, setIsLoading] = useState<boolean>(true)
const [error, setError] = useState<Error>()
const [attribute, setAttribute] = useState<TAttribute>()
const [directAddress, setDirectAddress] = useState<string>(idReference)

const reference = getTarget(idReference, viewConfig)

useEffect(() => {
dmssAPI
.attributeGet({
address: reference,
resolve: props.viewConfig.resolve,
})
.then((response: AxiosResponse) => {
setAttribute(response.data)
setAttribute(response.data.attribute)
setDirectAddress(response.data.address)
})
.catch((error) => setError(error))
.finally(() => setIsLoading(false))
Expand All @@ -77,7 +80,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
if (isInlineRecipeViewConfig(viewConfig)) {
return (
<InlineRecipeView
idReference={reference}
idReference={directAddress}
type={attribute.attributeType}
viewConfig={viewConfig}
onOpen={onOpen}
Expand All @@ -89,7 +92,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
return (
<EntityView
type={attribute.attributeType}
idReference={reference}
idReference={directAddress}
recipeName={viewConfig.recipe}
onOpen={onOpen}
dimensions={attribute.dimensions}
Expand All @@ -98,7 +101,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
} else if (isViewConfig(viewConfig)) {
return (
<EntityView
idReference={reference}
idReference={directAddress}
type={attribute.attributeType}
onOpen={onOpen}
dimensions={attribute.dimensions}
Expand Down
1 change: 1 addition & 0 deletions packages/dm-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type TUserIdMapping = { userId: string; username: string }
export type TViewConfig = {
type: string
scope?: string
resolve?: boolean
label?: string
eds_icon?: string
roles?: string[]
Expand Down

0 comments on commit 8c385c0

Please sign in to comment.