Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

- Added: migrate forms and personal data blocks from a V1 supplier (EnableU, PinkRoccade, VrijBRP) to a V2 supplier (EnableU V2, PinkRoccade V2) when changing the supplier in the add-on settings, after confirmation
- Changed: personal data block only shows the options of the API version of the selected supplier
- Added: WP-CLI command `wp prefill migrate-supplier` to migrate forms and personal data blocks to a V2 supplier

## [v2.1.1] - 2026-10-27

- Added: make log directory configurable to keep log files outside the webroot
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ In addition, at least one of the following plug-ins must be installed to enable
2. Go to the form settings of the form you want to configure.
3. Scroll down and look for the 'OWC Prefill' panel and configure the settings.

### Migrating from a V1 to a V2 supplier

When the supplier in the add-on settings is changed from a V1 supplier (EnableU, PinkRoccade or VrijBRP) to a V2 supplier (EnableU V2 or PinkRoccade V2), you will be asked to migrate the linked forms and personal data blocks. Every V1 supplier can be migrated to every V2 supplier, e.g. VrijBRP to EnableU V2.
After confirming, the supplier in the form settings is switched and the linked fields are mapped to their V2 counterparts, see `config/supplier-migrations/`.
Fields without a V2 counterpart and forms using a mapping file from the theme are reported after saving and need to be updated manually.
The original values are kept in the form setting `owc-form-setting-supplier-legacy` and the field property `linkedFieldValueLegacy`.

The migration can also be run with WP-CLI, use `--dry-run` to see what will be migrated first:

```sh
wp prefill migrate-supplier enable-u enable-u-v2 --dry-run
wp prefill migrate-supplier vrij-brp enable-u-v2
```

On a multisite, add `--url=<site>` to migrate a specific site.

### Cache Encryption

To enable secure caching of sensitive data, you **must define an encryption key** in your `wp-config.php` file. This key is used to encrypt and decrypt the cached data and should be kept secret at all times.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return ['dependencies' => ['react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'], 'version' => 'df0a722bfd18e3eb3f64'];
<?php return ['dependencies' => ['react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'], 'version' => '634ba1e632324dd12941'];
2 changes: 1 addition & 1 deletion build/personal-data-table/personal-data-row/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/supplier-migration.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return ['dependencies' => [], 'version' => '7f54652d5ce551171503'];
1 change: 1 addition & 0 deletions build/supplier-migration.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions config/supplier-migrations/block_options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/**
* Maps the 'selectedOption' attribute of the 'personal-data-row' block from the V1 to the V2 option.
*
* Options that are not listed remain unchanged, these are translated on runtime by the PersonalDataService.
* The mapped values must be available in resources/js/blocks/personal-data-table/personal-data-row/config/personalDataOptions.js.
*
* @since NEXT
*/
return [
'verblijfplaats.straat' => ['value' => 'verblijfplaats.verblijfadres.officieleStraatnaam', 'label' => 'Straat'],
'verblijfplaats.straatnaam' => ['value' => 'verblijfplaats.verblijfadres.officieleStraatnaam', 'label' => 'Straat'],
'verblijfplaats.woonplaats' => ['value' => 'verblijfplaats.verblijfadres.woonplaats', 'label' => 'Woonplaats'],
'verblijfplaats.woonplaatsnaam' => ['value' => 'verblijfplaats.verblijfadres.woonplaats', 'label' => 'Woonplaats'],
'naam.aanduidingNaamgebruik' => ['value' => 'naam.aanduidingNaamgebruik.omschrijving', 'label' => 'Aanduiding Naamgebruik'],
];
16 changes: 16 additions & 0 deletions config/supplier-migrations/sources/enable-u.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use OWC\PrefillGravityForms\SupplierMigration\V1ToV2FieldMapping;

/**
* Maps the 'linkedFieldValue' of EnableU (V1) fields to the V2 option.
* Fields without a V2 counterpart (null or not listed) need to be linked manually after migrating.
*
* @since NEXT
*/
return array_merge(V1ToV2FieldMapping::base(), [
'verblijfplaats.straatnaam' => 'verblijfplaats.verblijfadres.officieleStraatnaam',
'verblijfplaats.woonplaatsnaam' => 'verblijfplaats.verblijfadres.woonplaats',
]);
17 changes: 17 additions & 0 deletions config/supplier-migrations/sources/pink-roccade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use OWC\PrefillGravityForms\SupplierMigration\V1ToV2FieldMapping;

/**
* Maps the 'linkedFieldValue' of PinkRoccade (V1) fields to the V2 option.
* Fields without a V2 counterpart (null or not listed) need to be linked manually after migrating.
*
* @since NEXT
*/
return array_merge(V1ToV2FieldMapping::base(), [
'verblijfplaats.straat' => 'verblijfplaats.verblijfadres.officieleStraatnaam',
'verblijfplaats.woonplaats' => 'verblijfplaats.verblijfadres.woonplaats',
'verblijfplaats.huisnummertoevoeging' => null,
]);
46 changes: 46 additions & 0 deletions config/supplier-migrations/sources/vrij-brp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

use OWC\PrefillGravityForms\SupplierMigration\V1ToV2FieldMapping;

/**
* Maps the 'linkedFieldValue' of VrijBRP (V1) fields to the V2 option.
* Fields without a V2 counterpart (null or not listed) need to be linked manually after migrating.
*
* @since NEXT
*/

// VrijBRP has a single partner, which is available with most of its attributes in V2 as well.
$partner = [
'burgerservicenummer' => null,
'soortVerbintenis' => 'soortVerbintenis.omschrijving',
'aangaanHuwelijkPartnerschap.datum.datum' => 'aangaanHuwelijkPartnerschap.datum.datum',
'aangaanHuwelijkPartnerschap.datum.dag' => null,
'aangaanHuwelijkPartnerschap.datum.maand' => null,
'aangaanHuwelijkPartnerschap.datum.jaar' => null,
'aangaanHuwelijkPartnerschap.land.code' => null,
'aangaanHuwelijkPartnerschap.land.omschrijving' => 'aangaanHuwelijkPartnerschap.land.omschrijving',
'aangaanHuwelijkPartnerschap.plaats.code' => null,
'aangaanHuwelijkPartnerschap.plaats.omschrijving' => 'aangaanHuwelijkPartnerschap.plaats.omschrijving',
] + V1ToV2FieldMapping::relative();

return array_merge(
V1ToV2FieldMapping::base(),
[
'naam.gebruikInLopendeTekst' => null,
'naam.aanduidingNaamgebruik.code' => 'naam.aanduidingNaamgebruik.code',
'naam.aanduidingNaamgebruik.omschrijving' => 'naam.aanduidingNaamgebruik.omschrijving',
'nationaliteiten.0.nationaliteit.omschrijving' => 'nationaliteiten.0.nationaliteit.omschrijving',
'nationaliteiten.0.nationaliteit.code' => 'nationaliteiten.0.nationaliteit.code',
'geboorte.datum.dag' => null,
'geboorte.datum.maand' => null,
'geboorte.plaats.code' => null,
'geboorte.land.code' => null,
'verblijfplaats.straat' => 'verblijfplaats.verblijfadres.officieleStraatnaam',
'verblijfplaats.straatnaam' => 'verblijfplaats.verblijfadres.officieleStraatnaam',
'verblijfplaats.woonplaats' => 'verblijfplaats.verblijfadres.woonplaats',
'verblijfplaats.woonplaatsnaam' => 'verblijfplaats.verblijfadres.woonplaats',
],
V1ToV2FieldMapping::prefix($partner, '_embedded.partners.0', 'partners.0')
);
16 changes: 16 additions & 0 deletions config/supplier-migrations/targets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

/**
* V2 suppliers a V1 supplier can be migrated to, every source can be migrated to every target.
*
* The 'block_supplier_label' is stored in the 'selectedSupplier' attribute of the 'personal-data-row' block,
* it must match the label in resources/js/blocks/personal-data-table/personal-data-row/config/supplierOptions.js.
*
* @since NEXT
*/
return [
'enable-u-v2' => ['block_supplier_label' => 'EnableU V2'],
'pink-roccade-v2' => ['block_supplier_label' => 'PinkRoccadeV2'],
];
34 changes: 34 additions & 0 deletions resources/js/admin/supplier-migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Asks for confirmation on the add-on settings page when the supplier is changed from a V1 supplier to a V2
* supplier, e.g. from VrijBRP to EnableU V2. The answer is stored in a hidden input and handled when saving.
*
* The config is provided by SupplierMigrationSettings::enqueueConfirmScript() as window.owcPrefillSupplierMigration.
*/
( function ( config ) {
if ( ! config ) {
return;
}

const form = document.getElementById( 'gform-settings' );

if ( ! form ) {
return;
}

const supplier = form.querySelector( `[name="${ config.supplierInput }"]` );
const confirmed = form.querySelector( `[name="${ config.confirmedInput }"]` );

if ( ! supplier || ! confirmed ) {
return;
}

form.addEventListener( 'submit', () => {
const isTarget = config.targets.includes( supplier.value );

confirmed.value =
isTarget &&
window.confirm( config.message.replace( '%s', supplier.value ) )
? '1'
: '';
} );
} )( window.owcPrefillSupplierMigration );
Loading