removed stuff to do with allowed activity types.
This commit is contained in:
parent
5eef57f470
commit
27e7e3ae2a
@ -3,13 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: asylum_support
|
||||
label: 'Asylum support'
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -3,13 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: employability
|
||||
label: Employability
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -4,14 +4,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: enquiry
|
||||
label: Enquiry
|
||||
allowedActivityTypes:
|
||||
application: 0
|
||||
case_note: 0
|
||||
destitution_funds_provided: 0
|
||||
email: 0
|
||||
interview: 0
|
||||
lete: 0
|
||||
research: 0
|
||||
supervision: 0
|
||||
telephone_call: 0
|
||||
volunteer_training_session: 0
|
||||
|
@ -3,13 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: health
|
||||
label: Health
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -3,13 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: immigration
|
||||
label: Immigration
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -4,13 +4,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: pro_bono_immigration_service
|
||||
label: 'Pro Bono Immigration Service'
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -3,14 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: volunteer_engagement
|
||||
label: 'Volunteer Engagement'
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
supervision: supervision
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: volunteer_training_session
|
||||
destitution_funds_provided: 0
|
||||
|
@ -3,13 +3,3 @@ status: true
|
||||
dependencies: { }
|
||||
id: welfare_rights
|
||||
label: 'Welfare Rights'
|
||||
allowedActivityTypes:
|
||||
application: application
|
||||
case_note: case_note
|
||||
destitution_funds_provided: destitution_funds_provided
|
||||
email: email
|
||||
interview: interview
|
||||
lete: lete
|
||||
research: research
|
||||
telephone_call: telephone_call
|
||||
volunteer_training_session: 0
|
||||
|
@ -10,7 +10,6 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\opencase_defaults\EntityTypeRelationsWidget;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
@ -59,21 +58,3 @@ function opencase_defaults_entity_base_field_info($entity_type) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_ID_alter
|
||||
*/
|
||||
function opencase_defaults_form_oc_case_type_add_form_alter(&$form, $form_state) {
|
||||
$widget = new EntityTypeRelationsWidget();
|
||||
$widget->setup($form);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_form_ID_alter
|
||||
*/
|
||||
function opencase_defaults_form_oc_case_type_edit_form_alter(&$form, $form_state) {
|
||||
$widget = new EntityTypeRelationsWidget();
|
||||
$widget->setup($form);
|
||||
$widget->populate($form);
|
||||
}
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_defaults;
|
||||
|
||||
/**
|
||||
* Stuff to do with the relationship of case types to actor types, and activity types to case types
|
||||
*
|
||||
*/
|
||||
class EntityTypeRelations {
|
||||
|
||||
public static function getAllowedActivityTypesForCaseType($case_type) {
|
||||
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type);
|
||||
$allowedActivityTypes = $caseTypeConfig->get('allowedActivityTypes'); // format: ['application' => 'application', 'interview' => 0]
|
||||
if (!$allowedActivityTypes) $allowedActivityTypes = array();
|
||||
return $allowedActivityTypes;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_defaults;
|
||||
|
||||
/**
|
||||
* Manages GUI for configuring relations between case types and actor types, or activity types and case types
|
||||
*
|
||||
*/
|
||||
class EntityTypeRelationsWidget {
|
||||
|
||||
/**
|
||||
* Adds actor type and activity type checkboxes to the case type form, and adds the submit handler
|
||||
*
|
||||
* $form - the form to be modified (reference)
|
||||
*/
|
||||
public function setup(&$form) {
|
||||
# $actor_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_actor');
|
||||
# $options = array();
|
||||
# foreach($actor_types as $machine_name => $info) {
|
||||
# $options[$machine_name] = $info['label'];
|
||||
# }
|
||||
# $form['allowed_actor_types'] = array(
|
||||
# '#title' => t('Allowed involved parties'),
|
||||
# '#description' => t('Types of people that can be involved in this kind of case.'),
|
||||
# '#type' => 'checkboxes',
|
||||
# '#options' => $options
|
||||
# );
|
||||
$activity_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||
$options = array();
|
||||
foreach($activity_types as $machine_name => $info) {
|
||||
$options[$machine_name] = $info['label'];
|
||||
}
|
||||
$form['allowed_activity_types'] = array(
|
||||
'#title' => t('Activity types'),
|
||||
'#description' => t('Types of activities that can be logged against this case.'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $options
|
||||
);
|
||||
$form['actions']['submit']['#submit'][] = array($this, 'submit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the form with actor/activity types that are already set
|
||||
*
|
||||
* $form - the form to be modified (reference)
|
||||
*/
|
||||
public function populate(&$form) {
|
||||
$case_type = $form['id']['#default_value'];
|
||||
# $allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type);
|
||||
# $form['allowed_actor_types']['#default_value'] = $allowedActorTypes;
|
||||
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($case_type);
|
||||
$form['allowed_activity_types']['#default_value'] = $allowedActivityTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback which takes the data from the actor types and activity types fields and
|
||||
* creates/edits the relevant config objects
|
||||
*
|
||||
* $form - the form that is being submitted
|
||||
* $form_state - the data in the form
|
||||
*/
|
||||
public function submit($form, $form_state) {
|
||||
$case_type_machine_name = $form['id']['#default_value'] ? $form['id']['#default_value'] : $form_state->getValue('id');
|
||||
# $base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type_machine_name.actors_involved");
|
||||
# if (!$base_field_override) {
|
||||
# $entity_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('oc_case');
|
||||
# $field_definition = $entity_fields['actors_involved'];
|
||||
# $base_field_override = \Drupal\Core\field\Entity\BaseFieldOverride::createFromBaseFieldDefinition($field_definition, $case_type_machine_name);
|
||||
# }
|
||||
# $base_field_override->setSetting('handler_settings', ['target_bundles' => $form_state->getValue('allowed_actor_types')]);
|
||||
# $base_field_override->save();
|
||||
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type_machine_name);
|
||||
$caseTypeConfig->set('allowedActivityTypes', $form_state->getValue('allowed_activity_types'));
|
||||
$caseTypeConfig->save();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user