From 690ec3b509f280ce8293827b4f0d58aa08d8a4a4 Mon Sep 17 00:00:00 2001 From: Naomi Date: Sun, 15 Nov 2020 17:39:50 +0000 Subject: [PATCH] Put cases menu link back, and some other things --- .../opencase_defaults.links.menu.yml | 7 -- .../opencase_entities.install | 12 +++ .../opencase_entities/src/Entity/OCCase.php | 1 - .../src/Entity/OCOrganisation.php | 99 ++++++++----------- opencase.links.menu.yml | 16 +++ ...uLink.php => AddOrganisationsMenuLink.php} | 0 ...uLink.php => AddOrganisationsMenuLink.php} | 0 .../Menu/SeeAllOrganisationsMenuLink.php | 2 +- 8 files changed, 70 insertions(+), 67 deletions(-) rename src/Plugin/Derivative/{AddOrganisationssMenuLink.php => AddOrganisationsMenuLink.php} (100%) rename src/Plugin/Menu/{AddOrganisationssMenuLink.php => AddOrganisationsMenuLink.php} (100%) diff --git a/modules/opencase_defaults/opencase_defaults.links.menu.yml b/modules/opencase_defaults/opencase_defaults.links.menu.yml index 7b8f542..676786c 100644 --- a/modules/opencase_defaults/opencase_defaults.links.menu.yml +++ b/modules/opencase_defaults/opencase_defaults.links.menu.yml @@ -10,10 +10,3 @@ opencase_defaults.report_on_volunteers: parent: opencase_reporting.reporting_menu url: internal:/opencase/reporting/volunteers weight: 1 -opencase.opencase_all_cases: - title: 'Cases' - description: 'All cases I have access to' - menu_name: opencase - parent: opencase.see_all - url: internal:/opencase/all-cases - weight: -1 diff --git a/modules/opencase_entities/opencase_entities.install b/modules/opencase_entities/opencase_entities.install index dbd0432..1ce7840 100644 --- a/modules/opencase_entities/opencase_entities.install +++ b/modules/opencase_entities/opencase_entities.install @@ -3,6 +3,18 @@ use \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchemaConverter; +function opencase_entities_update_80197() { + //check if the table exists first. If not, then create the entity. + if(!db_table_exists('oc_organisation')) { + \Drupal::entityTypeManager()->clearCachedDefinitions(); + \Drupal::entityDefinitionUpdateManager() + ->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_organisation')); + } + else { + return 'Organisation entity already exists'; + } +} + function opencase_entities_update_80192(&$sandbox) { $schema_converter = new SqlContentEntityStorageSchemaConverter( 'oc_actor', diff --git a/modules/opencase_entities/src/Entity/OCCase.php b/modules/opencase_entities/src/Entity/OCCase.php index e4902cc..b6526fc 100644 --- a/modules/opencase_entities/src/Entity/OCCase.php +++ b/modules/opencase_entities/src/Entity/OCCase.php @@ -272,7 +272,6 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { ->setDisplayOptions('view', [ 'label' => 'above', ]) - ->setDisplayConfigurable('form', true) ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCCase::defaultVal') ->setRequired(TRUE); diff --git a/modules/opencase_entities/src/Entity/OCOrganisation.php b/modules/opencase_entities/src/Entity/OCOrganisation.php index 27f30d0..743caf8 100644 --- a/modules/opencase_entities/src/Entity/OCOrganisation.php +++ b/modules/opencase_entities/src/Entity/OCOrganisation.php @@ -56,17 +56,17 @@ use Drupal\user\UserInterface; * "published" = "status", * }, * links = { - * "canonical" = "/opencase//oc_organisation/{oc_organisation}", - * "add-page" = "/opencase//oc_organisation/add", - * "add-form" = "/opencase//oc_organisation/add/{oc_organisation_type}", - * "edit-form" = "/opencase//oc_organisation/{oc_organisation}/edit", - * "delete-form" = "/opencase//oc_organisation/{oc_organisation}/delete", - * "version-history" = "/opencase//oc_organisation/{oc_organisation}/revisions", - * "revision" = "/opencase//oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/view", - * "revision_revert" = "/opencase//oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/revert", - * "revision_delete" = "/opencase//oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/delete", - * "translation_revert" = "/opencase//oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/revert/{langcode}", - * "collection" = "/opencase//oc_organisation", + * "canonical" = "/opencase/oc_organisation/{oc_organisation}", + * "add-page" = "/opencase/oc_organisation/add", + * "add-form" = "/opencase/oc_organisation/add/{oc_organisation_type}", + * "edit-form" = "/opencase/oc_organisation/{oc_organisation}/edit", + * "delete-form" = "/opencase/oc_organisation/{oc_organisation}/delete", + * "version-history" = "/opencase/oc_organisation/{oc_organisation}/revisions", + * "revision" = "/opencase/oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/view", + * "revision_revert" = "/opencase/oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/revert", + * "revision_delete" = "/opencase/oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/delete", + * "translation_revert" = "/opencase/oc_organisation/{oc_organisation}/revisions/{oc_organisation_revision}/revert/{langcode}", + * "collection" = "/opencase/oc_organisation", * }, * bundle_entity_type = "oc_organisation_type", * field_ui_base_route = "entity.oc_organisation_type.edit_form" @@ -205,11 +205,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'basic_string', - 'weight' => -10, + 'weight' => 50, )) ->setDisplayOptions('form', array( 'type' => 'string_textarea', - 'weight' => -10, + 'weight' => 50, )); $fields['contact_name'] = BaseFieldDefinition::create('string') ->setLabel(t('Contact Name')) @@ -223,11 +223,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', [ 'label' => 'above', 'type' => 'string', - 'weight' => -8, + 'weight' => 51, ]) ->setDisplayOptions('form', [ 'type' => 'string_textfield', - 'weight' => -8, + 'weight' => 51, ]) ->setRequired(FALSE); @@ -242,11 +242,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => -8, + 'weight' => 52, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => -8, + 'weight' => 52, )); $fields['phone'] = BaseFieldDefinition::create('string') @@ -260,11 +260,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => -7, + 'weight' => 53, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => -7, + 'weight' => 53, )); $fields['postal_address'] = BaseFieldDefinition::create('string_long') ->setRevisionable(TRUE) @@ -278,11 +278,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'basic_string', - 'weight' => -5, + 'weight' => 54, )) ->setDisplayOptions('form', array( 'type' => 'string_textarea', - 'weight' => -5, + 'weight' => 54, )); $fields['post_code'] = BaseFieldDefinition::create('string') ->setRevisionable(TRUE) @@ -295,11 +295,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => -4, + 'weight' => 55, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => -4, + 'weight' => 55, )); $fields['billing_contact_name'] = BaseFieldDefinition::create('string') ->setLabel(t('Billing Contact Name')) @@ -313,11 +313,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', [ 'label' => 'above', 'type' => 'string', - 'weight' => -3, + 'weight' => 56, ]) ->setDisplayOptions('form', [ 'type' => 'string_textfield', - 'weight' => -3, + 'weight' => 56, ]) ->setRequired(FALSE); @@ -332,11 +332,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => -2, + 'weight' => 57, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => -2, + 'weight' => 57, )); $fields['billing_phone'] = BaseFieldDefinition::create('string') @@ -350,11 +350,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => -1, + 'weight' => 58, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => -1, + 'weight' => 58, )); $fields['billing_postal_address'] = BaseFieldDefinition::create('string_long') ->setRevisionable(TRUE) @@ -368,11 +368,11 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'basic_string', - 'weight' => -0, + 'weight' => 59, )) ->setDisplayOptions('form', array( 'type' => 'string_textarea', - 'weight' => -0, + 'weight' => 59, )); $fields['billing_post_code'] = BaseFieldDefinition::create('string') ->setRevisionable(TRUE) @@ -385,36 +385,23 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ->setDisplayOptions('view', array( 'label' => 'above', 'type' => 'string', - 'weight' => 1, + 'weight' => 60, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', - 'weight' => 1, + 'weight' => 60, )); $fields['user_id'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Authored by')) - ->setDescription(t('The user ID of author of the Organisation entity.')) + ->setLabel(t('Added by')) ->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' => 80, + ]); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Name')) @@ -426,23 +413,19 @@ class OCOrganisation extends EditorialContentEntityBase implements OCOrganisatio ]) ->setDefaultValue('') ->setDisplayOptions('view', [ - 'label' => 'above', + 'label' => 'hidden', 'type' => 'string', - 'weight' => -4, + 'weight' => -100, ]) ->setDisplayOptions('form', [ 'type' => 'string_textfield', - 'weight' => -4, + 'weight' => -100, ]) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE) ->setRequired(TRUE); - $fields['status']->setDescription(t('A boolean indicating whether the Organisation is published.')) - ->setDisplayOptions('form', [ - 'type' => 'boolean_checkbox', - 'weight' => -3, - ]); + $fields['status']->setDescription(t('A boolean indicating whether the Organisation is published.')); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) diff --git a/opencase.links.menu.yml b/opencase.links.menu.yml index 3cdaa02..8b383c0 100644 --- a/opencase.links.menu.yml +++ b/opencase.links.menu.yml @@ -3,11 +3,22 @@ opencase.see_all: menu_name: opencase route_name: opencase.opencase_cases_menu weight: 0 +opencase.opencase_all_cases: + title: 'Cases' + menu_name: opencase + parent: opencase.see_all + url: internal:/opencase/all-cases + weight: -1 opencase.see_all_people_links: class: Drupal\opencase\Plugin\Menu\SeeAllActorsMenuLink deriver: Drupal\opencase\Plugin\Derivative\SeeAllActorsMenuLink menu_name: opencase parent: opencase.see_all +opencase.see_all_organisations_links: + class: Drupal\opencase\Plugin\Menu\SeeAllOrganisationsMenuLink + deriver: Drupal\opencase\Plugin\Derivative\SeeAllOrganisationsMenuLink + menu_name: opencase + parent: opencase.see_all opencase.opencase_add_new_things_menu: title: 'Add new...' menu_name: opencase @@ -18,6 +29,11 @@ opencase.add_people_links: deriver: Drupal\opencase\Plugin\Derivative\AddActorsMenuLink menu_name: opencase parent: opencase.opencase_add_new_things_menu +opencase.add_organisations_links: + class: Drupal\opencase\Plugin\Menu\AddOrganisationsMenuLink + deriver: Drupal\opencase\Plugin\Derivative\AddOrganisationsMenuLink + menu_name: opencase + parent: opencase.opencase_add_new_things_menu opencase.opencase_admin_menu: title: 'Administration' description: 'Management and Configuration' diff --git a/src/Plugin/Derivative/AddOrganisationssMenuLink.php b/src/Plugin/Derivative/AddOrganisationsMenuLink.php similarity index 100% rename from src/Plugin/Derivative/AddOrganisationssMenuLink.php rename to src/Plugin/Derivative/AddOrganisationsMenuLink.php diff --git a/src/Plugin/Menu/AddOrganisationssMenuLink.php b/src/Plugin/Menu/AddOrganisationsMenuLink.php similarity index 100% rename from src/Plugin/Menu/AddOrganisationssMenuLink.php rename to src/Plugin/Menu/AddOrganisationsMenuLink.php diff --git a/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php b/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php index ebe98b7..02849a4 100644 --- a/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php +++ b/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php @@ -3,4 +3,4 @@ namespace Drupal\opencase\Plugin\Menu; use Drupal\Core\Menu\MenuLinkDefault; -class SeeAllOrganisationgMenuLink extends MenuLinkDefault {} +class SeeAllOrganisationsMenuLink extends MenuLinkDefault {}