Skip to content

Commit f291b5c

Browse files
Alter the library to enable the column size (#156)
Add ability to change column size
1 parent 98493a1 commit f291b5c

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

src/formBuilder/CardGeneralParameterInputs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default function CardGeneralParameterInputs({
6060
let inputKeys = Object.keys(categoryMap).filter(
6161
(key) => key !== 'ref' || definitionsInSchema,
6262
);
63-
6463
// Exclude hidden inputs based on mods
6564
if (mods) inputKeys = subtractArray(inputKeys, mods.deactivatedFormInputs);
6665

@@ -243,6 +242,7 @@ export default function CardGeneralParameterInputs({
243242
/>
244243
</div>
245244
</div>
245+
246246
<div className='card-category-options'>
247247
<GeneralParameterInputs
248248
category={parameters.category}

src/formBuilder/FormBuilder.test.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,44 @@ describe('FormBuilder', () => {
264264
expect(errors).toEqual([]);
265265
});
266266

267+
it('supports column size', () => {
268+
const jsonSchema = {
269+
$schema: 'http://json-schema.org/draft-07/schema#',
270+
meta: {
271+
some: 'meta information',
272+
},
273+
};
274+
275+
const uischema = {
276+
newInput1: {
277+
'ui:column': 4,
278+
},
279+
'ui:order': ['newInput1'],
280+
};
281+
282+
const props = {
283+
schema: JSON.stringify(jsonSchema),
284+
uiSchema: JSON.stringify(uischema),
285+
onChange: jest.fn(() => {}),
286+
mods: {},
287+
className: 'my-form-builder',
288+
};
289+
290+
const div = document.createElement('div');
291+
document.body.appendChild(div);
292+
const wrapper = mount(<FormBuilder {...props} />, { attachTo: div });
293+
const errors = wrapper
294+
.find('.alert-warning')
295+
.first()
296+
.find('li')
297+
.map((error) => error.text());
298+
expect(errors).toEqual([]);
299+
});
300+
267301
it('validates additionalProperties as a valid property', () => {
268302
const jsonSchema = {
269303
$schema: `http://json-schema.org/draft-07/schema#`,
270304
properties: {},
271-
required: [],
272305
additionalProperties: false,
273306
};
274307

src/formBuilder/defaults/shortAnswerInputs.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,33 @@ function CardShortAnswerParameterInputs({
176176
}}
177177
className='card-modal-select'
178178
/>
179+
<h4>
180+
Column Size{' '}
181+
<a
182+
href='https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout'
183+
target='_blank'
184+
rel='noopener noreferrer'
185+
>
186+
<Tooltip
187+
id={`${elementId}_column_size`}
188+
type='help'
189+
text='Set the column size of the input'
190+
/>
191+
</a>
192+
</h4>
193+
<Input
194+
value={parameters['ui:column'] ? parameters['ui:column'] : ''}
195+
placeholder='Column size'
196+
key='ui:column'
197+
type='number'
198+
onChange={(ev: SyntheticInputEvent<HTMLInputElement>) => {
199+
onChange({
200+
...parameters,
201+
'ui:column': ev.target.value,
202+
});
203+
}}
204+
className='card-modal-text'
205+
/>
179206
<div className='card-modal-boolean'>
180207
<FBCheckbox
181208
onChangeValue={() => {

src/formBuilder/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const supportedUiParameters = new Set([
156156
'ui:autocomplete',
157157
'ui:options',
158158
'ui:field',
159+
'ui:column',
159160
'items',
160161
'definitions',
161162
]);

0 commit comments

Comments
 (0)