Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c7cd2067b | |||
a0ab7282b8 | |||
12afa00df8 | |||
1878d1e2fd | |||
050bee1a9b | |||
d46142ee2b | |||
fd1a0d5156 | |||
e601fde1ef | |||
74b6f90c94 | |||
e10096c1ca | |||
8941cdfb49 | |||
9715401dfc | |||
7448048f2d | |||
48e5080a9c | |||
cba43a04e5 | |||
ce1d3ca38b | |||
8294a9647f | |||
c261552cc1 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*.swp
|
*.swp
|
||||||
|
vendor
|
||||||
|
@ -8,3 +8,8 @@
|
|||||||
#edit-revision-log-message-wrapper{
|
#edit-revision-log-message-wrapper{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Same for revision checkbox. */
|
||||||
|
.js-form-item.form-item.js-form-type-checkbox.form-type-checkbox.js-form-item-new-revision.form-item-new-revision {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
@ -5,13 +5,12 @@ dependencies:
|
|||||||
- system.menu.opencase-admin
|
- system.menu.opencase-admin
|
||||||
module:
|
module:
|
||||||
- system
|
- system
|
||||||
- user
|
|
||||||
theme:
|
theme:
|
||||||
- bartik
|
- bartik
|
||||||
id: opencase
|
id: opencase
|
||||||
theme: bartik
|
theme: bartik
|
||||||
region: sidebar_first
|
region: sidebar_first
|
||||||
weight: -6
|
weight: -7
|
||||||
provider: null
|
provider: null
|
||||||
plugin: 'system_menu_block:opencase-admin'
|
plugin: 'system_menu_block:opencase-admin'
|
||||||
settings:
|
settings:
|
||||||
@ -21,11 +20,4 @@ settings:
|
|||||||
label_display: visible
|
label_display: visible
|
||||||
level: 1
|
level: 1
|
||||||
depth: 0
|
depth: 0
|
||||||
visibility:
|
visibility: { }
|
||||||
user_role:
|
|
||||||
id: user_role
|
|
||||||
roles:
|
|
||||||
administrator: administrator
|
|
||||||
negate: false
|
|
||||||
context_mapping:
|
|
||||||
user: '@user.current_user_context:current_user'
|
|
||||||
|
@ -16,9 +16,9 @@ provider: null
|
|||||||
plugin: 'system_menu_block:opencase-add-actors'
|
plugin: 'system_menu_block:opencase-add-actors'
|
||||||
settings:
|
settings:
|
||||||
id: 'system_menu_block:opencase-add-actors'
|
id: 'system_menu_block:opencase-add-actors'
|
||||||
label: 'OpenCase Add Actors'
|
label: 'Add Records'
|
||||||
provider: system
|
provider: system
|
||||||
label_display: '0'
|
label_display: visible
|
||||||
level: 1
|
level: 1
|
||||||
depth: 0
|
depth: 0
|
||||||
visibility:
|
visibility:
|
||||||
|
@ -11,7 +11,7 @@ dependencies:
|
|||||||
id: opencaseglobal
|
id: opencaseglobal
|
||||||
theme: bartik
|
theme: bartik
|
||||||
region: sidebar_first
|
region: sidebar_first
|
||||||
weight: -7
|
weight: -6
|
||||||
provider: null
|
provider: null
|
||||||
plugin: 'system_menu_block:openc'
|
plugin: 'system_menu_block:openc'
|
||||||
settings:
|
settings:
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
langcode: en
|
langcode: en
|
||||||
status: true
|
status: true
|
||||||
dependencies:
|
dependencies:
|
||||||
|
config:
|
||||||
|
- user.role.authenticated
|
||||||
module:
|
module:
|
||||||
- opencase_entities
|
- opencase_entities
|
||||||
|
- user
|
||||||
id: activities
|
id: activities
|
||||||
label: Activities
|
label: Activities
|
||||||
module: views
|
module: views
|
||||||
@ -19,8 +22,10 @@ display:
|
|||||||
position: 0
|
position: 0
|
||||||
display_options:
|
display_options:
|
||||||
access:
|
access:
|
||||||
type: none
|
type: role
|
||||||
options: { }
|
options:
|
||||||
|
role:
|
||||||
|
authenticated: authenticated
|
||||||
cache:
|
cache:
|
||||||
type: tag
|
type: tag
|
||||||
options: { }
|
options: { }
|
||||||
@ -130,6 +135,71 @@ display:
|
|||||||
entity_type: null
|
entity_type: null
|
||||||
entity_field: name
|
entity_field: name
|
||||||
plugin_id: field
|
plugin_id: field
|
||||||
|
type:
|
||||||
|
id: type
|
||||||
|
table: oc_activity_field_data
|
||||||
|
field: type
|
||||||
|
relationship: none
|
||||||
|
group_type: group
|
||||||
|
admin_label: ''
|
||||||
|
label: Type
|
||||||
|
exclude: false
|
||||||
|
alter:
|
||||||
|
alter_text: false
|
||||||
|
text: ''
|
||||||
|
make_link: false
|
||||||
|
path: ''
|
||||||
|
absolute: false
|
||||||
|
external: false
|
||||||
|
replace_spaces: false
|
||||||
|
path_case: none
|
||||||
|
trim_whitespace: false
|
||||||
|
alt: ''
|
||||||
|
rel: ''
|
||||||
|
link_class: ''
|
||||||
|
prefix: ''
|
||||||
|
suffix: ''
|
||||||
|
target: ''
|
||||||
|
nl2br: false
|
||||||
|
max_length: 0
|
||||||
|
word_boundary: true
|
||||||
|
ellipsis: true
|
||||||
|
more_link: false
|
||||||
|
more_link_text: ''
|
||||||
|
more_link_path: ''
|
||||||
|
strip_tags: false
|
||||||
|
trim: false
|
||||||
|
preserve_tags: ''
|
||||||
|
html: false
|
||||||
|
element_type: ''
|
||||||
|
element_class: ''
|
||||||
|
element_label_type: ''
|
||||||
|
element_label_class: ''
|
||||||
|
element_label_colon: true
|
||||||
|
element_wrapper_type: ''
|
||||||
|
element_wrapper_class: ''
|
||||||
|
element_default_classes: true
|
||||||
|
empty: ''
|
||||||
|
hide_empty: false
|
||||||
|
empty_zero: false
|
||||||
|
hide_alter_empty: true
|
||||||
|
click_sort_column: target_id
|
||||||
|
type: entity_reference_label
|
||||||
|
settings:
|
||||||
|
link: false
|
||||||
|
group_column: target_id
|
||||||
|
group_columns: { }
|
||||||
|
group_rows: true
|
||||||
|
delta_limit: 0
|
||||||
|
delta_offset: 0
|
||||||
|
delta_reversed: false
|
||||||
|
delta_first_last: false
|
||||||
|
multi_type: separator
|
||||||
|
separator: ', '
|
||||||
|
field_api_classes: false
|
||||||
|
entity_type: oc_activity
|
||||||
|
entity_field: type
|
||||||
|
plugin_id: field
|
||||||
description:
|
description:
|
||||||
id: description
|
id: description
|
||||||
table: oc_activity_field_data
|
table: oc_activity_field_data
|
||||||
@ -367,6 +437,7 @@ display:
|
|||||||
- 'languages:language_interface'
|
- 'languages:language_interface'
|
||||||
- url
|
- url
|
||||||
- url.query_args
|
- url.query_args
|
||||||
|
- user.roles
|
||||||
tags: { }
|
tags: { }
|
||||||
page_1:
|
page_1:
|
||||||
display_plugin: page
|
display_plugin: page
|
||||||
@ -383,4 +454,5 @@ display:
|
|||||||
- 'languages:language_interface'
|
- 'languages:language_interface'
|
||||||
- url
|
- url
|
||||||
- url.query_args
|
- url.query_args
|
||||||
|
- user.roles
|
||||||
tags: { }
|
tags: { }
|
||||||
|
@ -188,6 +188,71 @@ display:
|
|||||||
entity_type: null
|
entity_type: null
|
||||||
entity_field: name
|
entity_field: name
|
||||||
plugin_id: field
|
plugin_id: field
|
||||||
|
type:
|
||||||
|
id: type
|
||||||
|
table: oc_case_field_data
|
||||||
|
field: type
|
||||||
|
relationship: none
|
||||||
|
group_type: group
|
||||||
|
admin_label: ''
|
||||||
|
label: Type
|
||||||
|
exclude: false
|
||||||
|
alter:
|
||||||
|
alter_text: false
|
||||||
|
text: ''
|
||||||
|
make_link: false
|
||||||
|
path: ''
|
||||||
|
absolute: false
|
||||||
|
external: false
|
||||||
|
replace_spaces: false
|
||||||
|
path_case: none
|
||||||
|
trim_whitespace: false
|
||||||
|
alt: ''
|
||||||
|
rel: ''
|
||||||
|
link_class: ''
|
||||||
|
prefix: ''
|
||||||
|
suffix: ''
|
||||||
|
target: ''
|
||||||
|
nl2br: false
|
||||||
|
max_length: 0
|
||||||
|
word_boundary: true
|
||||||
|
ellipsis: true
|
||||||
|
more_link: false
|
||||||
|
more_link_text: ''
|
||||||
|
more_link_path: ''
|
||||||
|
strip_tags: false
|
||||||
|
trim: false
|
||||||
|
preserve_tags: ''
|
||||||
|
html: false
|
||||||
|
element_type: ''
|
||||||
|
element_class: ''
|
||||||
|
element_label_type: ''
|
||||||
|
element_label_class: ''
|
||||||
|
element_label_colon: true
|
||||||
|
element_wrapper_type: ''
|
||||||
|
element_wrapper_class: ''
|
||||||
|
element_default_classes: true
|
||||||
|
empty: ''
|
||||||
|
hide_empty: false
|
||||||
|
empty_zero: false
|
||||||
|
hide_alter_empty: true
|
||||||
|
click_sort_column: target_id
|
||||||
|
type: entity_reference_label
|
||||||
|
settings:
|
||||||
|
link: false
|
||||||
|
group_column: target_id
|
||||||
|
group_columns: { }
|
||||||
|
group_rows: true
|
||||||
|
delta_limit: 0
|
||||||
|
delta_offset: 0
|
||||||
|
delta_reversed: false
|
||||||
|
delta_first_last: false
|
||||||
|
multi_type: separator
|
||||||
|
separator: ', '
|
||||||
|
field_api_classes: false
|
||||||
|
entity_type: oc_case
|
||||||
|
entity_field: type
|
||||||
|
plugin_id: field
|
||||||
actors_involved_target_id:
|
actors_involved_target_id:
|
||||||
id: actors_involved_target_id
|
id: actors_involved_target_id
|
||||||
table: oc_case__actors_involved
|
table: oc_case__actors_involved
|
||||||
|
@ -1 +0,0 @@
|
|||||||
bundle: opencase_features
|
|
@ -1,4 +0,0 @@
|
|||||||
name: 'Opencase User Roles'
|
|
||||||
type: module
|
|
||||||
core: 8.x
|
|
||||||
package: 'OpenCase Features'
|
|
14
modules/opencase_defaults/composer.json
Normal file
14
modules/opencase_defaults/composer.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "drupal/opencase_defaults",
|
||||||
|
"type": "drupal-module",
|
||||||
|
"description": "OpenCase Default Configuration",
|
||||||
|
"keywords": ["Drupal"],
|
||||||
|
"license": "GPL-2.0+",
|
||||||
|
"homepage": "https://www.drupal.org/project/opencase_defaults",
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://www.drupal.org/project/issues/opencase_defaults",
|
||||||
|
"source": "http://cgit.drupalcode.org/opencase_defaults"
|
||||||
|
},
|
||||||
|
"require": { }
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
langcode: en
|
||||||
|
status: true
|
||||||
|
dependencies: { }
|
||||||
|
id: opencase_admin
|
||||||
|
label: 'CRM Admin'
|
||||||
|
weight: 7
|
||||||
|
is_admin: null
|
||||||
|
permissions:
|
||||||
|
- 'add client entities'
|
||||||
|
- 'add volunteer entities'
|
||||||
|
- 'administer oc_activity fields'
|
||||||
|
- 'administer oc_actor fields'
|
||||||
|
- 'administer oc_case fields'
|
||||||
|
- 'administer opencase entity bundles'
|
||||||
|
- 'administer users'
|
||||||
|
- 'delete activity entities'
|
||||||
|
- 'delete case entities'
|
||||||
|
- 'delete client entities'
|
||||||
|
- 'delete volunteer entities'
|
||||||
|
- 'edit client entities'
|
||||||
|
- 'edit volunteer entities'
|
5
modules/opencase_defaults/opencase_defaults.info.yml
Normal file
5
modules/opencase_defaults/opencase_defaults.info.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
name: 'opencase_defaults'
|
||||||
|
type: module
|
||||||
|
description: 'OpenCase Default Configuration'
|
||||||
|
core: 8.x
|
||||||
|
package: 'OpenCase'
|
35
modules/opencase_defaults/opencase_defaults.module
Normal file
35
modules/opencase_defaults/opencase_defaults.module
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains opencase_defaults.module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_help().
|
||||||
|
*/
|
||||||
|
function opencase_defaults_help($route_name, RouteMatchInterface $route_match) {
|
||||||
|
switch ($route_name) {
|
||||||
|
// Main module help for the opencase_defaults module.
|
||||||
|
case 'help.page.opencase_defaults':
|
||||||
|
$output = '';
|
||||||
|
$output .= '<h3>' . t('About') . '</h3>';
|
||||||
|
$output .= '<p>' . t('OpenCase Default Configuration') . '</p>';
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_theme().
|
||||||
|
*/
|
||||||
|
function opencase_defaults_theme() {
|
||||||
|
return [
|
||||||
|
'opencase_defaults' => [
|
||||||
|
'render element' => 'children',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<!-- Add you custom twig html here -->
|
46
modules/opencase_defaults/tests/src/Functional/LoadTest.php
Normal file
46
modules/opencase_defaults/tests/src/Functional/LoadTest.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\opencase_defaults\Functional;
|
||||||
|
|
||||||
|
use Drupal\Core\Url;
|
||||||
|
use Drupal\Tests\BrowserTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple test to ensure that main page loads with module enabled.
|
||||||
|
*
|
||||||
|
* @group opencase_defaults
|
||||||
|
*/
|
||||||
|
class LoadTest extends BrowserTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modules to enable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $modules = ['opencase_defaults'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A user with permission to administer site configuration.
|
||||||
|
*
|
||||||
|
* @var \Drupal\user\UserInterface
|
||||||
|
*/
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->user = $this->drupalCreateUser(['administer site configuration']);
|
||||||
|
$this->drupalLogin($this->user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the home page loads with a 200 response.
|
||||||
|
*/
|
||||||
|
public function testLoad() {
|
||||||
|
$this->drupalGet(Url::fromRoute('<front>'));
|
||||||
|
$this->assertSession()->statusCodeEquals(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,5 +8,8 @@ opencase_entities.oc_case_type.*:
|
|||||||
label:
|
label:
|
||||||
type: label
|
type: label
|
||||||
label: 'Label'
|
label: 'Label'
|
||||||
|
allowedActivityTypes:
|
||||||
|
type: sequence
|
||||||
|
label: 'Allowed Activity Types'
|
||||||
uuid:
|
uuid:
|
||||||
type: string
|
type: string
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
administer opencase entity bundles:
|
||||||
|
title: 'Administer OpenCase Actor/Case/Activity Types'
|
||||||
|
description: 'Create, configure and delete types of actor (such as "Client" or "Legal Advisor"), types of case (such as "Housing" or "Asylum") and types of activity (such as "Case Note" or "Interview")'
|
||||||
|
|
||||||
administer actor entities:
|
administer actor entities:
|
||||||
title: 'Administer Actor entities'
|
title: 'Administer Actor entities'
|
||||||
description: 'Allow to access the administration form to configure Actor entities.'
|
description: 'Allow to access the administration form to configure Actor entities.'
|
||||||
|
@ -78,7 +78,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
|||||||
* When creating an activity, it sets the case id from the URL.
|
* When creating an activity, it sets the case id from the URL.
|
||||||
*/
|
*/
|
||||||
public static function defaultVal() {
|
public static function defaultVal() {
|
||||||
return \Drupal::request()->query->get('case_id');;
|
return array(\Drupal::request()->query->get('case_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* id = "oc_activity_type",
|
* id = "oc_activity_type",
|
||||||
* label = @Translation("Activity type"),
|
* label = @Translation("Activity type"),
|
||||||
* handlers = {
|
* handlers = {
|
||||||
|
* "access" = "Drupal\opencase_entities\OCActivityTypeAccessControlHandler",
|
||||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||||
* "list_builder" = "Drupal\opencase_entities\OCActivityTypeListBuilder",
|
* "list_builder" = "Drupal\opencase_entities\OCActivityTypeListBuilder",
|
||||||
* "form" = {
|
* "form" = {
|
||||||
@ -23,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* },
|
* },
|
||||||
* },
|
* },
|
||||||
* config_prefix = "oc_activity_type",
|
* config_prefix = "oc_activity_type",
|
||||||
* admin_permission = "administer site configuration",
|
* admin_permission = "administer opencase entity bundles",
|
||||||
* bundle_of = "oc_activity",
|
* bundle_of = "oc_activity",
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
* "id" = "id",
|
* "id" = "id",
|
||||||
|
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* id = "oc_actor_type",
|
* id = "oc_actor_type",
|
||||||
* label = @Translation("Actor type"),
|
* label = @Translation("Actor type"),
|
||||||
* handlers = {
|
* handlers = {
|
||||||
|
* "access" = "Drupal\opencase_entities\OCActorTypeAccessControlHandler",
|
||||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||||
* "list_builder" = "Drupal\opencase_entities\OCActorTypeListBuilder",
|
* "list_builder" = "Drupal\opencase_entities\OCActorTypeListBuilder",
|
||||||
* "form" = {
|
* "form" = {
|
||||||
@ -23,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* },
|
* },
|
||||||
* },
|
* },
|
||||||
* config_prefix = "oc_actor_type",
|
* config_prefix = "oc_actor_type",
|
||||||
* admin_permission = "administer site configuration",
|
* admin_permission = "administer opencase entity bundles",
|
||||||
* bundle_of = "oc_actor",
|
* bundle_of = "oc_actor",
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
* "id" = "id",
|
* "id" = "id",
|
||||||
|
@ -79,7 +79,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
* id from the URL.
|
* id from the URL.
|
||||||
*/
|
*/
|
||||||
public static function defaultVal() {
|
public static function defaultVal() {
|
||||||
return \Drupal::request()->query->get('actor_id');
|
return array(\Drupal::request()->query->get('actor_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -281,6 +281,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
|
|||||||
->setSetting('handler', 'default:file')
|
->setSetting('handler', 'default:file')
|
||||||
->setSetting('file_extensions', 'txt jpg jpeg gif rtf xls xlsx doc swf png pdf docx csv')
|
->setSetting('file_extensions', 'txt jpg jpeg gif rtf xls xlsx doc swf png pdf docx csv')
|
||||||
->setSetting('description_field', 'true')
|
->setSetting('description_field', 'true')
|
||||||
|
->setSetting('uri_scheme', 'private')
|
||||||
->setCardinality(-1)
|
->setCardinality(-1)
|
||||||
->setDisplayOptions('form', [
|
->setDisplayOptions('form', [
|
||||||
'type' => 'file_generic',
|
'type' => 'file_generic',
|
||||||
|
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* id = "oc_case_type",
|
* id = "oc_case_type",
|
||||||
* label = @Translation("Case type"),
|
* label = @Translation("Case type"),
|
||||||
* handlers = {
|
* handlers = {
|
||||||
|
* "access" = "Drupal\opencase_entities\OCCaseTypeAccessControlHandler",
|
||||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||||
* "list_builder" = "Drupal\opencase_entities\OCCaseTypeListBuilder",
|
* "list_builder" = "Drupal\opencase_entities\OCCaseTypeListBuilder",
|
||||||
* "form" = {
|
* "form" = {
|
||||||
@ -23,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
|||||||
* },
|
* },
|
||||||
* },
|
* },
|
||||||
* config_prefix = "oc_case_type",
|
* config_prefix = "oc_case_type",
|
||||||
* admin_permission = "administer site configuration",
|
* admin_permission = "administer opencase entity bundles",
|
||||||
* bundle_of = "oc_case",
|
* bundle_of = "oc_case",
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
* "id" = "id",
|
* "id" = "id",
|
||||||
@ -55,4 +56,10 @@ class OCCaseType extends ConfigEntityBundleBase implements OCCaseTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $label;
|
protected $label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity types that can be attached to this type of case.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $allowedActivityTypes;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase_entities;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||||
|
use Drupal\Core\Session\AccountInterface;
|
||||||
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
|
use Drupal\Core\Access\AccessResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the access control handler for the OCActivityType Config Entity.
|
||||||
|
* Always allows viewing the label of the bundle.
|
||||||
|
*
|
||||||
|
* @see Drupal\opencase_entities\Entity\OCActivityType
|
||||||
|
*/
|
||||||
|
class OCActivityTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||||
|
|
||||||
|
protected $viewLabelOperation = TRUE;
|
||||||
|
|
||||||
|
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||||
|
if ($operation == 'view label') {
|
||||||
|
return AccessResult::allowed();
|
||||||
|
}
|
||||||
|
return parent::checkAccess();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase_entities;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||||
|
use Drupal\Core\Session\AccountInterface;
|
||||||
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
|
use Drupal\Core\Access\AccessResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the access control handler for the OCActorType Config Entity.
|
||||||
|
* Always allows viewing the label of the bundle.
|
||||||
|
*
|
||||||
|
* @see Drupal\opencase_entities\Entity\OCActorType
|
||||||
|
*/
|
||||||
|
class OCActorTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||||
|
|
||||||
|
protected $viewLabelOperation = TRUE;
|
||||||
|
|
||||||
|
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||||
|
if ($operation == 'view label') {
|
||||||
|
return AccessResult::allowed();
|
||||||
|
}
|
||||||
|
return parent::checkAccess();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase_entities;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||||
|
use Drupal\Core\Session\AccountInterface;
|
||||||
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
|
use Drupal\Core\Access\AccessResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the access control handler for the OCCaseType Config Entity.
|
||||||
|
* Always allows viewing the label of the bundle.
|
||||||
|
*
|
||||||
|
* @see Drupal\opencase_entities\Entity\OCCaseType
|
||||||
|
*/
|
||||||
|
class OCCaseTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||||
|
|
||||||
|
protected $viewLabelOperation = TRUE;
|
||||||
|
|
||||||
|
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||||
|
if ($operation == 'view label') {
|
||||||
|
return AccessResult::allowed();
|
||||||
|
}
|
||||||
|
return parent::checkAccess();
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use Drupal\opencase\EntityTypeRelationsWidget;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,3 +112,21 @@ function opencase_theme() {
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_form_ID_alter
|
||||||
|
*/
|
||||||
|
function opencase_form_oc_case_type_add_form_alter(&$form, $form_state) {
|
||||||
|
$widget = new EntityTypeRelationsWidget();
|
||||||
|
$widget->setup($form);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_form_ID_alter
|
||||||
|
*/
|
||||||
|
function opencase_form_oc_case_type_edit_form_alter(&$form, $form_state) {
|
||||||
|
$widget = new EntityTypeRelationsWidget();
|
||||||
|
$widget->setup($form);
|
||||||
|
$widget->populate($form);
|
||||||
|
}
|
||||||
|
13
opencase.schema.yml
Normal file
13
opencase.schema.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Config for storing which types of actors can be
|
||||||
|
# involved in which kinds of cases.
|
||||||
|
# The * is a case_type
|
||||||
|
opencase.case_type.actor_types.*:
|
||||||
|
type: config_entity
|
||||||
|
label: Actor types per case type
|
||||||
|
mapping:
|
||||||
|
actor_types:
|
||||||
|
label: Actor types
|
||||||
|
type: sequence
|
||||||
|
sequence: { }
|
||||||
|
|
||||||
|
|
27
src/EntityTypeRelations.php
Normal file
27
src/EntityTypeRelations.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stuff to do with the relationship of case types to actor types, and activity types to case types
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class EntityTypeRelations {
|
||||||
|
|
||||||
|
|
||||||
|
public static function getAllowedActorTypesForCaseType($case_type) {
|
||||||
|
$base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type.actors_involved");
|
||||||
|
$allowedActorTypes = array();
|
||||||
|
if ($base_field_override) {
|
||||||
|
$allowedActorTypes = $base_field_override->getSettings()['handler_settings']['target_bundles'];
|
||||||
|
}
|
||||||
|
return $allowedActorTypes; // // format: ['volunteer' => 0, 'client' => 'client']
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllowedActivityTypesForCaseType($case_type) {
|
||||||
|
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type);
|
||||||
|
$allowedActivityTypes = $caseTypeConfig->get('allowedActivityTypes'); // format: ['application' => 'application', 'interview' => 0]
|
||||||
|
if (!$allowedActivityTypes) $allowedActivityTypes = array();
|
||||||
|
return $allowedActivityTypes;
|
||||||
|
}
|
||||||
|
}
|
76
src/EntityTypeRelationsWidget.php
Normal file
76
src/EntityTypeRelationsWidget.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\opencase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages GUI for configuring relations between case types and actor types, or activity types and case types
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class EntityTypeRelationsWidget {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds actor type and activity type checkboxes to the case type form, and adds the submit handler
|
||||||
|
*
|
||||||
|
* $form - the form to be modified (reference)
|
||||||
|
*/
|
||||||
|
public function setup(&$form) {
|
||||||
|
$actor_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_actor');
|
||||||
|
$options = array();
|
||||||
|
foreach($actor_types as $machine_name => $info) {
|
||||||
|
$options[$machine_name] = $info['label'];
|
||||||
|
}
|
||||||
|
$form['allowed_actor_types'] = array(
|
||||||
|
'#title' => t('Actor types'),
|
||||||
|
'#description' => t('Types of people that can be involved in this kind of case.'),
|
||||||
|
'#type' => 'checkboxes',
|
||||||
|
'#options' => $options
|
||||||
|
);
|
||||||
|
$activity_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||||
|
$options = array();
|
||||||
|
foreach($activity_types as $machine_name => $info) {
|
||||||
|
$options[$machine_name] = $info['label'];
|
||||||
|
}
|
||||||
|
$form['allowed_activity_types'] = array(
|
||||||
|
'#title' => t('Activity types'),
|
||||||
|
'#description' => t('Types of activities that can be logged against this case.'),
|
||||||
|
'#type' => 'checkboxes',
|
||||||
|
'#options' => $options
|
||||||
|
);
|
||||||
|
$form['actions']['submit']['#submit'][] = array($this, 'submit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the form with actor/activity types that are already set
|
||||||
|
*
|
||||||
|
* $form - the form to be modified (reference)
|
||||||
|
*/
|
||||||
|
public function populate(&$form) {
|
||||||
|
$case_type = $form['id']['#default_value'];
|
||||||
|
$allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type);
|
||||||
|
$form['allowed_actor_types']['#default_value'] = $allowedActorTypes;
|
||||||
|
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($case_type);
|
||||||
|
$form['allowed_activity_types']['#default_value'] = $allowedActivityTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit callback which takes the data from the actor types and activity types fields and
|
||||||
|
* creates/edits the relevant config objects
|
||||||
|
*
|
||||||
|
* $form - the form that is being submitted
|
||||||
|
* $form_state - the data in the form
|
||||||
|
*/
|
||||||
|
public function submit($form, $form_state) {
|
||||||
|
$case_type_machine_name = $form['id']['#default_value'] ? $form['id']['#default_value'] : $form_state->getValue('id');
|
||||||
|
$base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type_machine_name.actors_involved");
|
||||||
|
if (!$base_field_override) {
|
||||||
|
$entity_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('oc_case');
|
||||||
|
$field_definition = $entity_fields['actors_involved'];
|
||||||
|
$base_field_override = \Drupal\Core\field\Entity\BaseFieldOverride::createFromBaseFieldDefinition($field_definition, $case_type_machine_name);
|
||||||
|
}
|
||||||
|
$base_field_override->setSetting('handler_settings', ['target_bundles' => $form_state->getValue('allowed_actor_types')]);
|
||||||
|
$base_field_override->save();
|
||||||
|
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type_machine_name);
|
||||||
|
$caseTypeConfig->set('allowedActivityTypes', $form_state->getValue('allowed_activity_types'));
|
||||||
|
$caseTypeConfig->save();
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace Drupal\opencase\Plugin\Block;
|
namespace Drupal\opencase\Plugin\Block;
|
||||||
|
|
||||||
|
use Drupal\opencase\EntityTypeRelations;
|
||||||
use Drupal\Core\Block\BlockBase;
|
use Drupal\Core\Block\BlockBase;
|
||||||
use Drupal\Core\Link;
|
use Drupal\Core\Link;
|
||||||
use Drupal\Core\Url;
|
use Drupal\Core\Url;
|
||||||
use Drupal\opencase\Utils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a 'ContextualMenu' block.
|
* Provides a 'ContextualMenu' block.
|
||||||
@ -82,10 +82,13 @@ class ContextualMenu extends BlockBase {
|
|||||||
private function caseListPage() {
|
private function caseListPage() {
|
||||||
$actor_id = \Drupal::routeMatch()->getParameter('actor_id');
|
$actor_id = \Drupal::routeMatch()->getParameter('actor_id');
|
||||||
\Drupal::service('user.private_tempstore')->get('opencase')->set('actor_id', $actor_id);
|
\Drupal::service('user.private_tempstore')->get('opencase')->set('actor_id', $actor_id);
|
||||||
$link = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id)->toLink()->toString();
|
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
|
||||||
|
$link = $actor->toLink()->toString();
|
||||||
$markup = $this->asNavLinks([$link]);
|
$markup = $this->asNavLinks([$link]);
|
||||||
$current_path = \Drupal::service('path.current')->getPath();
|
$current_path = \Drupal::service('path.current')->getPath();
|
||||||
$markup .= Utils::generateAddLinks('oc_case', "Add new case", ['actor_id' => $actor_id, 'destination' => $current_path]);
|
$title = "Add new case";
|
||||||
|
$query = ['actor_id' => $actor_id, 'destination' => $current_path];
|
||||||
|
$markup .= $this->generateLinksForAddingNewCases($actor, $title, $query);
|
||||||
return $markup;
|
return $markup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +128,7 @@ class ContextualMenu extends BlockBase {
|
|||||||
$link = Link::fromTextAndUrl(t($case->getName() .": Case Details and Files"), $url)->toString();
|
$link = Link::fromTextAndUrl(t($case->getName() .": Case Details and Files"), $url)->toString();
|
||||||
$markup = $this->asNavLinks([$link]);
|
$markup = $this->asNavLinks([$link]);
|
||||||
$current_path = \Drupal::service('path.current')->getPath();
|
$current_path = \Drupal::service('path.current')->getPath();
|
||||||
return $markup . Utils::generateAddLinks('oc_activity', "Add activity", ['case_id' => $case_id, 'destination' => $current_path]);
|
return $markup . $this->generateLinksForAddingNewActivities($case, "Add activity", ['case_id' => $case_id, 'destination' => $current_path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,4 +183,51 @@ class ContextualMenu extends BlockBase {
|
|||||||
return "<div class='opencase_nav_links'><h1>$title</h1>$markup</div>";
|
return "<div class='opencase_nav_links'><h1>$title</h1>$markup</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns html markup.
|
||||||
|
*/
|
||||||
|
private function generateLinksForAddingNewCases($actor, $title, $query = []) {
|
||||||
|
$actor_type = $actor->bundle();
|
||||||
|
$allCaseTypes = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_case');
|
||||||
|
// $allCaseTypes is array where the key is the machine name and the value is array containing label
|
||||||
|
// Now we pick just the allowed ones and produced an array of labels keyed by machine name
|
||||||
|
$allowedCaseTypes = array();
|
||||||
|
foreach(array_keys($allCaseTypes) as $caseType) {
|
||||||
|
if (in_array($actor_type, EntityTypeRelations::getAllowedActorTypesForCaseType($caseType))) {
|
||||||
|
$allowedCaseTypes[$caseType] = $allCaseTypes[$caseType]['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$title = t($title);
|
||||||
|
$markup = "<h1>$title: </h1>";
|
||||||
|
foreach($allowedCaseTypes as $machine_name => $label) {
|
||||||
|
$url = \Drupal\Core\Url::fromRoute("entity.oc_case.add_form", ['oc_case_type' => $machine_name]);
|
||||||
|
$url->setOption('query', $query);
|
||||||
|
$link = \Drupal\Core\Link::fromTextAndUrl($label, $url)->toString();
|
||||||
|
$markup .= "<p>$link</p>";
|
||||||
|
}
|
||||||
|
return "<div class='opencase_add_links'>$markup</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns html markup.
|
||||||
|
*/
|
||||||
|
private function generateLinksForAddingNewActivities($case, $title, $query = []) {
|
||||||
|
$title = t($title);
|
||||||
|
$markup = "<h1>$title: </h1>";
|
||||||
|
$caseType = $case->bundle();
|
||||||
|
$allActivityTypes = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||||
|
// $allActivityTypes is array where the key is the machine name and the value is array containing label
|
||||||
|
// Now we pick just the allowed ones and produced an array of labels keyed by machine name
|
||||||
|
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($caseType);
|
||||||
|
foreach($allowedActivityTypes as $machine_name => $is_allowed) {
|
||||||
|
if ($is_allowed) {
|
||||||
|
$label = $allActivityTypes[$machine_name]['label'];
|
||||||
|
$url = \Drupal\Core\Url::fromRoute("entity.oc_activity.add_form", ['oc_activity_type' => $machine_name]);
|
||||||
|
$url->setOption('query', $query);
|
||||||
|
$link = \Drupal\Core\Link::fromTextAndUrl($label, $url)->toString();
|
||||||
|
$markup .= "<p>$link</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "<div class='opencase_add_links'>$markup</div>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\opencase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shared functions for the opencase module
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class Utils {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a set of links for adding different types of a base entity
|
|
||||||
*
|
|
||||||
* $baseEntityType the type of entity to generate the links for (it will generate one for each bundle of the base type)
|
|
||||||
* $title the title to be placed above the set of links)
|
|
||||||
* $query optionally append a query string to the links (key => value format
|
|
||||||
*
|
|
||||||
* returns html markup.
|
|
||||||
*/
|
|
||||||
public static function generateAddLinks($baseEntityType, $title, $query = []) {
|
|
||||||
|
|
||||||
$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($baseEntityType);
|
|
||||||
$title = t($title);
|
|
||||||
$markup = "<h1>$title: </h1>";
|
|
||||||
foreach($bundles as $bundle_id => $bundle) {
|
|
||||||
$label = t($bundle['label']);
|
|
||||||
$url = \Drupal\Core\Url::fromRoute("entity.$baseEntityType.add_form", [$baseEntityType . '_type' => $bundle_id]);
|
|
||||||
$url->setOption('query', $query);
|
|
||||||
$link = \Drupal\Core\Link::fromTextAndUrl($label, $url)->toString();
|
|
||||||
$markup .= "<p>$link</p>";
|
|
||||||
}
|
|
||||||
return "<div class='opencase_add_links'>$markup</div>";
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user