Compare commits
6 Commits
801c69fa06
...
95bb467d76
Author | SHA1 | Date | |
---|---|---|---|
95bb467d76 | |||
ccbac9473b | |||
07683cd1b8 | |||
2b4b9696db | |||
03c826087a | |||
c47e4b7b22 |
@ -1,30 +0,0 @@
|
||||
uuid: 14120f1a-9009-4ed1-858a-875d748f93fe
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- views.view.activities
|
||||
module:
|
||||
- route_condition
|
||||
- views
|
||||
theme:
|
||||
- bartik
|
||||
id: views_block__activities_block_1
|
||||
theme: bartik
|
||||
region: content
|
||||
weight: 0
|
||||
provider: null
|
||||
plugin: 'views_block:activities-block_1'
|
||||
settings:
|
||||
id: 'views_block:activities-block_1'
|
||||
label: ''
|
||||
label_display: visible
|
||||
provider: views
|
||||
context_mapping: { }
|
||||
views_label: ''
|
||||
items_per_page: none
|
||||
visibility:
|
||||
route:
|
||||
id: route
|
||||
negate: false
|
||||
routes: entity.oc_actor.canonical
|
@ -18,10 +18,12 @@ dependencies:
|
||||
- field.field.oc_actor.client.field_nationalities
|
||||
- field.field.oc_actor.client.field_referred_by
|
||||
- field.field.oc_actor.client.field_sex
|
||||
- field.field.oc_actor.client.field_status
|
||||
- opencase_entities.oc_actor_type.client
|
||||
module:
|
||||
- datetime
|
||||
- file
|
||||
- hide_revision_field
|
||||
_core:
|
||||
default_config_hash: 90BCsdjSFMMiSp2Da3WhMM2sOUliF433LfErYxVCrgk
|
||||
id: oc_actor.client.default
|
||||
@ -140,6 +142,16 @@ content:
|
||||
size: 60
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
field_status:
|
||||
type: entity_reference_autocomplete
|
||||
weight: 81
|
||||
region: content
|
||||
settings:
|
||||
match_operator: CONTAINS
|
||||
match_limit: 10
|
||||
size: 60
|
||||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
first_name:
|
||||
type: string_textfield
|
||||
weight: 0
|
||||
|
@ -18,6 +18,7 @@ dependencies:
|
||||
- field.field.oc_actor.client.field_nationalities
|
||||
- field.field.oc_actor.client.field_referred_by
|
||||
- field.field.oc_actor.client.field_sex
|
||||
- field.field.oc_actor.client.field_status
|
||||
- opencase_entities.oc_actor_type.client
|
||||
module:
|
||||
- datetime
|
||||
@ -154,6 +155,14 @@ content:
|
||||
third_party_settings: { }
|
||||
weight: 16
|
||||
region: content
|
||||
field_status:
|
||||
type: entity_reference_label
|
||||
label: above
|
||||
settings:
|
||||
link: true
|
||||
third_party_settings: { }
|
||||
weight: 20
|
||||
region: content
|
||||
name:
|
||||
type: string
|
||||
label: above
|
||||
@ -200,4 +209,5 @@ hidden:
|
||||
middle_names: true
|
||||
search_api_excerpt: true
|
||||
status: true
|
||||
total_cases: true
|
||||
user_id: true
|
||||
|
@ -0,0 +1,44 @@
|
||||
uuid: 2df09597-78e1-4410-82a4-a49dd00349c2
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- user.role.authenticated
|
||||
module:
|
||||
- datetime
|
||||
- opencase_entities
|
||||
- user
|
||||
id: oc_actor.client.activities
|
||||
label: Activities
|
||||
display_label: true
|
||||
name: activities
|
||||
description: ''
|
||||
base_entity_type_id: oc_actor
|
||||
base_bundle_type_id: client
|
||||
field_type_id: views
|
||||
field_type_config:
|
||||
view_name: activities
|
||||
display: block_1
|
||||
arguments: ''
|
||||
field_type_condition:
|
||||
'entity_bundle:oc_actor':
|
||||
id: 'entity_bundle:oc_actor'
|
||||
negate: false
|
||||
context_mapping:
|
||||
oc_actor: entity_extra_field.target_entity
|
||||
bundles: { }
|
||||
route:
|
||||
id: route
|
||||
negate: false
|
||||
routes: ''
|
||||
request_path:
|
||||
id: request_path
|
||||
negate: false
|
||||
pages: ''
|
||||
current_theme:
|
||||
id: current_theme
|
||||
theme: ''
|
||||
negate: 0
|
||||
field_conditions_all_pass: false
|
||||
display:
|
||||
type: view
|
@ -0,0 +1,44 @@
|
||||
uuid: c5f2c484-212c-4b18-ad10-60cbca03029f
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- system.menu.opencase
|
||||
- user.role.authenticated
|
||||
module:
|
||||
- opencase_cases
|
||||
- user
|
||||
id: oc_actor.client.cases
|
||||
label: Cases
|
||||
display_label: true
|
||||
name: cases
|
||||
description: ''
|
||||
base_entity_type_id: oc_actor
|
||||
base_bundle_type_id: client
|
||||
field_type_id: views
|
||||
field_type_config:
|
||||
view_name: cases
|
||||
display: block_1
|
||||
arguments: ''
|
||||
field_type_condition:
|
||||
'entity_bundle:oc_actor':
|
||||
id: 'entity_bundle:oc_actor'
|
||||
negate: false
|
||||
context_mapping:
|
||||
oc_actor: entity_extra_field.target_entity
|
||||
bundles: { }
|
||||
route:
|
||||
id: route
|
||||
negate: false
|
||||
routes: ''
|
||||
request_path:
|
||||
id: request_path
|
||||
negate: false
|
||||
pages: ''
|
||||
current_theme:
|
||||
id: current_theme
|
||||
theme: ''
|
||||
negate: 0
|
||||
field_conditions_all_pass: false
|
||||
display:
|
||||
type: view
|
21
config/optional/field.field.oc_actor.client.field_status.yml
Normal file
21
config/optional/field.field.oc_actor.client.field_status.yml
Normal file
@ -0,0 +1,21 @@
|
||||
uuid: 00fcbe97-883d-496c-b22e-fa9bce157a1d
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.oc_actor.field_status
|
||||
- opencase_entities.oc_actor_type.client
|
||||
id: oc_actor.client.field_status
|
||||
field_name: field_status
|
||||
entity_type: oc_actor
|
||||
bundle: client
|
||||
label: Status
|
||||
description: ''
|
||||
required: false
|
||||
translatable: false
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings:
|
||||
handler: 'default:taxonomy_term'
|
||||
handler_settings: { }
|
||||
field_type: entity_reference
|
20
config/optional/field.storage.oc_actor.field_status.yml
Normal file
20
config/optional/field.storage.oc_actor.field_status.yml
Normal file
@ -0,0 +1,20 @@
|
||||
uuid: cde29136-624d-46a0-8199-820f26cd23fd
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- opencase_entities
|
||||
- taxonomy
|
||||
id: oc_actor.field_status
|
||||
field_name: field_status
|
||||
entity_type: oc_actor
|
||||
type: entity_reference
|
||||
settings:
|
||||
target_type: taxonomy_term
|
||||
module: core
|
||||
locked: false
|
||||
cardinality: 1
|
||||
translatable: true
|
||||
indexes: { }
|
||||
persist_with_no_fields: false
|
||||
custom_storage: false
|
8
config/optional/taxonomy.vocabulary.client_statuses.yml
Normal file
8
config/optional/taxonomy.vocabulary.client_statuses.yml
Normal file
@ -0,0 +1,8 @@
|
||||
uuid: ba139c72-00f4-44d1-be2d-f8ada5aef0c1
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
name: 'Client statuses'
|
||||
vid: client_statuses
|
||||
description: ''
|
||||
weight: 0
|
@ -36,7 +36,7 @@ class OCCaseForm extends ContentEntityForm {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
public function save(array $form, FormStateInterface $form_state): void {
|
||||
$entity = $this->entity;
|
||||
$entity->setNewRevision();
|
||||
$entity->setRevisionCreationTime(REQUEST_TIME);
|
||||
@ -57,7 +57,7 @@ class OCCaseForm extends ContentEntityForm {
|
||||
]));
|
||||
}
|
||||
// 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')) {
|
||||
if (!$this->isPublished($form_state) && !\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(),
|
||||
]));
|
||||
@ -67,4 +67,12 @@ class OCCaseForm extends ContentEntityForm {
|
||||
}
|
||||
}
|
||||
|
||||
private function isPublished(FormStateInterface $form_state): bool {
|
||||
if (is_null($form_state->getValue('status'))) {
|
||||
return false; // some entities have nothing set for the status in which case we want to treat them as published by default.
|
||||
// TODO why don't they??
|
||||
}
|
||||
return $form_state->getValue('status')['value'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_cases\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a Block for adding a case for the current client
|
||||
*
|
||||
* @Block(
|
||||
* id = "add_case",
|
||||
* admin_label = @Translation("Add Case"),
|
||||
* category = @Translation("Opencase"),
|
||||
* )
|
||||
*/
|
||||
class AddCase extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build():array {
|
||||
$target_id = \Drupal::routeMatch()->getParameter('oc_actor')->id();
|
||||
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_case');
|
||||
$markup = "<ul>";
|
||||
foreach($case_types as $id => $info) {
|
||||
$label = $info['label'];
|
||||
$markup .= "<li><a href='/opencase/oc_case/add/$id?target_id=$target_id'>$label</a></li>";
|
||||
}
|
||||
$markup .= "</ul>";
|
||||
return array(
|
||||
'#markup' => $markup
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getCacheMaxAge():int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -177,17 +177,42 @@ function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefini
|
||||
}
|
||||
|
||||
/*
|
||||
Implementation of hook_relevant_activity_type_ids which is a custom hook invoked in the AddActivity block.
|
||||
Custom hook
|
||||
*/
|
||||
function opencase_relevant_activity_type_ids($actorTypeID) {
|
||||
switch ($actorTypeID) {
|
||||
case 'volunteer':
|
||||
return ['email', 'phone_call', 'supervision'];
|
||||
case 'client':
|
||||
return ['email', 'lete', 'phone_call', 'case_note', 'destitution_funds_provided', 'research', 'application'];
|
||||
case 'staff_member':
|
||||
return ['application', 'interview'];
|
||||
function opencase_relevant_case_type_ids(string $bundle):array {
|
||||
switch ($bundle) {
|
||||
case 'client':
|
||||
return ['accommodation', 'asylum_support', 'employability', 'health', 'immigration', 'welfare_rights'];
|
||||
case 'volunteer':
|
||||
return ['volunteer_engagement'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Custom hook
|
||||
*/
|
||||
function opencase_relevant_activity_type_ids(string $entityType, string $bundle):array {
|
||||
if ($entityType == 'oc_actor') {
|
||||
switch ($bundle) {
|
||||
case 'volunteer':
|
||||
return ['email', 'phone_call', 'supervision', 'application', 'interview'];
|
||||
case 'client':
|
||||
return ['email', 'lete', 'phone_call', 'case_note', 'destitution_funds_provided', 'research', 'application'];
|
||||
case 'staff_member':
|
||||
return ['application', 'interview'];
|
||||
}
|
||||
}
|
||||
if ($entityType == 'oc_case') {
|
||||
switch ($bundle) {
|
||||
case 'volunteer_engagement':
|
||||
return ['email', 'phone_call', 'supervision', 'application', 'interview'];
|
||||
default:
|
||||
return ['email', 'lete', 'phone_call', 'case_note', 'destitution_funds_provided', 'research', 'application'];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
37
resources/Client Report-24 May 2022.csv
Normal file
37
resources/Client Report-24 May 2022.csv
Normal file
@ -0,0 +1,37 @@
|
||||
Name,"Accreditation date","Client type","Client subtype","Client Status","Client substatus",Tags,"Umbrella client","Type of umbrella client",Address
|
||||
testqweqew,"03 Apr 2022","Nightlife Organisation",,Accredited,"Recently Accredited",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,test,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead","Community Project",,,
|
||||
test,,,,Lead,"New lead",,test,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,test,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
test,,,,Lead,"New lead",,,,
|
||||
testd,,,,Lead,"New lead",,,,
|
||||
Friday,"16 May 2022",,,Accredited,"Recently Accredited","Open Access Session",test,,
|
|
23
resources/Debrief Report-24 May 2022.csv
Normal file
23
resources/Debrief Report-24 May 2022.csv
Normal file
@ -0,0 +1,23 @@
|
||||
"Date submitted",Training,"Submitted by",view_oc_activity
|
||||
"12 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"11 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"17 Sep 2021",,,view
|
||||
"23 Oct 2021",,,view
|
||||
"23 Oct 2021",,,view
|
||||
"12 Nov 2021",,,view
|
||||
"12 Nov 2021",,,view
|
||||
"16 Nov 2021",,,view
|
|
@ -3,6 +3,8 @@
|
||||
namespace Drupal\opencase\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\opencase_cases\Entity\OCCase;
|
||||
use Drupal\opencase_entities\Entity\OCActor;
|
||||
|
||||
/**
|
||||
* Provides a Block with some help text about actor type fields
|
||||
@ -19,28 +21,57 @@ class AddActivity extends BlockBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build():array {
|
||||
if ($this->isOnACase()) {
|
||||
return $this->makeBlockForAddingActivityToCase();
|
||||
} elseif ($this->isOnAnActor()) {
|
||||
return $this->makeBlockForAddingActivityToActor();
|
||||
}
|
||||
return ['#markup' => 'This block should only be placed on a case or on an actor.'];
|
||||
}
|
||||
|
||||
private function makeBlockForAddingActivityToCase():array {
|
||||
$case = \Drupal::routeMatch()->getParameter('oc_case');
|
||||
$case_id = $case->id();
|
||||
$markup = "<ul>";
|
||||
$bundles = $this->getActivityBundlesFor('oc_case', $case->bundle());
|
||||
foreach($bundles as $bundle => $info) {
|
||||
$label = $info['label'];
|
||||
$markup .= "<li><a href='/opencase/oc_activity/add/$bundle?case_id=$case_id&destination=/opencase/oc_case/$case_id'>$label</a></li>";
|
||||
}
|
||||
$markup .= "</ul>";
|
||||
return array('#markup' => $markup);
|
||||
}
|
||||
private function makeBlockForAddingActivityToActor():array {
|
||||
$actor = \Drupal::routeMatch()->getParameter('oc_actor');
|
||||
$target_id = $actor->id();
|
||||
$actorType = $actor->bundle();
|
||||
$markup = "<ul>";
|
||||
$activity_types = $this->getActivityTypesToDisplay($actorType);
|
||||
foreach($activity_types as $id => $info) {
|
||||
$bundles = $this->getActivityBundlesFor('oc_actor', $actor->bundle());
|
||||
foreach($bundles as $bundle => $info) {
|
||||
$label = $info['label'];
|
||||
$markup .= "<li><a href='/opencase/oc_activity/add/$id?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
|
||||
$markup .= "<li><a href='/opencase/oc_activity/add/$bundle?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
|
||||
}
|
||||
$markup .= "</ul>";
|
||||
return array('#markup' => $markup);
|
||||
}
|
||||
|
||||
private function isOnACase():bool {
|
||||
return \Drupal::routeMatch()->getParameter('oc_case') instanceof OCCase;
|
||||
}
|
||||
|
||||
private function isOnAnActor():bool {
|
||||
return \Drupal::routeMatch()->getParameter('oc_actor') instanceof OCActor;
|
||||
}
|
||||
|
||||
|
||||
public function getCacheMaxAge():int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getActivityTypesToDisplay(string $actorType): array {
|
||||
private function getActivityBundlesFor(string $entityType, string $bundle): array {
|
||||
// Client modules will provide a list of what activity types (bundles) are relevant for each actor type.
|
||||
// Check if they are implemented, and if so display them.
|
||||
$implemented_activity_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||
$relevant_activity_type_ids = \Drupal::moduleHandler()->invokeAll('relevant_activity_type_ids', [$actorType]);
|
||||
$relevant_activity_type_ids = \Drupal::moduleHandler()->invokeAll('relevant_activity_type_ids', [$entityType, $bundle]);
|
||||
$activity_types_to_display = [];
|
||||
foreach ($relevant_activity_type_ids as $type_id) {
|
||||
if (array_key_exists($type_id, $implemented_activity_types)) {
|
||||
|
52
src/Plugin/Block/AddCase.php
Normal file
52
src/Plugin/Block/AddCase.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Drupal\opencase\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a Block for adding cases to an actor
|
||||
*
|
||||
* @Block(
|
||||
* id = "add_case",
|
||||
* admin_label = @Translation("Add Case"),
|
||||
* category = @Translation("Opencase"),
|
||||
* )
|
||||
*/
|
||||
class AddCase extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build():array {
|
||||
$actor = \Drupal::routeMatch()->getParameter('oc_actor');
|
||||
$target_id = $actor->id();
|
||||
$actorType = $actor->bundle();
|
||||
$markup = "<ul>";
|
||||
$case_types = $this->getCaseTypesToDisplay($actorType);
|
||||
foreach($case_types as $id => $info) {
|
||||
$label = $info['label'];
|
||||
$markup .= "<li><a href='/opencase/oc_case/add/$id?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
|
||||
}
|
||||
$markup .= "</ul>";
|
||||
return array('#markup' => $markup);
|
||||
}
|
||||
|
||||
public function getCacheMaxAge():int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getCaseTypesToDisplay(string $actorType): array {
|
||||
// Client modules will provide a list of what case types (bundles) are relevant for each actor type.
|
||||
// Check if they are implemented, and if so display them.
|
||||
$implemented_case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_case');
|
||||
$relevant_case_type_ids = \Drupal::moduleHandler()->invokeAll('relevant_case_type_ids', [$actorType]);
|
||||
$case_types_to_display = [];
|
||||
foreach ($relevant_case_type_ids as $type_id) {
|
||||
if (array_key_exists($type_id, $implemented_case_types)) {
|
||||
$case_types_to_display[$type_id] = $implemented_case_types[$type_id];
|
||||
}
|
||||
}
|
||||
return $case_types_to_display;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user