Hid some fields in case form display
also added destination to case creator ajax links
This commit is contained in:
parent
109c3e14c9
commit
74e98818ba
@ -161,24 +161,22 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
|
|||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
# ->setDisplayOptions('view', [
|
||||||
->setDisplayOptions('view', [
|
# 'label' => 'hidden',
|
||||||
'label' => 'hidden',
|
# 'type' => 'author',
|
||||||
'type' => 'author',
|
# 'weight' => 0,
|
||||||
'weight' => 0,
|
# ])
|
||||||
])
|
# ->setDisplayOptions('form', [
|
||||||
->setDisplayOptions('form', [
|
# 'type' => 'entity_reference_autocomplete',
|
||||||
'type' => 'entity_reference_autocomplete',
|
# 'weight' => 5,
|
||||||
'weight' => 5,
|
# 'settings' => [
|
||||||
'settings' => [
|
# 'match_operator' => 'CONTAINS',
|
||||||
'match_operator' => 'CONTAINS',
|
# 'size' => '60',
|
||||||
'size' => '60',
|
# 'autocomplete_type' => 'tags',
|
||||||
'autocomplete_type' => 'tags',
|
# 'placeholder' => '',
|
||||||
'placeholder' => '',
|
# ],
|
||||||
],
|
# ])
|
||||||
])
|
->setTranslatable(TRUE);
|
||||||
->setDisplayConfigurable('form', TRUE)
|
|
||||||
->setDisplayConfigurable('view', TRUE);
|
|
||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Name'))
|
->setLabel(t('Name'))
|
||||||
@ -197,8 +195,6 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
|
|||||||
'type' => 'string_textfield',
|
'type' => 'string_textfield',
|
||||||
'weight' => -4,
|
'weight' => -4,
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('form', TRUE)
|
|
||||||
->setDisplayConfigurable('view', TRUE)
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
|
|
||||||
@ -229,11 +225,11 @@ class CaseEntity extends ContentEntityBase implements CaseEntityInterface {
|
|||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Publishing status'))
|
->setLabel(t('Publishing status'))
|
||||||
->setDescription(t('A boolean indicating whether the Case entity is published.'))
|
->setDescription(t('A boolean indicating whether the Case entity is published.'))
|
||||||
->setDefaultValue(TRUE)
|
# ->setDisplayOptions('form', [
|
||||||
->setDisplayOptions('form', [
|
# 'type' => 'boolean_checkbox',
|
||||||
'type' => 'boolean_checkbox',
|
# 'weight' => -3,
|
||||||
'weight' => -3,
|
# ])
|
||||||
]);
|
->setDefaultValue(TRUE);
|
||||||
|
|
||||||
$fields['created'] = BaseFieldDefinition::create('created')
|
$fields['created'] = BaseFieldDefinition::create('created')
|
||||||
->setLabel(t('Created'))
|
->setLabel(t('Created'))
|
||||||
|
@ -54,7 +54,7 @@ class PersonPanel extends BlockBase {
|
|||||||
// they have hats, so display the case view for each hat.
|
// they have hats, so display the case view for each hat.
|
||||||
foreach($hats as $hat) {
|
foreach($hats as $hat) {
|
||||||
$markup .= $this->showCases($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.
|
// 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();
|
$hat_id = $hat->id();
|
||||||
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('case_entity');
|
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('case_entity');
|
||||||
foreach($case_types as $case_type_id => $type) {
|
foreach($case_types as $case_type_id => $type) {
|
||||||
$label = $type['label'];
|
$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>";
|
return "<div class='zencrm_creationlinks'>$markup</div>";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user