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) { public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($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') $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.')) ->setDescription(t('The user ID of author of the Activity entity.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSetting('target_type', 'user') ->setSetting('target_type', 'user')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'hidden', 'label' => 'inline',
'type' => 'author', 'type' => 'author',
'weight' => 0, 'weight' => -3,
]) ]);
->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') $fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name')) ->setLabel(t('Name'))
@ -247,14 +242,12 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'type' => 'string', 'type' => 'string',
'weight' => -4, 'weight' => -2,
]) ])
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -4, 'weight' => -2,
]) ])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE); ->setRequired(TRUE);
$fields['oc_case'] = BaseFieldDefinition::create('entity_reference') $fields['oc_case'] = BaseFieldDefinition::create('entity_reference')
@ -266,7 +259,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setCardinality(1) ->setCardinality(1)
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete', 'type' => 'entity_reference_autocomplete',
'weight' => 5, 'weight' => -1,
'settings' => [ 'settings' => [
'match_operator' => 'CONTAINS', 'match_operator' => 'CONTAINS',
'size' => '60', 'size' => '60',
@ -274,19 +267,13 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'placeholder' => '', 'placeholder' => '',
], ],
]) ])
->setDisplayOptions('form', [
'label' => 'above',
'weight' => -1
])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::defaultVal') ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::defaultVal')
->setRequired(TRUE); ->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') $fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created')) ->setLabel(t('Created'))
->setDescription(t('The time that the entity was 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) { public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($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') $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.')) ->setDescription(t('The user ID of author of the Actor entity.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSetting('target_type', 'user') ->setSetting('target_type', 'user')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'hidden', 'label' => 'inline',
'type' => 'author', 'type' => 'author',
'weight' => 0, 'weight' => -4,
]) ]);
->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);
$fields['first_name'] = BaseFieldDefinition::create('string') $fields['first_name'] = BaseFieldDefinition::create('string')
->setLabel(t('First Name')) ->setLabel(t('First Name'))
@ -255,11 +250,11 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'type' => 'string', 'type' => 'string',
'weight' => -4, 'weight' => -3,
]) ])
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -4, 'weight' => -3,
]) ])
->setRequired(TRUE); ->setRequired(TRUE);
@ -275,11 +270,11 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'type' => 'string', 'type' => 'string',
'weight' => -4, 'weight' => -2,
]) ])
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -4, 'weight' => -2,
]) ])
->setRequired(FALSE); ->setRequired(FALSE);
@ -295,31 +290,21 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'type' => 'string', 'type' => 'string',
'weight' => -4, 'weight' => -1,
]) ])
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -4, 'weight' => -1,
]) ])
->setRequired(TRUE); ->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') $fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created')) ->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.')); ->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed') $fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('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') $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected')) ->setLabel(t('Revision translation affected'))

View File

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