Skip to content

Commit

Permalink
Added os2forms_maestro_webform settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed May 16, 2023
1 parent e5b6b85 commit 10e14f0
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 46 deletions.
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module:
os2forms_fbs_handler: 0
os2forms_forloeb: 0
os2forms_get_organized: 0
os2forms_maestro_webform: 0
os2forms_nemid: 0
os2forms_nemlogin_openid_connect: 0
os2forms_organisation: 0
Expand Down
2 changes: 2 additions & 0 deletions config/sync/maestro.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ maestro_orchestrator_development_mode: 0
_core:
default_config_hash: mCGD8kihnK7wqaQPAlYskypDDPWuP2VO502z-Wwg_RM
langcode: da
maestro_sitewide_token: task
maestro_token_zero_user: 1
14 changes: 14 additions & 0 deletions config/sync/os2forms_maestro_webform.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
known_anonymous_roles:
anonymous: anonymous
virksomhed: virksomhed
citizen: citizen
authenticated: 0
administrator: 0
site_admin: 0
flow_designer: 0
forloeb_designer: 0
sagsbehandler: 0
medarbejder: 0
leder: 0
os2forms_rest_api_user: 0
os2forms_rest_api_user_write: 0
14 changes: 0 additions & 14 deletions config/sync/system.action.user_add_role_action.borger.yml

This file was deleted.

14 changes: 14 additions & 0 deletions config/sync/system.action.user_add_role_action.citizen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 569a7733-ae74-40a0-9e91-5756d9a6d982
langcode: en
status: true
dependencies:
config:
- user.role.citizen
module:
- user
id: user_add_role_action.citizen
label: 'Add the citizen role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: citizen
14 changes: 0 additions & 14 deletions config/sync/system.action.user_remove_role_action.borger.yml

This file was deleted.

14 changes: 14 additions & 0 deletions config/sync/system.action.user_remove_role_action.citizen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: cec4dd8e-b94f-40ea-bd35-4ac38ac0315d
langcode: en
status: true
dependencies:
config:
- user.role.citizen
module:
- user
id: user_remove_role_action.citizen
label: 'Remove the citizen role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: citizen
16 changes: 0 additions & 16 deletions config/sync/user.role.borger.yml

This file was deleted.

9 changes: 9 additions & 0 deletions config/sync/user.role.citizen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
uuid: b4026821-ce05-4a4d-9be2-ca1e2972d66e
langcode: en
status: true
dependencies: { }
id: citizen
label: borger
weight: 3
is_admin: null
permissions: { }
2 changes: 1 addition & 1 deletion config/sync/user.role.forloeb_designer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ permissions:
- 'edit webform twig'
- 'revert webform revisions'
- 'search content'
- 'translate own webform'
- 'translate any webform'
- 'translate own webform'
- 'use advanced search'
- 'use text format full_html'
- 'use udgivelse_af_forlob_og_webformularer transition create_new_draft'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ description: Stubbed-out code for OS2Forms
core_version_requirement: ^9.4 || ^10
package: OS2Forms
type: module
scripts:

configure: os2forms_maestro_webform.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
os2forms_maestro_webform.settings:
title: OS2Forms maestro webform
description: Configure the OS2Forms maestro webform module
parent: system.admin_config_system
route_name: os2forms_maestro_webform.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
os2forms_maestro_webform.settings:
path: '/admin/config/system/os2forms_maestro_webform'
defaults:
_form: '\Drupal\os2forms_maestro_webform\Form\SettingsForm'
_title: 'OS2Forms maestro webform'
requirements:
_permission: 'administer site configuration'
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Drupal\os2forms_maestro_webform\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\RoleInterface;
use Drupal\user\RoleStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Settings for os2forms_maestro_webform.
*/
class SettingsForm extends ConfigFormBase {
/**
* Config settings.
*
* @var string
*/
const SETTINGS = 'os2forms_maestro_webform.settings';

/**
* {@inheritdoc}
*/
public function __construct(
ConfigFactoryInterface $configFactory,
readonly private RoleStorageInterface $roleStorage
) {
parent::__construct($configFactory);
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('entity_type.manager')->getStorage('user_role'),
);
}

/**
* {@inheritdoc}
*/
public function getFormId() {
return 'os2forms_maestro_webform_config';
}

/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
self::SETTINGS,
];
}

/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config(static::SETTINGS);

$roles = $this->roleStorage->loadMultiple();
$form['known_anonymous_roles'] = [
'#title' => $this->t('Known anonymous roles'),
'#type' => 'checkboxes',
'#options' => array_map(static fn (RoleInterface $role) => $role->label(), $roles),
'#default_value' => $config->get('known_anonymous_roles') ?: [],
'#description' => $this->t('Roles that can act as “known anonymous”'),
];

return parent::buildForm($form, $form_state);
}

/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $formState) {
$this->config(static::SETTINGS)
->set('known_anonymous_roles', $formState->getValue('known_anonymous_roles'))
->save();

parent::submitForm($form, $formState);
}

}

0 comments on commit 10e14f0

Please sign in to comment.