Skip to content

Commit 8bee05f

Browse files
author
Mike van den Hoek
committed
(feat): add 'zaak' document descriptions
1 parent 9f053c5 commit 8bee05f

12 files changed

Lines changed: 133 additions & 13 deletions

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
use function OWC\Zaaksysteem\Foundation\Helpers\config;
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 _e('Document beschrijving', config('core.text_domain')) ?>
12+
</label>
13+
<input type="text" id="linkedUploadFieldDescriptionZGW" onchange="SetFieldProperty('linkedUploadFieldDescriptionValueZGW', this.value);" />
14+
<small>Gebruik het ID van een veld om de waarde daarvan te gebruiken (e.g. [id]) in de beschrijving van het bestand.</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: 8 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';
@@ -156,6 +159,8 @@ protected function prepareInformationObjectArgs(string $objectURL, string $infor
156159
$args['creatiedatum'] = date('Y-m-d');
157160
$args['informatieobjecttype'] = $informationObjectType;
158161

162+
dd($args);
163+
159164
return $args;
160165
}
161166

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)