Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
712bc78
Fixing composer.lock to fetch fixed Forløb module release.
Oct 8, 2021
5837092
Add function to set username from webform submission.
agger-magenta Oct 11, 2021
52181c6
Adding example webforms to enable flow with multiple webforms.
Oct 11, 2021
e8fbebc
Make basic workflow work, without copying of fields.
agger-magenta Oct 12, 2021
4ea9b75
New task class in place - now ready to implement the functionality.
agger-magenta Oct 12, 2021
f9a5108
Commit day's work.
agger-magenta Oct 12, 2021
85886ad
Added form_alter hook to intercept submit on WebformMultiple task.
agger-magenta Oct 13, 2021
0dc6257
It works, next step some prettification.
agger-magenta Oct 13, 2021
1bcd8b6
Lint changes.
agger-magenta Oct 13, 2021
6b55456
Fix notification by variable for part1
Oct 14, 2021
909db46
Changed so that field names in source forms are prefixed with unique ID.
agger-magenta Oct 14, 2021
de62762
Remove composer update from CI check
Oct 14, 2021
a77e701
Set composer update to get latest version per tag
Oct 14, 2021
6219777
Brushup before review.
agger-magenta Oct 14, 2021
73a5c91
Merge branch '43378_support_multiple_parties_with_multiple_webforms' …
agger-magenta Oct 14, 2021
c87ff6a
Travis CI fix.
agger-magenta Oct 14, 2021
3e3c511
Merge branch 'develop' into 43378_support_multiple_parties_with_multi…
agger-magenta Oct 14, 2021
bf74ebc
Remove tag versioning of forloeb module
Oct 14, 2021
b7bc109
Fix linting error.
agger-magenta Oct 14, 2021
e2dc176
Update README.md
madsnorgaard Oct 15, 2021
ef7e60e
Refactor unused webforms and flows
Oct 18, 2021
ff20637
Merge pull request #86 from OS2Forms/travis_urls_update
agger-magenta Oct 18, 2021
e3616a5
Add, install and configure r4032login module
Oct 18, 2021
826a827
Adjust description text
Oct 18, 2021
c583af7
Rename template
Oct 18, 2021
d7cfba7
Change category
Oct 18, 2021
6fbfd75
Remove custom_theme and gin dependencies. The os2forms_forloeb module…
Oct 19, 2021
2fd720a
Merge pull request #87 from OS2Forms/feature/46203_remove_custom_theme
Oct 20, 2021
b412eab
Merge branch 'develop' into 43378_support_multiple_parties_with_multi…
madsnorgaard Oct 20, 2021
64f3dab
Merge pull request #84 from OS2Forms/43378_support_multiple_parties_w…
madsnorgaard Oct 20, 2021
3df55e2
Remove rules modules as dependency
Nov 3, 2021
b9508ed
lock to dev branch
Nov 3, 2021
2d12123
Remove Forløb profile as a dependency
Nov 4, 2021
bed9310
Merge pull request #89 from OS2Forms/remove_rules_modules_from_forloeb
agger-magenta Nov 5, 2021
de2740d
Merge branch 'master' into develop
madsnorgaard Nov 5, 2021
8bd8d5c
[#46780] Removed all parts of HK/Holstebro, to make the webform gener…
mBoegvald Nov 5, 2021
637f33e
Merge pull request #91 from OS2Forms/change/46780_make_grundskabelon_…
mBoegvald Nov 10, 2021
991b561
[#46800] Created new task-type for inheriting webform in flow
mBoegvald Nov 23, 2021
9b0d930
[#46800] adding returns after logs
mBoegvald Nov 26, 2021
5773ad5
Merge pull request #92 from OS2Forms/change/46800_webform_inherit_tas…
mBoegvald Nov 26, 2021
b258d2d
[#46800] Adding all form fields to 'prepareTaskForSave'
mBoegvald Nov 27, 2021
77cd8c4
Enable URL override for webform submissions and hashed url patterns (…
madsnorgaard Nov 29, 2021
c4275f4
[#46800] Added custom field to parent prepareTaskForSave method
mBoegvald Nov 29, 2021
8393d7b
Merge pull request #94 from OS2Forms/bugfix/46800_webform_inherit_tas…
mBoegvald Nov 29, 2021
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
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
"drupal/queue_mail": "1.3.0",
"drupal/queue_ui": "^2.1",
"drupal/r4032login": "^2.1",
"drupal/rules": "3.0.0-alpha6",
"drupal/rules_token": "1.2.0",
"drupal/rules_webform": "1.5.0",
"drupal/simple_ldap": "1.0.0-alpha3",
"drupal/simplesamlphp_auth": "3.2.0",
"drupal/switch_page_theme": "1.0",
Expand All @@ -52,7 +49,6 @@
"drupal/webform_scheduled_tasks": "^2.0",
"drupal/webform_views": "^5.0@alpha",
"drupal/workflow_participants": "^2.4",
"os2forms/os2forms_forloeb_profile": "^1.0",
"webmozart/path-util": "2.3.0",
"zaporylie/composer-drupal-optimizations": "1.2.0"
},
Expand Down
13 changes: 13 additions & 0 deletions config/optional/pathauto.pattern.anonymous_submissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
status: true
dependencies:
module:
- ctools
- webform
id: anonymous_submissions
label: 'Anonymisering af indsendelser'
type: 'canonical_entities:webform_submission'
pattern: 'indsendelse/[random:hash:sha1]'
selection_criteria: { }
selection_logic: and
weight: 0
relationships: { }
6 changes: 3 additions & 3 deletions config/optional/webform.webform.grundskabelon.yml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions os2forms_forloeb.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ dependencies:
- pathauto
- r4032login
- redirect
- rules
- rules_token
- rules_webform
- smtp
- system
- switch_page_theme
Expand Down
154 changes: 154 additions & 0 deletions src/Plugin/EngineTasks/MaestroWebformInheritTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php

namespace Drupal\os2forms_forloeb\Plugin\EngineTasks;

use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\WebformSubmissionForm;
use Drupal\maestro_webform\Plugin\EngineTasks\MaestroWebformTask;
use Drupal\maestro\Form\MaestroExecuteInteractive;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Entity\Webform;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;

/**
* Maestro Webform Task Plugin for Multiple Submissions.
*
* @Plugin(
* id = "MaestroWebformInherit",
* task_description = @Translation("Maestro Webform task for multiple submissions."),
* )
*/
class MaestroWebformInheritTask extends MaestroWebformTask {

/**
* Constructor.
*
* @param array $configuration
* The incoming configuration information from the engine execution.
* [0] - is the process ID
* [1] - is the queue ID
* The processID and queueID properties are defined in the MaestroTaskTrait.
*/
public function __construct(array $configuration = NULL) {
if (is_array($configuration)) {
$this->processID = $configuration[0];
$this->queueID = $configuration[1];
}
}

/**
* {@inheritDoc}
*/
public function shortDescription() {
return t('Webform with Inherited submission');
}

/**
* {@inheritDoc}
*/
public function description() {
return $this->t('Webform with Inherited submission');
}

/**
* {@inheritDoc}
*
* @see \Drupal\Component\Plugin\PluginBase::getPluginId()
*/
public function getPluginId() {
return 'MaestroWebformInherit';
}

/**
* {@inheritDoc}
*/
public function getTaskEditForm(array $task, $templateMachineName) {

// We call the parent, as we need to add a field to the inherited form
$form = parent::getTaskEditForm($task, $templateMachineName);
$form['inherit_webform_unique_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Inherit Webform from:'),
'#description' => $this->t('Put the unique identifier of the webform you want to inherit from (start-task=submission'),
'#default_value' => $task['data']['inherit_webform_unique_id'] ?? '',
'#required' => TRUE,
];
return $form;
}

/**
* {@inheritDoc}
*/
public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {

// Inherit from parent
parent::prepareTaskForSave($form, $form_state, $task);
// Add custom field(s) to the inherited prepareTaskForSave method.
$task['data']['inherit_webform_unique_id'] = $form_state->getValue('inherit_webform_unique_id');
}

/**
* {@inheritDoc}
*/
public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {

// First, get hold of the interesting previous tasks.
$templateMachineName = MaestroEngine::getTemplateIdFromProcessId($this->processID);
$taskMachineName = MaestroEngine::getTaskIdFromQueueId($this->queueID);
$task = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskMachineName);

// Get user input from 'inherit_webform_unique_id'
$webformInheritID = $task['data']['inherit_webform_unique_id'];

// Load its corresponding webform submission.
$sid = MaestroEngine::getEntityIdentiferByUniqueID($this->processID, $webformInheritID);
if ($sid) {
$webform_submission = WebformSubmission::load($sid);
}
if (!isset($webform_submission)) {
\Drupal::logger('os2forms_forloeb')->error(
"Predecessors must have submissions with webforms attached."
);
return FALSE;
}
// Copy the fields of the webform submission to the values array.
foreach ($webform_submission->getData() as $key => $value) {
if ($value) {
$field_values[$webformInheritID . '_' . $key] = $value;
}
}
// Now create webform submission, submit and attach to current process.
$templateTask = MaestroEngine::getTemplateTaskByQueueID($this->queueID);
$taskUniqueSubmissionId = $templateTask['data']['unique_id'];
$webformMachineName = $templateTask['data']['webform_machine_name'];

$values = [];
$values['webform_id'] = $webformMachineName;
$values['data'] = $field_values;

// Create submission.
$new_submission = WebformSubmission::create($values);

$errors = WebformSubmissionForm::validateWebformSubmission($webform_submission);

if (!empty($errors)) {
\Drupal::logger('os2forms_forloeb')->error(
"Can't create new submission: " . json_encode($errors)
);
return FALSE;
}
// Submit it.
$new_submission = WebformSubmissionForm::submitWebformSubmission($new_submission);

// Attach it to the Maestro process.
$sid = $new_submission->id();
MaestroEngine::createEntityIdentifier(
$this->processID, $new_submission->getEntityTypeId(),
$new_submission->bundle(), $taskUniqueSubmissionId, $sid
);

return parent::getExecutableForm($modal, $parent);
}
}