Skip to content

Commit

Permalink
[#3607] Register address component
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Nov 30, 2023
1 parent 0e5dbb5 commit ac41fa8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/openforms/formio/components/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,8 @@ def mutate_config_dynamically(
}
for value, label in child_choices
]

@register("address")
class Default(BasePlugin):

formatter = DefaultFormatter
50 changes: 50 additions & 0 deletions src/openforms/js/components/form/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {Formio} from 'react-formio';

import {localiseSchema} from './i18n';

const FieldComponent = Formio.Components.components.field;

/**
* An address component.
*/
class Address extends FieldComponent {
constructor(component, options, data) {
super(component, options, data);
this.checks = [];
}

static schema(...extend) {
const schema = FieldComponent.schema(
{
label: 'Address',
type: 'address',
input: false,
},
...extend
);
return localiseSchema(schema);
}

static get builderInfo() {
return {
title: 'Address',
icon: 'home',
group: 'basic',
weight: 300,
schema: Address.schema(),
};
}

render(content) {
const btnContent = this.t('Address', {
authPlugin: this.component.authPlugin,
});
const context = {
content: content,
btnContent: btnContent,
};
return super.render(this.renderTemplate('address', context));
}
}

export default Address;
1 change: 1 addition & 0 deletions src/openforms/js/components/formio_builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const getBuilderOptions = () => {
cosign: true,
map: true,
editgrid: true,
address: true,
},
},
custom_layout: {
Expand Down
2 changes: 2 additions & 0 deletions src/openforms/js/formio_module.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Address from './components/form/address';
import BsnField from './components/form/bsn';
import CheckboxField from './components/form/checkbox';
import CoSignFieldOld from './components/form/coSignOld';
Expand Down Expand Up @@ -64,6 +65,7 @@ const FormIOModule = {
currency: CurrencyField,
editgrid: EditGrid,
datamap: Datamap,
address: Address,
},
builders: {
webform: WebformBuilder,
Expand Down

0 comments on commit ac41fa8

Please sign in to comment.