Skip to content

Commit

Permalink
✨ [open-formulieren/open-forms#5016] Referentielijsten dataSrc for op…
Browse files Browse the repository at this point in the history
…tions

dynamically fetch options for select, selectboxes and radio components
  • Loading branch information
stevenbal committed Jan 27, 2025
1 parent 9888f01 commit 7475aad
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/formio/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ export interface VariableValues {
dataSrc: 'variable';
itemsExpression: string | JSONObject;
}

/**
* @category Utilities
*/
export interface ReferentielijstenValues {
dataSrc: 'referentielijsten';
service: string;
code: string;
}
20 changes: 16 additions & 4 deletions src/formio/components/radio.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {InputComponentSchema} from '..';
import {ManualValues, Option, VariableValues} from '../common';
import {ManualValues, Option, ReferentielijstenValues, VariableValues} from '../common';
import {Require} from '../util';

type Validator = 'required';
Expand All @@ -12,6 +12,8 @@ export type RadioInputSchema<Extensions> = InputComponentSchema<
Extensions
>;

export type RadioUnsupported = 'hideLabel' | 'disabled';

/**
* @group Form.io components
* @category Base types
Expand All @@ -25,7 +27,7 @@ interface BaseRadioSchema {
* @group Form.io components
* @category Base types
*/
type RadioManualValuesSchema = Omit<RadioInputSchema<ManualValues>, 'hideLabel' | 'disabled'> &
type RadioManualValuesSchema = Omit<RadioInputSchema<ManualValues>, RadioUnsupported> &
BaseRadioSchema & {
values: Option[];
};
Expand All @@ -34,14 +36,24 @@ type RadioManualValuesSchema = Omit<RadioInputSchema<ManualValues>, 'hideLabel'
* @group Form.io components
* @category Base types
*/
type RadioVariableValuesSchema = Omit<RadioInputSchema<VariableValues>, 'hideLabel' | 'disabled'> &
type RadioVariableValuesSchema = Omit<RadioInputSchema<VariableValues>, RadioUnsupported> &
BaseRadioSchema;

/**
* @group Form.io components
* @category Base types
*/
type RadioReferentielijstenValuesSchema = Omit<
RadioInputSchema<ReferentielijstenValues>,
RadioUnsupported
> &
BaseRadioSchema;

/**
* @group Form.io components
* @category Concrete types
*/
export type RadioComponentSchema = Require<
RadioManualValuesSchema | RadioVariableValuesSchema,
RadioManualValuesSchema | RadioVariableValuesSchema | RadioReferentielijstenValuesSchema,
'openForms'
>;
17 changes: 15 additions & 2 deletions src/formio/components/select.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {InputComponentSchema} from '..';
import {MultipleCapable} from '../base';
import {ManualValues, Option, VariableValues} from '../common';
import {ManualValues, Option, ReferentielijstenValues, VariableValues} from '../common';
import {Require} from '../util';

type Validator = 'required';
Expand Down Expand Up @@ -50,10 +50,23 @@ type SelectManualValuesSchema = Omit<SelectInputSchema<ManualValues>, SelectUnsu
type SelectVariableValuesSchema = Omit<SelectInputSchema<VariableValues>, SelectUnsupported> &
BaseSelectSchema;

/**
* @group Form.io components
* @category Base types
*/
type SelectReferentielijstenValuesSchema = Omit<
SelectInputSchema<ReferentielijstenValues>,
SelectUnsupported
> &
BaseSelectSchema;

/**
* @group Form.io components
* @category Concrete types
*/
export type SelectComponentSchema = MultipleCapable<
Require<SelectManualValuesSchema | SelectVariableValuesSchema, 'openForms'>
Require<
SelectManualValuesSchema | SelectVariableValuesSchema | SelectReferentielijstenValuesSchema,
'openForms'
>
>;
22 changes: 18 additions & 4 deletions src/formio/components/selectboxes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {InputComponentSchema} from '..';
import {ManualValues, Option, VariableValues} from '../common';
import {ManualValues, Option, ReferentielijstenValues, VariableValues} from '../common';
import {Require} from '../util';

type Validator = 'required' | 'minSelectedCount' | 'maxSelectedCount';
Expand All @@ -12,6 +12,8 @@ export type SelectboxesInputSchema<Extensions> = InputComponentSchema<
Extensions
>;

export type SelectboxesUnsupported = 'hideLabel' | 'disabled';

/**
* @group Form.io components
* @category Base types
Expand All @@ -27,7 +29,7 @@ interface BaseSelectboxesSchema {
*/
type SelectboxesManualValuesSchema = Omit<
SelectboxesInputSchema<ManualValues>,
'hideLabel' | 'disabled'
SelectboxesUnsupported
> &
BaseSelectboxesSchema & {
values: Option[];
Expand All @@ -39,7 +41,17 @@ type SelectboxesManualValuesSchema = Omit<
*/
type SelectboxesVariableValuesSchema = Omit<
SelectboxesInputSchema<VariableValues>,
'hideLabel' | 'disabled'
SelectboxesUnsupported
> &
BaseSelectboxesSchema;

/**
* @group Form.io components
* @category Base types
*/
type SelectboxesReferentielijstenValuesSchema = Omit<
SelectboxesInputSchema<ReferentielijstenValues>,
SelectboxesUnsupported
> &
BaseSelectboxesSchema;

Expand All @@ -48,6 +60,8 @@ type SelectboxesVariableValuesSchema = Omit<
* @category Concrete types
*/
export type SelectboxesComponentSchema = Require<
SelectboxesManualValuesSchema | SelectboxesVariableValuesSchema,
| SelectboxesManualValuesSchema
| SelectboxesVariableValuesSchema
| SelectboxesReferentielijstenValuesSchema,
'openForms'
>;

0 comments on commit 7475aad

Please sign in to comment.