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
8 changes: 8 additions & 0 deletions build/mijn-zaken/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"type": "string",
"default": "openzaak"
},
"byBSN": {
"type": "boolean",
"default": true
},
"byKVK": {
"type": "boolean",
"default": false
},
"perPage": {
"type": "number",
"default": 10
Expand Down
2 changes: 1 addition & 1 deletion build/mijn-zaken/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-server-side-render'), 'version' => 'ab2ec9e9526dd2830637');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-server-side-render'), 'version' => 'c255df62cd6927a2b215');
2 changes: 1 addition & 1 deletion build/mijn-zaken/index.js

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

6 changes: 6 additions & 0 deletions config/php-di.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
/**
* Specific client settings.
*/
'ow.enabled' => function (Container $container ) {
return (bool) $container->make( 'zgw.get-configured-client', array( 'openwave' ) );
},
'ow.api-client-settings' => function (Container $container ) {
return $container->make( 'zgw.get-configured-client', array( 'openwave' ) );
},
'oz.enabled' => function (Container $container ) {
return (bool) $container->make( 'zgw.get-configured-client', array( 'openzaak' ) );
},
Expand Down
2 changes: 2 additions & 0 deletions resources/blocks/mijn-zaken/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"description": "Toont Mijn Zaken blok.",
"attributes": {
"zaakClient": { "type": "string", "default": "openzaak" },
"byBSN": { "type": "boolean", "default": true },
"byKVK": { "type": "boolean", "default": false },
"perPage": {
"type": "number",
"default": 10
Expand Down
25 changes: 24 additions & 1 deletion resources/blocks/mijn-zaken/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import {
PanelBody,
Disabled,
CheckboxControl,
RangeControl,
SelectControl,
} from '@wordpress/components';
Expand All @@ -18,7 +19,7 @@ import metadata from './block.json';
import './editor.css';

export default function Edit( { attributes, setAttributes } ) {
const { zaakClient, perPage, orderBy, orderByDirection } = attributes;
const { zaakClient, byBSN, byKVK, perPage, orderBy, orderByDirection } = attributes;

const min = 1;
const max = 25;
Expand Down Expand Up @@ -53,6 +54,28 @@ export default function Edit( { attributes, setAttributes } ) {
} )
}
/>
<CheckboxControl
label="Filter op BSN"
help="Filter zaken die aangemaakt zijn door de ingelogde gebruiker op basis van het BSN nummer."
checked={ byBSN }
onChange={ ( byBSN ) =>
setAttributes( {
byBSN,
byKVK: byBSN ? false : attributes.byKVK,
} )
}
/>
<CheckboxControl
label="Filter op KVK"
help="Filter zaken die aangemaakt zijn door de ingelogde gebruiker op basis van het KVK nummer."
checked={ byKVK }
onChange={ ( byKVK ) =>
setAttributes( {
byKVK,
byBSN: byKVK ? false : attributes.byBSN,
} )
}
/>
<RangeControl
label={ __( 'Aantal zaken', 'owc-my-services' ) }
value={ perPage }
Expand Down
27 changes: 23 additions & 4 deletions src/Blocks/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
namespace OWC\My_Services\Blocks;

use DI\NotFoundException;
use Exception;
use OWC\My_Services\Auth\DigiD;
use OWC\My_Services\ContainerResolver;
use OWC\My_Services\Auth\eHerkenning;
use OWC\My_Services\Providers\BlockServiceProvider;
use OWC\My_Services\Traits\Supplier;
use OWC\ZGW\Contracts\Client;
use OWC\ZGW\Endpoints\Filter\ZaakinformatieobjectenFilter;
use OWC\ZGW\Endpoints\Filter\ZakenFilter;
use OWC\ZGW\Entities\Zaak;
use OWC\ZGW\Support\Collection;
use TypeError;
use Throwable;
use WP_Block;
use WP_Screen;

Expand All @@ -30,6 +31,7 @@ abstract class Block
protected Client $client;
protected ZakenFilter $zaken_filter;
protected string $bsn;
protected string $kvk;

final public function render(array $attributes, string $block_content, WP_Block $block ): string
{
Expand All @@ -39,14 +41,19 @@ final public function render(array $attributes, string $block_content, WP_Block

try {
$this->bsn = DigiD::make()->bsn();
} catch (TypeError $e) {
$this->kvk = eHerkenning::make()->kvk();

if ('' === $this->bsn && '' === $this->kvk) {
throw new Exception( 'No BSN or KVK found.' );
}
} catch (Throwable $e) {
return owc_mijn_services_render_view( 'owc-error', array( 'message' => __( 'Je moet ingelogd zijn om deze informatie te kunnen zien.', 'owc-mijn-services' ) ) );
}

$this->zaken_filter = new ZakenFilter();
$this->zaken_filter->byBsn( $this->bsn );

try {
$this->add_zaken_filter_args_by_auth_method( $attributes );
$this->client = apiClientManager()->getClient( $attributes['zaakClient'] ?? ( (string) get_query_var( BlockServiceProvider::QUERY_VAR_SUPPLIER ) ) );
} catch (NotFoundException $e) {
return owc_mijn_services_render_view( 'owc-error', array( 'message' => __( 'De gekozen zaaksysteem leverancier client is niet geconfigureerd.', 'owc-mijn-services' ) ) );
Expand All @@ -61,6 +68,18 @@ final public function render(array $attributes, string $block_content, WP_Block

abstract protected function render_block(array $attributes, string $block_content, WP_Block $block ): string;

/**
* @since NEXT
*/
private function add_zaken_filter_args_by_auth_method(array $attributes ): void
{
if ( '' !== $this->bsn && ( $attributes['byBSN'] ?? true ) ) {
$this->zaken_filter->byBsn( $this->bsn );
} elseif ( '' !== $this->kvk && ( $attributes['byKVK'] ?? false ) ) {
$this->zaken_filter->add( 'rol__betrokkeneIdentificatie__vestiging__kvkNummer', $this->kvk );
}
}

protected function is_block_editor(): bool
{
global $current_screen;
Expand Down