Deleting activity in "No Cases" mode should redirect to first linked person, and other changes

This commit is contained in:
2021-02-05 13:43:11 +00:00
parent 06937b7443
commit 2bc1abc7a7
9 changed files with 437 additions and 24 deletions

View File

@ -191,3 +191,18 @@ function opencase_entities_theme_suggestions_oc_event(array $variables) {
$suggestions[] = 'oc_event__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/* Presave hook on actor entities to manage user creation.
- If a linked user already exists with that email, it does nothing.
- If a user exists with that email but it has no linked actor, it links it.
- If a user exists with that email which already has a linked actor, it fails validation.
- If a linked user exists with a different email, it updates the email.
*/
function opencase_entities_oc_actor_presave(Drupal\Core\Entity\EntityInterface $entity) {
if ($entity->get('user_login')->value) {
error_log($entity->get('first_name')->value);
error_log($entity->get('last_name')->value);
error_log($entity->get('email')->value);
}
}

View File

@ -263,6 +263,8 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
@ -299,6 +301,8 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setSettings([
'suffix' => 'minutes',
])
->SetDisplayConfigurable("form", true)
->SetDisplayConfigurable("view", true)
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',

View File

@ -118,7 +118,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
$name = $this->get('first_name')->value . ' ';
if ($this->get('middle_names')->value) $name .= $this->get('middle_names')->value . ' ';
$name .= $this->get('last_name')->value . ' ';
$name .= '(' . $this->bundle() . ')';
$name .= '(' . $this->type->entity->label() . ')';
$this->setName($name);
@ -284,7 +284,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setRequired(TRUE);
// Contact details.
// so it is not exposed to user configuration.
$fields['email'] = BaseFieldDefinition::create('string')
->setLabel(t('Email Address'))
->setRevisionable(TRUE)
@ -293,6 +292,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'max_length' => 30,
'text_processing' => 0,
))
->setDisplayConfigurable('form', true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
@ -387,6 +387,13 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['user_login'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Login Access'))
->setDescription(t('Whether this person should be able to log into the system.'))
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('display', true)
->setDefaultValue(FALSE);
return $fields;
}