Compare commits

...

7 Commits

19 changed files with 162 additions and 109 deletions

View File

@ -25,7 +25,7 @@ content:
label: above label: above
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
weight: 5 weight: 4
region: content region: content
name: name:
type: string type: string
@ -33,17 +33,9 @@ content:
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 4
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2 weight: 2
region: content region: content
oc_target: oc_provider:
type: entity_reference_label type: entity_reference_label
label: above label: above
settings: settings:
@ -63,6 +55,7 @@ content:
weight: 3 weight: 3
region: content region: content
hidden: hidden:
oc_target: true
search_api_excerpt: true search_api_excerpt: true
status: true status: true
user_id: true user_id: true

View File

@ -25,7 +25,7 @@ content:
label: above label: above
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
weight: 5 weight: 4
region: content region: content
name: name:
type: string type: string
@ -33,17 +33,9 @@ content:
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 4
region: content
oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2 weight: 2
region: content region: content
oc_target: oc_provider:
type: entity_reference_label type: entity_reference_label
label: above label: above
settings: settings:
@ -63,6 +55,7 @@ content:
weight: 3 weight: 3
region: content region: content
hidden: hidden:
oc_target: true
search_api_excerpt: true search_api_excerpt: true
status: true status: true
user_id: true user_id: true

View File

@ -39,14 +39,14 @@ content:
scale: 2 scale: 2
prefix_suffix: true prefix_suffix: true
third_party_settings: { } third_party_settings: { }
weight: 5 weight: 4
region: content region: content
field_funds_for: field_funds_for:
type: list_default type: list_default
label: above label: above
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
weight: 4 weight: 3
region: content region: content
name: name:
type: string type: string
@ -54,17 +54,9 @@ content:
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 3 weight: 2
region: content region: content
oc_provider: oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label type: entity_reference_label
label: above label: above
settings: settings:
@ -72,8 +64,19 @@ content:
third_party_settings: { } third_party_settings: { }
weight: 1 weight: 1
region: content region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 5
region: content
hidden: hidden:
oc_target: true
search_api_excerpt: true search_api_excerpt: true
status: true status: true
time_taken: true
user_id: true user_id: true

View File

@ -29,7 +29,7 @@ content:
region: content region: content
name: name:
type: string type: string
label: above label: hidden
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }

View File

@ -29,21 +29,13 @@ content:
region: content region: content
name: name:
type: string type: string
label: above label: hidden
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 3 weight: 2
region: content region: content
oc_provider: oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label type: entity_reference_label
label: above label: above
settings: settings:
@ -51,8 +43,19 @@ content:
third_party_settings: { } third_party_settings: { }
weight: 1 weight: 1
region: content region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 3
region: content
hidden: hidden:
oc_target: true
search_api_excerpt: true search_api_excerpt: true
status: true status: true
time_taken: true
user_id: true user_id: true

View File

@ -29,21 +29,13 @@ content:
region: content region: content
name: name:
type: string type: string
label: above label: hidden
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }
weight: 3 weight: 2
region: content region: content
oc_provider: oc_provider:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 2
region: content
oc_target:
type: entity_reference_label type: entity_reference_label
label: above label: above
settings: settings:
@ -51,8 +43,19 @@ content:
third_party_settings: { } third_party_settings: { }
weight: 1 weight: 1
region: content region: content
time_taken:
type: number_decimal
label: above
settings:
thousand_separator: ''
decimal_separator: .
scale: 2
prefix_suffix: true
third_party_settings: { }
weight: 3
region: content
hidden: hidden:
oc_target: true
search_api_excerpt: true search_api_excerpt: true
status: true status: true
time_taken: true
user_id: true user_id: true

View File

@ -29,7 +29,7 @@ content:
region: content region: content
name: name:
type: string type: string
label: above label: hidden
settings: settings:
link_to_entity: false link_to_entity: false
third_party_settings: { } third_party_settings: { }

View File

@ -8,7 +8,7 @@ slogan: ''
page: page:
403: /user/login 403: /user/login
404: '' 404: ''
front: /opencase/actors/client front: /opencase/my-cases
admin_compact_mode: false admin_compact_mode: false
weight_select_max: 100 weight_select_max: 100
default_langcode: en default_langcode: en

View File

@ -26,43 +26,12 @@ permissions:
- 'access shortcuts' - 'access shortcuts'
- 'access site-wide contact form' - 'access site-wide contact form'
- 'add activity entities' - 'add activity entities'
- 'add case entities'
- 'add client entities'
- 'add equal opps entities'
- 'add event entities'
- 'add organisation entities'
- 'add staff_member entities'
- 'add volunteer entities'
- 'edit activity entities' - 'edit activity entities'
- 'edit bank account entities'
- 'edit case entities'
- 'edit client entities'
- 'edit equal opps entities'
- 'edit event entities'
- 'edit organisation entities'
- 'edit staff_member entities'
- 'edit volunteer entities'
- 'post comments' - 'post comments'
- 'revert all activity revisions'
- 'revert all client revisions'
- 'revert all organisation revisions'
- 'revert all staff_member revisions'
- 'revert all volunteer revisions'
- 'search content' - 'search content'
- 'skip comment approval' - 'skip comment approval'
- 'use opencase' - 'use opencase'
- 'use text format basic_html' - 'use text format basic_html'
- 'view all activity revisions'
- 'view all client revisions'
- 'view all organisation revisions'
- 'view all staff_member revisions'
- 'view all volunteer revisions'
- 'view published activity entities' - 'view published activity entities'
- 'view published case provision entities' - 'view published case provision entities'
- 'view published client entities'
- 'view published equal opps entities'
- 'view published event entities'
- 'view published organisation entities' - 'view published organisation entities'
- 'view published organisation relation entities'
- 'view published staff_member entities'
- 'view published volunteer entities'

View File

@ -3,7 +3,10 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- user.role.authenticated - user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module: module:
- opencase_entities - opencase_entities
- user - user
@ -186,7 +189,10 @@ display:
type: role type: role
options: options:
role: role:
authenticated: authenticated administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache: cache:
type: tag type: tag
options: { } options: { }

View File

@ -4,7 +4,10 @@ status: true
dependencies: dependencies:
config: config:
- system.menu.opencase - system.menu.opencase
- user.role.authenticated - user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module: module:
- opencase_cases - opencase_cases
- user - user
@ -318,7 +321,10 @@ display:
type: role type: role
options: options:
role: role:
authenticated: authenticated administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache: cache:
type: tag type: tag
options: { } options: { }

View File

@ -3,7 +3,10 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- user.role.authenticated - user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module: module:
- opencase_entities - opencase_entities
- user - user
@ -120,7 +123,10 @@ display:
type: role type: role
options: options:
role: role:
authenticated: authenticated administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache: cache:
type: tag type: tag
options: { } options: { }

View File

@ -3,7 +3,10 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- user.role.authenticated - user.role.administrator
- user.role.opencase_admin
- user.role.overseer
- user.role.volunteer_co_ord
module: module:
- opencase_entities - opencase_entities
- user - user
@ -120,7 +123,10 @@ display:
type: role type: role
options: options:
role: role:
authenticated: authenticated administrator: administrator
overseer: overseer
volunteer_co_ord: volunteer_co_ord
opencase_admin: opencase_admin
cache: cache:
type: tag type: tag
options: { } options: { }

View File

@ -139,12 +139,9 @@ function _opencase_cases_delete_activity_redirect($form, &$form_state) {
$entity = $form_state->getFormObject()->getEntity(); $entity = $form_state->getFormObject()->getEntity();
// for some reason this fires when deleting an activity type, shouldn't do but.s // for some reason this fires when deleting an activity type, shouldn't do but.s
if ($entity instanceof \Drupal\opencase_entities\Entity\OCActivityType) return; if ($entity instanceof \Drupal\opencase_entities\Entity\OCActivityType) return;
if (!IsEmpty($entity->oc_case)) { $case_id = $entity->oc_case->target_id;
$case_id = $entity->oc_case->target_id; if ($case_id) {
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]); $form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
} else {
$target_actor_id = $entity->oc_target->target_id;
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
} }
} }
/** /**

View File

@ -20,12 +20,12 @@ function opencase_form_user_login_form_alter(&$form, FormStateInterface $form_st
} }
/** /**
* If the user does not have permissions to see all cases, then when the login they are * If the user has permission to see all cases, then when the login they are
* redirected to a view of just their own cases. * redirected to the all cases view.
*/ */
function opencase_user_login_form_submit($form, FormStateInterface $form_state) { function opencase_user_login_form_submit($form, FormStateInterface $form_state) {
if (!\Drupal::currentUser()->hasPermission('view published case entities')) { if (Drupal::currentUser()->hasPermission('view published case entities')) {
$form_state->setRedirectUrl(Url::fromRoute('view.cases_by_provider.page_1')); $form_state->setRedirectUrl( Url::fromUserInput('/opencase/cases/all'));
} }
} }

View File

@ -2,4 +2,8 @@ use opencase:
title: 'Use OpenCase' title: 'Use OpenCase'
description: 'Use the OpenCase case management system' description: 'Use the OpenCase case management system'
restrict access: true restrict access: true
view opencase add new things menu:
title: 'View OpenCase "add new things" menu'
description: 'View OpenCase "add new things" menu'
restrict access: true

View File

@ -5,12 +5,12 @@ opencase.opencase_admin_menu:
opencase.opencase_cases_menu: opencase.opencase_cases_menu:
path: '/' path: '/'
requirements: requirements:
_permission: 'use opencase' _permission: 'view published case entities'
opencase.opencase_add_new_things_menu: opencase.opencase_add_new_things_menu:
path: '/' path: '/'
requirements: requirements:
_permission: 'use opencase' _permission: 'view published case entities'
opencase.opencase_reporting_menu: opencase.opencase_reporting_menu:
path: '/' path: '/'
requirements: requirements:
_permission: 'use opencase' _permission: 'view published case entities'

View File

@ -5,4 +5,9 @@ services:
# Priority determines the order in which Breadcrumb services run. # Priority determines the order in which Breadcrumb services run.
tags: tags:
- { name: breadcrumb_builder, priority: 100 } - { name: breadcrumb_builder, priority: 100 }
opencase.subscriber:
class: Drupal\opencase\EventSubscriber\OpencaseSubscriber
tags:
- { name: event_subscriber }

View File

@ -0,0 +1,59 @@
<?php
namespace Drupal\opencase\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Drupal\Core\Url;
/**
* Class OpencaseSubscriber.
*
* @package Drupal\opencase\EventSubscriber
*/
class OpencaseSubscriber implements EventSubscriberInterface {
private $alternativeHomePage = '/opencase/cases/all';
/**
* Registers the methods in this class that should be listeners.
*
* @return array
* An array of event listener definitions.
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = ['onRequest'];
return $events;
}
/**
* Manipulates the request object.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process.
*/
public function onRequest(GetResponseEvent $event): void {
if ($this->requestIsForHomePage($event) && $this->currentUserShouldBeDirectedToAlternativeHomePage()){
$this->redirectToAlternativeHomePage($event);
}
}
private function requestIsForHomePage($event):bool {
return $event->getRequest()->getRequestUri() == '/';
}
private function currentUserShouldBeDirectedToAlternativeHomePage():bool {
return $this->currentUserCanSeeAllCases();
}
private function currentUserCanSeeAllCases():bool {
return \Drupal::currentUser()->hasPermission('view published case entities');
}
private function redirectToAlternativeHomePage(GetResponseEvent $event):void {
$redirect_target_url = Url::fromUserInput($this->alternativeHomePage);
$response = new RedirectResponse($redirect_target_url->setAbsolute()->toString());
$event->setResponse($response);
}
}