Compare commits

...

22 Commits
MORE ... sep_10

Author SHA1 Message Date
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
3f3945f9a0 Added base field "contact role" to organisation, and bumped version 2021-06-15 19:55:45 +02:00
1cb3a4356a Removed it again - it's the wrong place for it. 2021-06-04 17:45:13 +02:00
34ac278a2e added menu item for managing tags. 2021-06-04 17:40:11 +02:00
b7cfaa9f64 Removed contextual menu block, as it does not work (keeps disappearing). 2021-04-14 11:36:00 +01:00
0df9cfecc8 Added some css classes to the contextual menu, and a temporary css hack. 2021-04-05 19:43:46 +01:00
27f0b33faa Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2021-03-23 18:27:19 +00:00
998f72f505 Merge branch 'dev' 2021-03-23 18:25:40 +00:00
4ac33273b9 Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase 2021-03-23 16:47:53 +01:00
62a3df034e css 2021-02-22 18:44:42 +01:00
df44524498 css 2021-02-22 18:28:02 +01:00
8d5dda3a7a css 2021-02-22 18:15:30 +01:00
74fac415c8 misc 2021-02-22 11:38:45 +00:00
20cc8cd753 removed EVA stuff from template, plus misc 2021-02-20 15:09:58 +00:00
4647ef6e3e Added equal opps view, and other changes. 2021-02-18 16:46:59 +00:00
1a7757394e Added fields to equal opps entity 2021-02-18 16:10:03 +00:00
fbdc64de3c Added equal opps entity 2021-02-18 15:32:10 +00:00
56 changed files with 2310 additions and 286 deletions

View File

@ -10,6 +10,7 @@
"require": {
"composer/installers": "*",
"drupal/superfish": "*",
"drupal/views_autosubmit": "*",
"drupal/smtp": "*",
"drupal/paragraphs_collapsible": "*"
}

View File

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- views.view.equal_opps_records
module:
- system
- views
theme:
- bartik
id: exposedformequal_opps_recordspage_1
theme: bartik
region: content
weight: 0
provider: null
plugin: 'views_exposed_filter_block:equal_opps_records-page_1'
settings:
id: 'views_exposed_filter_block:equal_opps_records-page_1'
label: ''
provider: views
label_display: visible
views_label: 'Search by (whole) first or last name.'
visibility:
request_path:
id: request_path
pages: /equal-opps-records
negate: false
context_mapping: { }

View File

@ -0,0 +1,308 @@
langcode: en
status: true
dependencies:
config:
- system.menu.opencase
module:
- opencase_entities
- user
- views_autosubmit
id: equal_opps_records
label: 'Equal Opps Records'
module: views
description: ''
tag: ''
base_table: oc_equal_opps
base_field: id
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'view published equal opps entities'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: autosubmit
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
autosubmit_hide: true
pager:
type: mini
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous:
next:
style:
type: table
row:
type: fields
fields:
name:
id: name
table: oc_equal_opps
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: null
entity_field: name
plugin_id: field
filters:
status:
value: '1'
table: oc_equal_opps
field: status
plugin_id: boolean
entity_type: oc_equal_opps
entity_field: status
id: status
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
group: 1
first_name:
id: first_name
table: oc_actor_field_data
field: first_name
relationship: oc_actor
group_type: group
admin_label: ''
operator: '='
value: ''
group: 1
exposed: true
expose:
operator_id: first_name_op
label: 'First Name'
description: ''
use_operator: false
operator: first_name_op
operator_limit_selection: false
operator_list: { }
identifier: first_name
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
gno_standard_user: '0'
placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: oc_actor
entity_field: first_name
plugin_id: string
last_name:
id: last_name
table: oc_actor_field_data
field: last_name
relationship: oc_actor
group_type: group
admin_label: ''
operator: '='
value: ''
group: 1
exposed: true
expose:
operator_id: last_name_op
label: 'Last Name'
description: ''
use_operator: false
operator: last_name_op
operator_limit_selection: false
operator_list: { }
identifier: last_name
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
gno_standard_user: '0'
placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: oc_actor
entity_field: last_name
plugin_id: string
sorts: { }
title: 'Equal Opps Records'
header: { }
footer: { }
empty:
area:
id: area
table: views
field: area
relationship: none
group_type: group
admin_label: ''
empty: true
tokenize: false
content:
value: 'There is no Equal Opps record by that name. Please check the spelling'
format: basic_html
plugin_id: text
relationships:
oc_actor:
id: oc_actor
table: oc_equal_opps
field: oc_actor
relationship: none
group_type: group
admin_label: Person
required: true
entity_type: oc_equal_opps
entity_field: oc_actor
plugin_id: standard
arguments: { }
display_extenders: { }
use_ajax: true
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
tags: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: equal-opps-records
exposed_block: true
menu:
type: normal
title: 'Equal Opps Records'
description: ''
expanded: false
parent: opencase.see_all
weight: 10
context: '0'
menu_name: opencase
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
tags: { }

View File

@ -1,7 +1,26 @@
/* MOVE THIS INTO MORE!! */
.top_ups_bought.add-activity-link {
display: none;
}
/* */
body {
font-size: 100% !important;
}
.field--type-entity-reference-revisions .field__items {
margin-left: 2em;
}
.field--type-entity-reference-revisions .field__items .field{
margin-top: 0;
}
.field--type-entity-reference-revisions .field__items .paragraph{
margin-top: 0.5em;
margin-bottom: 0.5em;
}
/* remove this confusing thing from user creation page */
#edit-password-policy-status {
display: none;
@ -98,7 +117,9 @@ table.views-table.views-view-table caption {
/* remove "details" accordion, see https://drupal.stackexchange.com/questions/294312/why-has-this-details-accordion-appeared-in-this-view */
.views-table details {
display: none;
}
form.oc-organisation-relation-form tr:first-child {
display: none;
}

View File

@ -23,15 +23,12 @@ function template_preprocess_oc_case(array &$variables) {
// Separate the fields into two sections to be displayed in two columns.
// Remove the name (title) field as this is displayed anyway.
$variables['id'] = $variables['elements']['#oc_case']->get('id')[0]->get('value')->getValue();
$variables['eva_fields'] = array(); // if the installation has any "EVA" (embedded view) fields this should catch them.
$variables['base_fields'] = array();
$variables['other_fields'] = array();
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
if (in_array($key, ['created', 'changed', 'files', 'actors_involved', 'status', 'user_id'])) {
$variables['base_fields'][$key] = $variables['elements'][$key];
} else if (strpos($key, "entity_view") !== false) {
$variables['eva_fields'][$key] = $variables['elements'][$key];
} else {
$variables['other_fields'][$key] = $variables['elements'][$key];
unset($variables['other_fields']['name']);

View File

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

View File

@ -29,10 +29,5 @@
{{ field }}
{% endfor %}
</div>
<div class="eva_fields">
{% for field in eva_fields %}
{{ field }}
{% endfor %}
</div>
</div>
</div>

View File

@ -0,0 +1,12 @@
opencase_entities.oc_organisation_relation_type.*:
type: config_entity
label: 'Organisation Relation 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_equal_opps.page.inc.
*
* Page callback for Equal Opps entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Equal Opps templates.
*
* Default template: oc_equal_opps.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_equal_opps(array &$variables) {
// Fetch OCEqualOpps Entity Object.
$oc_equal_opps = $variables['elements']['#oc_equal_opps'];
// 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_organisation_relation.page.inc.
*
* Page callback for Organisation Relation entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Organisation Relation templates.
*
* Default template: oc_organisation_relation.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_organisation_relation(array &$variables) {
// Fetch OCOrganisationRelation Entity Object.
$oc_organisation_relation = $variables['elements']['#oc_organisation_relation'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}

View File

@ -2,6 +2,75 @@
use \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchemaConverter;
use \Drupal\Core\Field\BaseFieldDefinition;
function opencase_entities_update_80202() {
\Drupal::entityTypeManager()->clearCachedDefinitions();
\Drupal::entityDefinitionUpdateManager()
->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_organisation_relation'));
}
function opencase_entities_update_80201() {
$update_manager = \Drupal::entityDefinitionUpdateManager();
$definition = $update_manager->getFieldStorageDefinition('phone', 'oc_actor');
$update_manager->updateFieldStorageDefinition($definition);
$definition = $update_manager->getFieldStorageDefinition('phone2', 'oc_actor');
$update_manager->updateFieldStorageDefinition($definition);
$definition = $update_manager->getFieldStorageDefinition('postal_address', 'oc_actor');
$update_manager->updateFieldStorageDefinition($definition);
$definition = $update_manager->getFieldStorageDefinition('email', 'oc_actor');
$update_manager->updateFieldStorageDefinition($definition);
$definition = $update_manager->getFieldStorageDefinition('post_code', 'oc_actor');
$update_manager->updateFieldStorageDefinition($definition);
}
function opencase_entities_update_80200() {
$field_storage_definition = BaseFieldDefinition::create('string')
->setLabel(t('Website'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => 49,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 49,
])
->setRequired(FALSE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('org_website', 'oc_organisation', 'opencase_entities', $field_storage_definition);
}
function opencase_entities_update_80199() {
$field_storage_definition = BaseFieldDefinition::create('string')
->setLabel(t('Contact Role'))
->setDescription(t('Role of the contact within the organisation'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => 52,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 52,
])
->setRequired(FALSE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('contact_role', 'oc_organisation', 'opencase_entities', $field_storage_definition);
}
function opencase_entities_update_80198() {
$field_storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('file')

View File

@ -45,3 +45,18 @@ entity.oc_bank_account.add_form:
title: 'Add Bank Account'
appears_on:
- entity.oc_bank_account.collection
entity.oc_equal_opps.add_form:
route_name: entity.oc_equal_opps.add_form
title: 'Add Equal Opps'
appears_on:
- entity.oc_equal_opps.collection
entity.oc_organisation_relation.add_form:
route_name: entity.oc_organisation_relation.add_page
title: 'Add Organisation Relation'
appears_on:
- entity.oc_organisation_relation.collection
entity.oc_organisation_relation_type.add_form:
route_name: entity.oc_organisation_relation_type.add_form
title: 'Add Organisation Relation type'
appears_on:
- entity.oc_organisation_relation_type.collection

View File

@ -82,3 +82,34 @@ oc_bank_account.admin.structure.settings:
description: 'Configure Bank Account entities'
route_name: oc_bank_account.settings
parent: system.admin_structure
# Equal Opps menu items definition
entity.oc_equal_opps.collection:
title: 'Equal Opps list'
route_name: entity.oc_equal_opps.collection
description: 'List Equal Opps entities'
parent: system.admin_structure
weight: 100
oc_equal_opps.admin.structure.settings:
title: 'Equal Opps settings'
description: 'Configure Equal Opps entities'
route_name: oc_equal_opps.settings
parent: system.admin_structure
# Organisation Relation menu items definition
entity.oc_organisation_relation.collection:
title: 'Organisation Relation list'
route_name: entity.oc_organisation_relation.collection
description: 'List Organisation Relation entities'
parent: system.admin_structure
weight: 100
# Organisation Relation type menu items definition
entity.oc_organisation_relation_type.collection:
title: 'Organisation Relation type'
route_name: entity.oc_organisation_relation_type.collection
description: 'List Organisation Relation type (bundles)'
parent: system.admin_structure
weight: 99

View File

@ -105,3 +105,41 @@ entity.oc_bank_account.delete_form:
base_route: entity.oc_bank_account.canonical
title: Delete
weight: 10
# Equal Opps routing definition
oc_equal_opps.settings_tab:
route_name: oc_equal_opps.settings
title: 'Settings'
base_route: oc_equal_opps.settings
entity.oc_equal_opps.canonical:
route_name: entity.oc_equal_opps.canonical
base_route: entity.oc_equal_opps.canonical
title: 'View'
entity.oc_equal_opps.edit_form:
route_name: entity.oc_equal_opps.edit_form
base_route: entity.oc_equal_opps.canonical
title: 'Edit'
entity.oc_equal_opps.delete_form:
route_name: entity.oc_equal_opps.delete_form
base_route: entity.oc_equal_opps.canonical
title: Delete
weight: 10
# Organisation Relation routing definition
entity.oc_organisation_relation.canonical:
route_name: entity.oc_organisation_relation.canonical
base_route: entity.oc_organisation_relation.canonical
title: 'View'
entity.oc_organisation_relation.edit_form:
route_name: entity.oc_organisation_relation.edit_form
base_route: entity.oc_organisation_relation.canonical
title: 'Edit'
entity.oc_organisation_relation.delete_form:
route_name: entity.oc_organisation_relation.delete_form
base_route: entity.oc_organisation_relation.canonical
title: Delete
weight: 10

View File

@ -29,6 +29,16 @@ function opencase_entities_help($route_name, RouteMatchInterface $route_match) {
*/
function opencase_entities_theme() {
$theme = [];
$theme['oc_organisation_relation'] = [
'render element' => 'elements',
'file' => 'oc_organisation_relation.page.inc',
'template' => 'oc_organisation_relation',
];
$theme['oc_organisation_relation_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_organisation_relation.page.inc',
];
$theme['opencase_entities'] = [
'render element' => 'children',
];
@ -140,3 +150,19 @@ function opencase_entities_theme_suggestions_oc_event(array $variables) {
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_organisation_relation(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_organisation_relation'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_organisation_relation__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation_relation__' . $entity->bundle();
$suggestions[] = 'oc_organisation_relation__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation_relation__' . $entity->id();
$suggestions[] = 'oc_organisation_relation__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}

View File

@ -157,3 +157,43 @@ view published bank account entities:
view unpublished bank account entities:
title: 'View unpublished Bank Account entities'
add equal opps entities:
title: 'Create new Equal Opps entities'
administer equal opps entities:
title: 'Administer Equal Opps entities'
description: 'Allow to access the administration form to configure Equal Opps entities.'
restrict access: true
delete equal opps entities:
title: 'Delete Equal Opps entities'
edit equal opps entities:
title: 'Edit Equal Opps entities'
view published equal opps entities:
title: 'View published Equal Opps entities'
view unpublished equal opps entities:
title: 'View unpublished Equal Opps entities'
add organisation relation entities:
title: 'Create new Organisation Relation entities'
administer organisation relation entities:
title: 'Administer Organisation Relation entities'
description: 'Allow to access the administration form to configure Organisation Relation entities.'
restrict access: true
delete organisation relation entities:
title: 'Delete Organisation Relation entities'
edit organisation relation entities:
title: 'Edit Organisation Relation entities'
view published organisation relation entities:
title: 'View published Organisation Relation entities'
view unpublished organisation relation entities:
title: 'View unpublished Organisation Relation entities'

View File

@ -268,8 +268,9 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDefaultValue('')
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -9,
]);
'weight' => -100,
])
->setRequired(TRUE);
$fields['middle_names'] = BaseFieldDefinition::create('string')
->setLabel(t('Middle Names'))
@ -284,7 +285,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDefaultValue('')
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -8,
'weight' => -99,
])
->setRequired(FALSE);
@ -301,8 +302,9 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDefaultValue('')
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -7,
]);
'weight' => -98,
])
->setRequired(TRUE);
// Contact details.
$fields['email'] = BaseFieldDefinition::create('string')
@ -313,7 +315,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 30,
'text_processing' => 0,
))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
@ -331,6 +334,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 20,
'text_processing' => 0,
))
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
@ -348,6 +353,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 20,
'text_processing' => 0,
))
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
@ -366,6 +373,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'basic_string',
@ -383,6 +392,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 10,
'text_processing' => 0,
))
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',

View File

@ -0,0 +1,260 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines the Equal Opps entity.
*
* @ingroup opencase_entities
*
* @ContentEntityType(
* id = "oc_equal_opps",
* label = @Translation("Equal Opps"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_entities\OCEqualOppsListBuilder",
* "views_data" = "Drupal\opencase_entities\Entity\OCEqualOppsViewsData",
*
* "form" = {
* "default" = "Drupal\opencase_entities\Form\OCEqualOppsForm",
* "add" = "Drupal\opencase_entities\Form\OCEqualOppsForm",
* "edit" = "Drupal\opencase_entities\Form\OCEqualOppsForm",
* "delete" = "Drupal\opencase_entities\Form\OCEqualOppsDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\opencase_entities\OCEqualOppsHtmlRouteProvider",
* },
* "access" = "Drupal\opencase_entities\OCEqualOppsAccessControlHandler",
* },
* base_table = "oc_equal_opps",
* translatable = FALSE,
* admin_permission = "administer equal opps entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "langcode" = "langcode",
* "published" = "status",
* },
* links = {
* "canonical" = "/opencase/oc_equal_opps/{oc_equal_opps}",
* "add-form" = "/opencase/oc_equal_opps/add",
* "edit-form" = "/opencase/oc_equal_opps/{oc_equal_opps}/edit",
* "delete-form" = "/opencase/oc_equal_opps/{oc_equal_opps}/delete",
* "collection" = "/opencase/oc_equal_opps",
* },
* field_ui_base_route = "oc_equal_opps.settings"
* )
*/
class OCEqualOpps extends ContentEntityBase implements OCEqualOppsInterface {
use EntityChangedTrait;
use EntityPublishedTrait;
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
// get the name of the person and make that the name of the thing.
$name = $this->get('oc_actor')->entity->get('name')->first()->value;
$this->setName($name);
}
/**
* {@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 static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// Add the published field.
$fields += static::publishedBaseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Equal Opps entity.'))
->setSettings([
'max_length' => 50,
'text_processing' => 0,
]);
$fields['oc_actor'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
->setLabel(t('Person'))
->setDescription(t('The person this pertains to.'))
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setCardinality(1)
->setDisplayOptions('view', [
'type' => 'string',
'weight' => -100,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete_tags',
'weight' => -100,
])
->setRequired(TRUE);
$fields['age'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Age'))
->setRevisionable(TRUE)
->setSettings([
'allowed_values' => [
'18-24' => '18-24',
'25-34' => '25-34',
'35-44' => '35-44',
'45-54' => '45-54',
'56-70' => '56-70',
'70+' => '70+',
],
])
->setDisplayConfigurable('form', true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
->setDisplayOptions('form', array(
'type' => 'options_select',
'weight' => -5,
));
$fields['access_needs'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Access Needs'))
->setRevisionable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_long',
'weight' => -4,
));
$fields['gender'] = BaseFieldDefinition::create('list_string')
->setRevisionable(TRUE)
->setLabel(t('Gender'))
->setSettings([
'allowed_values' => [
'man' => 'Man',
'woman' => 'Woman',
'non-binary' => 'Non-Binary',
'trans-gnc' => 'Trans / GNC',
'trans-man' => 'Trans man',
'trans-woman' => 'Trans woman',
'trans-nb' => 'Trans NB',
],
])
->setDisplayConfigurable('form', true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
->setDisplayOptions('form', array(
'type' => 'options_select',
'weight' => -5,
));
$fields['race_ethnicity'] = BaseFieldDefinition::create('list_string')
->setRevisionable(TRUE)
->setLabel(t('Race/Ethnicity'))
->setSettings([
'allowed_values' => [
'white1' => 'White: English, Welsh, Scottish, Northern Irish or British',
'white2' => 'White: Irish',
'white3' => 'White: Gypsy or Irish Traveller',
'white4' => 'White: Any other White background',
'mixed1' => 'Mixed: White and Black Caribbean',
'mixed2' => 'Mixed: White and Black African',
'mixed3' => 'Mixed: White and Asian',
'mixed4' => 'Mixed: Other',
'asian1' => 'Asian: Indian',
'asian2' => 'Asian: Bangladeshi',
'asian3' => 'Asian: Pakistani',
'asian4' => 'Asian: Chinese',
'asian5' => 'Asian: Other',
'black1' => 'Black: African',
'black2' => 'Black: Caribbean',
'black3' => 'Black: Other',
'arab' => 'Arab',
'other' => 'Other',
],
])
->setDisplayConfigurable('form', true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
->setDisplayOptions('form', array(
'type' => 'options_select',
'weight' => -5,
));
$fields['sexuality'] = BaseFieldDefinition::create('string')
->setLabel(t('Sexuality'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 20,
'text_processing' => 0,
])
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -1,
))
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -1,
]);
$fields['status']->setDescription(t('A boolean indicating whether the Equal Opps is published.'));
$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.'));
return $fields;
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
/**
* Provides an interface for defining Equal Opps entities.
*
* @ingroup opencase_entities
*/
interface OCEqualOppsInterface extends ContentEntityInterface, EntityChangedInterface, EntityPublishedInterface {
/**
* Add get/set methods for your configuration properties here.
*/
/**
* Gets the Equal Opps name.
*
* @return string
* Name of the Equal Opps.
*/
public function getName();
/**
* Sets the Equal Opps name.
*
* @param string $name
* The Equal Opps name.
*
* @return \Drupal\opencase_entities\Entity\OCEqualOppsInterface
* The called Equal Opps entity.
*/
public function setName($name);
/**
* Gets the Equal Opps creation timestamp.
*
* @return int
* Creation timestamp of the Equal Opps.
*/
public function getCreatedTime();
/**
* Sets the Equal Opps creation timestamp.
*
* @param int $timestamp
* The Equal Opps creation timestamp.
*
* @return \Drupal\opencase_entities\Entity\OCEqualOppsInterface
* The called Equal Opps entity.
*/
public function setCreatedTime($timestamp);
}

View File

@ -0,0 +1,23 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for Equal Opps entities.
*/
class OCEqualOppsViewsData 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

@ -149,13 +149,7 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
->setDescription(t('The user ID of author of the Event entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'author',
'weight' => -4,
]);
->setSetting('handler', 'default');
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -165,11 +159,6 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,

View File

@ -211,9 +211,27 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
'type' => 'string_textarea',
'weight' => 50,
));
$fields['website'] = BaseFieldDefinition::create('string')
->setLabel(t('Website'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => 49,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 49,
])
->setRequired(FALSE);
$fields['contact_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Contact Name'))
->setDescription(t('Name of the main contact for this client.'))
->setDescription(t('Name of the main contact for this organisation.'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
@ -231,6 +249,25 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio
])
->setRequired(FALSE);
$fields['contact_role'] = BaseFieldDefinition::create('string')
->setLabel(t('Contact Role'))
->setDescription(t('Role of the contact within the organisation'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => 52,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 52,
])
->setRequired(FALSE);
$fields['email'] = BaseFieldDefinition::create('string')
->setLabel(t('Email Address'))
->setRevisionable(TRUE)

View File

@ -0,0 +1,151 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines the Organisation Relation entity.
*
* @ingroup opencase_entities
*
* @ContentEntityType(
* id = "oc_organisation_relation",
* label = @Translation("Organisation Relation"),
* bundle_label = @Translation("Organisation Relation type"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_entities\OCOrganisationRelationListBuilder",
* "views_data" = "Drupal\opencase_entities\Entity\OCOrganisationRelationViewsData",
*
* "form" = {
* "default" = "Drupal\opencase_entities\Form\OCOrganisationRelationForm",
* "add" = "Drupal\opencase_entities\Form\OCOrganisationRelationForm",
* "edit" = "Drupal\opencase_entities\Form\OCOrganisationRelationForm",
* "delete" = "Drupal\opencase_entities\Form\OCOrganisationRelationDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\opencase_entities\OCOrganisationRelationHtmlRouteProvider",
* },
* "access" = "Drupal\opencase_entities\OCOrganisationRelationAccessControlHandler",
* },
* base_table = "oc_organisation_relation",
* translatable = FALSE,
* admin_permission = "administer organisation relation entities",
* entity_keys = {
* "id" = "id",
* "bundle" = "type",
* "label" = "name",
* "uuid" = "uuid",
* "langcode" = "langcode",
* "published" = "status",
* },
* links = {
* "canonical" = "/opencase/oc_organisation_relation/{oc_organisation_relation}",
* "add-page" = "/opencase/oc_organisation_relation/add",
* "add-form" = "/opencase/oc_organisation_relation/add/{oc_organisation_relation_type}",
* "edit-form" = "/opencase/oc_organisation_relation/{oc_organisation_relation}/edit",
* "delete-form" = "/opencase/oc_organisation_relation/{oc_organisation_relation}/delete",
* "collection" = "/opencase/oc_organisation_relation",
* },
* bundle_entity_type = "oc_organisation_relation_type",
* field_ui_base_route = "entity.oc_organisation_relation_type.edit_form"
* )
*/
class OCOrganisationRelation extends ContentEntityBase implements OCOrganisationRelationInterface {
use EntityChangedTrait;
use EntityPublishedTrait;
/**
* {@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 static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// Add the published field.
$fields += static::publishedBaseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Organisation Relation entity.'))
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('Link between organisations')
->setRequired(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['organisations'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Organisation to Link To'))
->setSetting('target_type', 'oc_organisation')
->setSetting('handler', 'default')
->setCardinality(2)
->setDisplayOptions('form', [
'label' => 'above',
'type' => 'entity_reference_autocomplete',
'weight' => -2,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayOptions('view', [
'label' => 'above',
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE)
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCOrganisationRelation::defaultValueCallback')
->setRequired(TRUE);
return $fields;
}
function defaultValueCallback() {
return [\Drupal::request()->query->get('organisation_id')];
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
/**
* Provides an interface for defining Organisation Relation entities.
*
* @ingroup opencase_entities
*/
interface OCOrganisationRelationInterface extends ContentEntityInterface, EntityChangedInterface, EntityPublishedInterface {
/**
* Add get/set methods for your configuration properties here.
*/
/**
* Gets the Organisation Relation name.
*
* @return string
* Name of the Organisation Relation.
*/
public function getName();
/**
* Sets the Organisation Relation name.
*
* @param string $name
* The Organisation Relation name.
*
* @return \Drupal\opencase_entities\Entity\OCOrganisationRelationInterface
* The called Organisation Relation entity.
*/
public function setName($name);
/**
* Gets the Organisation Relation creation timestamp.
*
* @return int
* Creation timestamp of the Organisation Relation.
*/
public function getCreatedTime();
/**
* Sets the Organisation Relation creation timestamp.
*
* @param int $timestamp
* The Organisation Relation creation timestamp.
*
* @return \Drupal\opencase_entities\Entity\OCOrganisationRelationInterface
* The called Organisation Relation entity.
*/
public function setCreatedTime($timestamp);
}

View File

@ -0,0 +1,58 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
/**
* Defines the Organisation Relation type entity.
*
* @ConfigEntityType(
* id = "oc_organisation_relation_type",
* label = @Translation("Organisation Relation type"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\opencase_entities\OCOrganisationRelationTypeListBuilder",
* "form" = {
* "add" = "Drupal\opencase_entities\Form\OCOrganisationRelationTypeForm",
* "edit" = "Drupal\opencase_entities\Form\OCOrganisationRelationTypeForm",
* "delete" = "Drupal\opencase_entities\Form\OCOrganisationRelationTypeDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\opencase_entities\OCOrganisationRelationTypeHtmlRouteProvider",
* },
* },
* config_prefix = "oc_organisation_relation_type",
* admin_permission = "administer site configuration",
* bundle_of = "oc_organisation_relation",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* },
* links = {
* "canonical" = "/admin/opencase/oc_organisation_relation_type/{oc_organisation_relation_type}",
* "add-form" = "/admin/opencase/oc_organisation_relation_type/add",
* "edit-form" = "/admin/opencase/oc_organisation_relation_type/{oc_organisation_relation_type}/edit",
* "delete-form" = "/admin/opencase/oc_organisation_relation_type/{oc_organisation_relation_type}/delete",
* "collection" = "/admin/opencase/oc_organisation_relation_type"
* }
* )
*/
class OCOrganisationRelationType extends ConfigEntityBundleBase implements OCOrganisationRelationTypeInterface {
/**
* The Organisation Relation type ID.
*
* @var string
*/
protected $id;
/**
* The Organisation Relation type label.
*
* @var string
*/
protected $label;
}

View File

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

View File

@ -0,0 +1,23 @@
<?php
namespace Drupal\opencase_entities\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for Organisation Relation entities.
*/
class OCOrganisationRelationViewsData 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,15 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
/**
* Provides a form for deleting Equal Opps entities.
*
* @ingroup opencase_entities
*/
class OCEqualOppsDeleteForm extends ContentEntityDeleteForm {
}

View File

@ -0,0 +1,66 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for Equal Opps edit forms.
*
* @ingroup opencase_entities
*/
class OCEqualOppsForm 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_entities\Entity\OCEqualOpps $entity */
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Equal Opps.', [
'%label' => $entity->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Equal Opps.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.oc_equal_opps.canonical', ['oc_equal_opps' => $entity->id()]);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCEqualOppsSettingsForm.
*
* @ingroup opencase_entities
*/
class OCEqualOppsSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'ocequalopps_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 Equal Opps 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['ocequalopps_settings']['#markup'] = 'Settings form for Equal Opps entities. Manage field settings here.';
return $form;
}
}

View File

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

View File

@ -0,0 +1,66 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for Organisation Relation edit forms.
*
* @ingroup opencase_entities
*/
class OCOrganisationRelationForm 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_entities\Entity\OCOrganisationRelation $entity */
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Organisation Relation.', [
'%label' => $entity->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Organisation Relation.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.oc_organisation_relation.canonical', ['oc_organisation_relation' => $entity->id()]);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCOrganisationRelationSettingsForm.
*
* @ingroup opencase_entities
*/
class OCOrganisationRelationSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'ocorganisationrelation_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 Organisation Relation 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['ocorganisationrelation_settings']['#markup'] = 'Settings form for Organisation Relation entities. Manage field settings here.';
return $form;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Drupal\opencase_entities\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Builds the form to delete Organisation Relation type entities.
*/
class OCOrganisationRelationTypeDeleteForm 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_organisation_relation_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_entities\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Class OCOrganisationRelationTypeForm.
*/
class OCOrganisationRelationTypeForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$oc_organisation_relation_type = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $oc_organisation_relation_type->label(),
'#description' => $this->t("Label for the Organisation Relation type."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $oc_organisation_relation_type->id(),
'#machine_name' => [
'exists' => '\Drupal\opencase_entities\Entity\OCOrganisationRelationType::load',
],
'#disabled' => !$oc_organisation_relation_type->isNew(),
];
/* You will need additional form elements for your custom properties. */
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$oc_organisation_relation_type = $this->entity;
$status = $oc_organisation_relation_type->save();
switch ($status) {
case SAVED_NEW:
$this->messenger()->addMessage($this->t('Created the %label Organisation Relation type.', [
'%label' => $oc_organisation_relation_type->label(),
]));
break;
default:
$this->messenger()->addMessage($this->t('Saved the %label Organisation Relation type.', [
'%label' => $oc_organisation_relation_type->label(),
]));
}
$form_state->setRedirectUrl($oc_organisation_relation_type->toUrl('collection'));
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace Drupal\opencase_entities;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Equal Opps entity.
*
* @see \Drupal\opencase_entities\Entity\OCEqualOpps.
*/
class OCEqualOppsAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opencase_entities\Entity\OCEqualOppsInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished equal opps entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published equal opps entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit equal opps entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete equal opps entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add equal opps entities');
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Drupal\opencase_entities;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for Equal Opps entities.
*
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCEqualOppsHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* 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_entities\Form\OCEqualOppsSettingsForm',
'_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_entities;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of Equal Opps entities.
*
* @ingroup opencase_entities
*/
class OCEqualOppsListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('Equal Opps ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var \Drupal\opencase_entities\Entity\OCEqualOpps $entity */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.oc_equal_opps.edit_form',
['oc_equal_opps' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace Drupal\opencase_entities;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Organisation Relation entity.
*
* @see \Drupal\opencase_entities\Entity\OCOrganisationRelation.
*/
class OCOrganisationRelationAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opencase_entities\Entity\OCOrganisationRelationInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished organisation relation entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published organisation relation entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit organisation relation entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete organisation relation entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add organisation relation entities');
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Drupal\opencase_entities;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
/**
* Provides routes for Organisation Relation entities.
*
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCOrganisationRelationHtmlRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
$collection->add("$entity_type_id.settings", $settings_form_route);
}
return $collection;
}
/**
* 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_entities\Form\OCOrganisationRelationSettingsForm',
'_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_entities;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of Organisation Relation entities.
*
* @ingroup opencase_entities
*/
class OCOrganisationRelationListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('Organisation Relation ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var \Drupal\opencase_entities\Entity\OCOrganisationRelation $entity */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.oc_organisation_relation.edit_form',
['oc_organisation_relation' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Drupal\opencase_entities;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
/**
* Provides routes for Organisation Relation type entities.
*
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class OCOrganisationRelationTypeHtmlRouteProvider 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_entities;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a listing of Organisation Relation type entities.
*/
class OCOrganisationRelationTypeListBuilder extends ConfigEntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = $this->t('Organisation Relation 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,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_organisation_relation_content_add_list()
*
* @ingroup themeable
*/
#}
{% spaceless %}
<dl>
{% for type in types %}
<dt>{{ type.link }}</dt>
{% endfor %}
</dl>
{% endspaceless %}

View File

@ -0,0 +1,22 @@
{#
/**
* @file oc_equal_opps.html.twig
* Default theme implementation to present Equal Opps data.
*
* This template is used when viewing Equal Opps 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_equal_opps()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('oc_equal_opps') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>

View File

@ -0,0 +1,22 @@
{#
/**
* @file oc_organisation_relation.html.twig
* Default theme implementation to present Organisation Relation data.
*
* This template is used when viewing Organisation Relation 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_organisation_relation()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('oc_organisation_relation') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>

View File

@ -1,65 +0,0 @@
<?php
namespace Drupal\opencase_no_cases\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
* Provides a 'ContextualMenu' block.
*
* Displays links for adding activities against a person.
*
* @Block(
* id = "opencase_no_cases_contextual_menu",
* admin_label = @Translation("OpenCase Contextual Menu"),
* )
*/
class ContextualMenu extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$route_name = \Drupal::routeMatch()->getRouteName();
\Drupal::logger('my_module')->error(\Drupal::routeMatch()->getParameter('oc_actor')->bundle());
if ($route_name == 'entity.oc_actor.canonical' && \Drupal::routeMatch()->getParameter('oc_actor')->bundle() == 'client' ) {
$markup = $this->actorPage();
$build = [];
$build['contextual_menu'] = [
'#markup' => "<div id='opencase_contextual_menu'>$markup</div",
'#cache' => ['max-age' => 0]
];
return $build;
}
}
/**
* Contextual menu for Actor page
* - Links to add activities of various types
*/
private function actorPage() {
$actor_id = \Drupal::routeMatch()->getParameter('oc_actor')->id();
return $this->generateLinksForAddingNewActivities("Add activity", $actor_id);
}
/**
* returns html markup.
*/
private function generateLinksForAddingNewActivities($title, $actor_id) {
$title = t($title);
$markup = "<br /><p><strong>$title: </strong>";
$allActivityTypes = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
$redirect_destination = \Drupal\Core\Url::fromRoute("entity.oc_actor.canonical", ['oc_actor' => $actor_id])->toString();
foreach($allActivityTypes as $machine_name => $activityType) {
$label = $activityType['label'];
$url = \Drupal\Core\Url::fromRoute("entity.oc_activity.add_form", ['oc_activity_type' => $machine_name]);
$url->setOption('query', ['actor_id' => $actor_id, 'destination' => $redirect_destination]);
$link = \Drupal\Core\Link::fromTextAndUrl($label, $url)->toString();
$markup .= "&nbsp;&nbsp; $link";
}
$markup .= "</p>";
return "<div class='openactor_add_links'>$markup</div>";
}
}

View File

@ -1,11 +1,11 @@
langcode: en
status: true
dependencies:
module:
- opencase_entities
- search_api
config:
- search_api.server.opencase_server
module:
- search_api
- opencase_entities
id: opencase_actors
name: 'OpenCase Search: Actors'
description: ''
@ -16,11 +16,33 @@ field_settings:
datasource_id: 'entity:oc_actor'
property_path: first_name
type: text
dependencies:
module:
- opencase_entities
full_name:
label: Name
datasource_id: 'entity:oc_actor'
property_path: full_name
type: text
dependencies:
module:
- opencase_entities
last_name:
label: 'Last Name'
datasource_id: 'entity:oc_actor'
property_path: last_name
type: text
dependencies:
module:
- opencase_entities
name:
label: Name
datasource_id: 'entity:oc_organisation'
property_path: name
type: text
dependencies:
module:
- opencase_entities
datasource_settings:
'entity:oc_actor':
bundles:
@ -29,6 +51,13 @@ datasource_settings:
languages:
default: true
selected: { }
'entity:oc_organisation':
bundles:
default: true
selected: { }
languages:
default: true
selected: { }
processor_settings:
add_url: { }
aggregated_field: { }
@ -36,10 +65,13 @@ processor_settings:
all_fields: true
fields:
- first_name
- full_name
- last_name
- name
weights:
preprocess_index: -20
preprocess_query: -20
language_with_fallback: { }
rendered_item: { }
tracker_settings:
default:

View File

@ -14,7 +14,6 @@ description: ''
tag: ''
base_table: search_api_index_opencase_actors
base_field: search_api_id
core: 8.x
display:
default:
display_plugin: default
@ -77,17 +76,13 @@ display:
description: ''
columns:
name: name
created: created
type: type
id: id
nothing: nothing
type_1: type_1
name_1: name_1
info:
name:
align: ''
separator: ''
empty_column: false
responsive: ''
created:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
@ -97,14 +92,12 @@ display:
separator: ''
empty_column: false
responsive: ''
id:
type_1:
align: ''
separator: ''
empty_column: false
responsive: ''
nothing:
sortable: false
default_sort_order: asc
name_1:
align: ''
separator: ''
empty_column: false
@ -114,15 +107,15 @@ display:
row:
type: fields
fields:
first_name:
id: first_name
table: search_api_datasource_opencase_actors_entity_oc_actor
field: first_name
name:
id: name
table: search_api_index_opencase_actors
field: name
relationship: none
group_type: group
admin_label: ''
label: 'First Name'
exclude: false
label: 'Organisation name '
exclude: true
alter:
alter_text: false
text: ''
@ -165,7 +158,7 @@ display:
click_sort_column: value
type: string
settings:
link_to_entity: false
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
@ -183,20 +176,19 @@ display:
use_highlighting: false
multi_type: separator
multi_separator: ', '
entity_type: oc_actor
plugin_id: search_api_field
last_name:
id: last_name
name_1:
id: name_1
table: search_api_datasource_opencase_actors_entity_oc_actor
field: last_name
field: name
relationship: none
group_type: group
admin_label: ''
label: 'Last Name'
label: Name
exclude: false
alter:
alter_text: false
text: ''
text: '{{ name_1 }}'
make_link: false
path: ''
absolute: false
@ -229,14 +221,14 @@ display:
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
empty: '{{ name }}'
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
@ -263,8 +255,8 @@ display:
relationship: none
group_type: group
admin_label: ''
label: Type
exclude: false
label: 'Person type'
exclude: true
alter:
alter_text: false
text: ''
@ -330,94 +322,18 @@ display:
display_method: label
entity_type: oc_actor
plugin_id: search_api_field
created:
id: created
table: search_api_datasource_opencase_actors_entity_oc_actor
field: created
type_1:
id: type_1
table: search_api_datasource_opencase_actors_entity_oc_organisation
field: type
relationship: none
group_type: group
admin_label: ''
label: 'Record created on'
label: Type
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
field_rendering: true
fallback_handler: search_api_date
fallback_options:
date_format: fallback
custom_date_format: ''
timezone: ''
link_to_item: false
use_highlighting: false
multi_type: separator
multi_separator: ', '
entity_type: oc_actor
plugin_id: search_api_field
id:
id: id
table: search_api_datasource_opencase_actors_entity_oc_actor
field: id
relationship: none
group_type: group
admin_label: ''
label: ID
exclude: true
alter:
alter_text: false
text: ''
alter_text: true
text: '{{ type }}{{ type_1 }}'
make_link: false
path: ''
absolute: false
@ -450,16 +366,15 @@ display:
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
empty: '{{ type }}{{ type_1 }}'
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
click_sort_column: target_id
type: entity_reference_label
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
link: false
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
@ -470,74 +385,17 @@ display:
separator: ', '
field_api_classes: false
field_rendering: true
fallback_handler: search_api_numeric
fallback_handler: search_api_entity
fallback_options:
set_precision: false
precision: 0
decimal: .
separator: ','
format_plural: false
format_plural_string: !!binary MQNAY291bnQ=
prefix: ''
suffix: ''
link_to_item: false
use_highlighting: false
multi_type: separator
multi_separator: ', '
format_plural_values:
- '1'
- '@count'
entity_type: oc_actor
display_methods:
oc_organisation_type:
display_method: label
entity_type: oc_organisation
plugin_id: search_api_field
nothing:
id: nothing
table: views
field: nothing
relationship: none
group_type: group
admin_label: ''
label: 'Go to'
exclude: false
alter:
alter_text: true
text: "&bull;&nbsp;<a href='/opencase/oc_actor/{{ id }}/'>Details</a>&nbsp;&nbsp;&nbsp;&bull;&nbsp;<a href='/opencase/oc_actor/{{ id}}/case_list'>Cases</a>\n"
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: false
plugin_id: custom
filters:
search_api_fulltext:
id: search_api_fulltext
@ -566,6 +424,8 @@ display:
administrator: '0'
standard_user: '0'
placeholder: ''
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -611,7 +471,8 @@ display:
- url
- url.query_args
- user.roles
tags: { }
tags:
- 'config:search_api.index.opencase_actors'
page_1:
display_plugin: page
id: page_1
@ -629,4 +490,5 @@ display:
- url
- url.query_args
- user.roles
tags: { }
tags:
- 'config:search_api.index.opencase_actors'

View File

@ -2,11 +2,12 @@ name: 'OpenCase'
type: module
description: 'Simple Case Management'
core: 8.x
version: 8.x-1.9.8
version: 8.x-2.0.2
package: 'OpenCase'
dependencies:
- opencase_entities
- superfish
- admin_toolbar
- views_autosubmit
libraries:
- opencase/opencase-lib

View File

@ -23,6 +23,12 @@ opencase.add_events_links:
deriver: Drupal\opencase\Plugin\Derivative\AddEventsMenuLink
menu_name: opencase
parent: opencase.opencase_add_new_things_menu
opencase.add_equal_opps:
title: 'Equal Opportunies record'
menu_name: opencase
url: internal:/opencase/oc_equal_opps/add
parent: opencase.opencase_add_new_things_menu
weight: 10
opencase.opencase_admin_menu:
title: 'Administration'
description: 'Management and Configuration'

View File

@ -89,6 +89,8 @@ function opencase_uninstall() {
'block.block.opencase',
'system.menu.opencase',
'views.view.contact_details_changes',
'views.view.equal_opps_records',
'block.block.exposedformequal_opps_recordspage_1',
];
foreach($configs as $config) {
Drupal::configFactory()->getEditable($config)->delete();
@ -112,3 +114,18 @@ function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefini
}
/**
* Implementation of hook_form_alter()
* Changes what page is redirected to after adding or deleting linked organisation
*/
function opencase_form_alter(&$form, &$form_state, $form_id) {
if (preg_match('/oc_organisation_relation_.*_delete_form/', $form_id) or (preg_match('/oc_organisation_relation_.*_add_form/', $form_id))) {
$form['actions']['submit']['#submit'][] = '_opencase_organisation_relation_redirect';
// $form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl();
}
}
function _opencase_organisation_relation_redirect($form, &$form_state) {
$organisation_id = \Drupal::request()->query->get('organisation_id');
$form_state->setRedirect('entity.oc_organisation.canonical', ['oc_organisation' => $organisation_id]);
}

View File

@ -45,7 +45,7 @@ class AddActorsMenuLink extends DeriverBase implements ContainerDeriverInterface
$actorTypes = $this->entityTypeManager->getStorage('oc_actor_type')->loadMultiple();
foreach ($actorTypes as $id => $actorType) {
$links[$id] = [
'title' => "Add ". $actorType->label(),
'title' => $actorType->label(),
'route_name' => "entity.oc_actor.add_form",
'route_parameters' => ['oc_actor_type' => $actorType->id()]
] + $base_plugin_definition;

View File

@ -45,7 +45,7 @@ class AddEventsMenuLink extends DeriverBase implements ContainerDeriverInterface
$eventTypes = $this->entityTypeManager->getStorage('oc_event_type')->loadMultiple();
foreach ($eventTypes as $id => $eventType) {
$links[$id] = [
'title' => "Add ". $eventType->label() . " Event",
'title' => $eventType->label() . " Event",
'route_name' => "entity.oc_event.add_form",
'route_parameters' => ['oc_event_type' => $eventType->id()]
] + $base_plugin_definition;

View File

@ -45,7 +45,7 @@ class AddOrganisationsMenuLink extends DeriverBase implements ContainerDeriverIn
$organisationTypes = $this->entityTypeManager->getStorage('oc_organisation_type')->loadMultiple();
foreach ($organisationTypes as $id => $organisationType) {
$links[$id] = [
'title' => "Add ". $organisationType->label(),
'title' => $organisationType->label(),
'route_name' => "entity.oc_organisation.add_form",
'route_parameters' => ['oc_organisation_type' => $organisationType->id()]
] + $base_plugin_definition;

View File

@ -0,0 +1,36 @@
<?php
namespace Drupal\opencase\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter;
/**
* Plugin implementation of the 'entity reference label delta' formatter.
*
* @FieldFormatter(
* id = "entity_reference_current_target_excluder",
* label = @Translation("Exclude current entity from list (ONLY WORKS WITH ORGS FOR NOW)"),
* description = @Translation("Don't show the referenced entity if it is the entity being currently viewed"),
* field_types = {
* "entity_reference"
* }
* )
*/
class EntityReferenceCurrentTargetExcluder extends EntityReferenceLabelFormatter {
// Remove the item which matches the organisation being currently viewed.
public function viewElements(\Drupal\Core\Field\FieldItemListInterface $items, $langcode) {
foreach($items as $delta=>$item) {
$current_org = \Drupal::routeMatch()->getParameter('oc_organisation')->id();
$item_target_id = $item->get('target_id')->getValue();
\Drupal::logger("foo")->error($current_org . " " . $item_target_id);
if ($current_org == $item_target_id) {
$items->removeItem($delta);
break;
}
}
$elements = parent::viewElements($items, $langcode);
return $elements;
}
//
}