Compare commits

..

108 Commits
1.9.9 ... alex

Author SHA1 Message Date
86c0fb1f65 case fee total updates when a fee is updated 2022-04-21 12:20:22 +01:00
92bce34fb1 total fee updates when a case fee is deleted 2022-04-21 12:15:00 +01:00
02715bdc44 Total fee now updates when a new fee is added 2022-04-21 12:11:56 +01:00
4ab621100f Merge branch 'master' into alex 2022-04-21 09:03:11 +01:00
aa0c350766 Added links to admin menu for managing taxonomies 2022-04-21 08:51:42 +01:00
17406061f9 commented out the yml line untill it works 2022-04-17 12:04:48 +02:00
489f4c0c94 made fields configurable for case and sub cases 2022-04-17 11:52:26 +02:00
2f06caa261 made EqualOpps fields configurable 2022-04-15 16:48:34 +02:00
aa6d580d62 made event fields configurable 2022-04-15 16:44:59 +02:00
8c3f2bcbc3 made org fields configurable 2022-04-15 16:41:59 +02:00
55f34cb4d7 Added the seeAllEvents but it is not workgin do to a bug I can't seem to fin 2022-04-15 16:29:26 +02:00
20ed3d4f39 added see al org's page and menu item, made fields configurable for actor 2022-04-08 14:00:44 +02:00
b85cbaf398 Added actor type links to see-all menu 2022-04-08 12:02:53 +01:00
34b7a1c7c9 fixed redirect after deleting activity - defaults to target if there's no case 2022-04-03 19:27:43 +01:00
fb2249d9bd fixed event attendees widget 2022-04-03 19:12:03 +01:00
614293c114 Added case provider role to opencase config 2022-04-03 17:52:12 +01:00
167166b898 Added target field to case, and added fee category vocab to opencase config 2022-04-03 17:31:00 +01:00
c3f802835f Made everything have revisions all the time 2022-04-03 17:01:19 +01:00
13ddf5aa13 fixed deprecated functions 2022-04-03 14:51:38 +01:00
225e92a51c Added target field to activity 2022-04-03 14:37:40 +01:00
60c64afcab removed config from opencase_defaults 2022-04-03 14:19:05 +01:00
49ab81ca23 fixed deprecated functions that were breaking revisions. 2022-04-03 13:39:01 +01:00
65fe65474e replaced deprecated function 2022-03-17 10:41:39 +00:00
57fae7c1c3 Removed full name field, thus fixing name-not-changing bug 2022-03-17 10:52:40 +01:00
cc551b0851 Added Provider field to cases, auto-completed from actor linked to logged-in user. DB update required 2022-01-21 15:00:26 +00:00
40435a16be Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2022-01-20 15:59:39 +00:00
f783fa2373 removed commented-out code 2022-01-20 15:59:23 +00:00
8b725e5a9a removed commented-out code 2022-01-20 15:42:37 +00:00
7c3b007ff9 Authenticated user can see cases they are a provider for. 2022-01-20 14:48:53 +00:00
f39f4a331d changed activity access controller to allow users to view and edit ones they own 2022-01-20 10:52:28 +00:00
6069ac0901 changed CaseInvolvement to reference case provisions 2022-01-20 10:52:04 +00:00
240a55f54f Activities get deleted when case deleted. 2021-12-30 13:43:19 +00:00
b194367eef changed label of published checkbox to "Visible" 2021-12-10 09:45:22 +00:00
f293676fa5 Added css for paragraphs 2021-12-10 09:35:42 +00:00
ba4e6668aa css and removing the "left" and "right" classes from templates 2021-12-05 19:16:39 +00:00
3b62ebd0ee removed default reporting module as it is broken. 2021-12-05 18:36:39 +00:00
198a3f0558 corrected url for contact details history link 2021-12-05 17:36:11 +00:00
833c21346d changed label of activity_date_time to "Date" 2021-12-05 16:27:07 +00:00
4b84c99541 fixed return type of client_id callback when creating a case 2021-12-04 16:58:18 +00:00
0de22b7e90 removed uuids from configs, and removed some depcreated code from update hook 2021-12-04 14:42:40 +00:00
dad1ffc746 removed name field from client form 2021-12-04 11:29:57 +00:00
f6c7519a11 added case fee and case provision permissions to opencase admin role 2021-12-04 11:24:44 +00:00
27e7e3ae2a removed stuff to do with allowed activity types. 2021-12-04 11:19:57 +00:00
5eef57f470 opencase_defaults config is in good order. 2021-12-04 11:14:53 +00:00
d0fea802ee changed namespace of case stuff from opencase_entities to opencase_cases 2021-12-04 10:11:02 +00:00
260979edcc Fixed bugs to do with entity type relations widget 2021-12-04 09:08:11 +00:00
dbc38e8f61 Added config_export stanzas to entity types 2021-12-04 07:26:17 +00:00
c95f8280bc removed contextual menu block 2021-12-04 06:54:45 +00:00
24a8e8864f Commented out actor types per case in entity relations widget 2021-12-04 06:47:38 +00:00
90c4462512 removed basefieldoverride configs for actors_involved as field no longer exists 2021-12-04 06:45:51 +00:00
52f77cb342 Added config directory to opencase_defaults 2021-12-04 06:43:37 +00:00
5f790c73c7 Removed obsolete code from opencase_defaults 2021-12-04 06:30:43 +00:00
f617fc207e versioning 2021-12-03 16:45:27 +00:00
0c9707419e final css tweaks 2021-11-29 20:24:37 +01:00
042e5853bb Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase into trav 2021-11-29 20:13:19 +01:00
720b6f005d removed duplicate permissions_callback key 2021-11-29 18:18:15 +00:00
cc2f03ddb3 versioning 2021-11-27 17:27:19 +00:00
2411813bd6 Added revision metadata keys for Drupal 9 2021-11-27 16:19:06 +00:00
d4e8991804 replaced deprecated functions 2021-11-27 15:19:16 +00:00
658e60f296 Merge branch 'master' into trav 2021-11-27 15:56:22 +01:00
2ecef5c1dd Merge branch 'trav' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase into trav 2021-11-27 15:56:09 +01:00
92e81ee518 css 2021-11-27 15:45:42 +01:00
d7197d7ed6 Follow-ups due 2021-11-27 15:45:42 +01:00
3458949bb0 extended name field on cases 2021-11-27 11:25:41 +00:00
9e18b3ea28 Added reporting menu 2021-11-17 07:55:22 +00:00
623e801c58 Made case provider field use view to filter out inactive and unpubllished 2021-11-16 08:06:06 +00:00
f9d4820ac2 made activity date and time field configurable 2021-11-16 07:05:07 +00:00
88cd511d9f Made amount field required on case fee 2021-11-15 18:08:49 +00:00
9ee00ed738 changed paths from /admin/opencase to /opencase for new entities, in line with existing ones 2021-11-15 13:51:03 +00:00
ff94eb8285 Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2021-11-12 10:06:32 +00:00
cf7892ed15 Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2021-11-12 10:06:11 +00:00
72e7cb99c3 Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2021-11-12 09:12:36 +00:00
04d6525d6c version 8.0-3.0 - update required
Added amount field to case fee, total fee to case, and code to calculate the total
2021-11-12 09:12:01 +00:00
d9453c1323 Added amount field to case fee, total fee to case, and code to calculate the total 2021-11-12 09:11:00 +00:00
3eba291d5a made field display configurable 2021-11-12 06:36:52 +00:00
de691b5a52 Added notes field to cases 2021-11-11 15:27:25 +00:00
8cde0b8892 made published field configurable on case fee 2021-11-11 14:35:45 +00:00
cffe817ce9 Added Case Fee entity 2021-11-11 14:07:13 +00:00
3753b4e25c removed working-out code 2021-11-11 08:42:15 +00:00
f601890ad0 Added Case Provision entity for recording caseworker involvement with cases 2021-11-11 08:39:18 +00:00
6dca2e98e9 Fixed duplicate key in permissions.yml which Drupal 9 disallows 2021-11-06 12:25:06 +00:00
c19b7d4be8 upgraded to drupal 9 2021-10-23 18:18:41 +01:00
b6afcfe47a OC Admin menu is now shown if you have permission to administer either bundles or users 2021-10-15 15:31:24 +01:00
4b8872b586 Increased character limit of email address fields 2021-10-06 10:39:37 +01:00
8d2d095b8e When a user who can't see unpublished entities unpublishes one, it redirects to the home page and displays a message. 2021-09-17 15:36:48 +01:00
0c977a7d48 Merge branch 'master' into trav 2021-09-17 15:37:11 +02:00
a4c02ed249 colour of accrediation count figures 2021-09-17 14:32:01 +01:00
a0e4b4028f Merge branch 'master' into trav 2021-09-17 15:27:04 +02:00
5c20e83ed5 Follow-ups due 2021-09-17 15:22:56 +02:00
78b8371be9 CSS for Accreditation Count form, and some other changes 2021-09-17 14:21:56 +01:00
48e6ae4196 Changed description of Published field 2021-09-13 14:34:29 +01:00
ac4e6eddd5 Made published field configurable on forms, and made views respect permissions 2021-09-13 14:15:53 +01:00
b1a8534d29 Removed debugging code and changed default name of organisation relation 2021-09-03 11:11:02 +02:00
42bf2c8e77 Removed ActorCaseRelation stuff- can't get it to work, will try again if it's asked for 2021-08-27 08:38:04 +01:00
7e4acae864 Revert "Added actor-case relation"
This reverts commit c7d36df842.
2021-08-27 08:37:16 +01:00
80f86c62fd Merge branch 'demo' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase into demo 2021-08-26 21:42:27 +01:00
794bc0da68 Pulling case_id through when creating an activity and client_id when creating a case. (Only for demo really; bit of tech debt) 2021-08-26 21:41:36 +01:00
892a7ae35b Commented out case access stuff; need to re-add that using relation entities 2021-08-26 19:10:05 +01:00
3586ef5788 Fixed theme function issue after creating entity, and remove "(Client)" etc from name finally! 2021-08-26 18:58:25 +01:00
436607a305 Added some class dependencies which were missing 2021-08-26 17:56:44 +01:00
c7d36df842 Added actor-case relation 2021-08-26 17:55:07 +01:00
8cb50d271b removed config from opencase_defaults 2021-08-26 16:41:12 +01:00
3dcd37bb8c removed circular module dependency 2021-08-07 14:55:52 +00:00
8816441f94 Added custom field formatter to exclude current organisation from entity reference list 2021-07-20 17:09:06 +02:00
73d9d6490a Added redirects to client screen after adding or deleting a linked client 2021-07-20 14:48:50 +02:00
d151b1744e Added Organisation Relation entity with update hook to install it, bumped version 2021-07-16 17:32:40 +02:00
26d78a4f7f Made person's address fields form- and view-configurable, and bumped version 2021-06-29 09:21:04 +02:00
41505594be Added website field to org, and bumped version (to 2.0.0 because ran out of numbers) 2021-06-15 20:13:42 +02:00
333 changed files with 6372 additions and 10891 deletions

View File

@ -0,0 +1,8 @@
uuid: 85aacc47-8df9-4309-b7f4-f58be70f83d0
langcode: en
status: true
dependencies: { }
name: 'Case Provider Roles'
vid: oc_case_provider_role
description: ''
weight: 0

View File

@ -0,0 +1,8 @@
uuid: 93a96bb4-da95-4d69-be37-d1477624f849
langcode: en
status: true
dependencies: { }
name: 'Fee categories'
vid: oc_fee_category
description: ''
weight: 0

View File

@ -3,22 +3,62 @@
display: none; display: none;
} }
/* paragraphs */
.paragraph .field {
width: auto;
}
.field.field--type-entity-reference-revisions {
border: none;
padding: 0.4em;
}
.field.field--type-entity-reference-revisions .field__item {
padding: 0;
}
/* end paragraphs */
/* MOVE THIS INTO GNO! */
#block-accreditationcount {
position: absolute;
right: 50%;
/*background-color: #fff;*/
background-image: linear-gradient(to top, #2a419a 0%, #1d84c3 100%);
border-radius: 5px;
}
#block-accreditationcount table {
border: 0px #2a419a;
background-color: #1d84c3;
}
#block-accreditationcount h1 {
color: white;
}
#block-accreditationcount td {
color: black;
}
/* */ /* */
body { body {
font-size: 100% !important; font-size: 100% !important;
} }
.field--type-entity-reference-revisions .field__items { .field.field--type-entity-reference {
margin-left: 2em; margin: inherit;
} }
.field--type-entity-reference-revisions .field__items .field{ .field {
margin-top: 0; width: 30%;
} display: inline-block;
.field--type-entity-reference-revisions .field__items .paragraph{ padding: 0.4em;
margin-top: 0.5em;
margin-bottom: 0.5em;
} }
/* remove this confusing thing from user creation page */ /* remove this confusing thing from user creation page */
@ -107,17 +147,66 @@ td.views-field {
font-weight: bold !important; font-weight: bold !important;
} }
/* Styling for grouped views */
table.views-table.views-view-table caption {
text-align: left;
margin-bottom: 1em;
margin-top: 2em;
font-weight: bold;
}
/* remove "details" accordion, see https://drupal.stackexchange.com/questions/294312/why-has-this-details-accordion-appeared-in-this-view */ /* remove "details" accordion, see https://drupal.stackexchange.com/questions/294312/why-has-this-details-accordion-appeared-in-this-view */
.views-table details { .views-table details {
display: none; display: none;
} }
form.oc-organisation-relation-form tr:first-child {
display: none;
}
/* trav styling */
.site-branding {
margin-top: -2.20em !important;
}
.follow-ups-due td {
background-color: #FB8A4F;
}
#block-accreditationcount th,
#block-accreditationcount td {
border: none;
}
#block-accreditationcount {
padding: 1em;
}
tr:nth-child(even) {
background-color: #fefefe;
}
tr:nth-child(odd) {
background-color: #eee;
}
.Off {
color:gray;
}
.Off a {
color:gray;
}
.field--type-entity-reference-revisions {
border-radius: 25px;
border: 2px solid #2A419A;
padding: 10px;
border-width: thin;
}
.follow-ups-due table{
background-color: #FB8A4F;
}
.views-field-field-client-substatus {
font-weight: bold;
}
thead {
background-color: #1d84c3;
}

View File

@ -0,0 +1,12 @@
opencase_cases.oc_case_fee_type.*:
type: config_entity
label: 'Case Fee type config'
mapping:
id:
type: string
label: 'ID'
label:
type: label
label: 'Label'
uuid:
type: string

View File

@ -0,0 +1,12 @@
opencase_cases.oc_case_provision_type.*:
type: config_entity
label: 'Case Provision type config'
mapping:
id:
type: string
label: 'ID'
label:
type: label
label: 'Label'
uuid:
type: string

View File

@ -0,0 +1,30 @@
<?php
/**
* @file
* Contains oc_case_fee.page.inc.
*
* Page callback for Case Fee entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Case Fee templates.
*
* Default template: oc_case_fee.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_oc_case_fee(array &$variables) {
// Fetch OCCaseFee Entity Object.
$oc_case_fee = $variables['elements']['#oc_case_fee'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}

View File

@ -0,0 +1,30 @@
<?php
/**
* @file
* Contains oc_case_provision.page.inc.
*
* Page callback for Case Provision entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Case Provision templates.
*
* Default template: oc_case_provision.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_oc_case_provision(array &$variables) {
// Fetch OCCaseProvision Entity Object.
$oc_case_provision = $variables['elements']['#oc_case_provision'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}

View File

@ -1,7 +1,11 @@
name: 'Opencase Cases' name: 'Opencase Cases'
type: module type: module
description: 'Provides case entities and a required field on activities linking them to a case.' description: 'Provides case entities and a required field on activities linking them to a case.'
core: 8.x core_version_requirement: 9.x
package: 'OpenCase' package: OpenCase
dependencies: dependencies:
- opencase_entities 0: opencase_entities
1: datetime
4: options
5: paragraphs
6: user

View File

@ -0,0 +1,102 @@
<?php
use \Drupal\Core\Field\BaseFieldDefinition;
function opencase_cases_update_90002() {
$field_storage_definition = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Target'))
->setRevisionable(TRUE)
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('oc_target', 'oc_case', 'opencase_cases', $field_storage_definition);
}
function opencase_cases_update_8025() {
//check if the table exists first. If not, then create the entity.
if(!db_table_exists('oc_case_provision')) {
\Drupal::entityTypeManager()->clearCachedDefinitions();
\Drupal::entityDefinitionUpdateManager()
->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_case_provision'));
}
}
function opencase_cases_update_8026() {
$storage_definition = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Role'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(FALSE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('oc_case_provider_role', 'oc_case_provision', 'oc_case_provision', $storage_definition);
}
function opencase_cases_update_8027() {
//check if the table exists first. If not, then create the entity.
if(!db_table_exists('oc_case_fee')) {
\Drupal::entityTypeManager()->clearCachedDefinitions();
\Drupal::entityDefinitionUpdateManager()
->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_case_fee'));
}
}
function opencase_cases_update_8028() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('decimal')
->setLabel(t('Amount'))
->setRevisionable(TRUE)
->setSettings([
'prefix' => '£',
])
->SetDisplayConfigurable("form", true)
->SetDisplayConfigurable("view", true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('amount', 'oc_case_fee', 'oc_case_fee', $storage_definition);
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Fee Category'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['oc_fee_category' => 'oc_fee_category']])
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(FALSE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('oc_fee_category', 'oc_case_fee', 'oc_case_fee', $storage_definition);
}
function opencase_cases_update_8029() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('string_long')
->setRevisionable(TRUE)
->setLabel(t('Notes'))
->setSettings(array(
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('notes', 'oc_case', 'oc_case', $storage_definition);
}
function opencase_cases_update_8030() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('decimal')
->setLabel(t('Total Fee'))
->setRevisionable(TRUE)
->setSettings([
'prefix' => '£',
])
->SetDisplayConfigurable("view", true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('total_fee', 'oc_case', 'oc_case', $storage_definition);
}

View File

@ -10,3 +10,23 @@ entity.oc_case_type.add_form:
appears_on: appears_on:
- entity.oc_case_type.collection - entity.oc_case_type.collection
entity.oc_case_provision.add_form:
route_name: entity.oc_case_provision.add_page
title: 'Add Case Provision'
appears_on:
- entity.oc_case_provision.collection
entity.oc_case_provision_type.add_form:
route_name: entity.oc_case_provision_type.add_form
title: 'Add Case Provision type'
appears_on:
- entity.oc_case_provision_type.collection
entity.oc_case_fee.add_form:
route_name: entity.oc_case_fee.add_page
title: 'Add Case Fee'
appears_on:
- entity.oc_case_fee.collection
entity.oc_case_fee_type.add_form:
route_name: entity.oc_case_fee_type.add_form
title: 'Add Case Fee type'
appears_on:
- entity.oc_case_fee_type.collection

View File

@ -23,3 +23,37 @@ entity.oc_case_type.collection:
weight: 99 weight: 99
# Case Provision menu items definition
entity.oc_case_provision.collection:
title: 'Case Provision list'
route_name: entity.oc_case_provision.collection
description: 'List Case Provision entities'
parent: system.admin_structure
weight: 100
# Case Provision type menu items definition
entity.oc_case_provision_type.collection:
title: 'Case Provision type'
route_name: entity.oc_case_provision_type.collection
description: 'List Case Provision type (bundles)'
parent: system.admin_structure
weight: 99
# Case Fee menu items definition
entity.oc_case_fee.collection:
title: 'Case Fee list'
route_name: entity.oc_case_fee.collection
description: 'List Case Fee entities'
parent: system.admin_structure
weight: 100
# Case Fee type menu items definition
entity.oc_case_fee_type.collection:
title: 'Case Fee type'
route_name: entity.oc_case_fee_type.collection
description: 'List Case Fee type (bundles)'
parent: system.admin_structure
weight: 99

View File

@ -21,3 +21,47 @@ entity.oc_case.delete_form:
base_route: entity.oc_case.canonical base_route: entity.oc_case.canonical
title: Delete title: Delete
weight: 10 weight: 10
# Case Provision routing definition
entity.oc_case_provision.canonical:
route_name: entity.oc_case_provision.canonical
base_route: entity.oc_case_provision.canonical
title: 'View'
entity.oc_case_provision.edit_form:
route_name: entity.oc_case_provision.edit_form
base_route: entity.oc_case_provision.canonical
title: 'Edit'
entity.oc_case_provision.version_history:
route_name: entity.oc_case_provision.version_history
base_route: entity.oc_case_provision.canonical
title: 'Revisions'
entity.oc_case_provision.delete_form:
route_name: entity.oc_case_provision.delete_form
base_route: entity.oc_case_provision.canonical
title: Delete
weight: 10
# Case Fee routing definition
entity.oc_case_fee.canonical:
route_name: entity.oc_case_fee.canonical
base_route: entity.oc_case_fee.canonical
title: 'View'
entity.oc_case_fee.edit_form:
route_name: entity.oc_case_fee.edit_form
base_route: entity.oc_case_fee.canonical
title: 'Edit'
entity.oc_case_fee.version_history:
route_name: entity.oc_case_fee.version_history
base_route: entity.oc_case_fee.canonical
title: 'Revisions'
entity.oc_case_fee.delete_form:
route_name: entity.oc_case_fee.delete_form
base_route: entity.oc_case_fee.canonical
title: Delete
weight: 10

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types = 1);
/** /**
* @file * @file
@ -6,6 +7,9 @@
*/ */
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use PHPUnit\Framework\Constraint\IsEmpty;
use function PHPUnit\Framework\isEmpty;
/** /**
* Implements hook_help(). * Implements hook_help().
@ -16,7 +20,7 @@ function opencase_cases_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.opencase_cases': case 'help.page.opencase_cases':
$output = ''; $output = '';
$output .= '<h3>' . t('About') . '</h3>'; $output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Provides case entities and a required field on activities linking them to a case.') . '</p>'; $output .= '<p>' . t('Provides case entities and a required field on activities linking them to a case, plus case fee and case provision entities.') . '</p>';
return $output; return $output;
default: default:
@ -40,10 +44,73 @@ function opencase_cases_theme() {
'render element' => 'content', 'render element' => 'content',
'variables' => ['content' => NULL], 'variables' => ['content' => NULL],
'file' => 'oc_case.page.inc', 'file' => 'oc_case.page.inc',
] ],
'oc_case_provision' => [
'render element' => 'elements',
'file' => 'oc_case_provision.page.inc',
'template' => 'oc_case_provision',
],
'oc_case_provision_content_add_list' => [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case_provision.page.inc',
],
'oc_case_fee' => [
'render element' => 'elements',
'file' => 'oc_case_fee.page.inc',
'template' => 'oc_case_fee',
],
'oc_case_fee_content_add_list' => [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case_fee.page.inc',
],
]; ];
} }
/**
* @return Drupal\opencase_cases\entity\OCCaseFee[]
*/
function opencase_cases_get_case_fees(Drupal\opencase_cases\entity\OCCase $case): array {
$query = \Drupal::entityQuery('oc_case_fee')
->condition('oc_case.target_id', $case->id());
$case_fee_ids = $query->execute();
$case_fees = [];
foreach($case_fee_ids as $id) {
$case_fees[] = Drupal\opencase_cases\entity\OCCaseFee::load($id);
}
return $case_fees;
}
/**
* @return Drupal\opencase_cases\entity\OCActivity[]
*/
function opencase_cases_get_activities(Drupal\opencase_cases\entity\OCCase $case): array {
$query = \Drupal::entityQuery('oc_activity')
->condition('oc_case.target_id', $case->id());
$activity_ids = $query->execute();
$activities = [];
foreach($activity_ids as $id) {
$activities[] = Drupal\opencase_entities\Entity\OCActivity::load($id);
}
return $activities;
}
function opencase_cases_oc_case_fee_update(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
$case = $case_fee->getCase();
$case->addToTotalFee($case_fee->amount->value - $case_fee->original->amount->value);
}
function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
$case = $case_fee->getCase();
$case->addToTotalFee($case_fee->amount->value);
}
function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void {
$case = $case_fee->getCase();
$case->addToTotalFee(0 - $case_fee->amount->value);
}
function opencase_cases_entity_base_field_info($entity_type) { function opencase_cases_entity_base_field_info($entity_type) {
$fields = array(); $fields = array();
@ -56,7 +123,7 @@ function opencase_cases_entity_base_field_info($entity_type) {
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setCardinality(1) ->setCardinality(1)
->setDefaultValueCallback('opencase_cases_default_activity_case_value') ->setDefaultValueCallback('opencase_cases_default_case_id')
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'type' => 'string', 'type' => 'string',
'weight' => -3, 'weight' => -3,
@ -66,10 +133,19 @@ function opencase_cases_entity_base_field_info($entity_type) {
return $fields; return $fields;
} }
// When deleting a case, delete the activities associated with it
function opencase_cases_oc_case_delete(Drupal\opencase_cases\Entity\OCCase $case): void {
$activities = opencase_cases_get_activities($case);
foreach ($activities as $activity) {
$activity->delete();
}
}
/** /**
* When creating an activity, it sets the case id from the URL. * When creating an activity, it sets the case id from the URL.
*/ */
function opencase_cases_default_activity_case_value() { function opencase_cases_default_case_id() {
return array(\Drupal::request()->query->get('case_id')); return array(\Drupal::request()->query->get('case_id'));
} }
@ -91,9 +167,16 @@ function opencase_cases_form_alter(&$form, &$form_state, $form_id) {
function _opencase_cases_redirect_to_home($form, &$form_state) { function _opencase_cases_redirect_to_home($form, &$form_state) {
$form_state->setRedirect('<front>'); $form_state->setRedirect('<front>');
} }
// Upon deletion of an activity, go to the related case if there is one, otherwise to its target.
function _opencase_cases_delete_activity_redirect($form, &$form_state) { function _opencase_cases_delete_activity_redirect($form, &$form_state) {
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id; if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) {
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]); $case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
} else {
$target_actor_id = $form_state->getFormObject()->getEntity()->oc_target->target_id;
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
}
} }
/** /**
* Implements hook_theme_suggestions_HOOK(). * Implements hook_theme_suggestions_HOOK().
@ -111,29 +194,34 @@ function opencase_cases_theme_suggestions_oc_case(array $variables) {
return $suggestions; return $suggestions;
} }
function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) { /**
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_case') { * Implements hook_theme_suggestions_HOOK().
$query->addTag('oc_case_access'); */
} function opencase_cases_theme_suggestions_oc_case_provision(array $variables) {
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_activity') { $suggestions = [];
$query->addTag('oc_activity_access'); $entity = $variables['elements']['#oc_case_provision'];
} $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_case_provision__' . $sanitized_view_mode;
$suggestions[] = 'oc_case_provision__' . $entity->bundle();
$suggestions[] = 'oc_case_provision__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_case_provision__' . $entity->id();
$suggestions[] = 'oc_case_provision__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
} }
function opencase_query_oc_case_access_alter($query) { /**
if (\Drupal::currentUser()->hasPermission('view published case entities')) { * Implements hook_theme_suggestions_HOOK().
return; */
} function opencase_cases_theme_suggestions_oc_case_fee(array $variables) {
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser()); $suggestions = [];
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_case_field_data.id'); $entity = $variables['elements']['#oc_case_fee'];
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id); $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
}
function opencase_query_oc_activity_access_alter($query) { $suggestions[] = 'oc_case_fee__' . $sanitized_view_mode;
if (\Drupal::currentUser()->hasPermission('view published case entities')) { $suggestions[] = 'oc_case_fee__' . $entity->bundle();
return; $suggestions[] = 'oc_case_fee__' . $entity->bundle() . '__' . $sanitized_view_mode;
} $suggestions[] = 'oc_case_fee__' . $entity->id();
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser()); $suggestions[] = 'oc_case_fee__' . $entity->id() . '__' . $sanitized_view_mode;
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_activity_field_data.oc_case'); return $suggestions;
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
} }

View File

@ -0,0 +1,61 @@
add case provision entities:
title: 'Create new Case Provision entities'
administer case provision entities:
title: 'Administer Case Provision entities'
description: 'Allow to access the administration form to configure Case Provision entities.'
restrict access: true
delete case provision entities:
title: 'Delete Case Provision entities'
edit case provision entities:
title: 'Edit Case Provision entities'
view published case provision entities:
title: 'View published Case Provision entities'
view unpublished case provision entities:
title: 'View unpublished Case Provision entities'
view all case provision revisions:
title: 'View all Case Provision revisions'
revert all case provision revisions:
title: 'Revert all Case Provision revisions'
description: 'Role requires permission <em>view Case Provision revisions</em> and <em>edit rights</em> for case provision entities in question or <em>administer case provision entities</em>.'
delete all case provision revisions:
title: 'Delete all revisions'
description: 'Role requires permission to <em>view Case Provision revisions</em> and <em>delete rights</em> for case provision entities in question or <em>administer case provision entities</em>.'
add case fee entities:
title: 'Create new Case Fee entities'
administer case fee entities:
title: 'Administer Case Fee entities'
description: 'Allow to access the administration form to configure Case Fee entities.'
restrict access: true
delete case fee entities:
title: 'Delete Case Fee entities'
edit case fee entities:
title: 'Edit Case Fee entities'
view published case fee entities:
title: 'View published Case Fee entities'
view unpublished case fee entities:
title: 'View unpublished Case Fee entities'
view all case fee revisions:
title: 'View all Case Fee revisions'
revert all case fee revisions:
title: 'Revert all Case Fee revisions'
description: 'Role requires permission <em>view Case Fee revisions</em> and <em>edit rights</em> for case fee entities in question or <em>administer case fee entities</em>.'
delete all case fee revisions:
title: 'Delete all revisions'
description: 'Role requires permission to <em>view Case Fee revisions</em> and <em>delete rights</em> for case fee entities in question or <em>administer case fee entities</em>.'

View File

@ -10,8 +10,11 @@ class CaseInvolvement {
public static function userIsInvolved($account, $case) { public static function userIsInvolved($account, $case) {
$actorId = self::getLinkedActorId($account); $actorId = self::getLinkedActorId($account);
$involvedIds = array_column($case->actors_involved->getValue(), 'target_id'); $query = \Drupal::entityQuery('oc_case_provision')
return in_array($actorId, $involvedIds); ->condition('oc_provider', $actorId)
->condition('oc_case', $case->id());
$results = $query->execute();
return !empty($results);
} }
public static function userIsInvolved_activity($account, $activity) { public static function userIsInvolved_activity($account, $activity) {

View File

@ -25,8 +25,8 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
* An array suitable for drupal_render(). * An array suitable for drupal_render().
*/ */
public function revisionShow($oc_case_revision) { public function revisionShow($oc_case_revision) {
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision); $oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
$view_builder = $this->entityManager()->getViewBuilder('oc_case'); $view_builder = $this->entityTypeManager()->getViewBuilder('oc_case');
return $view_builder->view($oc_case); return $view_builder->view($oc_case);
} }
@ -41,8 +41,10 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
* The page title. * The page title.
*/ */
public function revisionPageTitle($oc_case_revision) { public function revisionPageTitle($oc_case_revision) {
$oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision); $oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision);
return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => format_date($oc_case->getRevisionCreationTime())]);
$date = \Drupal::service('date.formatter')->format($oc_case->getRevisionCreationTime());
return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => $date]);
} }
/** /**
@ -60,7 +62,7 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
$langname = $oc_case->language()->getName(); $langname = $oc_case->language()->getName();
$languages = $oc_case->getTranslationLanguages(); $languages = $oc_case->getTranslationLanguages();
$has_translations = (count($languages) > 1); $has_translations = (count($languages) > 1);
$oc_case_storage = $this->entityManager()->getStorage('oc_case'); $oc_case_storage = $this->entityTypeManager()->getStorage('oc_case');
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case->label()]); $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case->label()]);
$header = [$this->t('Revision'), $this->t('Operations')]; $header = [$this->t('Revision'), $this->t('Operations')];
@ -88,10 +90,11 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter
// Use revision link to link to revisions that are not active. // Use revision link to link to revisions that are not active.
$date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short'); $date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
if ($vid != $oc_case->getRevisionId()) { if ($vid != $oc_case->getRevisionId()) {
$link = $this->l($date, new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid])); $url = new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid]);
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
} }
else { else {
$link = $oc_case->link($date); $link = $oc_case->toLink($date)->toString();
} }
$row = []; $row = [];

View File

@ -0,0 +1,210 @@
<?php
namespace Drupal\opencase_cases\Controller;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Url;
use Drupal\opencase_cases\Entity\OCCaseFeeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class OCCaseFeeController.
*
* Returns responses for Case Fee routes.
*/
class OCCaseFeeController extends ControllerBase implements ContainerInjectionInterface {
/**
* The date formatter.
*
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
/**
* The renderer.
*
* @var \Drupal\Core\Render\Renderer
*/
protected $renderer;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->dateFormatter = $container->get('date.formatter');
$instance->renderer = $container->get('renderer');
return $instance;
}
/**
* Displays a Case Fee revision.
*
* @param int $oc_case_fee_revision
* The Case Fee revision ID.
*
* @return array
* An array suitable for drupal_render().
*/
public function revisionShow($oc_case_fee_revision) {
$oc_case_fee = $this->entityTypeManager()->getStorage('oc_case_fee')
->loadRevision($oc_case_fee_revision);
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_case_fee');
return $view_builder->view($oc_case_fee);
}
/**
* Page title callback for a Case Fee revision.
*
* @param int $oc_case_fee_revision
* The Case Fee revision ID.
*
* @return string
* The page title.
*/
public function revisionPageTitle($oc_case_fee_revision) {
$oc_case_fee = $this->entityTypeManager()->getStorage('oc_case_fee')
->loadRevision($oc_case_fee_revision);
return $this->t('Revision of %title from %date', [
'%title' => $oc_case_fee->label(),
'%date' => $this->dateFormatter->format($oc_case_fee->getRevisionCreationTime()),
]);
}
/**
* Generates an overview table of older revisions of a Case Fee.
*
* @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $oc_case_fee
* A Case Fee object.
*
* @return array
* An array as expected by drupal_render().
*/
public function revisionOverview(OCCaseFeeInterface $oc_case_fee) {
$account = $this->currentUser();
$oc_case_fee_storage = $this->entityTypeManager()->getStorage('oc_case_fee');
$langcode = $oc_case_fee->language()->getId();
$langname = $oc_case_fee->language()->getName();
$languages = $oc_case_fee->getTranslationLanguages();
$has_translations = (count($languages) > 1);
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case_fee->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case_fee->label()]);
$header = [$this->t('Revision'), $this->t('Operations')];
$revert_permission = (($account->hasPermission("revert all case fee revisions") || $account->hasPermission('administer case fee entities')));
$delete_permission = (($account->hasPermission("delete all case fee revisions") || $account->hasPermission('administer case fee entities')));
$rows = [];
$vids = $oc_case_fee_storage->revisionIds($oc_case_fee);
$latest_revision = TRUE;
foreach (array_reverse($vids) as $vid) {
/** @var \Drupal\opencase_cases\OCCaseFeeInterface $revision */
$revision = $oc_case_fee_storage->loadRevision($vid);
// Only show revisions that are affected by the language that is being
// displayed.
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
$username = [
'#theme' => 'username',
'#account' => $revision->getRevisionUser(),
];
// Use revision link to link to revisions that are not active.
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
if ($vid != $oc_case_fee->getRevisionId()) {
$url = new Url('entity.oc_case_fee.revision', [
'oc_case_fee' => $oc_case_fee->id(),
'oc_case_fee_revision' => $vid,
]);
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
}
else {
$link = $oc_case_fee->toLink($date)->toString();
}
$row = [];
$column = [
'data' => [
'#type' => 'inline_template',
'#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}',
'#context' => [
'date' => $link,
'username' => $this->renderer->renderPlain($username),
'message' => [
'#markup' => $revision->getRevisionLogMessage(),
'#allowed_tags' => Xss::getHtmlTagList(),
],
],
],
];
$row[] = $column;
if ($latest_revision) {
$row[] = [
'data' => [
'#prefix' => '<em>',
'#markup' => $this->t('Current revision'),
'#suffix' => '</em>',
],
];
foreach ($row as &$current) {
$current['class'] = ['revision-current'];
}
$latest_revision = FALSE;
}
else {
$links = [];
if ($revert_permission) {
$links['revert'] = [
'title' => $this->t('Revert'),
'url' => $has_translations ?
Url::fromRoute('entity.oc_case_fee.translation_revert', [
'oc_case_fee' => $oc_case_fee->id(),
'oc_case_fee_revision' => $vid,
'langcode' => $langcode,
]) :
Url::fromRoute('entity.oc_case_fee.revision_revert', [
'oc_case_fee' => $oc_case_fee->id(),
'oc_case_fee_revision' => $vid,
]),
];
}
if ($delete_permission) {
$links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('entity.oc_case_fee.revision_delete', [
'oc_case_fee' => $oc_case_fee->id(),
'oc_case_fee_revision' => $vid,
]),
];
}
$row[] = [
'data' => [
'#type' => 'operations',
'#links' => $links,
],
];
}
$rows[] = $row;
}
}
$build['oc_case_fee_revisions_table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
];
return $build;
}
}

View File

@ -0,0 +1,210 @@
<?php
namespace Drupal\opencase_cases\Controller;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Url;
use Drupal\opencase_cases\Entity\OCCaseProvisionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class OCCaseProvisionController.
*
* Returns responses for Case Provision routes.
*/
class OCCaseProvisionController extends ControllerBase implements ContainerInjectionInterface {
/**
* The date formatter.
*
* @var \Drupal\Core\Datetime\DateFormatter
*/
protected $dateFormatter;
/**
* The renderer.
*
* @var \Drupal\Core\Render\Renderer
*/
protected $renderer;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->dateFormatter = $container->get('date.formatter');
$instance->renderer = $container->get('renderer');
return $instance;
}
/**
* Displays a Case Provision revision.
*
* @param int $oc_case_provision_revision
* The Case Provision revision ID.
*
* @return array
* An array suitable for drupal_render().
*/
public function revisionShow($oc_case_provision_revision) {
$oc_case_provision = $this->entityTypeManager()->getStorage('oc_case_provision')
->loadRevision($oc_case_provision_revision);
$view_builder = $this->entityTypeManager()->getViewBuilder('oc_case_provision');
return $view_builder->view($oc_case_provision);
}
/**
* Page title callback for a Case Provision revision.
*
* @param int $oc_case_provision_revision
* The Case Provision revision ID.
*
* @return string
* The page title.
*/
public function revisionPageTitle($oc_case_provision_revision) {
$oc_case_provision = $this->entityTypeManager()->getStorage('oc_case_provision')
->loadRevision($oc_case_provision_revision);
return $this->t('Revision of %title from %date', [
'%title' => $oc_case_provision->label(),
'%date' => $this->dateFormatter->format($oc_case_provision->getRevisionCreationTime()),
]);
}
/**
* Generates an overview table of older revisions of a Case Provision.
*
* @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $oc_case_provision
* A Case Provision object.
*
* @return array
* An array as expected by drupal_render().
*/
public function revisionOverview(OCCaseProvisionInterface $oc_case_provision) {
$account = $this->currentUser();
$oc_case_provision_storage = $this->entityTypeManager()->getStorage('oc_case_provision');
$langcode = $oc_case_provision->language()->getId();
$langname = $oc_case_provision->language()->getName();
$languages = $oc_case_provision->getTranslationLanguages();
$has_translations = (count($languages) > 1);
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case_provision->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case_provision->label()]);
$header = [$this->t('Revision'), $this->t('Operations')];
$revert_permission = (($account->hasPermission("revert all case provision revisions") || $account->hasPermission('administer case provision entities')));
$delete_permission = (($account->hasPermission("delete all case provision revisions") || $account->hasPermission('administer case provision entities')));
$rows = [];
$vids = $oc_case_provision_storage->revisionIds($oc_case_provision);
$latest_revision = TRUE;
foreach (array_reverse($vids) as $vid) {
/** @var \Drupal\opencase_cases\OCCaseProvisionInterface $revision */
$revision = $oc_case_provision_storage->loadRevision($vid);
// Only show revisions that are affected by the language that is being
// displayed.
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
$username = [
'#theme' => 'username',
'#account' => $revision->getRevisionUser(),
];
// Use revision link to link to revisions that are not active.
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
if ($vid != $oc_case_provision->getRevisionId()) {
$url = new Url('entity.oc_case_provision.revision', [
'oc_case_provision' => $oc_case_provision->id(),
'oc_case_provision_revision' => $vid,
]);
$link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString();
}
else {
$link = $oc_case_provision->toLink($date)->toString();
}
$row = [];
$column = [
'data' => [
'#type' => 'inline_template',
'#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}',
'#context' => [
'date' => $link,
'username' => $this->renderer->renderPlain($username),
'message' => [
'#markup' => $revision->getRevisionLogMessage(),
'#allowed_tags' => Xss::getHtmlTagList(),
],
],
],
];
$row[] = $column;
if ($latest_revision) {
$row[] = [
'data' => [
'#prefix' => '<em>',
'#markup' => $this->t('Current revision'),
'#suffix' => '</em>',
],
];
foreach ($row as &$current) {
$current['class'] = ['revision-current'];
}
$latest_revision = FALSE;
}
else {
$links = [];
if ($revert_permission) {
$links['revert'] = [
'title' => $this->t('Revert'),
'url' => $has_translations ?
Url::fromRoute('entity.oc_case_provision.translation_revert', [
'oc_case_provision' => $oc_case_provision->id(),
'oc_case_provision_revision' => $vid,
'langcode' => $langcode,
]) :
Url::fromRoute('entity.oc_case_provision.revision_revert', [
'oc_case_provision' => $oc_case_provision->id(),
'oc_case_provision_revision' => $vid,
]),
];
}
if ($delete_permission) {
$links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('entity.oc_case_provision.revision_delete', [
'oc_case_provision' => $oc_case_provision->id(),
'oc_case_provision_revision' => $vid,
]),
];
}
$row[] = [
'data' => [
'#type' => 'operations',
'#links' => $links,
],
];
}
$rows[] = $row;
}
}
$build['oc_case_provision_revisions_table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
];
return $build;
}
}

View File

@ -41,6 +41,11 @@ use Drupal\user\UserInterface;
* data_table = "oc_case_field_data", * data_table = "oc_case_field_data",
* revision_table = "oc_case_revision", * revision_table = "oc_case_revision",
* revision_data_table = "oc_case_field_revision", * revision_data_table = "oc_case_field_revision",
* revision_metadata_keys = {
* "revision_user" = "revision_user",
* "revision_created" = "revision_created",
* "revision_log_message" = "revision_log"
* },
* translatable = TRUE, * translatable = TRUE,
* admin_permission = "administer case entities", * admin_permission = "administer case entities",
* entity_keys = { * entity_keys = {
@ -70,30 +75,39 @@ use Drupal\user\UserInterface;
* field_ui_base_route = "entity.oc_case_type.edit_form" * field_ui_base_route = "entity.oc_case_type.edit_form"
* ) * )
*/ */
class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
{
use EntityChangedTrait; use EntityChangedTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) { public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
{
parent::preCreate($storage_controller, $values); parent::preCreate($storage_controller, $values);
$values += [ $values += [
'user_id' => \Drupal::currentUser()->id(), 'user_id' => \Drupal::currentUser()->id(),
]; ];
} }
public static function defaultTarget()
{
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
else return [];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function urlRouteParameters($rel) { protected function urlRouteParameters($rel)
{
$uri_route_parameters = parent::urlRouteParameters($rel); $uri_route_parameters = parent::urlRouteParameters($rel);
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) { if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
} } elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
} }
@ -103,7 +117,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function preSave(EntityStorageInterface $storage) { public function preSave(EntityStorageInterface $storage)
{
parent::preSave($storage); parent::preSave($storage);
foreach (array_keys($this->getTranslationLanguages()) as $langcode) { foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
@ -125,14 +140,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() { public function getName()
{
return $this->get('name')->value; return $this->get('name')->value;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setName($name) { public function setName($name)
{
$this->set('name', $name); $this->set('name', $name);
return $this; return $this;
} }
@ -140,14 +157,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getCreatedTime() { public function getCreatedTime()
{
return $this->get('created')->value; return $this->get('created')->value;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setCreatedTime($timestamp) { public function setCreatedTime($timestamp)
{
$this->set('created', $timestamp); $this->set('created', $timestamp);
return $this; return $this;
} }
@ -155,21 +174,24 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getOwner() { public function getOwner()
{
return $this->get('user_id')->entity; return $this->get('user_id')->entity;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getOwnerId() { public function getOwnerId()
{
return $this->get('user_id')->target_id; return $this->get('user_id')->target_id;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setOwnerId($uid) { public function setOwnerId($uid)
{
$this->set('user_id', $uid); $this->set('user_id', $uid);
return $this; return $this;
} }
@ -177,7 +199,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setOwner(UserInterface $account) { public function setOwner(UserInterface $account)
{
$this->set('user_id', $account->id()); $this->set('user_id', $account->id());
return $this; return $this;
} }
@ -185,29 +208,39 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isPublished() { public function isPublished()
return (bool) $this->getEntityKey('status'); {
return (bool)$this->getEntityKey('status');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setPublished($published) { public function setPublished($published)
{
$this->set('status', $published ? TRUE : FALSE); $this->set('status', $published ? TRUE : FALSE);
return $this; return $this;
} }
public function addToTotalFee(float $amountToAdd): void {
$this->set('total_fee', $this->total_fee->value + $amountToAdd);
$this->save();
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type); $fields = parent::baseFieldDefinitions($entity_type);
// not currently used. Will add form and view settings when ready // not currently used. Will add form and view settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean') $fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status')) ->setLabel(t('Visible'))
->setDescription(t('A boolean indicating whether the Case is published.')) ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDefaultValue(TRUE); ->setDefaultValue(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference') $fields['user_id'] = BaseFieldDefinition::create('entity_reference')
@ -217,27 +250,29 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setSetting('target_type', 'user') ->setSetting('target_type', 'user')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', [ ->setDisplayConfigurable('form', true)
'label' => 'above', ->setDisplayConfigurable('view', true);
'type' => 'author',
'weight' => 80,
]); $fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Target'))
->setRevisionable(TRUE)
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['name'] = BaseFieldDefinition::create('string') $fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Title')) ->setLabel(t('Title'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSettings([ ->setSettings([
'max_length' => 50, 'max_length' => 120,
'text_processing' => 0, 'text_processing' => 0,
]) ])
->setDefaultValue('') ->setDefaultValue('')
->setDisplayOptions('view', [ ->setDisplayConfigurable('form', true)
'label' => 'hidden', ->setDisplayConfigurable('view', true)
'type' => 'string',
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -100,
])
->setRequired(TRUE); ->setRequired(TRUE);
@ -250,33 +285,18 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setSetting('description_field', 'true') ->setSetting('description_field', 'true')
->setSetting('uri_scheme', 'private') ->setSetting('uri_scheme', 'private')
->setCardinality(-1) ->setCardinality(-1)
->setDisplayOptions('form', [ ->setDisplayConfigurable('form', true)
'type' => 'file_generic', ->setDisplayConfigurable('view', true);
'weight' => -1,
'settings' => [
'progress_indicator' => 'throbber',
],
])
->setDisplayOptions('view', [
'label' => 'above',
'settings' => ['use_description_as_link_text' => 'true']
]);
$fields['created'] = BaseFieldDefinition::create('created') $fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created on')) ->setLabel(t('Created on'))
->setDescription(t('When the case was created.')) ->setDescription(t('When the case was created.'))
->setDisplayOptions('view', [ ->setDisplayConfigurable('view', true);
'label' => 'above',
'weight' => 80,
]);
$fields['changed'] = BaseFieldDefinition::create('changed') $fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Last updated')) ->setLabel(t('Last updated'))
->setDescription(t('When the case was last edited.')) ->setDescription(t('When the case was last edited.'))
->setDisplayOptions('view', [ ->setDisplayConfigurable('view', true);
'label' => 'above',
'weight' => 80,
]);
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean') $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected')) ->setLabel(t('Revision translation affected'))
@ -285,6 +305,27 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setTranslatable(TRUE); ->setTranslatable(TRUE);
$fields['notes'] = BaseFieldDefinition::create('string_long')
->setRevisionable(TRUE)
->setLabel(t('Notes'))
->setSettings(array(
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['total_fee'] = BaseFieldDefinition::create('decimal')
->setLabel(t('Total Fee'))
->setRevisionable(TRUE)
->setSettings([
'prefix' => '£',
])
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
return $fields; return $fields;
} }
} }

View File

@ -0,0 +1,283 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EditorialContentEntityBase;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
/**
* Defines the Case Fee entity.
*
* @ingroup opencase_cases
*
* @ContentEntityType(
* id = "oc_case_fee",
* label = @Translation("Case Fee"),
* bundle_label = @Translation("Case Fee type"),
* handlers = {
* "storage" = "Drupal\opencase_cases\OCCaseFeeStorage",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_cases\OCCaseFeeListBuilder",
* "views_data" = "Drupal\opencase_cases\Entity\OCCaseFeeViewsData",
* "translation" = "Drupal\opencase_cases\OCCaseFeeTranslationHandler",
*
* "form" = {
* "default" = "Drupal\opencase_cases\Form\OCCaseFeeForm",
* "add" = "Drupal\opencase_cases\Form\OCCaseFeeForm",
* "edit" = "Drupal\opencase_cases\Form\OCCaseFeeForm",
* "delete" = "Drupal\opencase_cases\Form\OCCaseFeeDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\opencase_cases\OCCaseFeeHtmlRouteProvider",
* },
* "access" = "Drupal\opencase_cases\OCCaseFeeAccessControlHandler",
* },
* base_table = "oc_case_fee",
* data_table = "oc_case_fee_field_data",
* revision_table = "oc_case_fee_revision",
* revision_data_table = "oc_case_fee_field_revision",
* translatable = TRUE,
* permission_granularity = "bundle",
* admin_permission = "administer case fee entities",
* entity_keys = {
* "id" = "id",
* "revision" = "vid",
* "bundle" = "type",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "published" = "status",
* },
* revision_metadata_keys = {
* "revision_user" = "revision_user",
* "revision_created" = "revision_created",
* "revision_log_message" = "revision_log",
* },
* links = {
* "canonical" = "/opencase/oc_case_fee/{oc_case_fee}",
* "add-page" = "/opencase/oc_case_fee/add",
* "add-form" = "/opencase/oc_case_fee/add/{oc_case_fee_type}",
* "edit-form" = "/opencase/oc_case_fee/{oc_case_fee}/edit",
* "delete-form" = "/opencase/oc_case_fee/{oc_case_fee}/delete",
* "version-history" = "/opencase/oc_case_fee/{oc_case_fee}/revisions",
* "revision" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/view",
* "revision_revert" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/revert",
* "revision_delete" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/delete",
* "translation_revert" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/revert/{langcode}",
* "collection" = "/opencase/oc_case_fee",
* },
* bundle_entity_type = "oc_case_fee_type",
* field_ui_base_route = "entity.oc_case_fee_type.edit_form"
* )
*/
class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface {
use EntityChangedTrait;
use EntityPublishedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'user_id' => \Drupal::currentUser()->id(),
];
}
/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel) {
$uri_route_parameters = parent::urlRouteParameters($rel);
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
}
elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
}
return $uri_route_parameters;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
$translation = $this->getTranslation($langcode);
// If no owner has been set explicitly, make the anonymous user the owner.
if (!$translation->getOwner()) {
$translation->setOwnerId(0);
}
}
// If no revision author has been set explicitly,
// make the oc_case_fee owner the revision author.
if (!$this->getRevisionUser()) {
$this->setRevisionUserId($this->getOwnerId());
}
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner() {
return $this->get('user_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
return $this->get('user_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this->set('user_id', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this->set('user_id', $account->id());
return $this;
}
public function getCase():\Drupal\opencase_cases\Entity\OCCase {
return \Drupal\opencase_cases\Entity\OCCase::load($this->oc_case->target_id);
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// Add the published field.
$fields += static::publishedBaseFieldDefinitions($entity_type);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the Case Fee entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Case Fee entity.'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['status']->setDescription(t('A boolean indicating whether the Case Fee is published.'))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
->setReadOnly(TRUE)
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['oc_case'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Case'))
->setSetting('target_type', 'oc_case')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(TRUE);
$fields['oc_fee_category'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Fee Category'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['oc_fee_category' => 'oc_fee_category']])
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(FALSE);
$fields['amount'] = BaseFieldDefinition::create('decimal')
->setLabel(t('Amount'))
->setRevisionable(TRUE)
->setSettings([
'prefix' => '£',
])
->setRequired(TRUE)
->SetDisplayConfigurable("form", true)
->SetDisplayConfigurable("view", true);
return $fields;
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining Case Fee entities.
*
* @ingroup opencase_cases
*/
interface OCCaseFeeInterface extends ContentEntityInterface, RevisionLogInterface, EntityChangedInterface, EntityPublishedInterface, EntityOwnerInterface {
/**
* Add get/set methods for your configuration properties here.
*/
/**
* Gets the Case Fee name.
*
* @return string
* Name of the Case Fee.
*/
public function getName();
/**
* Sets the Case Fee name.
*
* @param string $name
* The Case Fee name.
*
* @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface
* The called Case Fee entity.
*/
public function setName($name);
/**
* Gets the Case Fee creation timestamp.
*
* @return int
* Creation timestamp of the Case Fee.
*/
public function getCreatedTime();
/**
* Sets the Case Fee creation timestamp.
*
* @param int $timestamp
* The Case Fee creation timestamp.
*
* @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface
* The called Case Fee entity.
*/
public function setCreatedTime($timestamp);
/**
* Gets the Case Fee revision creation timestamp.
*
* @return int
* The UNIX timestamp of when this revision was created.
*/
public function getRevisionCreationTime();
/**
* Sets the Case Fee revision creation timestamp.
*
* @param int $timestamp
* The UNIX timestamp of when this revision was created.
*
* @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface
* The called Case Fee entity.
*/
public function setRevisionCreationTime($timestamp);
/**
* Gets the Case Fee revision author.
*
* @return \Drupal\user\UserInterface
* The user entity for the revision author.
*/
public function getRevisionUser();
/**
* Sets the Case Fee revision author.
*
* @param int $uid
* The user ID of the revision author.
*
* @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface
* The called Case Fee entity.
*/
public function setRevisionUserId($uid);
}

View File

@ -0,0 +1,63 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
/**
* Defines the Case Fee type entity.
*
* @ConfigEntityType(
* id = "oc_case_fee_type",
* label = @Translation("Case Fee type"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_cases\OCCaseFeeTypeListBuilder",
* "form" = {
* "add" = "Drupal\opencase_cases\Form\OCCaseFeeTypeForm",
* "edit" = "Drupal\opencase_cases\Form\OCCaseFeeTypeForm",
* "delete" = "Drupal\opencase_cases\Form\OCCaseFeeTypeDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\opencase_cases\OCCaseFeeTypeHtmlRouteProvider",
* },
* },
* config_prefix = "oc_case_fee_type",
* admin_permission = "administer site configuration",
* bundle_of = "oc_case_fee",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* config_export = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* links = {
* "canonical" = "/opencase/oc_case_fee_type/{oc_case_fee_type}",
* "add-form" = "/opencase/oc_case_fee_type/add",
* "edit-form" = "/opencase/oc_case_fee_type/{oc_case_fee_type}/edit",
* "delete-form" = "/opencase/oc_case_fee_type/{oc_case_fee_type}/delete",
* "collection" = "/opencase/oc_case_fee_type"
* }
* )
*/
class OCCaseFeeType extends ConfigEntityBundleBase implements OCCaseFeeTypeInterface {
/**
* The Case Fee type ID.
*
* @var string
*/
protected $id;
/**
* The Case Fee type label.
*
* @var string
*/
protected $label;
}

View File

@ -0,0 +1,13 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface for defining Case Fee type entities.
*/
interface OCCaseFeeTypeInterface extends ConfigEntityInterface {
// Add get/set methods for your configuration properties here.
}

View File

@ -0,0 +1,23 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for Case Fee entities.
*/
class OCCaseFeeViewsData extends EntityViewsData {
/**
* {@inheritdoc}
*/
public function getViewsData() {
$data = parent::getViewsData();
// Additional information for Views integration, such as table joins, can be
// put here.
return $data;
}
}

View File

@ -0,0 +1,303 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EditorialContentEntityBase;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
/**
* Defines the Case Provision entity.
*
* @ingroup opencase_cases
*
* @ContentEntityType(
* id = "oc_case_provision",
* label = @Translation("Case Provision"),
* bundle_label = @Translation("Case Provision type"),
* handlers = {
* "storage" = "Drupal\opencase_cases\OCCaseProvisionStorage",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_cases\OCCaseProvisionListBuilder",
* "views_data" = "Drupal\opencase_cases\Entity\OCCaseProvisionViewsData",
* "translation" = "Drupal\opencase_cases\OCCaseProvisionTranslationHandler",
*
* "form" = {
* "default" = "Drupal\opencase_cases\Form\OCCaseProvisionForm",
* "add" = "Drupal\opencase_cases\Form\OCCaseProvisionForm",
* "edit" = "Drupal\opencase_cases\Form\OCCaseProvisionForm",
* "delete" = "Drupal\opencase_cases\Form\OCCaseProvisionDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\opencase_cases\OCCaseProvisionHtmlRouteProvider",
* },
* "access" = "Drupal\opencase_cases\OCCaseProvisionAccessControlHandler",
* },
* base_table = "oc_case_provision",
* data_table = "oc_case_provision_field_data",
* revision_table = "oc_case_provision_revision",
* revision_data_table = "oc_case_provision_field_revision",
* translatable = TRUE,
* permission_granularity = "bundle",
* admin_permission = "administer case provision entities",
* entity_keys = {
* "id" = "id",
* "revision" = "vid",
* "bundle" = "type",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "published" = "status",
* },
* revision_metadata_keys = {
* "revision_user" = "revision_user",
* "revision_created" = "revision_created",
* "revision_log_message" = "revision_log",
* },
* links = {
* "canonical" = "/opencase/oc_case_provision/{oc_case_provision}",
* "add-page" = "/opencase/oc_case_provision/add",
* "add-form" = "/opencase/oc_case_provision/add/{oc_case_provision_type}",
* "edit-form" = "/opencase/oc_case_provision/{oc_case_provision}/edit",
* "delete-form" = "/opencase/oc_case_provision/{oc_case_provision}/delete",
* "version-history" = "/opencase/oc_case_provision/{oc_case_provision}/revisions",
* "revision" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/view",
* "revision_revert" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/revert",
* "revision_delete" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/delete",
* "translation_revert" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/revert/{langcode}",
* "collection" = "/opencase/oc_case_provision",
* },
* bundle_entity_type = "oc_case_provision_type",
* field_ui_base_route = "entity.oc_case_provision_type.edit_form"
* )
*/
class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvisionInterface
{
use EntityChangedTrait;
use EntityPublishedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
{
parent::preCreate($storage_controller, $values);
$values += [
'user_id' => \Drupal::currentUser()->id(),
];
}
/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel)
{
$uri_route_parameters = parent::urlRouteParameters($rel);
if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
} elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) {
$uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId();
}
return $uri_route_parameters;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage)
{
parent::preSave($storage);
foreach (array_keys($this->getTranslationLanguages()) as $langcode) {
$translation = $this->getTranslation($langcode);
// If no owner has been set explicitly, make the anonymous user the owner.
if (!$translation->getOwner()) {
$translation->setOwnerId(0);
}
}
// If no revision author has been set explicitly,
// make the oc_case_provision owner the revision author.
if (!$this->getRevisionUser()) {
$this->setRevisionUserId($this->getOwnerId());
}
}
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name)
{
$this->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedTime()
{
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp)
{
$this->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner()
{
return $this->get('user_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId()
{
return $this->get('user_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid)
{
$this->set('user_id', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account)
{
$this->set('user_id', $account->id());
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
// Add the published field.
$fields += static::publishedBaseFieldDefinitions($entity_type);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the Case Provision entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Case Provision entity.'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Visible'))
->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
->setRevisionable(TRUE)
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
->setReadOnly(TRUE)
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['oc_case'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Case'))
->setSetting('target_type', 'oc_case')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDefaultValueCallback('opencase_cases_default_case_id') // defined in opencase_cases.module
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['oc_provider'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Provider'))
->setSetting('target_type', 'oc_actor') // TODO: this should eventually point to a Provider rather than an Actor
->setSetting('handler', 'views')
->setTranslatable(TRUE)
->setCardinality(1)
->setSetting('handler_settings', [
'view' => [
'view_name' => 'case_providers',
'display_name' => 'entity_reference_1',
'arguments' => [],
]
])
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(TRUE);
$fields['oc_case_provider_role'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Role'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDisplayConfigurable("view", true)
->setDisplayConfigurable("form", true)
->setRequired(FALSE);
return $fields;
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining Case Provision entities.
*
* @ingroup opencase_cases
*/
interface OCCaseProvisionInterface extends ContentEntityInterface, RevisionLogInterface, EntityChangedInterface, EntityPublishedInterface, EntityOwnerInterface {
/**
* Add get/set methods for your configuration properties here.
*/
/**
* Gets the Case Provision name.
*
* @return string
* Name of the Case Provision.
*/
public function getName();
/**
* Sets the Case Provision name.
*
* @param string $name
* The Case Provision name.
*
* @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
* The called Case Provision entity.
*/
public function setName($name);
/**
* Gets the Case Provision creation timestamp.
*
* @return int
* Creation timestamp of the Case Provision.
*/
public function getCreatedTime();
/**
* Sets the Case Provision creation timestamp.
*
* @param int $timestamp
* The Case Provision creation timestamp.
*
* @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
* The called Case Provision entity.
*/
public function setCreatedTime($timestamp);
/**
* Gets the Case Provision revision creation timestamp.
*
* @return int
* The UNIX timestamp of when this revision was created.
*/
public function getRevisionCreationTime();
/**
* Sets the Case Provision revision creation timestamp.
*
* @param int $timestamp
* The UNIX timestamp of when this revision was created.
*
* @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
* The called Case Provision entity.
*/
public function setRevisionCreationTime($timestamp);
/**
* Gets the Case Provision revision author.
*
* @return \Drupal\user\UserInterface
* The user entity for the revision author.
*/
public function getRevisionUser();
/**
* Sets the Case Provision revision author.
*
* @param int $uid
* The user ID of the revision author.
*
* @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
* The called Case Provision entity.
*/
public function setRevisionUserId($uid);
}

View File

@ -0,0 +1,63 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
/**
* Defines the Case Provision type entity.
*
* @ConfigEntityType(
* id = "oc_case_provision_type",
* label = @Translation("Case Provision type"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_cases\OCCaseProvisionTypeListBuilder",
* "form" = {
* "add" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeForm",
* "edit" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeForm",
* "delete" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\opencase_cases\OCCaseProvisionTypeHtmlRouteProvider",
* },
* },
* config_prefix = "oc_case_provision_type",
* admin_permission = "administer site configuration",
* bundle_of = "oc_case_provision",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* config_export = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* links = {
* "canonical" = "/opencase/oc_case_provision_type/{oc_case_provision_type}",
* "add-form" = "/opencase/oc_case_provision_type/add",
* "edit-form" = "/opencase/oc_case_provision_type/{oc_case_provision_type}/edit",
* "delete-form" = "/opencase/oc_case_provision_type/{oc_case_provision_type}/delete",
* "collection" = "/opencase/oc_case_provision_type"
* }
* )
*/
class OCCaseProvisionType extends ConfigEntityBundleBase implements OCCaseProvisionTypeInterface {
/**
* The Case Provision type ID.
*
* @var string
*/
protected $id;
/**
* The Case Provision type label.
*
* @var string
*/
protected $label;
}

View File

@ -0,0 +1,13 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface for defining Case Provision type entities.
*/
interface OCCaseProvisionTypeInterface extends ConfigEntityInterface {
// Add get/set methods for your configuration properties here.
}

View File

@ -0,0 +1,23 @@
<?php
namespace Drupal\opencase_cases\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for Case Provision entities.
*/
class OCCaseProvisionViewsData extends EntityViewsData {
/**
* {@inheritdoc}
*/
public function getViewsData() {
$data = parent::getViewsData();
// Additional information for Views integration, such as table joins, can be
// put here.
return $data;
}
}

View File

@ -31,6 +31,11 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
* "label" = "label", * "label" = "label",
* "uuid" = "uuid" * "uuid" = "uuid"
* }, * },
* config_export = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* links = { * links = {
* "canonical" = "/admin/opencase/oc_case_type/{oc_case_type}", * "canonical" = "/admin/opencase/oc_case_type/{oc_case_type}",
* "add-form" = "/admin/opencase/oc_case_type/add", * "add-form" = "/admin/opencase/oc_case_type/add",

View File

@ -0,0 +1,15 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
/**
* Provides a form for deleting Case Fee entities.
*
* @ingroup opencase_cases
*/
class OCCaseFeeDeleteForm extends ContentEntityDeleteForm {
}

View File

@ -0,0 +1,78 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for Case Fee edit forms.
*
* @ingroup opencase_cases
*/
class OCCaseFeeForm extends ContentEntityForm {
/**
* The current user account.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $account;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
// Instantiates this form class.
$instance = parent::create($container);
$instance->account = $container->get('current_user');
return $instance;
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var \Drupal\opencase_cases\Entity\OCCaseFee $entity */
$form = parent::buildForm($form, $form_state);
if (!$this->entity->isNew()) {
$form['new_revision'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create new revision'),
'#default_value' => FALSE,
'#weight' => 10,
];
}
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$entity->setNewRevision();
$entity->setRevisionCreationTime(REQUEST_TIME);
$entity->setRevisionUserId(\Drupal::currentUser()->id());
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Case Fee.', [
'%label' => $entity->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Case Fee.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.oc_case_fee.canonical', ['oc_case_fee' => $entity->id()]);
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for deleting a Case Fee revision.
*
* @ingroup opencase_cases
*/
class OCCaseFeeRevisionDeleteForm extends ConfirmFormBase {
/**
* The Case Fee revision.
*
* @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface
*/
protected $revision;
/**
* The Case Fee storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $oCCaseFeeStorage;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->oCCaseFeeStorage = $container->get('entity_type.manager')->getStorage('oc_case_fee');
$instance->connection = $container->get('database');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_fee_revision_delete_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the revision from %revision-date?', [
'%revision-date' => format_date($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_fee.version_history', ['oc_case_fee' => $this->revision->id()]);
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL) {
$this->revision = $this->OCCaseFeeStorage->loadRevision($oc_case_fee_revision);
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->OCCaseFeeStorage->deleteRevision($this->revision->getRevisionId());
$this->logger('content')->notice('Case Fee: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$this->messenger()->addMessage(t('Revision from %revision-date of Case Fee %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
$form_state->setRedirect(
'entity.oc_case_fee.canonical',
['oc_case_fee' => $this->revision->id()]
);
if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {oc_case_fee_field_revision} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) {
$form_state->setRedirect(
'entity.oc_case_fee.version_history',
['oc_case_fee' => $this->revision->id()]
);
}
}
}

View File

@ -0,0 +1,137 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\opencase_cases\Entity\OCCaseFeeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for reverting a Case Fee revision.
*
* @ingroup opencase_cases
*/
class OCCaseFeeRevisionRevertForm extends ConfirmFormBase {
/**
* The Case Fee revision.
*
* @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface
*/
protected $revision;
/**
* The Case Fee storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $oCCaseFeeStorage;
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->oCCaseFeeStorage = $container->get('entity_type.manager')->getStorage('oc_case_fee');
$instance->dateFormatter = $container->get('date.formatter');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_fee_revision_revert_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to revert to the revision from %revision-date?', [
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_fee.version_history', ['oc_case_fee' => $this->revision->id()]);
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Revert');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return '';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL) {
$this->revision = $this->OCCaseFeeStorage->loadRevision($oc_case_fee_revision);
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// The revision timestamp will be updated when the revision is saved. Keep
// the original one for the confirmation message.
$original_revision_timestamp = $this->revision->getRevisionCreationTime();
$this->revision = $this->prepareRevertedRevision($this->revision, $form_state);
$this->revision->revision_log = $this->t('Copy of the revision from %date.', [
'%date' => $this->dateFormatter->format($original_revision_timestamp),
]);
$this->revision->save();
$this->logger('content')->notice('Case Fee: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$this->messenger()->addMessage(t('Case Fee %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
$form_state->setRedirect(
'entity.oc_case_fee.version_history',
['oc_case_fee' => $this->revision->id()]
);
}
/**
* Prepares a revision to be reverted.
*
* @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $revision
* The revision to be reverted.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface
* The prepared revision ready to be stored.
*/
protected function prepareRevertedRevision(OCCaseFeeInterface $revision, FormStateInterface $form_state) {
$revision->setNewRevision();
$revision->isDefaultRevision(TRUE);
$revision->setRevisionCreationTime(REQUEST_TIME);
return $revision;
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\opencase_cases\Entity\OCCaseFeeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for reverting a Case Fee revision for a single trans.
*
* @ingroup opencase_cases
*/
class OCCaseFeeRevisionRevertTranslationForm extends OCCaseFeeRevisionRevertForm {
/**
* The language to be reverted.
*
* @var string
*/
protected $langcode;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->languageManager = $container->get('language_manager');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_fee_revision_revert_translation_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to revert @language translation to the revision from %revision-date?', [
'@language' => $this->languageManager->getLanguageName($this->langcode),
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL, $langcode = NULL) {
$this->langcode = $langcode;
$form = parent::buildForm($form, $form_state, $oc_case_fee_revision);
$form['revert_untranslated_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Revert content shared among translations'),
'#default_value' => FALSE,
];
return $form;
}
/**
* {@inheritdoc}
*/
protected function prepareRevertedRevision(OCCaseFeeInterface $revision, FormStateInterface $form_state) {
$revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields');
/** @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface $default_revision */
$latest_revision = $this->OCCaseFeeStorage->load($revision->id());
$latest_revision_translation = $latest_revision->getTranslation($this->langcode);
$revision_translation = $revision->getTranslation($this->langcode);
foreach ($latest_revision_translation->getFieldDefinitions() as $field_name => $definition) {
if ($definition->isTranslatable() || $revert_untranslated_fields) {
$latest_revision_translation->set($field_name, $revision_translation->get($field_name)->getValue());
}
}
$latest_revision_translation->setNewRevision();
$latest_revision_translation->isDefaultRevision(TRUE);
$revision->setRevisionCreationTime(REQUEST_TIME);
return $latest_revision_translation;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCCaseFeeSettingsForm.
*
* @ingroup opencase_cases
*/
class OCCaseFeeSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'occasefee_settings';
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Empty implementation of the abstract submit class.
}
/**
* Defines the settings form for Case Fee entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['occasefee_settings']['#markup'] = 'Settings form for Case Fee entities. Manage field settings here.';
return $form;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Builds the form to delete Case Fee type entities.
*/
class OCCaseFeeTypeDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_fee_type.collection');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
$this->messenger()->addMessage(
$this->t('content @type: deleted @label.', [
'@type' => $this->entity->bundle(),
'@label' => $this->entity->label(),
])
);
$form_state->setRedirectUrl($this->getCancelUrl());
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCCaseFeeTypeForm.
*/
class OCCaseFeeTypeForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$oc_case_fee_type = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $oc_case_fee_type->label(),
'#description' => $this->t("Label for the Case Fee type."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $oc_case_fee_type->id(),
'#machine_name' => [
'exists' => '\Drupal\opencase_cases\Entity\OCCaseFeeType::load',
],
'#disabled' => !$oc_case_fee_type->isNew(),
];
/* You will need additional form elements for your custom properties. */
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$oc_case_fee_type = $this->entity;
$status = $oc_case_fee_type->save();
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Case Fee type.', [
'%label' => $oc_case_fee_type->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Case Fee type.', [
'%label' => $oc_case_fee_type->label(),
]));
}
$form_state->setRedirectUrl($oc_case_fee_type->toUrl('collection'));
}
}

View File

@ -38,34 +38,33 @@ class OCCaseForm extends ContentEntityForm {
*/ */
public function save(array $form, FormStateInterface $form_state) { public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity; $entity = $this->entity;
$entity->setNewRevision();
// Save as a new revision if requested to do so. $entity->setRevisionCreationTime(REQUEST_TIME);
if (!$form_state->isValueEmpty('new_revision') && $form_state->getValue('new_revision') != FALSE) { $entity->setRevisionUserId(\Drupal::currentUser()->id());
$entity->setNewRevision();
// If a new revision is created, save the current user as revision author.
$entity->setRevisionCreationTime(REQUEST_TIME);
$entity->setRevisionUserId(\Drupal::currentUser()->id());
}
else {
$entity->setNewRevision(FALSE);
}
$status = parent::save($form, $form_state); $status = parent::save($form, $form_state);
switch ($status) { switch ($status) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message($this->t('Created the %label Case.', [ \Drupal::messenger()->addMessage($this->t('Created the %label Case.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
break; break;
default: default:
drupal_set_message($this->t('Saved the %label Case.', [ \Drupal::messenger()->addMessage($this->t('Saved the %label Case.', [
'%label' => $entity->label(), '%label' => $entity->label(),
])); ]));
} }
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $entity->id()]); // If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied".
if (!$form_state->getValue('status')['value'] && !\Drupal::currentUser()->hasPermission('view unpublished case entities')) {
\Drupal::messenger()->addMessage($this->t('The record for "%label" is now unpublished & hidden from you.', [
'%label' => $entity->label(),
]));
$form_state->setRedirect('<front>');
} else {
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $entity->id()]);
}
} }
} }

View File

@ -0,0 +1,15 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
/**
* Provides a form for deleting Case Provision entities.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionDeleteForm extends ContentEntityDeleteForm {
}

View File

@ -0,0 +1,78 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for Case Provision edit forms.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionForm extends ContentEntityForm {
/**
* The current user account.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $account;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
// Instantiates this form class.
$instance = parent::create($container);
$instance->account = $container->get('current_user');
return $instance;
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var \Drupal\opencase_cases\Entity\OCCaseProvision $entity */
$form = parent::buildForm($form, $form_state);
if (!$this->entity->isNew()) {
$form['new_revision'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create new revision'),
'#default_value' => FALSE,
'#weight' => 10,
];
}
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$entity->setNewRevision();
$entity->setRevisionCreationTime(REQUEST_TIME);
$entity->setRevisionUserId(\Drupal::currentUser()->id());
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Case Provision.', [
'%label' => $entity->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Case Provision.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.oc_case_provision.canonical', ['oc_case_provision' => $entity->id()]);
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for deleting a Case Provision revision.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionRevisionDeleteForm extends ConfirmFormBase {
/**
* The Case Provision revision.
*
* @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
*/
protected $revision;
/**
* The Case Provision storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $oCCaseProvisionStorage;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->oCCaseProvisionStorage = $container->get('entity_type.manager')->getStorage('oc_case_provision');
$instance->connection = $container->get('database');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_provision_revision_delete_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the revision from %revision-date?', [
'%revision-date' => format_date($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_provision.version_history', ['oc_case_provision' => $this->revision->id()]);
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL) {
$this->revision = $this->OCCaseProvisionStorage->loadRevision($oc_case_provision_revision);
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->OCCaseProvisionStorage->deleteRevision($this->revision->getRevisionId());
$this->logger('content')->notice('Case Provision: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$this->messenger()->addMessage(t('Revision from %revision-date of Case Provision %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
$form_state->setRedirect(
'entity.oc_case_provision.canonical',
['oc_case_provision' => $this->revision->id()]
);
if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {oc_case_provision_field_revision} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) {
$form_state->setRedirect(
'entity.oc_case_provision.version_history',
['oc_case_provision' => $this->revision->id()]
);
}
}
}

View File

@ -0,0 +1,137 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\opencase_cases\Entity\OCCaseProvisionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for reverting a Case Provision revision.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionRevisionRevertForm extends ConfirmFormBase {
/**
* The Case Provision revision.
*
* @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
*/
protected $revision;
/**
* The Case Provision storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $oCCaseProvisionStorage;
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->oCCaseProvisionStorage = $container->get('entity_type.manager')->getStorage('oc_case_provision');
$instance->dateFormatter = $container->get('date.formatter');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_provision_revision_revert_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to revert to the revision from %revision-date?', [
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_provision.version_history', ['oc_case_provision' => $this->revision->id()]);
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Revert');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return '';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL) {
$this->revision = $this->OCCaseProvisionStorage->loadRevision($oc_case_provision_revision);
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// The revision timestamp will be updated when the revision is saved. Keep
// the original one for the confirmation message.
$original_revision_timestamp = $this->revision->getRevisionCreationTime();
$this->revision = $this->prepareRevertedRevision($this->revision, $form_state);
$this->revision->revision_log = $this->t('Copy of the revision from %date.', [
'%date' => $this->dateFormatter->format($original_revision_timestamp),
]);
$this->revision->save();
$this->logger('content')->notice('Case Provision: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$this->messenger()->addMessage(t('Case Provision %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
$form_state->setRedirect(
'entity.oc_case_provision.version_history',
['oc_case_provision' => $this->revision->id()]
);
}
/**
* Prepares a revision to be reverted.
*
* @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $revision
* The revision to be reverted.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface
* The prepared revision ready to be stored.
*/
protected function prepareRevertedRevision(OCCaseProvisionInterface $revision, FormStateInterface $form_state) {
$revision->setNewRevision();
$revision->isDefaultRevision(TRUE);
$revision->setRevisionCreationTime(REQUEST_TIME);
return $revision;
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\opencase_cases\Entity\OCCaseProvisionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a form for reverting a Case Provision revision for a single trans.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionRevisionRevertTranslationForm extends OCCaseProvisionRevisionRevertForm {
/**
* The language to be reverted.
*
* @var string
*/
protected $langcode;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->languageManager = $container->get('language_manager');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'oc_case_provision_revision_revert_translation_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to revert @language translation to the revision from %revision-date?', [
'@language' => $this->languageManager->getLanguageName($this->langcode),
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
]);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL, $langcode = NULL) {
$this->langcode = $langcode;
$form = parent::buildForm($form, $form_state, $oc_case_provision_revision);
$form['revert_untranslated_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Revert content shared among translations'),
'#default_value' => FALSE,
];
return $form;
}
/**
* {@inheritdoc}
*/
protected function prepareRevertedRevision(OCCaseProvisionInterface $revision, FormStateInterface $form_state) {
$revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields');
/** @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $default_revision */
$latest_revision = $this->OCCaseProvisionStorage->load($revision->id());
$latest_revision_translation = $latest_revision->getTranslation($this->langcode);
$revision_translation = $revision->getTranslation($this->langcode);
foreach ($latest_revision_translation->getFieldDefinitions() as $field_name => $definition) {
if ($definition->isTranslatable() || $revert_untranslated_fields) {
$latest_revision_translation->set($field_name, $revision_translation->get($field_name)->getValue());
}
}
$latest_revision_translation->setNewRevision();
$latest_revision_translation->isDefaultRevision(TRUE);
$revision->setRevisionCreationTime(REQUEST_TIME);
return $latest_revision_translation;
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCCaseProvisionSettingsForm.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'occaseprovision_settings';
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Empty implementation of the abstract submit class.
}
/**
* Defines the settings form for Case Provision entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['occaseprovision_settings']['#markup'] = 'Settings form for Case Provision entities. Manage field settings here.';
return $form;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Builds the form to delete Case Provision type entities.
*/
class OCCaseProvisionTypeDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('entity.oc_case_provision_type.collection');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
$this->messenger()->addMessage(
$this->t('content @type: deleted @label.', [
'@type' => $this->entity->bundle(),
'@label' => $this->entity->label(),
])
);
$form_state->setRedirectUrl($this->getCancelUrl());
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace Drupal\opencase_cases\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCCaseProvisionTypeForm.
*/
class OCCaseProvisionTypeForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$oc_case_provision_type = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $oc_case_provision_type->label(),
'#description' => $this->t("Label for the Case Provision type."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $oc_case_provision_type->id(),
'#machine_name' => [
'exists' => '\Drupal\opencase_cases\Entity\OCCaseProvisionType::load',
],
'#disabled' => !$oc_case_provision_type->isNew(),
];
/* You will need additional form elements for your custom properties. */
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$oc_case_provision_type = $this->entity;
$status = $oc_case_provision_type->save();
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Case Provision type.', [
'%label' => $oc_case_provision_type->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Case Provision type.', [
'%label' => $oc_case_provision_type->label(),
]));
}
$form_state->setRedirectUrl($oc_case_provision_type->toUrl('collection'));
}
}

View File

@ -107,7 +107,7 @@ class OCCaseRevisionDeleteForm extends ConfirmFormBase {
$this->OCCaseStorage->deleteRevision($this->revision->getRevisionId()); $this->OCCaseStorage->deleteRevision($this->revision->getRevisionId());
$this->logger('content')->notice('Case: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); $this->logger('content')->notice('Case: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
drupal_set_message(t('Revision from %revision-date of Case %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); \Drupal::messenger()->addMessage(t('Revision from %revision-date of Case %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
$form_state->setRedirect( $form_state->setRedirect(
'entity.oc_case.canonical', 'entity.oc_case.canonical',
['oc_case' => $this->revision->id()] ['oc_case' => $this->revision->id()]

View File

@ -120,7 +120,7 @@ class OCCaseRevisionRevertForm extends ConfirmFormBase {
$this->revision->save(); $this->revision->save();
$this->logger('content')->notice('Case: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); $this->logger('content')->notice('Case: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
drupal_set_message(t('Case %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); \Drupal::messenger()->addMessage(t('Case %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
$form_state->setRedirect( $form_state->setRedirect(
'entity.oc_case.version_history', 'entity.oc_case.version_history',
['oc_case' => $this->revision->id()] ['oc_case' => $this->revision->id()]

View File

@ -38,7 +38,7 @@ class OCCaseTypeDeleteForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete(); $this->entity->delete();
drupal_set_message( \Drupal::messenger()->addMessage(
$this->t('content @type: deleted @label.', $this->t('content @type: deleted @label.',
[ [
'@type' => $this->entity->bundle(), '@type' => $this->entity->bundle(),

View File

@ -49,13 +49,13 @@ class OCCaseTypeForm extends EntityForm {
switch ($status) { switch ($status) {
case SAVED_NEW: case SAVED_NEW:
drupal_set_message($this->t('Created the %label Case type.', [ \Drupal::messenger()->addMessage($this->t('Created the %label Case type.', [
'%label' => $oc_case_type->label(), '%label' => $oc_case_type->label(),
])); ]));
break; break;
default: default:
drupal_set_message($this->t('Saved the %label Case type.', [ \Drupal::messenger()->addMessage($this->t('Saved the %label Case type.', [
'%label' => $oc_case_type->label(), '%label' => $oc_case_type->label(),
])); ]));
} }

View File

@ -32,7 +32,6 @@ class OCCaseAccessControlHandler extends EntityAccessControlHandler {
case 'update': // you can edit the case only if a) you can see it and b) you have the permission to edit cases. case 'update': // you can edit the case only if a) you can see it and b) you have the permission to edit cases.
return AccessResult::allowedIf( return AccessResult::allowedIf(
$account->hasPermission('edit case entities') $account->hasPermission('edit case entities')
&& ($account->hasPermission('view published case entities') || CaseInvolvement::userIsInvolved($account, $entity))
); );
case 'delete': // you can delete the case only if a) you can see it and b) you have the permission to delete cases. case 'delete': // you can delete the case only if a) you can see it and b) you have the permission to delete cases.
return AccessResult::allowedIf( return AccessResult::allowedIf(

View File

@ -0,0 +1,116 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Case Fee entity.
*
* @see \Drupal\opencase_cases\Entity\OCCaseFee.
*/
class OCCaseFeeAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
$permission = $this->checkOwn($entity, 'view unpublished', $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'view unpublished case fee entities');
}
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'view published case fee entities');
case 'update':
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'edit case fee entities');
case 'delete':
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'delete case fee entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add case fee entities');
}
/**
* Test for given 'own' permission.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* @param $operation
* @param \Drupal\Core\Session\AccountInterface $account
*
* @return string|null
* The permission string indicating it's allowed.
*/
protected function checkOwn(EntityInterface $entity, $operation, AccountInterface $account) {
$status = $entity->isPublished();
$uid = $entity->getOwnerId();
$is_own = $account->isAuthenticated() && $account->id() == $uid;
if (!$is_own) {
return;
}
$bundle = $entity->bundle();
$ops = [
'create' => '%bundle add own %bundle entities',
'view unpublished' => '%bundle view own unpublished %bundle entities',
'view' => '%bundle view own entities',
'update' => '%bundle edit own entities',
'delete' => '%bundle delete own entities',
];
$permission = strtr($ops[$operation], ['%bundle' => $bundle]);
if ($operation === 'view unpublished') {
if (!$status && $account->hasPermission($permission)) {
return $permission;
}
else {
return NULL;
}
}
if ($account->hasPermission($permission)) {
return $permission;
}
return NULL;
}
}

View File

@ -0,0 +1,196 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for Case Fee entities.
*
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCCaseFeeHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($history_route = $this->getHistoryRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.version_history", $history_route);
}
if ($revision_route = $this->getRevisionRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision", $revision_route);
}
if ($revert_route = $this->getRevisionRevertRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision_revert", $revert_route);
}
if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision_delete", $delete_route);
}
if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) {
$collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route);
}
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* Gets the version history route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getHistoryRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('version-history')) {
$route = new Route($entity_type->getLinkTemplate('version-history'));
$route
->setDefaults([
'_title' => "{$entity_type->getLabel()} revisions",
'_controller' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionOverview',
])
->setRequirement('_permission', 'view all case fee revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision')) {
$route = new Route($entity_type->getLinkTemplate('revision'));
$route
->setDefaults([
'_controller' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionShow',
'_title_callback' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionPageTitle',
])
->setRequirement('_permission', 'view all case fee revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision revert route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionRevertRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision_revert')) {
$route = new Route($entity_type->getLinkTemplate('revision_revert'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionRevertForm',
'_title' => 'Revert to earlier revision',
])
->setRequirement('_permission', 'revert all case fee revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision delete route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionDeleteRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision_delete')) {
$route = new Route($entity_type->getLinkTemplate('revision_delete'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionDeleteForm',
'_title' => 'Delete earlier revision',
])
->setRequirement('_permission', 'delete all case fee revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision translation revert route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionTranslationRevertRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('translation_revert')) {
$route = new Route($entity_type->getLinkTemplate('translation_revert'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionRevertTranslationForm',
'_title' => 'Revert to earlier revision of a translation',
])
->setRequirement('_permission', 'revert all case fee revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the settings form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getSettingsFormRoute(EntityTypeInterface $entity_type) {
if (!$entity_type->getBundleEntityType()) {
$route = new Route("/admin/structure/{$entity_type->id()}/settings");
$route
->setDefaults([
'_form' => 'Drupal\opencase_cases\Form\OCCaseFeeSettingsForm',
'_title' => "{$entity_type->getLabel()} settings",
])
->setRequirement('_permission', $entity_type->getAdminPermission())
->setOption('_admin_route', TRUE);
return $route;
}
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of Case Fee entities.
*
* @ingroup opencase_cases
*/
class OCCaseFeeListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('Case Fee ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var \Drupal\opencase_cases\Entity\OCCaseFee $entity */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.oc_case_fee.edit_form',
['oc_case_fee' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\opencase_cases\Entity\OCCaseFee;
/**
* Provides dynamic permissions for Case Fee of different types.
*
* @ingroup opencase_cases
*
*/
class OCCaseFeePermissions{
use StringTranslationTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The OCCaseFee by bundle permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function generatePermissions() {
$perms = [];
foreach (OCCaseFee::loadMultiple() as $type) {
$perms += $this->buildPermissions($type);
}
return $perms;
}
/**
* Returns a list of node permissions for a given node type.
*
* @param \Drupal\opencase_cases\Entity\OCCaseFee $type
* The OCCaseFee type.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(OCCaseFee $type) {
$type_id = $type->id();
$type_params = ['%type_name' => $type->label()];
return [
"$type_id create entities" => [
'title' => $this->t('Create new %type_name entities', $type_params),
],
"$type_id edit own entities" => [
'title' => $this->t('Edit own %type_name entities', $type_params),
],
"$type_id edit any entities" => [
'title' => $this->t('Edit any %type_name entities', $type_params),
],
"$type_id delete own entities" => [
'title' => $this->t('Delete own %type_name entities', $type_params),
],
"$type_id delete any entities" => [
'title' => $this->t('Delete any %type_name entities', $type_params),
],
"$type_id view revisions" => [
'title' => $this->t('View %type_name revisions', $type_params),
'description' => t('To view a revision, you also need permission to view the entity item.'),
],
"$type_id revert revisions" => [
'title' => $this->t('Revert %type_name revisions', $type_params),
'description' => t('To revert a revision, you also need permission to edit the entity item.'),
],
"$type_id delete revisions" => [
'title' => $this->t('Delete %type_name revisions', $type_params),
'description' => $this->t('To delete a revision, you also need permission to delete the entity item.'),
],
];
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\opencase_cases\Entity\OCCaseFeeInterface;
/**
* Defines the storage handler class for Case Fee entities.
*
* This extends the base storage class, adding required special handling for
* Case Fee entities.
*
* @ingroup opencase_cases
*/
class OCCaseFeeStorage extends SqlContentEntityStorage implements OCCaseFeeStorageInterface {
/**
* {@inheritdoc}
*/
public function revisionIds(OCCaseFeeInterface $entity) {
return $this->database->query(
'SELECT vid FROM {oc_case_fee_revision} WHERE id=:id ORDER BY vid',
[':id' => $entity->id()]
)->fetchCol();
}
/**
* {@inheritdoc}
*/
public function userRevisionIds(AccountInterface $account) {
return $this->database->query(
'SELECT vid FROM {oc_case_fee_field_revision} WHERE uid = :uid ORDER BY vid',
[':uid' => $account->id()]
)->fetchCol();
}
/**
* {@inheritdoc}
*/
public function countDefaultLanguageRevisions(OCCaseFeeInterface $entity) {
return $this->database->query('SELECT COUNT(*) FROM {oc_case_fee_field_revision} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()])
->fetchField();
}
/**
* {@inheritdoc}
*/
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database->update('oc_case_fee_revision')
->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
->condition('langcode', $language->getId())
->execute();
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\opencase_cases\Entity\OCCaseFeeInterface;
/**
* Defines the storage handler class for Case Fee entities.
*
* This extends the base storage class, adding required special handling for
* Case Fee entities.
*
* @ingroup opencase_cases
*/
interface OCCaseFeeStorageInterface extends ContentEntityStorageInterface {
/**
* Gets a list of Case Fee revision IDs for a specific Case Fee.
*
* @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity
* The Case Fee entity.
*
* @return int[]
* Case Fee revision IDs (in ascending order).
*/
public function revisionIds(OCCaseFeeInterface $entity);
/**
* Gets a list of revision IDs having a given user as Case Fee author.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The user entity.
*
* @return int[]
* Case Fee revision IDs (in ascending order).
*/
public function userRevisionIds(AccountInterface $account);
/**
* Counts the number of revisions in the default language.
*
* @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity
* The Case Fee entity.
*
* @return int
* The number of revisions in the default language.
*/
public function countDefaultLanguageRevisions(OCCaseFeeInterface $entity);
/**
* Unsets the language for all Case Fee with the given language.
*
* @param \Drupal\Core\Language\LanguageInterface $language
* The language object.
*/
public function clearRevisionsLanguage(LanguageInterface $language);
}

View File

@ -0,0 +1,13 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\content_translation\ContentTranslationHandler;
/**
* Defines the translation handler for oc_case_fee.
*/
class OCCaseFeeTranslationHandler extends ContentTranslationHandler {
// Override here the needed methods from ContentTranslationHandler.
}

View File

@ -0,0 +1,26 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
/**
* Provides routes for Case Fee type entities.
*
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCCaseFeeTypeHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
// Provide your custom entity routes here.
return $collection;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a listing of Case Fee type entities.
*/
class OCCaseFeeTypeListBuilder extends ConfigEntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = $this->t('Case Fee type');
$header['id'] = $this->t('Machine name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
$row['id'] = $entity->id();
// You probably want a few more properties here...
return $row + parent::buildRow($entity);
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Case Provision entity.
*
* @see \Drupal\opencase_cases\Entity\OCCaseProvision.
*/
class OCCaseProvisionAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
$permission = $this->checkOwn($entity, 'view unpublished', $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'view unpublished case provision entities');
}
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'view published case provision entities');
case 'update':
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'edit case provision entities');
case 'delete':
$permission = $this->checkOwn($entity, $operation, $account);
if (!empty($permission)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($account, 'delete case provision entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add case provision entities');
}
/**
* Test for given 'own' permission.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* @param $operation
* @param \Drupal\Core\Session\AccountInterface $account
*
* @return string|null
* The permission string indicating it's allowed.
*/
protected function checkOwn(EntityInterface $entity, $operation, AccountInterface $account) {
$status = $entity->isPublished();
$uid = $entity->getOwnerId();
$is_own = $account->isAuthenticated() && $account->id() == $uid;
if (!$is_own) {
return;
}
$bundle = $entity->bundle();
$ops = [
'create' => '%bundle add own %bundle entities',
'view unpublished' => '%bundle view own unpublished %bundle entities',
'view' => '%bundle view own entities',
'update' => '%bundle edit own entities',
'delete' => '%bundle delete own entities',
];
$permission = strtr($ops[$operation], ['%bundle' => $bundle]);
if ($operation === 'view unpublished') {
if (!$status && $account->hasPermission($permission)) {
return $permission;
}
else {
return NULL;
}
}
if ($account->hasPermission($permission)) {
return $permission;
}
return NULL;
}
}

View File

@ -0,0 +1,196 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for Case Provision entities.
*
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCCaseProvisionHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($history_route = $this->getHistoryRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.version_history", $history_route);
}
if ($revision_route = $this->getRevisionRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision", $revision_route);
}
if ($revert_route = $this->getRevisionRevertRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision_revert", $revert_route);
}
if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) {
$collection->add("entity.{$entity_type_id}.revision_delete", $delete_route);
}
if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) {
$collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route);
}
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* Gets the version history route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getHistoryRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('version-history')) {
$route = new Route($entity_type->getLinkTemplate('version-history'));
$route
->setDefaults([
'_title' => "{$entity_type->getLabel()} revisions",
'_controller' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionOverview',
])
->setRequirement('_permission', 'view all case provision revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision')) {
$route = new Route($entity_type->getLinkTemplate('revision'));
$route
->setDefaults([
'_controller' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionShow',
'_title_callback' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionPageTitle',
])
->setRequirement('_permission', 'view all case provision revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision revert route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionRevertRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision_revert')) {
$route = new Route($entity_type->getLinkTemplate('revision_revert'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionRevertForm',
'_title' => 'Revert to earlier revision',
])
->setRequirement('_permission', 'revert all case provision revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision delete route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionDeleteRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('revision_delete')) {
$route = new Route($entity_type->getLinkTemplate('revision_delete'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionDeleteForm',
'_title' => 'Delete earlier revision',
])
->setRequirement('_permission', 'delete all case provision revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the revision translation revert route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionTranslationRevertRoute(EntityTypeInterface $entity_type) {
if ($entity_type->hasLinkTemplate('translation_revert')) {
$route = new Route($entity_type->getLinkTemplate('translation_revert'));
$route
->setDefaults([
'_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionRevertTranslationForm',
'_title' => 'Revert to earlier revision of a translation',
])
->setRequirement('_permission', 'revert all case provision revisions')
->setOption('_admin_route', TRUE);
return $route;
}
}
/**
* Gets the settings form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getSettingsFormRoute(EntityTypeInterface $entity_type) {
if (!$entity_type->getBundleEntityType()) {
$route = new Route("/admin/structure/{$entity_type->id()}/settings");
$route
->setDefaults([
'_form' => 'Drupal\opencase_cases\Form\OCCaseProvisionSettingsForm',
'_title' => "{$entity_type->getLabel()} settings",
])
->setRequirement('_permission', $entity_type->getAdminPermission())
->setOption('_admin_route', TRUE);
return $route;
}
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of Case Provision entities.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('Case Provision ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var \Drupal\opencase_cases\Entity\OCCaseProvision $entity */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.oc_case_provision.edit_form',
['oc_case_provision' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\opencase_cases\Entity\OCCaseProvision;
/**
* Provides dynamic permissions for Case Provision of different types.
*
* @ingroup opencase_cases
*
*/
class OCCaseProvisionPermissions{
use StringTranslationTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The OCCaseProvision by bundle permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function generatePermissions() {
$perms = [];
foreach (OCCaseProvision::loadMultiple() as $type) {
$perms += $this->buildPermissions($type);
}
return $perms;
}
/**
* Returns a list of node permissions for a given node type.
*
* @param \Drupal\opencase_cases\Entity\OCCaseProvision $type
* The OCCaseProvision type.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(OCCaseProvision $type) {
$type_id = $type->id();
$type_params = ['%type_name' => $type->label()];
return [
"$type_id create entities" => [
'title' => $this->t('Create new %type_name entities', $type_params),
],
"$type_id edit own entities" => [
'title' => $this->t('Edit own %type_name entities', $type_params),
],
"$type_id edit any entities" => [
'title' => $this->t('Edit any %type_name entities', $type_params),
],
"$type_id delete own entities" => [
'title' => $this->t('Delete own %type_name entities', $type_params),
],
"$type_id delete any entities" => [
'title' => $this->t('Delete any %type_name entities', $type_params),
],
"$type_id view revisions" => [
'title' => $this->t('View %type_name revisions', $type_params),
'description' => t('To view a revision, you also need permission to view the entity item.'),
],
"$type_id revert revisions" => [
'title' => $this->t('Revert %type_name revisions', $type_params),
'description' => t('To revert a revision, you also need permission to edit the entity item.'),
],
"$type_id delete revisions" => [
'title' => $this->t('Delete %type_name revisions', $type_params),
'description' => $this->t('To delete a revision, you also need permission to delete the entity item.'),
],
];
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\opencase_cases\Entity\OCCaseProvisionInterface;
/**
* Defines the storage handler class for Case Provision entities.
*
* This extends the base storage class, adding required special handling for
* Case Provision entities.
*
* @ingroup opencase_cases
*/
class OCCaseProvisionStorage extends SqlContentEntityStorage implements OCCaseProvisionStorageInterface {
/**
* {@inheritdoc}
*/
public function revisionIds(OCCaseProvisionInterface $entity) {
return $this->database->query(
'SELECT vid FROM {oc_case_provision_revision} WHERE id=:id ORDER BY vid',
[':id' => $entity->id()]
)->fetchCol();
}
/**
* {@inheritdoc}
*/
public function userRevisionIds(AccountInterface $account) {
return $this->database->query(
'SELECT vid FROM {oc_case_provision_field_revision} WHERE uid = :uid ORDER BY vid',
[':uid' => $account->id()]
)->fetchCol();
}
/**
* {@inheritdoc}
*/
public function countDefaultLanguageRevisions(OCCaseProvisionInterface $entity) {
return $this->database->query('SELECT COUNT(*) FROM {oc_case_provision_field_revision} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()])
->fetchField();
}
/**
* {@inheritdoc}
*/
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database->update('oc_case_provision_revision')
->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
->condition('langcode', $language->getId())
->execute();
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\opencase_cases\Entity\OCCaseProvisionInterface;
/**
* Defines the storage handler class for Case Provision entities.
*
* This extends the base storage class, adding required special handling for
* Case Provision entities.
*
* @ingroup opencase_cases
*/
interface OCCaseProvisionStorageInterface extends ContentEntityStorageInterface {
/**
* Gets a list of Case Provision revision IDs for a specific Case Provision.
*
* @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity
* The Case Provision entity.
*
* @return int[]
* Case Provision revision IDs (in ascending order).
*/
public function revisionIds(OCCaseProvisionInterface $entity);
/**
* Gets a list of revision IDs having a given user as Case Provision author.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The user entity.
*
* @return int[]
* Case Provision revision IDs (in ascending order).
*/
public function userRevisionIds(AccountInterface $account);
/**
* Counts the number of revisions in the default language.
*
* @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity
* The Case Provision entity.
*
* @return int
* The number of revisions in the default language.
*/
public function countDefaultLanguageRevisions(OCCaseProvisionInterface $entity);
/**
* Unsets the language for all Case Provision with the given language.
*
* @param \Drupal\Core\Language\LanguageInterface $language
* The language object.
*/
public function clearRevisionsLanguage(LanguageInterface $language);
}

View File

@ -0,0 +1,13 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\content_translation\ContentTranslationHandler;
/**
* Defines the translation handler for oc_case_provision.
*/
class OCCaseProvisionTranslationHandler extends ContentTranslationHandler {
// Override here the needed methods from ContentTranslationHandler.
}

View File

@ -0,0 +1,26 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
/**
* Provides routes for Case Provision type entities.
*
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCCaseProvisionTypeHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
// Provide your custom entity routes here.
return $collection;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Drupal\opencase_cases;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a listing of Case Provision type entities.
*/
class OCCaseProvisionTypeListBuilder extends ConfigEntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = $this->t('Case Provision type');
$header['id'] = $this->t('Machine name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
$row['id'] = $entity->id();
// You probably want a few more properties here...
return $row + parent::buildRow($entity);
}
}

View File

@ -9,15 +9,15 @@
* - link: A link to add a content entity of this type. * - link: A link to add a content entity of this type.
* - description: A description of this content entity types/bundle. * - description: A description of this content entity types/bundle.
* *
* @see template_preprocess_oc_case_content_add_list() * @see template_preprocess_oc_activity_content_add_list()
* *
* @ingroup themeable * @ingroup themeable
*/ */
#} #}
{% spaceless %} {% spaceless %}
<dl> <dl>
{% for type in types %} {% for id,type in bundles %}
<dt>{{ type.link }}</dt> <dt><a href="/opencase/oc_case/add/{{ id }}?client_id={{ client_id }}">{{ type.label }}</a></dt>
{% endfor %} {% endfor %}
</dl> </dl>
{% endspaceless %} {% endspaceless %}

View File

@ -0,0 +1,23 @@
{#
/**
* @file
* Default theme implementation to present a list of custom content entity types/bundles.
*
* Available variables:
* - types: A collection of all the available custom entity types/bundles.
* Each type/bundle contains the following:
* - link: A link to add a content entity of this type.
* - description: A description of this content entity types/bundle.
*
* @see template_preprocess_oc_case_fee_content_add_list()
*
* @ingroup themeable
*/
#}
{% spaceless %}
<dl>
{% for type in types %}
<dt>{{ type.link }}</dt>
{% endfor %}
</dl>
{% endspaceless %}

View File

@ -0,0 +1,23 @@
{#
/**
* @file
* Default theme implementation to present a list of custom content entity types/bundles.
*
* Available variables:
* - types: A collection of all the available custom entity types/bundles.
* Each type/bundle contains the following:
* - link: A link to add a content entity of this type.
* - description: A description of this content entity types/bundle.
*
* @see template_preprocess_oc_case_provision_content_add_list()
*
* @ingroup themeable
*/
#}
{% spaceless %}
<dl>
{% for type in types %}
<dt>{{ type.link }}</dt>
{% endfor %}
</dl>
{% endspaceless %}

View File

@ -16,18 +16,7 @@
*/ */
#} #}
<div{{ attributes.addClass('oc_case') }}> <div{{ attributes.addClass('oc_case') }}>
<h2>{{ title }}</h2> {% if content %}
<div class="oc_entity"> {{- content -}}
<div class="left"> {% endif %}
{{ base_fields.actors_involved }}
{{ base_fields.changed }}
{{ base_fields.created }}
{{ base_fields.user_id }}
</div>
<div class="right">
{% for field in other_fields %}
{{ field }}
{% endfor %}
</div>
</div>
</div> </div>

View File

@ -0,0 +1,22 @@
{#
/**
* @file oc_case_fee.html.twig
* Default theme implementation to present Case Fee data.
*
* This template is used when viewing Case Fee pages.
*
*
* Available variables:
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
*
* @see template_preprocess_oc_case_fee()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('oc_case_fee') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>

View File

@ -0,0 +1,22 @@
{#
/**
* @file oc_case_provision.html.twig
* Default theme implementation to present Case Provision data.
*
* This template is used when viewing Case Provision pages.
*
*
* Available variables:
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
*
* @see template_preprocess_oc_case_provision()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('oc_case_provision') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.asylum_status
module:
- facets
- system
theme:
- bartik
id: facet_asylum_status
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:asylum_status'
settings:
id: 'facet_block:asylum_status'
label: 'Asylum Status'
provider: facets
label_display: visible
block_id: facet_asylum_status
visibility:
request_path:
id: request_path
pages: '/opencase/reporting/clients'
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.created
module:
- facets
- system
theme:
- bartik
id: facet_created
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:created'
settings:
id: 'facet_block:created'
label: 'Created Date'
provider: facets
label_display: visible
block_id: facet_created
visibility:
request_path:
id: request_path
pages: '/opencase/reporting/clients'
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.disability
module:
- facets
- system
theme:
- bartik
id: facet_disability
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:disability'
settings:
id: 'facet_block:disability'
label: 'Disability'
provider: facets
label_display: visible
block_id: facet_disability
visibility:
request_path:
id: request_path
pages: '/opencase/reporting/clients'
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.gender_identified_with
module:
- facets
- system
theme:
- bartik
id: facet_gender_identified_with
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:gender_identified_with'
settings:
id: 'facet_block:gender_identified_with'
label: 'Gender Identity'
provider: facets
label_display: visible
block_id: facet_gender_identified_with
visibility:
request_path:
id: request_path
pages: '/opencase/reporting/clients'
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.languages
module:
- facets
- system
theme:
- bartik
id: facet_languages
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:languages'
settings:
id: 'facet_block:languages'
label: 'Languages'
provider: facets
label_display: visible
block_id: facet_languages
visibility:
request_path:
id: request_path
pages: '/opencase/reporting/clients'
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.involved_parties
module:
- facets
- system
theme:
- bartik
id: involvedparties
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:involved_parties'
settings:
id: 'facet_block:involved_parties'
label: 'Involved Parties'
provider: facets
label_display: visible
block_id: involvedparties
visibility:
request_path:
id: request_path
pages: /opencase/reporting/cases
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.nationalities
module:
- facets
- system
theme:
- bartik
id: nationalities
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:nationalities'
settings:
id: 'facet_block:nationalities'
label: Nationalities
provider: facets
label_display: visible
block_id: nationalities
visibility:
request_path:
id: request_path
pages: /opencase/reporting/clients
negate: false
context_mapping: { }

View File

@ -1,28 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.osic_level
module:
- facets
- system
theme:
- bartik
id: osiclevel
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:osic_level'
settings:
id: 'facet_block:osic_level'
label: 'OSIC level'
provider: facets
label_display: visible
block_id: osiclevel
visibility:
request_path:
id: request_path
pages: /opencase/reporting/volunteers
negate: false
context_mapping: { }

View File

@ -1,29 +0,0 @@
langcode: en
status: true
dependencies:
config:
- facets.facet.outcome
module:
- facets
- system
theme:
- bartik
id: outcome
theme: bartik
region: sidebar_second
weight: 0
provider: null
plugin: 'facet_block:outcome'
settings:
id: 'facet_block:outcome'
label: Outcome
provider: facets
label_display: visible
block_id: outcome
visibility:
request_path:
id: request_path
pages: /opencase/reporting/cases
negate: false
context_mapping: { }

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: asylum_status
name: 'Asylum status'
url_alias: asylum_status
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_asylum_status
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: asylum_status_export
name: 'Asylum status'
url_alias: asylum_status
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_asylum_status
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,67 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: created
name: Created
url_alias: created
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: created
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: true
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: -8
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: -9
settings:
sort: DESC
date_item:
processor_id: date_item
weights:
build: 35
settings:
date_display: actual_date
granularity: 5
date_format: ''
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: -10
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,67 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
module:
- views_data_export
id: created_export
name: 'Created - Export'
url_alias: created
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: created
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: checkbox
config:
show_numbers: true
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: 20
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: 30
settings:
sort: DESC
date_item:
processor_id: date_item
weights:
build: 35
settings:
date_display: actual_date
granularity: 5
date_format: ''
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: disability
name: 'Disability'
url_alias: disability
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_disability
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: disability_export
name: 'Disability'
url_alias: disability
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_disability
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: gender_identified_with
name: 'Gender Identity'
url_alias: gender_identified_with
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_gender_identified_with
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: gender_identified_with_export
name: 'Gender Identity'
url_alias: gender_identified_with
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_gender_identified_with
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,62 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_cases
- views.view.reporting_cases
module:
- search_api
id: involved_parties
name: 'Involved Parties'
url_alias: involved_parties
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: actors_involved
facet_source_id: 'search_api:views_page__reporting_cases__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
show_reset_link: false
reset_text: 'Show all'
hide_reset_when_no_selection: false
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
exclude_specified_items:
processor_id: exclude_specified_items
weights:
build: 50
settings:
exclude: client
regex: true
translate_entity:
processor_id: translate_entity
weights:
build: 5
settings: { }
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,55 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_cases
- views.view.reporting_cases
module:
- search_api
id: involved_parties_export
name: 'Involved Parties (Export)'
url_alias: involved_parties
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: actors_involved
facet_source_id: 'search_api:views_data_export__reporting_cases__data_export_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
show_reset_link: false
reset_text: 'Show all'
hide_reset_when_no_selection: false
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
translate_entity:
processor_id: translate_entity
weights:
build: 5
settings: { }
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: languages
name: 'Languages'
url_alias: languages
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_languages_spoken
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: languages_export
name: 'Languages'
url_alias: languages
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_languages_spoken
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
- views.view.reporting_clients
module:
- search_api
id: nationalities
name: Nationalities
url_alias: nationalities
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_nationalities
facet_source_id: 'search_api:views_page__reporting_clients__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,58 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_clients
module:
- views_data_export
id: nationalities_export
name: Nationalities-export
url_alias: nationalities_export
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_nationalities
facet_source_id: 'search_api:views_data_export__reporting_clients__data_export_1'
widget:
type: links
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
active_widget_order:
processor_id: active_widget_order
weights:
sort: 20
settings:
sort: DESC
count_widget_order:
processor_id: count_widget_order
weights:
sort: 30
settings:
sort: DESC
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

View File

@ -1,47 +0,0 @@
langcode: en
status: true
dependencies:
config:
- search_api.index.opencase_reporting_volunteers
- views.view.reporting_volunteers
module:
- search_api
id: osic_level
name: 'OSIC level'
url_alias: osic_level
weight: 0
min_count: 0
show_only_one_result: false
field_identifier: field_osic_level
facet_source_id: 'search_api:views_page__reporting_volunteers__page_1'
widget:
type: checkbox
config:
show_numbers: false
soft_limit: 0
soft_limit_settings:
show_less_label: 'Show less'
show_more_label: 'Show more'
query_operator: or
use_hierarchy: false
expand_hierarchy: false
enable_parent_when_child_gets_disabled: true
hard_limit: 0
exclude: false
only_visible_when_facet_source_is_visible: true
processor_configs:
display_value_widget_order:
processor_id: display_value_widget_order
weights:
sort: 40
settings:
sort: ASC
url_processor_handler:
processor_id: url_processor_handler
weights:
pre_query: 50
build: 15
settings: { }
empty_behavior:
behavior: none
show_title: false

Some files were not shown because too many files have changed in this diff Show More