Moved base fields around

Because you can't make it put them at the bottom, so I have given them all negative weights so they go at the top and the custom fields start at 0. User is at the top
This commit is contained in:
naomi 2018-05-07 14:49:31 +02:00
parent c1c981fddd
commit 18d0303f54
3 changed files with 59 additions and 103 deletions

View File

@ -210,30 +210,25 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// not currently in use. Will set view and form settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Activity is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setLabel(t('Entered by'))
->setDescription(t('The user ID of author of the Activity entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'label' => 'inline',
'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);
'weight' => -3,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -247,14 +242,12 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
'weight' => -2,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -2,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['oc_case'] = BaseFieldDefinition::create('entity_reference')
@ -266,7 +259,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setCardinality(1)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'weight' => -1,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
@ -274,19 +267,13 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'placeholder' => '',
],
])
->setDisplayOptions('form', [
'label' => 'above',
'weight' => -1
])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::defaultVal')
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Activity is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));

View File

@ -210,38 +210,33 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// Currently not using this, but will add form and view settings when ready.
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('Whether this record is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE);
// The name gets set on preSave, from the first middle and last
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setSettings([
'max_length' => 100,
'text_processing' => 0,
]);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setLabel(t('Entered by'))
->setDescription(t('The user ID of author of the Actor entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'label' => 'inline',
'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);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setSettings([
'max_length' => 100,
'text_processing' => 0,
])
->setRequired(TRUE);
'weight' => -4,
]);
$fields['first_name'] = BaseFieldDefinition::create('string')
->setLabel(t('First Name'))
@ -255,11 +250,11 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -3,
])
->setRequired(TRUE);
@ -275,11 +270,11 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
'weight' => -2,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -2,
])
->setRequired(FALSE);
@ -295,31 +290,21 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
'weight' => -1,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -1,
])
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Actor is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
->setDescription(t('The time that the entity was last edited.'));
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))

View File

@ -211,31 +211,25 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// not currently used. Will add form and view settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Case is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setLabel(t('Entered by'))
->setDescription(t('The user ID of author of the Case entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'label' => 'inline',
'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);
'weight' => -3,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Case entity.'))
@ -248,16 +242,14 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -4,
'weight' => -2,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -2,
])
->setRequired(TRUE);
$fields['actors_involved'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Involved Parties'))
->setDescription(t('People involved in this case, in their various capacities'))
@ -267,7 +259,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setCardinality(-1)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'weight' => -1,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
@ -277,19 +269,11 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
])
->setDisplayOptions('view', [
'label' => 'above',
'weight' => -1
])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCCase::defaultVal')
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Case is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))