-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sanity): get correct expand operations from path
- Loading branch information
Showing
8 changed files
with
164 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {Box, Card, Stack, Text} from '@sanity/ui' | ||
|
||
import {useQuery} from './loader' | ||
|
||
export function FieldGroups(): JSX.Element { | ||
const {data, loading, error} = useQuery< | ||
{ | ||
_id: string | ||
field1: string | null | ||
field2: string | null | ||
nested: { | ||
field3: string | null | ||
field4: string | null | ||
field5: string | null | ||
} | null | ||
}[] | ||
>( | ||
/* groq */ `*[_type == "fieldGroupsWithFieldsetsHidden"]{_id,field1,field2,nested{field3,field4,field5}}`, | ||
) | ||
|
||
if (error) { | ||
throw error | ||
} | ||
|
||
if (loading) { | ||
return <p>Loading...</p> | ||
} | ||
|
||
return ( | ||
<Box paddingX={4}> | ||
{data?.map((item) => { | ||
return ( | ||
<Card key={item._id} padding={4}> | ||
<Stack space={4}> | ||
<Text weight={'bold'}>{item.field1 || 'Not Set'}</Text> | ||
<Text weight={'bold'}>{item.field2 || 'Not Set'}</Text> | ||
{item.nested && ( | ||
<Stack space={4} paddingLeft={2}> | ||
<Text>{item.nested.field3 || 'Not Set'}</Text> | ||
<Text>{item.nested.field4 || 'Not Set'}</Text> | ||
<Text>{item.nested.field5 || 'Not Set'}</Text> | ||
</Stack> | ||
)} | ||
</Stack> | ||
</Card> | ||
) | ||
})} | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
dev/test-studio/schema/debug/fieldGroupsWithFieldsetsHidden.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const group = { | ||
name: 'group', | ||
title: 'Group', | ||
default: true, | ||
} | ||
const group2 = { | ||
name: 'group2', | ||
title: 'Group 2', | ||
} | ||
const fieldset = { | ||
name: 'fieldset', | ||
title: 'Fieldset', | ||
options: {collapsed: true}, | ||
} | ||
|
||
export default { | ||
name: 'fieldGroupsWithFieldsetsHidden', | ||
title: 'With default groups and collapsed fieldsets', | ||
type: 'document', | ||
groups: [group, group2], | ||
fieldsets: [fieldset], | ||
fields: [ | ||
{ | ||
name: 'field1', | ||
type: 'string', | ||
}, | ||
{ | ||
name: 'field2', | ||
type: 'string', | ||
group: group.name, | ||
fieldset: fieldset.name, | ||
}, | ||
{ | ||
name: 'nested', | ||
type: 'object', | ||
group: group.name, | ||
fieldset: fieldset.name, | ||
groups: [group, group2], | ||
fieldsets: [fieldset], | ||
fields: [ | ||
{ | ||
name: 'field3', | ||
type: 'string', | ||
fieldset: fieldset.name, | ||
}, | ||
{ | ||
name: 'field4', | ||
type: 'string', | ||
group: group.name, | ||
}, | ||
{ | ||
name: 'field5', | ||
type: 'string', | ||
group: group2.name, | ||
}, | ||
], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters