Hid some fields in case form display

also added destination to case creator ajax links
This commit is contained in:
naomi 2018-04-12 18:45:49 +02:00
parent 109c3e14c9
commit 74e98818ba
2 changed files with 24 additions and 28 deletions

View File

@ -161,24 +161,22 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->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);
# ->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' => '',
# ],
# ])
->setTranslatable(TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -197,8 +195,6 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
'type' => 'string_textfield',
'weight' => -4,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
@ -229,11 +225,11 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Case entity is published.'))
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
# ->setDisplayOptions('form', [
# 'type' => 'boolean_checkbox',
# 'weight' => -3,
# ])
->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))

View File

@ -54,7 +54,7 @@ class PersonPanel extends BlockBase {
// they have hats, so display the case view for each hat.
foreach($hats as $hat) {
$markup .= $this->showCases($hat);
$markup .= $this->showCaseCreationLinks($hat);
$markup .= $this->showCaseCreationLinks($hat, $person_id);
}
}
}
@ -77,12 +77,12 @@ class PersonPanel extends BlockBase {
}
// Provides links to create different types of cases, passing in the hat id.
private function showCaseCreationLinks($hat) {
private function showCaseCreationLinks($hat, $person_id) {
$hat_id = $hat->id();
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('case_entity');
foreach($case_types as $case_type_id => $type) {
$label = $type['label'];
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/case/$hat_id/add/$case_type_id?destination=/zencrm/hat/$hat_id'>Add a $label Case</a></p>";
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/case/$hat_id/add/$case_type_id?destination=/zencrm/person/$person_id'>Add a $label Case</a></p>";
}
return "<div class='zencrm_creationlinks'>$markup</div>";
}