1616 <Field :label =" __('Prefix')" :instructions =" __('messages.fieldset_import_prefix_instructions')" class =" form-group field-w-100" >
1717 <Input autofocus :model-value =" config.prefix" @update:model-value =" updateField('prefix', $event)" />
1818 </Field >
19+
20+ <Field
21+ v-if =" fieldsetHasSections"
22+ :label =" __('Section Behavior')"
23+ :instructions =" sectionBehaviorInstructions"
24+ class =" form-group field-w-100"
25+ >
26+ <RadioGroup
27+ :model-value =" sectionBehavior"
28+ @update:model-value =" updateField('section_behavior', $event)"
29+ >
30+ <Radio
31+ v-for =" option in sectionBehaviorOptions"
32+ :key =" option.value"
33+ :label =" option.label"
34+ :description =" option.description"
35+ :value =" option.value"
36+ />
37+ </RadioGroup >
38+ </Field >
1939 </div >
2040 </CardPanel >
2141 </StackContent >
2242</template >
2343
2444<script >
25- import { Button , Heading , CardPanel , Field , Input , StackHeader , StackContent } from ' @/components/ui' ;
45+ import { Button , Heading , CardPanel , Field , Input , StackHeader , StackContent , RadioGroup , Radio } from ' @/components/ui' ;
2646
2747export default {
28- components: { StackContent, StackHeader, Heading, Button, CardPanel, Field, Input },
48+ components: { StackContent, StackHeader, Heading, Button, CardPanel, Field, Input, RadioGroup, Radio },
2949
3050 props: [' config' , ' isInsideSet' ],
3151
@@ -46,13 +66,52 @@ export default {
4666 };
4767 },
4868
69+ computed: {
70+ fieldsetMeta () {
71+ const handle = this .values .fieldset ;
72+
73+ return this .$page ? .props ? .fieldsets ? .[handle] ?? null ;
74+ },
75+
76+ fieldsetHasSections () {
77+ return this .fieldsetMeta ? .has_sections === true ;
78+ },
79+
80+ sectionBehavior () {
81+ return this .values .section_behavior ?? ' preserve' ;
82+ },
83+
84+ sectionBehaviorInstructions () {
85+ return __ (' Choose whether imported fieldset sections should be preserved or flattened into this section.' );
86+ },
87+
88+ sectionBehaviorOptions () {
89+ return [
90+ {
91+ label: __ (' Preserve' ),
92+ description: __ (' Keep imported sections as-is.' ),
93+ value: ' preserve' ,
94+ },
95+ {
96+ label: __ (' Flatten' ),
97+ description: __ (' Merge all fields into this section.' ),
98+ value: ' flatten' ,
99+ },
100+ ];
101+ },
102+ },
103+
49104 methods: {
50105 focus () {
51106 this .$els .display .select ();
52107 },
53108
54109 updateField (handle , value ) {
55110 this .values [handle] = value;
111+
112+ if (handle === ' fieldset' && ! this .fieldsetHasSections ) {
113+ this .values .section_behavior = ' preserve' ;
114+ }
56115 },
57116
58117 commit (shouldCommitParent = false ) {
0 commit comments