Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .ddev/.env.playwright
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PLAYWRIGHT_DOCKER_IMAGE="mcr.microsoft.com/playwright:v1.64.1-noble"
PLAYWRIGHT_DOCKER_IMAGE="mcr.microsoft.com/playwright:v1.65.1-noble"
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0] - 2026-11-10

* [PR-16](https://github.com/itk-dev/os2forms_f2/pull/16)
* Handled more matter properties
* Added global defaults for matter properties
* [PR-14](https://github.com/itk-dev/os2forms_f2/pull/14)
Improved error logging
* [PR-13](https://github.com/itk-dev/os2forms_f2/pull/13)
Expand Down
31 changes: 29 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ tasks:
decs: Create settings for os2forms_f2 module
prompt: Really reset Drupal site?
cmds:
- ddev drush config:delete os2forms_f2.settings
- ddev drush --yes config:import --partial --source modules/custom/os2forms_f2/modules/os2forms_f2_examples/config/install
- ddev drush --yes config:import --partial --source modules/custom/os2forms_f2/modules/os2forms_f2_test/config/install
- >-
Expand All @@ -249,6 +250,30 @@ tasks:
UPDATE webform SET next_serial = 1;
"

drupal:site:reset:aarhus:
decs: Create Aarhus settings for os2forms_f2 module
prompt: Really reset Drupal site?
deps:
- drupal:site:reset
vars:
CONFIG_GENERAL: |
matter_file_document_title_default_value: '[file:name]'
archive_targets:
case: case
archive_target_case:
matter_type_default_value: Internal
matter_type_allow_override: 0
matter_status_default_value: Closed
matter_status_allow_override: 0
matter_access_level_default_value: All
matter_access_level_allow_override: 0
matter_archived_default_value: 1
matter_archived_allow_override: 0
queue: os2forms_f2
cmds:
- ddev drush --yes config:set os2forms_f2.settings general --input-format=yaml "{{.CONFIG_GENERAL}}"
- ddev drush --yes config:get os2forms_f2.settings

playwright:install:
desc: Install Playwright stuff
cmd: ddev playwright-install --pm npm
Expand All @@ -272,11 +297,13 @@ tasks:
BORDER_WIDTH: 4
# Trim and add border
cmd:
# https://autocrop.org/guides/imagemagick-trim-transparent/
cmd: |
docker run --volume $PWD:/app --workdir /app --rm itkdev/php8.5-fpm mogrify \
ddev exec magick mogrify \
-strip \
-background white \
-trim \
+repage \
-gravity north -splice 0x{{.BORDER_WIDTH}}+0+0 \
-gravity south -splice 0x{{.BORDER_WIDTH}}+0+0 \
-gravity west -splice {{.BORDER_WIDTH}}x0+0+0 \
Expand Down Expand Up @@ -306,7 +333,7 @@ tasks:
status=$(git status --porcelain "$file")
if [[ "$status" =~ $status_modified_pattern ]]; then
if git cat-file -p "$latest_commit":"$file" | \
docker run --volume $PWD:/app --workdir /app --rm itkdev/php8.5-fpm compare \
ddev exec magick compare \
- \
"$file" \
{{.COMPARE_OUTPUT_FILENAME | default "-"}} > /dev/null 2>&1; then
Expand Down
25 changes: 23 additions & 2 deletions docs/user-manual/da/administrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,35 @@ Generelle indstillinger for F2-modulet laves under Administration > Indstillinge

![F2-indstillinger](./images/generated/administrator/f2-settings-empty.png)

## F2-api

Under F2-api konfigureres forbindelsen til F2's api:

![F2-api-indstillinger](./images/generated/administrator/f2-settings-empty-f2-api.png)

Passende værdier for "Url", "Bruger", "Hemmelighed" og "F2-brugernavn" kan udleveres af en F2-administrator, fx

![Udfyldte F2-indstillinger](./images/generated/administrator/f2-settings-filled.png)
![Udfyldte F2-indstillinger](./images/generated/administrator/f2-settings-filled-f2-api.png)

Når indstillingerne er gemt kan man tjekke at der er hul igennem til api'et ved at trykke på "Tjek forbindelse til api":
Når F2-api-indstillingerne er gemt kan man tjekke at der er hul igennem til api'et ved at trykke på "Tjek forbindelse
til api":

![Fejl under forbindelse til F2-api](./images/generated/administrator/f2-settings-api-pinged-error.png)

Når man indsætter gyldige og korrekte værdier skulle der gerne være hul igennem til api'et:

![Forbindelse til F2-api oprettet](./images/generated/administrator/f2-settings-api-pinged-success.png)

## Generelt

Under Generelt kan en administrator sætte standardindstillinger for F2-behandlere og styre om en formularbygger skal
kunne overskrive en standardindstilling.

![F2-api-general](./images/generated/administrator/f2-settings-empty-general.png)

Restriktive, men fornuftige, standardindstillinger kan fx være

![F2-api-general-filled](./images/generated/administrator/f2-settings-filled-general.png)

En formularbygger vil så ikke skulle forholde sig til om der skal arkiveres på en sag eller på en akt, og akter der
oprettes får de egenskaber (fx type og status) som administratoren har sat.
9 changes: 9 additions & 0 deletions docs/user-manual/da/form-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ og konfigureres på passende vis.

![Formularbehandler](./images/generated/form-builder/webform-handler-add-general.png)

> [!NOTE]
> Bemærk at de faktiske muligheder afhænger af generelle indstillinger sat af en administrator, så indstillingsformularen
> kan fx også se ud som
>
> ![Aarhusindstillinger](./images/generated/form-builder/webform-handler-add-general-archive-settings-aarhus.png)
>
> hvor "[Arkivering på sag](#arkivering-på-sag)" er valgt på forhånd (valgmuligheden er derfor skjult) og egenskaber for
> akten også er sat af administratoren.

De afgørende indstillinger for F2-behandleren ligger under "F2-arkiveringsindstillinger":

![F2-arkiveringsindstillinger](./images/generated/form-builder/webform-handler-add-general-archive-settings.png)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\os2forms_f2\Helper\F2Helper;
use Drupal\os2forms_f2\Settings;
use Drupal\os2forms_f2\Settings\ArchiveSettings\ArchiveTarget;
use Drupal\os2forms_f2\Settings\GeneralSettings\ArchiveTargetCase;
use Drupal\os2forms_f2\Settings\F2ApiSettings;
use Drupal\os2forms_f2\Settings\GeneralSettings;
use ItkDev\F2ApiClient\Model\Document;
use Psr\Log\LogLevel;
use ItkDev\F2ApiClient\Model\Matter\Type as MatterType;
use ItkDev\F2ApiClient\Model\Matter\Status as MatterStatus;
use ItkDev\F2ApiClient\Model\Matter\AccessLevel as MatterAccessLevel;

/**
* Configure F2 settings for this site.
Expand Down Expand Up @@ -157,6 +163,109 @@ private function buildFormF2Api(): array {
private function buildFormGeneral(): array {
$settings = $this->settings->getGeneralSettings();

$section[GeneralSettings::MATTER_FILE_DOCUMENT_TITLE_DEFAULT_VALUE] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => $this->t('Matter file document title default value', options: ['context' => 'os2forms_f2']),
'#description' => $this->t(<<<'DESCRIPTION'
Title used for file documents. Tokens can be used in the title, and in addition the regular webform submission token (e.g. <code>[webform_submission:label]</code>) these tokens can be used:
<ul>
<li><code>[file:name]</code> the name of the file without any extension, e.g. <code>my-document</code></li>
<li><code>[file:filename]</code> the full filename e.g. <code>my-document.pdf</code></li>
<li><code>[file:element:title]</code> the title of the file element</li>
</ul>
Max allowed length (after token expansion): @title_max_length.
DESCRIPTION, [
'@title_max_length' => Document::TITLE_MAX_LENGTH,
], options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->matterFileDocumentTitleDefaultValue,
];

$section[GeneralSettings::ARCHIVE_TARGETS] = [
'#type' => 'checkboxes',
'#options' => [
ArchiveTarget::Case->value => $this->t('Case', options: ['context' => 'os2forms_f2']),
ArchiveTarget::Matter->value => $this->t('Matter', options: ['context' => 'os2forms_f2']),
],
'#required' => TRUE,
'#title' => $this->t('Enabled archive targets', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargets,
];

$section[ArchiveTargetCase::NAME] = [
'#type' => 'fieldset',
'#title' => $this->t('Settings for "Archive on case"', options: ['context' => 'os2forms_f2']),

ArchiveTargetCase::MATTER_TYPE_DEFAULT_VALUE => [
'#type' => 'select',
'#options' => [
MatterType::Inbound->value => $this->t('Inbound', options: ['context' => 'os2forms_f2']),
MatterType::Internal->value => $this->t('Internal', options: ['context' => 'os2forms_f2']),
MatterType::Outbound->value => $this->t('Outbound', options: ['context' => 'os2forms_f2']),
],
'#title' => $this->t('Default matter type', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterTypeDefaultValue->value,
'#required' => TRUE,
],

ArchiveTargetCase::MATTER_TYPE_ALLOW_OVERRIDE => [
'#type' => 'checkbox',
'#title' => $this->t('Allow override', options: ['context' => 'os2forms_f2']),
'#description' => $this->t('If set, a form builder can override the matter type in the F2 handler settings', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterTypeAllowOverride,
],

ArchiveTargetCase::MATTER_STATUS_DEFAULT_VALUE => [
'#type' => 'select',
'#options' => [
MatterStatus::InProgress->value => $this->t('In progress', options: ['context' => 'os2forms_f2']),
MatterStatus::Closed->value => $this->t('Closed', options: ['context' => 'os2forms_f2']),
],
'#title' => $this->t('Default matter status', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterStatusDefaultValue->value,
'#required' => TRUE,
],

ArchiveTargetCase::MATTER_STATUS_ALLOW_OVERRIDE => [
'#type' => 'checkbox',
'#title' => $this->t('Allow override', options: ['context' => 'os2forms_f2']),
'#description' => $this->t('If set, a form builder can override the matter status in the F2 handler settings', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterStatusAllowOverride,
],

ArchiveTargetCase::MATTER_ACCESS_LEVEL_DEFAULT_VALUE => [
'#type' => 'select',
'#options' => [
MatterAccessLevel::Involved->value => $this->t('Involved', options: ['context' => 'os2forms_f2']),
MatterAccessLevel::Unit->value => $this->t('Unit', options: ['context' => 'os2forms_f2']),
MatterAccessLevel::All->value => $this->t('All', options: ['context' => 'os2forms_f2']),
],
'#title' => $this->t('Default matter access level', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterAccessLevelDefaultValue->value,
'#required' => TRUE,
],

ArchiveTargetCase::MATTER_ACCESS_LEVEL_ALLOW_OVERRIDE => [
'#type' => 'checkbox',
'#title' => $this->t('Allow override', options: ['context' => 'os2forms_f2']),
'#description' => $this->t('If set, a form builder can override the matter access level in the F2 handler settings', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterAccessLevelAllowOverride,
],

ArchiveTargetCase::MATTER_ARCHIVED_DEFAULT_VALUE => [
'#type' => 'checkbox',
'#title' => $this->t('Archive matter by default?', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterArchivedDefaultValue,
],

ArchiveTargetCase::MATTER_ARCHIVED_ALLOW_OVERRIDE => [
'#type' => 'checkbox',
'#title' => $this->t('Allow override', options: ['context' => 'os2forms_f2']),
'#description' => $this->t('If set, a form builder can override whether a not a matter is archived in the F2 handler settings', options: ['context' => 'os2forms_f2']),
'#default_value' => $settings->archiveTargetCase?->matterArchivedAllowOverride,
],
];

$description = empty($settings->queue)
? $this->t('Queue for F2 jobs.', options: ['context' => 'os2forms_f2'])
: $this->t("Queue for F2 jobs. <a href=':queue_url'>The queue</a> must be run via Drupal's cron or via <code>drush advancedqueue:queue:process @queue</code> (in a cron job).",
Expand Down
11 changes: 5 additions & 6 deletions src/Helper/WebformHelperF2.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,14 @@ public function log($level, $message, array $context = []): void {
*
* @see self::processJob()
*/
public function createJob(WebformSubmissionInterface $webformSubmission, WebformHandlerF2|ArchiveSettings $handlerSettings, ?string $state = NULL, ?array $payload = []): ?Job {
public function createJob(WebformSubmissionInterface $webformSubmission, WebformHandlerF2 $handler): ?Job {
$context = [
'handler_id' => WebformHandlerF2::ID,
'webform_submission' => $webformSubmission,
];

try {
if ($handlerSettings instanceof WebformHandlerF2) {
$handlerSettings = $this->settings->getHandlerSettings($handlerSettings);
}
$handlerSettings = $this->settings->getHandlerSettings($handler, applyGlobals: TRUE);

$job = Job::create(F2::class, [
'formId' => $webformSubmission->getWebform()->id(),
Expand Down Expand Up @@ -267,9 +265,10 @@ private function archiveOnCase(WebformSubmissionInterface $submission, HandlerSe
$title = $this->replaceTokens($handlerSettings->archive->archiveTargetCase->matterTitle, $submission);
$matter->title = $this->truncate($title, Matter::TITLE_MAX_LENGTH);
$matter->type = $handlerSettings->archive->archiveTargetCase->matterType;
$matter->status = $handlerSettings->archive->archiveTargetCase->matterStatus;
$matter->accessLevel = $handlerSettings->archive->archiveTargetCase->matterAccessLevel;
// Always archive ("journaliser") matter.
$matter->archived = TRUE;
// Archive ("journaliser") matter?
$matter->archived = $handlerSettings->archive->archiveTargetCase->matterArchived;
$this->setMatterResponsible($matter, $handlerSettings);
$matter = $this->f2->client()->matterCreate(matter: $matter, case: $case);

Expand Down
Loading
Loading