Skip to content

Commit d6986ee

Browse files
author
Mike van den Hoek
committed
(feat): add 'zaak' document descriptions
1 parent b95ccbf commit d6986ee

File tree

12 files changed

+146
-25
lines changed

12 files changed

+146
-25
lines changed

resources/views/partials/gf-field-options.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
use function OWC\Zaaksysteem\Foundation\Helpers\config;
56

67
?>
78
<li class="label_setting field_setting">
89
<label for="linkedFieldZGW" class="section_label">
9-
<?php _e('Zaaksysteem mapping', config('core.text_domain')) ?>
10+
<?php esc_html_e('Zaaksysteem mapping', config('core.text_domain')) ?>
1011
</label>
1112

1213
<select id="linkedFieldZGW" onchange="SetFieldProperty('linkedFieldValueZGW', this.value);">
13-
<option value=""><?php _e('Kies veldnaam Zaaksysteem', config('core.text_domain')) ?></option>
14-
<option value="bronorganisatie"><?php _e('Bronorganisatie', config('core.text_domain')) ?></option>
15-
<option value="zaaktype"><?php _e('Zaaktype', config('core.text_domain')) ?></option>
16-
<option value="omschrijving"><?php _e('Omschrijving', config('core.text_domain')) ?></option>
17-
<option value="toelichting"><?php _e('Toelichting', config('core.text_domain')) ?></option>
18-
<option value="registratiedatum"><?php _e('Registratiedatum', config('core.text_domain')) ?></option>
19-
<option value="verantwoordelijkeOrganisatie"><?php _e('Verantwoordelijke organisatie', config('core.text_domain')) ?></option>
20-
<option value="startdatum"><?php _e('Startdatum', config('core.text_domain')) ?></option>
21-
<option value="informatieobject"><?php _e('Informatieobject', config('core.text_domain')) ?></option>
14+
<option value=""><?php esc_html_e('Kies veldnaam Zaaksysteem', config('core.text_domain')) ?></option>
15+
<option value="bronorganisatie"><?php esc_html_e('Bronorganisatie', config('core.text_domain')) ?></option>
16+
<option value="zaaktype"><?php esc_html_e('Zaaktype', config('core.text_domain')) ?></option>
17+
<option value="omschrijving"><?php esc_html_e('Omschrijving', config('core.text_domain')) ?></option>
18+
<option value="toelichting"><?php esc_html_e('Toelichting', config('core.text_domain')) ?></option>
19+
<option value="registratiedatum"><?php esc_html_e('Registratiedatum', config('core.text_domain')) ?></option>
20+
<option value="verantwoordelijkeOrganisatie"><?php esc_html_e('Verantwoordelijke organisatie', config('core.text_domain')) ?></option>
21+
<option value="startdatum"><?php esc_html_e('Startdatum', config('core.text_domain')) ?></option>
22+
<option value="informatieobject"><?php esc_html_e('Informatieobject', config('core.text_domain')) ?></option>
2223
<optgroup label="Zaakeigenschappen">
2324
<?php foreach ($vars['properties'] ?? [] as $property) : ?>
2425
<option value="<?php echo $property['value']; ?>">
@@ -29,10 +30,10 @@
2930
</li>
3031
<li class="label_setting field_setting">
3132
<label for="linkedFieldDocumentType" class="section_label">
32-
<?php _e('Document typen', config('core.text_domain')) ?>
33+
<?php esc_html_e('Document typen', config('core.text_domain')) ?>
3334
</label>
3435
<select id="linkedFieldDocumentType" onchange="SetFieldProperty('linkedFieldValueDocumentType', this.value);">
35-
<option value=""><?php _e('Kies een document type', config('core.text_domain')) ?></option>
36+
<option value=""><?php esc_html_e('Kies een document type', config('core.text_domain')) ?></option>
3637
<?php foreach ($vars['objecttypes'] ?? [] as $property) : ?>
3738
<option value="<?php echo $property['value']; ?>">
3839
<?php echo $property['label']; ?>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use function OWC\Zaaksysteem\Foundation\Helpers\config;
6+
7+
?>
8+
9+
<li class="zgw_upload_setting field_setting">
10+
<label for="linkedUploadFieldDescriptionZGW" class="section_label">
11+
<?php esc_html_e('Document beschrijving', config('core.text_domain')); ?>
12+
</label>
13+
<input type="text" id="linkedUploadFieldDescriptionZGW" onchange="SetFieldProperty('linkedUploadFieldDescriptionValueZGW', this.value);" />
14+
<small><?php esc_html_e('Gebruik het ID van een veld om de waarde daarvan te gebruiken (e.g. [id]) in de beschrijving van het bestand.', config('core.text_domain')); ?></small>
15+
</li>

resources/views/scriptSelect.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
// To display custom field under each type of Gravity Forms field.
88
jQuery.each(fieldSettings, function(index, value) {
99
fieldSettings[index] += ', .highlight_setting_zgw';
10+
11+
if (index === 'fileupload') {
12+
fieldSettings[index] += ', .zgw_upload_setting';
13+
}
1014
});
1115
jQuery(document).bind('gform_load_field_settings', function(event, field, form) {
1216
jQuery('#linkedFieldZGW').val(field['linkedFieldValueZGW']);
1317
jQuery('#linkedFieldDocumentType').val(field['linkedFieldValueDocumentType']);
18+
jQuery('#linkedUploadFieldDescriptionZGW').val(field['linkedUploadFieldDescriptionValueZGW']);
1419
});
1520
</script>

src/Clients/DecosJoin/Actions/CreateUploadedDocumentsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addUploadedDocuments(): ?bool
3131
continue;
3232
}
3333

34-
$args = $this->prepareInformationObjectArgs($object['url'], $object['type']);
34+
$args = $this->prepareInformationObjectArgs($object['url'], $object['type'], $object['description']);
3535
$connectionResult = $this->connectZaakToInformationObject($this->createInformationObject($args));
3636

3737
if ($connectionResult instanceof Zaakinformatieobject) {

src/Clients/OpenZaak/Actions/CreateUploadedDocumentsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addUploadedDocuments(): ?bool
3131
continue;
3232
}
3333

34-
$args = $this->prepareInformationObjectArgs($object['url'], $object['type']);
34+
$args = $this->prepareInformationObjectArgs($object['url'], $object['type'], $object['description']);
3535
$connectionResult = $this->connectZaakToInformationObject($this->createInformationObject($args));
3636

3737
if ($connectionResult instanceof Zaakinformatieobject) {

src/Clients/Procura/Actions/CreateUploadedDocumentsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addUploadedDocuments(): ?bool
3131
continue;
3232
}
3333

34-
$args = $this->prepareInformationObjectArgs($object['url'], $object['type']);
34+
$args = $this->prepareInformationObjectArgs($object['url'], $object['type'], $object['description']);
3535
$connectionResult = $this->connectZaakToInformationObject($this->createInformationObject($args));
3636

3737
if ($connectionResult instanceof Zaakinformatieobject) {

src/Clients/RxMission/Actions/CreateUploadedDocumentsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addUploadedDocuments(): ?bool
3131
continue;
3232
}
3333

34-
$args = $this->prepareInformationObjectArgs($object['url'], $object['type']);
34+
$args = $this->prepareInformationObjectArgs($object['url'], $object['type'], $object['description']);
3535
$connectionResult = $this->connectZaakToInformationObject($this->createInformationObject($args));
3636

3737
if ($connectionResult instanceof Zaakinformatieobject) {

src/Clients/Xxllnc/Actions/CreateUploadedDocumentsAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addUploadedDocuments(): ?bool
3131
continue;
3232
}
3333

34-
$args = $this->prepareInformationObjectArgs($object['url'], $object['type']);
34+
$args = $this->prepareInformationObjectArgs($object['url'], $object['type'], $object['description']);
3535
$connectionResult = $this->connectZaakToInformationObject($this->createInformationObject($args));
3636

3737
if ($connectionResult instanceof Zaakinformatieobject) {

src/Contracts/AbstractCreateUploadedDocumentsAction.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
use OWC\Zaaksysteem\Resolvers\ContainerResolver;
1212
use OWC\Zaaksysteem\Traits\CheckURL;
1313
use OWC\Zaaksysteem\Traits\InformationObject;
14+
use OWC\Zaaksysteem\Traits\MergeTags;
1415

1516
abstract class AbstractCreateUploadedDocumentsAction
1617
{
1718
use CheckURL;
1819
use InformationObject;
20+
use MergeTags;
1921

2022
public const CLIENT_NAME = '';
2123

@@ -77,7 +79,7 @@ protected function mapInformationObjectArg(array $args, GF_Field $field, $fieldV
7779

7880
if (is_string($fieldValue)) {
7981
$fieldValue = [
80-
['type' => $field->linkedFieldValueDocumentType, 'url' => $fieldValue],
82+
['type' => $field->linkedFieldValueDocumentType, 'url' => $fieldValue, 'description' => $field->linkedUploadFieldDescriptionValueZGW ?? ''],
8183
];
8284
}
8385

@@ -107,7 +109,7 @@ protected function convertInformationObjectFieldJSON(string $fieldValue, $field)
107109
}
108110

109111
return array_map(function ($fieldValue) use ($field) {
110-
return ['type' => $field->linkedFieldValueDocumentType, 'url' => $fieldValue];
112+
return ['type' => $field->linkedFieldValueDocumentType, 'url' => $fieldValue, 'description' => $field->linkedUploadFieldDescriptionValueZGW ?? ''];
111113
}, $fieldValues);
112114
}
113115

@@ -132,7 +134,7 @@ protected function connectZaakToInformationObject(?Enkelvoudiginformatieobject $
132134
return $this->client->zaakinformatieobjecten()->create(new Zaakinformatieobject($object->toArray(), $this->client->getClientName(), $this->client->getClientNamePretty())); // What to do when this one fails?
133135
}
134136

135-
protected function prepareInformationObjectArgs(string $objectURL, string $informationObjectType): array
137+
protected function prepareInformationObjectArgs(string $objectURL, string $informationObjectType, string $objectDescription): array
136138
{
137139
if (empty($informationObjectType)) {
138140
return [];
@@ -147,6 +149,7 @@ protected function prepareInformationObjectArgs(string $objectURL, string $infor
147149
$args['formaat'] = $this->getContentType($objectURL);
148150
$args['bestandsnaam'] = sprintf('%s.%s', \sanitize_title($fileName), $this->getExtension($objectURL));
149151
$args['bestandsomvang'] = $bestandsomvang ? (int) $bestandsomvang : strlen($inhoud);
152+
$args['beschrijving'] = 0 < strlen($objectDescription) ? $this->handleMergeTags($this->entry, $objectDescription) : $fileName;
150153
$args['inhoud'] = $inhoud;
151154
$args['vertrouwelijkheidaanduiding'] = 'vertrouwelijk';
152155
$args['auteur'] = 'OWC';

src/Contracts/AbstractCreateZaakAction.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
use OWC\Zaaksysteem\Resolvers\ContainerResolver;
1616
use OWC\Zaaksysteem\Support\PagedCollection;
1717
use OWC\Zaaksysteem\Traits\FormSetting;
18+
use OWC\Zaaksysteem\Traits\MergeTags;
1819

1920
abstract class AbstractCreateZaakAction
2021
{
2122
use FormSetting;
23+
use MergeTags;
2224

2325
public const CLIENT_NAME = '';
2426
public const CALLABLE_NAME = '';
@@ -110,7 +112,7 @@ protected function mapArgs(array $args, array $form, array $entry): array
110112
$fieldValue = (new DateTime($fieldValue))->format('Y-m-d');
111113
}
112114

113-
$args[$field->linkedFieldValueZGW] = $fieldValue;
115+
$args[$field->linkedFieldValueZGW] = $this->handleMergeTags($entry, $fieldValue);
114116
}
115117

116118
return $args;
@@ -144,7 +146,7 @@ public function addZaakEigenschappen(Zaak $zaak, $fields, $entry): void
144146
);
145147
} catch (BadRequestError $e) {
146148
$e->getInvalidParameters();
147-
} catch(Exception $e) {
149+
} catch (Exception $e) {
148150
// Fail silently.
149151
}
150152
}
@@ -224,7 +226,7 @@ public function addRolToZaak(Zaak $zaak, string $zaaktypeURL): ?Rol
224226
$rol = $client->rollen()->create(new Rol($args, $client->getClientName(), $client->getClientNamePretty()));
225227
} catch (BadRequestError $e) {
226228
$e->getInvalidParameters();
227-
} catch(Exception $e) {
229+
} catch (Exception $e) {
228230
// Fail silently.
229231
}
230232

0 commit comments

Comments
 (0)