From 2b293d0ae1bd682589b7af67f07fff8ec00a47b8 Mon Sep 17 00:00:00 2001 From: s j <sj@1729.be> Date: Fri, 21 Apr 2023 09:00:59 +0200 Subject: [PATCH 1/2] imp: remove page manager and panels --- .gitlab-ci/build.php | 2 - modules/dsr_dashboard/composer.json | 2 - ...er.page.shareholder_register_dashboard.yml | 11 ---- ...er_register_dashboard-panels_variant-0.yml | 46 -------------- .../optional/tour.tour.dsr_dashboard.yml | 63 ------------------- modules/dsr_dashboard/dsr_dashboard.info.yml | 3 - 6 files changed, 127 deletions(-) delete mode 100644 modules/dsr_dashboard/config/install/page_manager.page.shareholder_register_dashboard.yml delete mode 100644 modules/dsr_dashboard/config/install/page_manager.page_variant.shareholder_register_dashboard-panels_variant-0.yml delete mode 100644 modules/dsr_dashboard/config/optional/tour.tour.dsr_dashboard.yml diff --git a/.gitlab-ci/build.php b/.gitlab-ci/build.php index c81e18b..eeca696 100644 --- a/.gitlab-ci/build.php +++ b/.gitlab-ci/build.php @@ -77,8 +77,6 @@ $this->composerRequire() ->dependency('drupal/inline_entity_form', '^1.0') ->dependency("drupal/mail_template", "^1.0.7") ->dependency("drupal/mollie_payment", "^3.0") - ->dependency("drupal/page_manager", "4.x-dev") - ->dependency("drupal/panels", "^4.3") ->dependency("drupal/payment", "^2.0") ->dependency("drupal/shareholder_register", "^1.0.26") ->dependency("drupal/shareholder_register_accounting", "^1.0.21") diff --git a/modules/dsr_dashboard/composer.json b/modules/dsr_dashboard/composer.json index 4edcbbc..dbf9a24 100644 --- a/modules/dsr_dashboard/composer.json +++ b/modules/dsr_dashboard/composer.json @@ -31,8 +31,6 @@ } ], "require": { - "drupal/page_manager": "4.x-dev", - "drupal/panels": "^4.3", "drupal/charts": "3.x-dev", "google/charts": "45" } diff --git a/modules/dsr_dashboard/config/install/page_manager.page.shareholder_register_dashboard.yml b/modules/dsr_dashboard/config/install/page_manager.page.shareholder_register_dashboard.yml deleted file mode 100644 index d35794c..0000000 --- a/modules/dsr_dashboard/config/install/page_manager.page.shareholder_register_dashboard.yml +++ /dev/null @@ -1,11 +0,0 @@ -langcode: en -status: true -dependencies: { } -id: shareholder_register_dashboard -label: 'Shareholder Register Dashboard' -description: '' -use_admin_theme: true -path: /admin/shareholder_register -access_logic: and -access_conditions: { } -parameters: { } diff --git a/modules/dsr_dashboard/config/install/page_manager.page_variant.shareholder_register_dashboard-panels_variant-0.yml b/modules/dsr_dashboard/config/install/page_manager.page_variant.shareholder_register_dashboard-panels_variant-0.yml deleted file mode 100644 index 02dfb91..0000000 --- a/modules/dsr_dashboard/config/install/page_manager.page_variant.shareholder_register_dashboard-panels_variant-0.yml +++ /dev/null @@ -1,46 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - page_manager.page.shareholder_register_dashboard - module: - - dsr_dashboard - - panels -id: shareholder_register_dashboard-panels_variant-0 -label: Panels -variant: panels_variant -variant_settings: - blocks: - 2e74085d-f902-44c2-8a06-1394fb625fc0: - id: dsr_infographic_block - label: 'DSR Infographic Block' - provider: dsr_dashboard - label_display: '0' - context_mapping: { } - region: top - uuid: 2e74085d-f902-44c2-8a06-1394fb625fc0 - weight: 1 - 21a11347-d0ee-4b41-9821-db5852bc5b36: - id: dsr_dashboard_block - label: 'DSR Dashboard Block' - provider: dsr_dashboard - label_display: '0' - context_mapping: { } - region: first - uuid: 21a11347-d0ee-4b41-9821-db5852bc5b36 - weight: 1 - id: panels_variant - uuid: e87d05be-920d-4d09-b57e-be2682465fc3 - label: null - weight: 0 - layout: layout_twocol - layout_settings: { } - page_title: '' - storage_type: page_manager - storage_id: shareholder_register_dashboard-panels_variant-0 - builder: ipe -page: shareholder_register_dashboard -weight: 0 -selection_criteria: { } -selection_logic: and -static_context: { } diff --git a/modules/dsr_dashboard/config/optional/tour.tour.dsr_dashboard.yml b/modules/dsr_dashboard/config/optional/tour.tour.dsr_dashboard.yml deleted file mode 100644 index c8f43d9..0000000 --- a/modules/dsr_dashboard/config/optional/tour.tour.dsr_dashboard.yml +++ /dev/null @@ -1,63 +0,0 @@ -id: dsr_dashboard -module: dsr_dashboard -label: Dashboard -langcode: en -routes: - - route_name: system.admin.shareholder_register -tips: - introduction: - id: Inleiding - plugin: text - label: Inleiding - body: Dit dashboard geeft een overzicht van de informatie stroom in het aandeelhoudersregister. Via de links bij de verschillende onderdelen kan u gedetailleerde overzichten raadplegen en de nodige acties uitvoeren. - weight: "1" - container-signup-forms: - id: container-signup-forms - plugin: text - label: Intekenformulieren - body: Dit getal geeft het aantal wachtende intekenformulieren weer. Dit zijn ingediende formulieren waarvoor nog geen betaling geregistreerd is. - weight: "2" - attributes: - data-id: data-signup-forms - container-pending-amount: - id: container-pending-amount - plugin: text - label: Gestort bedrag - body: Dit cijfer geeft het gestorte bedrag weer. Dit bedrag is door kandidaad aandeelhouders aan u overgemaakt maar nog niet in aandelen omgezet. - weight: "3" - attributes: - data-id: data-pending-amount - container-draft-bank-amount: - id: container-draft-bank-amount - plugin: text - label: Niet toegewezen bedrag - body: Dit cijfer geeft het bedrag weer dat in bankafschriften geimporteerd werd maar nog niet toegewezen is. Via de link komt u op een overzicht van bank transacties die u manueel moet opvolgen. U kan deze toewijzen aan een intekenformulier of aangeven dat de transactie niet relevant is voor het aandeelhoudersregister. - weight: "3" - attributes: - data-id: data-draft-bank-amount - container-last-import: - id: container-last-import - plugin: text - label: Laatste bank import - body: Dit is de datum van het laatst geimporteerde bankafschrift. Via de link komt u op een scherm waar u nieuwe bankafschriften kan importeren. - weight: "3" - attributes: - data-id: data-last-import - container-pending-transactions: - id: container-pending-transactions - plugin: text - location: top - label: Aangevraagde transacties - body: Dit cijfer geeft het aantal aangevraagde transacties weer. Aangevraagde transacties worden automatisch aangemaakt wanneer het correcte bedrag gestort is voor een intekenformulier. Via de link kan u de aangevraagde transacties bekijken en door de raad van bestuur laten goedkeuren. Na goedkeuring wordt de transactie opgenomen in het aandeelhoudersregister. - weight: "6" - attributes: - data-id: data-pending-transactions - container-shareholders: - id: container-shareholders - plugin: text - location: top - label: Aandeelhouders - body: Dit cijfer geeft het aantal aandeelhouders weer. Na validatie van een eerste transactie wordt de aandeelhouder geregistreerd. Via de link komt u op een overzicht van alle aandeelhouders. - weight: "7" - attributes: - data-id: data-shareholders diff --git a/modules/dsr_dashboard/dsr_dashboard.info.yml b/modules/dsr_dashboard/dsr_dashboard.info.yml index 61e7d91..f162b28 100644 --- a/modules/dsr_dashboard/dsr_dashboard.info.yml +++ b/modules/dsr_dashboard/dsr_dashboard.info.yml @@ -9,6 +9,3 @@ dependencies: - charts_google - charts_blocks - views - - panels - - panels_ipe - - page_manager -- GitLab From 3b3d410e5b167a7b8d0ac62aba055087c235f9a0 Mon Sep 17 00:00:00 2001 From: s j <sj@1729.be> Date: Sat, 22 Apr 2023 08:26:57 +0200 Subject: [PATCH 2/2] imp: show dsr version on dashboard --- dsr.module | 6 +-- modules/dsr_dashboard/css/dashboard.css | 4 ++ .../dsr_dashboard/dsr_dashboard.services.yml | 7 +++ .../src/Controller/DashboardController.php | 24 +++++++++ .../src/Plugin/Block/DsrDashboardBlock.php | 2 +- .../src/Plugin/Block/DsrInfographicBlock.php | 50 +++++++++++++++++-- .../src/Routing/RouteSubscriber.php | 21 ++++++++ src/DsrDrushService.php | 11 ++++ 8 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 modules/dsr_dashboard/dsr_dashboard.services.yml create mode 100644 modules/dsr_dashboard/src/Controller/DashboardController.php create mode 100644 modules/dsr_dashboard/src/Routing/RouteSubscriber.php diff --git a/dsr.module b/dsr.module index 8b0a08d..1fcd3d3 100644 --- a/dsr.module +++ b/dsr.module @@ -5,8 +5,6 @@ * Contains dsr.module. */ -use Composer\InstalledVersions; - use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Extension\Extension; @@ -56,8 +54,6 @@ function dsr_mail_alter(&$message) { */ function dsr_system_info_alter(array &$info, Extension $file, $type) { if ($file->getName() === 'dsr' && empty($info['version'])) { - if (InstalledVersions::isInstalled('drupal/dsr')) { - $info['version'] = InstalledVersions::getVersion('drupal/dsr'); - } + $info['version'] = \Drupal::service('dsr.drush')->getVersion(); } } diff --git a/modules/dsr_dashboard/css/dashboard.css b/modules/dsr_dashboard/css/dashboard.css index cefdd9a..437e300 100644 --- a/modules/dsr_dashboard/css/dashboard.css +++ b/modules/dsr_dashboard/css/dashboard.css @@ -63,3 +63,7 @@ div.dsr-dashboard-infographic #chart-shares-by-type { width: 30%; height: 20%; } +div.dsr-dashboard-infographic .dsr-version { + font-size: small; + text-align: right; +} diff --git a/modules/dsr_dashboard/dsr_dashboard.services.yml b/modules/dsr_dashboard/dsr_dashboard.services.yml new file mode 100644 index 0000000..fb21b76 --- /dev/null +++ b/modules/dsr_dashboard/dsr_dashboard.services.yml @@ -0,0 +1,7 @@ +services: + + dsr_dashboard.route_subscriber: + class: Drupal\dsr_dashboard\Routing\RouteSubscriber + tags: + - { name: event_subscriber } + diff --git a/modules/dsr_dashboard/src/Controller/DashboardController.php b/modules/dsr_dashboard/src/Controller/DashboardController.php new file mode 100644 index 0000000..1e04d21 --- /dev/null +++ b/modules/dsr_dashboard/src/Controller/DashboardController.php @@ -0,0 +1,24 @@ +<?php + +namespace Drupal\dsr_dashboard\Controller; + +use Drupal\Core\Controller\ControllerBase; + +/** + * The dsr dashboard controller. + */ +class DashboardController extends ControllerBase { + + /** + * Returns a render-able array for the dashboard page. + */ + public function content() { + $block_manager = \Drupal::service('plugin.manager.block'); + $config = []; + $plugin_block = $block_manager->createInstance('dsr_infographic_block', $config); + return [ + $plugin_block->build(), + ]; + } + +} diff --git a/modules/dsr_dashboard/src/Plugin/Block/DsrDashboardBlock.php b/modules/dsr_dashboard/src/Plugin/Block/DsrDashboardBlock.php index a87af99..27e94f9 100644 --- a/modules/dsr_dashboard/src/Plugin/Block/DsrDashboardBlock.php +++ b/modules/dsr_dashboard/src/Plugin/Block/DsrDashboardBlock.php @@ -32,7 +32,7 @@ class DsrDashboardBlock extends BlockBase { * {@inheritdoc} */ public function build() { - $share_type_ids = \Drupal::entityQuery('share_type')->execute(); + $share_type_ids = \Drupal::entityQuery('share_type')->accessCheck(FALSE)->execute(); $categories = []; $series = []; diff --git a/modules/dsr_dashboard/src/Plugin/Block/DsrInfographicBlock.php b/modules/dsr_dashboard/src/Plugin/Block/DsrInfographicBlock.php index 331858d..d70ce4f 100644 --- a/modules/dsr_dashboard/src/Plugin/Block/DsrInfographicBlock.php +++ b/modules/dsr_dashboard/src/Plugin/Block/DsrInfographicBlock.php @@ -2,9 +2,13 @@ namespace Drupal\dsr_dashboard\Plugin\Block; +use Symfony\Component\DependencyInjection\ContainerInterface; + use Drupal\Core\Block\BlockBase; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; +use Drupal\dsr\DsrDrushServiceInterface; use Drupal\shareholder_register\Entity\ShareType; /** @@ -16,7 +20,14 @@ use Drupal\shareholder_register\Entity\ShareType; * category = @Translation("DSR Infographic Block"), * ) */ -class DsrInfographicBlock extends BlockBase { +class DsrInfographicBlock extends BlockBase implements ContainerFactoryPluginInterface { + + /** + * DsrService definition. + * + * @var \Drupal\dsr\DsrDrushServiceInterface + */ + protected $dsrService; private $palette = [ "#aadae2", @@ -29,8 +40,29 @@ class DsrInfographicBlock extends BlockBase { "#09394c", ]; + /** - * + * {@inheritdoc} + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, DsrDrushServiceInterface $dsrService) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->dsrService = $dsrService; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('dsr.drush') + ); + } + + /** + * {@inheritdoc} */ private function get_share_types_donut() { $serie = [ @@ -132,7 +164,7 @@ class DsrInfographicBlock extends BlockBase { ], [ '#type' => 'link', - '#title' => \Drupal::entityQuery('share_transaction')->condition('state', 'draft')->count()->execute(), + '#title' => \Drupal::entityQuery('share_transaction')->accessCheck(FALSE)->condition('state', 'draft')->count()->execute(), '#url' => Url::fromRoute('view.share_transactions.page_2'), '#attributes' => [ 'class' => [ @@ -176,7 +208,7 @@ class DsrInfographicBlock extends BlockBase { ], [ '#type' => 'link', - '#title' => \Drupal::entityQuery('shareholder')->condition('state', 'valid')->condition('current', '1')->count()->execute(), + '#title' => \Drupal::entityQuery('shareholder')->accessCheck(FALSE)->condition('state', 'valid')->condition('current', '1')->count()->execute(), '#url' => Url::fromRoute('entity.shareholder.collection'), '#attributes' => [ 'class' => [ @@ -187,6 +219,16 @@ class DsrInfographicBlock extends BlockBase { ], // $build, $this->get_share_types_donut(), + [ + '#prefix' => '<div class="dsr-version"><span>', + '#suffix' => '</span></div>', + '#markup' => $this->t( + 'Version @version', + [ + '@version' => $this->dsrService->getVersion(), + ] + ), + ] ], '#attached' => [ 'library' => [ diff --git a/modules/dsr_dashboard/src/Routing/RouteSubscriber.php b/modules/dsr_dashboard/src/Routing/RouteSubscriber.php new file mode 100644 index 0000000..aa46764 --- /dev/null +++ b/modules/dsr_dashboard/src/Routing/RouteSubscriber.php @@ -0,0 +1,21 @@ +<?php +namespace Drupal\dsr_dashboard\Routing; + +use Drupal\Core\Routing\RouteSubscriberBase; +use Symfony\Component\Routing\RouteCollection; + +/** + * Subscriber to alter the dashboard route. + */ +class RouteSubscriber extends RouteSubscriberBase { + + /** + * {@inheritdoc} + */ + protected function alterRoutes(RouteCollection $collection) { + if ($route = $collection->get('system.admin.shareholder_register')) { + $route->setDefault('_controller', '\Drupal\dsr_dashboard\Controller\DashboardController::content'); + } + } + +} diff --git a/src/DsrDrushService.php b/src/DsrDrushService.php index ab8d4a3..ee40a13 100644 --- a/src/DsrDrushService.php +++ b/src/DsrDrushService.php @@ -2,6 +2,8 @@ namespace Drupal\dsr; +use Composer\InstalledVersions; + use Symfony\Component\Validator\Constraints\Iban; use Symfony\Component\Validator\Validation; @@ -302,4 +304,13 @@ class DsrDrushService implements DsrDrushServiceInterface { ->save(); } + /** + * {@inheritdoc} + */ + public function getVersion() { + if (InstalledVersions::isInstalled('drupal/dsr')) { + return InstalledVersions::getVersion('drupal/dsr'); + } + return ''; + } } -- GitLab