Skip to content

Commit

Permalink
chore: refactor children to use prefabs directly
Browse files Browse the repository at this point in the history
  • Loading branch information
ingmar-stipriaan committed Dec 17, 2024
1 parent 162e8ed commit 147decf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 52 deletions.
58 changes: 15 additions & 43 deletions src/prefabs/structures/ActionJSForm/children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ import {
textInputOptions,
} from '..';

export const inputTypes = [
TextInput({ label: 'Text field', options: { ...textInputOptions } }),
SelectInput({ label: 'Select', options: { ...selectInputOptions } }),
PriceInput({ label: 'Price', options: { ...priceInputOptions } }),
TextArea({ label: 'Textarea', options: { ...textAreaOptions } }),
];

const defaultOptions = {
property: property('Property', {
value: '',
Expand All @@ -40,57 +47,22 @@ const defaultOptions = {
}),
};

export const inputTypes = [
{
label: 'Text (single line)',
structure: [TextInput({ options: { ...textInputOptions } })],
},
{
label: 'Select',
structure: [SelectInput({ options: { ...selectInputOptions } })],
},
{
label: 'Price',
structure: [PriceInput({ options: { ...priceInputOptions } })],
},
{
label: 'TextArea',
structure: [TextArea({ options: { ...textAreaOptions } })],
},
];

export const children = [
TextInput({
options: { ...textInputOptions, ...defaultOptions },
}),
SelectInput({
options: { ...selectInputOptions, ...defaultOptions },
}),
CheckboxInput({
options: { ...checkboxInputOptions, ...defaultOptions },
}),
TextInput({ options: { ...textInputOptions, ...defaultOptions } }),
SelectInput({ options: { ...selectInputOptions, ...defaultOptions } }),
CheckboxInput({ options: { ...checkboxInputOptions, ...defaultOptions } }),
AutocompleteInput({
options: { ...autocompleteInputOptions, ...defaultOptions },
}),
DateTimePicker({
options: { ...dateTimePickerOptions, ...defaultOptions },
}),
DateTimePicker({ options: { ...dateTimePickerOptions, ...defaultOptions } }),
CheckboxGroup({
options: { ...checkboxGroupInputOptions, ...defaultOptions },
}),
RadioInput({
options: { ...radioInputOptions, ...defaultOptions },
}),
RadioInput({ options: { ...radioInputOptions, ...defaultOptions } }),
MultiAutocomplete({
options: { ...multiAutocompleteOptions, ...defaultOptions },
}),
FileUpload({
options: { ...fileUploadOptions, ...defaultOptions },
}),
RatingInput({
options: { ...ratingInputOptions, ...defaultOptions },
}),
RichTextInput({
options: { ...richTextOptions, ...defaultOptions },
}),
FileUpload({ options: { ...fileUploadOptions, ...defaultOptions } }),
RatingInput({ options: { ...ratingInputOptions, ...defaultOptions } }),
RichTextInput({ options: { ...richTextOptions, ...defaultOptions } }),
];
4 changes: 2 additions & 2 deletions src/prefabs/structures/PriceInput/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export const options = {
},
}),

label: variable('Label', { value: [''], showInAddChild: true }),
value: variable('Value', { value: [''], showInAddChild: true }),
label: variable('Label', { value: [''] }),
value: variable('Value', { value: [''] }),

...validation,

Expand Down
4 changes: 1 addition & 3 deletions src/prefabs/structures/SelectInput/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ export const options = {
label: variable('Label', {
value: ['Select'],
configuration: { allowFormatting: false, allowPropertyName: true },
showInAddChild: true,
}),
value: variable('Value', { value: [''], showInAddChild: true }),
value: variable('Value', { value: [''] }),

optionType: buttongroup(
'Option type',
Expand All @@ -82,7 +81,6 @@ export const options = {
),
model: modelAndRelation('Model', {
value: '',
showInAddChild: true,
configuration: {
condition: showIf('optionType', 'EQ', 'variable'),
},
Expand Down
4 changes: 2 additions & 2 deletions src/prefabs/structures/TextArea/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const options = {
},
}),

label: variable('Label', { value: [''], showInAddChild: true }),
value: variable('Value', { value: [''], showInAddChild: true }),
label: variable('Label', { value: [''] }),
value: variable('Value', { value: [''] }),

...validation,

Expand Down
3 changes: 1 addition & 2 deletions src/prefabs/structures/TextInput/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ export const options = {
label: variable('Label', {
value: [''],
configuration: { allowFormatting: false, allowPropertyName: true },
showInAddChild: true,
}),
value: variable('Value', { value: [''], showInAddChild: true }),
value: variable('Value', { value: [''] }),

...validation,
...styles,
Expand Down

0 comments on commit 147decf

Please sign in to comment.