Added full_name field to actors, and made the administer entities permission finer grained

This commit is contained in:
2021-02-08 13:38:54 +00:00
parent 6fbaf433e8
commit 3dd71bf2c0
11 changed files with 62 additions and 38 deletions

View File

@ -24,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
* },
* },
* config_prefix = "oc_activity_type",
* admin_permission = "administer opencase entity bundles",
* admin_permission = "administer activity bundles",
* bundle_of = "oc_activity",
* entity_keys = {
* "id" = "id",

View File

@ -114,10 +114,14 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
$translation->setOwnerId(0);
}
}
$name = $this->get('first_name')->value . ' ';
if ($this->get('middle_names')->value) $name .= $this->get('middle_names')->value . ' ';
$name .= $this->get('last_name')->value . ' ';
if ($this->get('full_name')->value) {
$name = $this->get('full_name')->value . ' ';
} else {
$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->type->entity->label() . ')';
$this->setName($name);
@ -238,6 +242,24 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
'weight' => -10,
]);
// When configuring a person type, you will need to choose whether to have full name or first and last name fields displayed.
$fields['full_name'] = BaseFieldDefinition::create('string')
->setDescription(t('The person\'s name.'))
->setLabel(t('Name'))
->setRevisionable(TRUE)
->setSettings([
'max_length' => 20,
'text_processing' => 0,
])
->setDisplayConfigurable("form", true)
->setDisplayConfigurable("view", true)
->setDefaultValue('')
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -50,
])
->setRequired(TRUE);
$fields['first_name'] = BaseFieldDefinition::create('string')
->setLabel(t('First Name'))
->setDescription(t("The person's first name."))

View File

@ -24,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
* },
* },
* config_prefix = "oc_actor_type",
* admin_permission = "administer opencase entity bundles",
* admin_permission = "administer actor bundles",
* bundle_of = "oc_actor",
* entity_keys = {
* "id" = "id",

View File

@ -144,24 +144,7 @@ class OCBankAccount extends ContentEntityBase implements OCBankAccountInterface
->setDescription(t('The user ID of author of the Bank Account entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
->setSetting('handler', 'default');
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))

View File

@ -24,7 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
* },
* },
* config_prefix = "oc_case_type",
* admin_permission = "administer opencase entity bundles",
* admin_permission = "administer case bundles",
* bundle_of = "oc_case",
* entity_keys = {
* "id" = "id",