From 20ed3d4f3916cc9567318bdef85c53e52d72a9c9 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 8 Apr 2022 14:00:44 +0200 Subject: [PATCH] added see al org's page and menu item, made fields configurable for actor --- .../src/Entity/OCActivity.php | 26 +----- .../opencase_entities/src/Entity/OCActor.php | 81 +++---------------- opencase.links.menu.yml | 29 ++++--- .../SeeAllOrganisationsMenuLink.php | 55 +++++++++++++ .../Menu/SeeAllOrganisationsMenuLink.php | 9 +++ 5 files changed, 94 insertions(+), 106 deletions(-) create mode 100644 src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php create mode 100644 src/Plugin/Menu/SeeAllOrganisationsMenuLink.php diff --git a/modules/opencase_entities/src/Entity/OCActivity.php b/modules/opencase_entities/src/Entity/OCActivity.php index 5389c92..3448444 100644 --- a/modules/opencase_entities/src/Entity/OCActivity.php +++ b/modules/opencase_entities/src/Entity/OCActivity.php @@ -267,6 +267,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.') ->setRevisionable(TRUE) ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', true) ->setDefaultValue(TRUE); $fields['user_id'] = BaseFieldDefinition::create('entity_reference') @@ -277,10 +278,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte ->setSetting('handler', 'default') ->setTranslatable(TRUE) ->setDisplayConfigurable('view', true) - ->setDisplayOptions('view', [ - 'label' => 'above', - 'type' => 'author', - ]); + ->setDisplayConfigurable('form', TRUE); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Subject')) @@ -292,15 +290,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte ->setDefaultValue('') ->setDisplayConfigurable('form', true) ->setDisplayConfigurable('view', true) - ->setDisplayOptions('view', [ - 'label' => 'hidden', - 'type' => 'string', - 'weight' => -3, - ]) - ->setDisplayOptions('form', [ - 'type' => 'string_textfield', - 'weight' => -3, - ]) ->setRequired(TRUE); $fields['description'] = BaseFieldDefinition::create('string_long') @@ -310,7 +299,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte 'max_length' => 50, 'text_processing' => 0, ]) - ->setDefaultValue('') ->setDisplayConfigurable('form', true) ->setDisplayConfigurable('view', true) ->setRequired(FALSE); @@ -322,15 +310,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte 'suffix' => 'minutes', ]) ->SetDisplayConfigurable("form", true) - ->SetDisplayConfigurable("view", true) - ->setDefaultValue('') - ->setDisplayOptions('view', [ - 'label' => 'above', - 'weight' => -3, - ]) - ->setDisplayOptions('form', [ - 'weight' => -3, - ]); + ->SetDisplayConfigurable("view", true); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) diff --git a/modules/opencase_entities/src/Entity/OCActor.php b/modules/opencase_entities/src/Entity/OCActor.php index a5f9509..49cac12 100644 --- a/modules/opencase_entities/src/Entity/OCActor.php +++ b/modules/opencase_entities/src/Entity/OCActor.php @@ -122,7 +122,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface $name = $this->get('first_name')->value . ' '; if ($this->get('middle_names')->value) $name .= $this->get('middle_names')->value . ' '; $name .= $this->get('last_name')->value . ' '; - + $this->setName($name); // If no revision author has been set explicitly, make the oc_actor owner the @@ -218,6 +218,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.') ->setRevisionable(TRUE) ->setDisplayConfigurable("form", true) + ->setDisplayConfigurable("view", true) ->setDefaultValue(TRUE); // The name gets set on preSave, from the first middle and last @@ -226,7 +227,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setSettings([ 'max_length' => 100, 'text_processing' => 0, - ]); + ]); $fields['user_id'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Entered by')) @@ -234,6 +235,8 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') + ->setDisplayConfigurable("form", true) + ->setDisplayConfigurable("view", true) ->setTranslatable(TRUE); $fields['first_name'] = BaseFieldDefinition::create('string') @@ -247,10 +250,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setDisplayConfigurable("form", true) ->setDisplayConfigurable("view", true) ->setDefaultValue('') - ->setDisplayOptions('form', [ - 'type' => 'string_textfield', - 'weight' => -100, - ]) ->setRequired(TRUE); $fields['middle_names'] = BaseFieldDefinition::create('string') @@ -264,10 +263,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setDisplayConfigurable("form", true) ->setDisplayConfigurable("view", true) ->setDefaultValue('') - ->setDisplayOptions('form', [ - 'type' => 'string_textfield', - 'weight' => -99, - ]) ->setRequired(FALSE); $fields['last_name'] = BaseFieldDefinition::create('string') @@ -281,10 +276,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, ]) ->setDefaultValue('') - ->setDisplayOptions('form', [ - 'type' => 'string_textfield', - 'weight' => -98, - ]) ->setRequired(TRUE); // Contact details. @@ -297,16 +288,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, )) ->setDisplayConfigurable("form", true) - ->setDisplayConfigurable("view", true) - ->setDisplayOptions('view', array( - 'label' => 'above', - 'type' => 'string', - 'weight' => -5, - )) - ->setDisplayOptions('form', array( - 'type' => 'string_textfield', - 'weight' => -5, - )); + ->setDisplayConfigurable("view", true); $fields['phone'] = BaseFieldDefinition::create('string') ->setLabel(t('Main Phone Number')) ->setRevisionable(TRUE) @@ -316,16 +298,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, )) ->setDisplayConfigurable("form", true) - ->setDisplayConfigurable("view", true) - ->setDisplayOptions('view', array( - 'label' => 'above', - 'type' => 'string', - 'weight' => -4, - )) - ->setDisplayOptions('form', array( - 'type' => 'string_textfield', - 'weight' => -4, - )); + ->setDisplayConfigurable("view", true); $fields['phone2'] = BaseFieldDefinition::create('string') ->setRevisionable(TRUE) ->setLabel(t('Alternative Phone Number')) @@ -335,16 +308,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, )) ->setDisplayConfigurable("form", true) - ->setDisplayConfigurable("view", true) - ->setDisplayOptions('view', array( - 'label' => 'above', - 'type' => 'string', - 'weight' => -3, - )) - ->setDisplayOptions('form', array( - 'type' => 'string_textfield', - 'weight' => -3, - )); + ->setDisplayConfigurable("view", true); $fields['postal_address'] = BaseFieldDefinition::create('string_long') ->setRevisionable(TRUE) ->setLabel(t('Postal Address')) @@ -355,16 +319,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, )) ->setDisplayConfigurable("form", true) - ->setDisplayConfigurable("view", true) - ->setDisplayOptions('view', array( - 'label' => 'above', - 'type' => 'basic_string', - 'weight' => -2, - )) - ->setDisplayOptions('form', array( - 'type' => 'string_textarea', - 'weight' => -2, - )); + ->setDisplayConfigurable("view", true); $fields['post_code'] = BaseFieldDefinition::create('string') ->setRevisionable(TRUE) ->setLabel(t('Post Code')) @@ -374,16 +329,7 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface 'text_processing' => 0, )) ->setDisplayConfigurable("form", true) - ->setDisplayConfigurable("view", true) - ->setDisplayOptions('view', array( - 'label' => 'above', - 'type' => 'string', - 'weight' => -1, - )) - ->setDisplayOptions('form', array( - 'type' => 'string_textfield', - 'weight' => -1, - )); + ->setDisplayConfigurable("view", true); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) @@ -400,13 +346,6 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setRevisionable(TRUE) ->setTranslatable(TRUE); - $fields['user_login'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Login Access')) - ->setDescription(t('Whether this person should be able to log into the system.')) - ->setDisplayConfigurable('form', true) - ->setDisplayConfigurable('display', true) - ->setDefaultValue(FALSE); - return $fields; } diff --git a/opencase.links.menu.yml b/opencase.links.menu.yml index 3eb8ffc..ef8ceea 100644 --- a/opencase.links.menu.yml +++ b/opencase.links.menu.yml @@ -1,16 +1,21 @@ opencase.see_all: title: 'See all...' - menu_name: opencase + menu_name: opencase route_name: opencase.opencase_cases_menu - weight: + weight: 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 + menu_name: opencase route_name: opencase.opencase_add_new_things_menu weight: 1 opencase.add_people_links: @@ -38,59 +43,59 @@ opencase.opencase_admin_menu: title: 'Administration' description: 'Management and Configuration' route_name: opencase.opencase_admin_menu - menu_name: opencase + menu_name: opencase weight: 100 opencase.manage_user_logins: title: 'Manage user logins' description: 'Manage who can access the system' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/admin/people weight: 0 opencase.manage_organisation_types: title: 'Manage organisation types' description: 'Configure types of people and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/admin/opencase/oc_organisation_type weight: 1 opencase.manage_person_types: title: 'Manage person types' description: 'Configure types of people and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/admin/opencase/oc_actor_type weight: 1 opencase.manage_activity_types: title: 'Manage activity types' description: 'Configure types of activities and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/admin/opencase/oc_activity_type weight: 3 opencase.manage_case_fee_types: title: 'Manage case fee types' description: 'Configure types of case fees and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/opencase/oc_case_fee_type weight: 3 opencase.manage_case_provision_types: title: 'Manage case provision types' description: 'Configure types of case provisions and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/opencase/oc_case_provision_type weight: 3 opencase.manage_event_types: title: 'Manage event types' description: 'Configure types of people and their fields' menu_name: opencase - parent: opencase.opencase_admin_menu + parent: opencase.opencase_admin_menu url: internal:/admin/opencase/oc_event_type weight: 1 opencase.reporting: title: 'Reporting' - menu_name: opencase + menu_name: opencase route_name: opencase.opencase_reporting_menu weight: 0 diff --git a/src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php b/src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php new file mode 100644 index 0000000..c563a80 --- /dev/null +++ b/src/Plugin/Derivative/SeeAllOrganisationsMenuLink.php @@ -0,0 +1,55 @@ +entityTypeManager = $entity_type_manager; + } + + /** +   * {@inheritdoc} +   */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $base_plugin_id, + $container->get('entity_type.manager') + ); + } + /** +   * {@inheritdoc} +   */ + public function getDerivativeDefinitions($base_plugin_definition) { + $links = []; + $organisationTypes = $this->entityTypeManager->getStorage('oc_organisation_type')->loadMultiple(); + foreach ($organisationTypes as $id => $organisationType) { + $links[$id] = [ + 'title' => $organisationType->label(), + 'route_name' => "view.organisations.page_1", + 'route_parameters' => ['type' => $organisationType->id()] + ] + $base_plugin_definition; + } + return $links; + } +} diff --git a/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php b/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php new file mode 100644 index 0000000..c7e6aa0 --- /dev/null +++ b/src/Plugin/Menu/SeeAllOrganisationsMenuLink.php @@ -0,0 +1,9 @@ +