Skip to content

Commit

Permalink
Merge pull request #2 from OS2Forms/feature/SUPP0RT-963-GO-handler-al…
Browse files Browse the repository at this point in the history
…low-textfields

Feature/supp0rt 963 go handler allow textfields
  • Loading branch information
jekuaitk authored Apr 25, 2023
2 parents 78e167d + f1ef184 commit d370ef3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1' ]
php-versions: [ '8.1' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1' ]
php-versions: [ '8.1' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1' ]
php-versions: [ '8.1' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ about writing changes to this log.

## [Unreleased]

[Unreleased]: https://github.com/OS2Forms/os2forms_get_organized/
* Updated GO handler to allow CPR and name to be textfields
(<https://github.com/OS2Forms/os2forms_get_organized/pull/2>).

## [1.0.0] 29.03.2023

[Unreleased]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.0.0...HEAD
[1.0.0]: https://github.com/OS2Forms/os2forms_get_organized/releases/tag/1.0.0
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ details work on `/admin/os2forms_get_organized/settings`.
Check coding standards:

```sh
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer install
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer coding-standards-check
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check
```

Apply coding standards:

```shell
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php7.4-fpm:latest composer coding-standards-apply
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply
docker run --rm --interactive --tty --volume ${PWD}:/app node:18 yarn --cwd /app coding-standards-apply
```
3 changes: 3 additions & 0 deletions src/Helper/ArchiveHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ private function createCitizenCase(string $cprElementValue, string $cprNameEleme

$response = $this->caseService->createCase(self::CITIZEN_CASE_TYPE_PREFIX, $metadataArray);

if (empty($response)) {
throw new CitizenArchivingException('Could not create citizen case');
}
// Example response.
// {"CaseID":"BOR-2022-000046","CaseRelativeUrl":"\/cases\/BOR12\/BOR-2022-000046",...}.
return $response['CaseID'];
Expand Down
21 changes: 14 additions & 7 deletions src/Plugin/WebformHandler/GetOrganizedWebformHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['general']['attachment_element'] = [
'#type' => 'select',
'#title' => $this->t('Attachment element'),
'#options' => $this->getAvailableElementsByType('webform_entity_print_attachment:pdf', $elements),
'#options' => $this->getAvailableElementsByType(['webform_entity_print_attachment:pdf'], $elements),
'#default_value' => $this->configuration['general']['attachment_element'] ?? '',
'#description' => $this->t('Choose the element responsible for creating response attachments.'),
'#required' => TRUE,
Expand Down Expand Up @@ -168,7 +168,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['choose_archiving_method']['cpr_value_element'] = [
'#type' => 'select',
'#title' => $this->t('CPR element'),
'#options' => $this->getAvailableElementsByType('cpr_value_element', $elements),
'#options' => $this->getAvailableElementsByType([
'cpr_value_element',
'textfield',
], $elements),
'#default_value' => $this->configuration['choose_archiving_method']['cpr_value_element'] ?? '',
'#description' => $this->t('Choose the element containing CPR number'),
'#size' => 5,
Expand All @@ -187,7 +190,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['choose_archiving_method']['cpr_name_element'] = [
'#type' => 'select',
'#title' => $this->t('CPR element'),
'#options' => $this->getAvailableElementsByType('cpr_name_element', $elements),
'#options' => $this->getAvailableElementsByType([
'cpr_name_element',
'textfield',
], $elements),
'#default_value' => $this->configuration['choose_archiving_method']['cpr_name_element'] ?? '',
'#description' => $this->t('Choose the element containing CPR name'),
'#size' => 5,
Expand Down Expand Up @@ -278,16 +284,17 @@ public function postSave(WebformSubmissionInterface $webform_submission, $update
/**
* Get available elements by type.
*
* @phpstan-param array<mixed, mixed> $types
* @phpstan-param array<string, mixed> $elements
* @phpstan-return array<string, mixed>
*/
private function getAvailableElementsByType(string $type, array $elements): array {
$attachmentElements = array_filter($elements, function ($element) use ($type) {
return $type === $element['#type'];
private function getAvailableElementsByType(array $types, array $elements): array {
$attachmentElements = array_filter($elements, function ($element) use ($types) {
return in_array($element['#type'], $types);
});

return array_map(function ($element) {
return $element['#title'];
return $element['#title'];
}, $attachmentElements);
}

Expand Down

0 comments on commit d370ef3

Please sign in to comment.