From c1b3f3071f1c20a52f2c2b725da70bccbe283514 Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Thu, 21 Nov 2024 16:38:22 +0100 Subject: [PATCH 1/7] HiH: Initial status model --- .../HiHApplicationActionStatusInfo.php | 4 +- .../HiHApplicationActionsDeterminer.php | 59 +++++++-- .../HiHApplicationStatusDeterminer.php | 92 ++++++++++++-- .../HiHApplicationSubmitActionsContainer.php | 22 +++- .../Actions/HiHCaseActionsDeterminer.php | 117 +++++++++++++++++- .../hihApplicationEditor.template.html | 66 ---------- ....js => hihApplicationSidebar.directive.js} | 10 +- .../hihApplicationSidebar.template.html | 13 ++ 8 files changed, 286 insertions(+), 97 deletions(-) delete mode 100644 ang/crmFundingHiH/hihApplicationEditor.template.html rename ang/crmFundingHiH/{hihApplicationEditor.directive.js => hihApplicationSidebar.directive.js} (70%) create mode 100644 ang/crmFundingHiH/hihApplicationSidebar.template.html diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionStatusInfo.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionStatusInfo.php index 283857494..b162ed978 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionStatusInfo.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionStatusInfo.php @@ -21,7 +21,6 @@ use Civi\Funding\ApplicationProcess\ActionStatusInfo\AbstractApplicationProcessActionStatusInfoDecorator; use Civi\Funding\ApplicationProcess\ActionStatusInfo\DefaultApplicationProcessActionStatusInfo; -use Civi\Funding\ApplicationProcess\ActionStatusInfo\ReworkPossibleApplicationProcessActionStatusInfo; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Traits\HiHSupportedFundingCaseTypesTrait; final class HiHApplicationActionStatusInfo extends AbstractApplicationProcessActionStatusInfoDecorator { @@ -29,8 +28,7 @@ final class HiHApplicationActionStatusInfo extends AbstractApplicationProcessAct use HiHSupportedFundingCaseTypesTrait; public function __construct() { - $info = new ReworkPossibleApplicationProcessActionStatusInfo(new DefaultApplicationProcessActionStatusInfo()); - parent::__construct($info); + parent::__construct(new DefaultApplicationProcessActionStatusInfo()); } } diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php index ce3af18f1..4ac29c223 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php @@ -19,19 +19,64 @@ namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions; -use Civi\Funding\ApplicationProcess\ActionsDeterminer\AbstractApplicationActionsDeterminerDecorator; -use Civi\Funding\ApplicationProcess\ActionsDeterminer\DefaultApplicationProcessActionsDeterminer; -use Civi\Funding\ApplicationProcess\ActionsDeterminer\ReworkPossibleApplicationProcessActionsDeterminer; +use Civi\Funding\ApplicationProcess\ActionsDeterminer\AbstractApplicationProcessActionsDeterminer; +use Civi\Funding\Entity\ApplicationProcessEntityBundle; +use Civi\Funding\FundingCase\FundingCaseStatus; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Traits\HiHSupportedFundingCaseTypesTrait; -final class HiHApplicationActionsDeterminer extends AbstractApplicationActionsDeterminerDecorator { +final class HiHApplicationActionsDeterminer extends AbstractApplicationProcessActionsDeterminer { use HiHSupportedFundingCaseTypesTrait; + private const FUNDING_CASE_FINAL_STATUS_LIST = [FundingCaseStatus::CLEARED]; + + private const STATUS_PERMISSION_ACTIONS_MAP = [ + NULL => [ + 'application_create' => ['save'], + 'application_apply' => ['apply'], + ], + 'new' => [ + 'application_modify' => ['save'], + 'application_apply' => ['apply'], + 'application_withdraw' => ['withdraw'], + ], + 'applied' => [ + 'application_modify' => ['modify'], + 'application_withdraw' => ['withdraw'], + 'review_application' => ['review', 'add-comment'], + ], + 'review' => [ + 'review_application' => ['request-change', 'update', 'reject', 'release', 'add-comment'], + ], + 'draft' => [ + 'application_modify' => ['save'], + 'application_apply' => ['apply'], + 'application_withdraw' => ['withdraw'], + 'review_application' => ['add-comment'], + ], + 'advisory' => [ + 'advisor' => ['approve', 'reject', 'add-comment'], + ], + 'eligible' => [ + 'advisor' => ['add-comment'], + 'review_application' => ['add-comment'], + ], + 'complete' => [ + 'advisor' => ['add-comment'], + 'review_application' => ['add-comment'], + ], + ]; + public function __construct() { - parent::__construct( - new ReworkPossibleApplicationProcessActionsDeterminer(new DefaultApplicationProcessActionsDeterminer()) - ); + parent::__construct(self::STATUS_PERMISSION_ACTIONS_MAP); + } + + public function getActions(ApplicationProcessEntityBundle $applicationProcessBundle, array $statusList): array { + if ($applicationProcessBundle->getFundingCase()->isStatusIn(self::FUNDING_CASE_FINAL_STATUS_LIST)) { + return []; + } + + return parent::getActions($applicationProcessBundle, $statusList); } } diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php index 4f7df6618..c16e533ce 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php @@ -19,21 +19,97 @@ namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions; -use Civi\Funding\ApplicationProcess\StatusDeterminer\AbstractApplicationProcessStatusDeterminerDecorator; -use Civi\Funding\ApplicationProcess\StatusDeterminer\DefaultApplicationProcessStatusDeterminer; -use Civi\Funding\ApplicationProcess\StatusDeterminer\ReworkPossibleApplicationProcessStatusDeterminer; +use Civi\Funding\ApplicationProcess\StatusDeterminer\AbstractApplicationProcessStatusDeterminer; +use Civi\Funding\Entity\FullApplicationProcessStatus; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Traits\HiHSupportedFundingCaseTypesTrait; -final class HiHApplicationStatusDeterminer extends AbstractApplicationProcessStatusDeterminerDecorator { +final class HiHApplicationStatusDeterminer extends AbstractApplicationProcessStatusDeterminer { use HiHSupportedFundingCaseTypesTrait; + private const STATUS_ACTION_STATUS_MAP = [ + NULL => [ + 'save' => 'new', + 'apply' => 'applied', + ], + 'new' => [ + 'save' => 'new', + 'apply' => 'applied', + 'withdraw' => 'withdrawn', + ], + 'applied' => [ + 'modify' => 'draft', + 'withdraw' => 'withdrawn', + 'review' => 'review', + 'add-comment' => 'applied', + ], + 'review' => [ + 'request-change' => 'draft', + 'release' => 'advisory', + 'reject' => 'rejected', + 'update' => 'review', + 'add-comment' => 'review', + ], + 'draft' => [ + 'save' => 'draft', + 'apply' => 'applied', + 'withdraw' => 'withdrawn', + 'add-comment' => 'draft', + ], + 'advisory' => [ + 'approve' => 'eligible', + 'reject' => 'rejected', + 'add-comment' => 'advisory', + ], + 'eligible' => [ + 'add-comment' => 'eligible', + ], + 'complete' => [], + ]; + public function __construct() { - parent::__construct( - new ReworkPossibleApplicationProcessStatusDeterminer( - new DefaultApplicationProcessStatusDeterminer() - ) + parent::__construct(self::STATUS_ACTION_STATUS_MAP); + } + + public function getStatusOnClearingProcessCreated(FullApplicationProcessStatus $currentStatus + ): FullApplicationProcessStatus { + return new FullApplicationProcessStatus( + 'complete', + $currentStatus->getIsReviewCalculative(), + $currentStatus->getIsReviewContent() ); } + protected function getIsReviewCalculative(FullApplicationProcessStatus $currentStatus, string $action): ?bool { + if ('request-change' === $action) { + return NULL; + } + + if ('release' === $action) { + return TRUE; + } + + if ('reject' === $action) { + return FALSE; + } + + return $currentStatus->getIsReviewCalculative(); + } + + protected function getIsReviewContent(FullApplicationProcessStatus $currentStatus, string $action): ?bool { + if ('request-change' === $action) { + return NULL; + } + + if ('release' === $action) { + return TRUE; + } + + if ('reject' === $action) { + return FALSE; + } + + return $currentStatus->getIsReviewContent(); + } + } diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php index 7b80f922f..6e298ff63 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php @@ -19,19 +19,33 @@ namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions; -use Civi\Funding\ApplicationProcess\ActionsContainer\AbstractApplicationSubmitActionsContainerDecorator; -use Civi\Funding\ApplicationProcess\ActionsContainer\ReworkPossibleApplicationSubmitActionsContainerFactory; +use Civi\Funding\ApplicationProcess\ActionsContainer\AbstractApplicationSubmitActionsContainer; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Traits\HiHSupportedFundingCaseTypesTrait; +use CRM_Funding_ExtensionUtil as E; /** * @codeCoverageIgnore */ -final class HiHApplicationSubmitActionsContainer extends AbstractApplicationSubmitActionsContainerDecorator { +final class HiHApplicationSubmitActionsContainer extends AbstractApplicationSubmitActionsContainer { use HiHSupportedFundingCaseTypesTrait; public function __construct() { - parent::__construct(ReworkPossibleApplicationSubmitActionsContainerFactory::create()); + $this + // Applicant actions. + ->add('save', E::ts('Save')) + ->add('modify', E::ts('Modify')) + ->add('apply', E::ts('Apply')) + ->add('withdraw', E::ts('Withdraw'), E::ts('Do you really want to withdraw the application?')) + ->add('delete', E::ts('Delete'), E::ts('Do you really want to delete the application?')) + // Reviewer actions. + ->add('review', E::ts('Start Review'), NULL, ['needsFormData' => FALSE]) + ->add('release', E::ts('Release for Advisory'), NULL, ['needsFormData' => FALSE]) + ->add('request-change', E::ts('Request Change'), NULL, ['needsFormData' => FALSE]) + // Reviewer and advisor actions. + ->add('reject', E::ts('Reject'), NULL, ['needsFormData' => FALSE]) + // Advisor actions. + ->add('approve', E::ts('Approve'), NULL, ['needsFormData' => FALSE]); } } diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/FundingCase/Actions/HiHCaseActionsDeterminer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/FundingCase/Actions/HiHCaseActionsDeterminer.php index 10f245348..ca8efeb1d 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/FundingCase/Actions/HiHCaseActionsDeterminer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/FundingCase/Actions/HiHCaseActionsDeterminer.php @@ -20,23 +20,128 @@ namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\FundingCase\Actions; use Civi\Funding\ClearingProcess\ClearingProcessManager; -use Civi\Funding\FundingCase\Actions\AbstractFundingCaseActionsDeterminerDecorator; -use Civi\Funding\FundingCase\Actions\DefaultFundingCaseActionsDeterminer; -use Civi\Funding\FundingCase\Actions\SetRecipientContactActionsDeterminer; +use Civi\Funding\ClearingProcess\ClearingProcessPermissions; +use Civi\Funding\FundingCase\Actions\FundingCaseActions as Actions; +use Civi\Funding\FundingCase\Actions\FundingCaseActionsDeterminer; +use Civi\Funding\FundingCase\FundingCaseStatus as Status; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationActionStatusInfo; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Traits\HiHSupportedFundingCaseTypesTrait; -final class HiHCaseActionsDeterminer extends AbstractFundingCaseActionsDeterminerDecorator { +final class HiHCaseActionsDeterminer extends FundingCaseActionsDeterminer { use HiHSupportedFundingCaseTypesTrait; + private const STATUS_PERMISSIONS_ACTION_MAP = [ + Status::OPEN => [ + 'review_application' => [Actions::SET_RECIPIENT_CONTACT, Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CALCULATIVE => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CONTENT => [Actions::SET_NOTIFICATION_CONTACTS], + 'review_drawdown' => [Actions::SET_NOTIFICATION_CONTACTS], + ], + Status::ONGOING => [ + 'review_application' => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CALCULATIVE => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CONTENT => [Actions::SET_NOTIFICATION_CONTACTS], + 'review_drawdown' => [Actions::SET_NOTIFICATION_CONTACTS], + ], + Status::CLEARED => [ + 'review_application' => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CALCULATIVE => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CONTENT => [Actions::SET_NOTIFICATION_CONTACTS], + 'review_drawdown' => [Actions::SET_NOTIFICATION_CONTACTS], + ], + Status::REJECTED => [ + 'review_application' => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CALCULATIVE => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CONTENT => [Actions::SET_NOTIFICATION_CONTACTS], + 'review_drawdown' => [Actions::SET_NOTIFICATION_CONTACTS], + ], + Status::WITHDRAWN => [ + 'review_application' => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CALCULATIVE => [Actions::SET_NOTIFICATION_CONTACTS], + ClearingProcessPermissions::REVIEW_CONTENT => [Actions::SET_NOTIFICATION_CONTACTS], + 'review_drawdown' => [Actions::SET_NOTIFICATION_CONTACTS], + ], + ]; + + private ClearingProcessManager $clearingProcessManager; + + private HiHApplicationActionStatusInfo $statusInfo; + public function __construct( ClearingProcessManager $clearingProcessManager, HiHApplicationActionStatusInfo $statusInfo ) { - parent::__construct(new SetRecipientContactActionsDeterminer( - new DefaultFundingCaseActionsDeterminer($clearingProcessManager, $statusInfo)) + parent::__construct(self::STATUS_PERMISSIONS_ACTION_MAP); + $this->statusInfo = $statusInfo; + $this->clearingProcessManager = $clearingProcessManager; + } + + public function getActions(string $status, array $applicationProcessStatusList, array $permissions): array { + $actions = parent::getActions( + $status, + $applicationProcessStatusList, + $permissions ); + + $posApprove = array_search(Actions::APPROVE, $actions, TRUE); + if (FALSE !== $posApprove && !$this->isApprovePossible($applicationProcessStatusList)) { + unset($actions[$posApprove]); + $actions = array_values($actions); + } + + $posFinishClearing = array_search(Actions::FINISH_CLEARING, $actions, TRUE); + if (FALSE !== $posFinishClearing && !$this->isFinishClearingPossible($applicationProcessStatusList)) { + unset($actions[$posFinishClearing]); + $actions = array_values($actions); + } + + return $actions; + } + + /** + * @phpstan-param array $applicationProcessStatusList + * + * @return bool + * TRUE If there's at least one eligible application and the eligibility of + * all applications is decided. + */ + private function isApprovePossible(array $applicationProcessStatusList): bool { + $eligibleCount = 0; + foreach ($applicationProcessStatusList as $applicationProcessStatus) { + $eligible = $this->statusInfo->isEligibleStatus($applicationProcessStatus->getStatus()); + if (NULL === $eligible) { + return FALSE; + } + + if ($eligible) { + ++$eligibleCount; + } + } + + return $eligibleCount > 0; + } + + /** + * @phpstan-param array $applicationProcessStatusList + */ + private function isFinishClearingPossible(array $applicationProcessStatusList): bool { + foreach ($applicationProcessStatusList as $applicationProcessId => $applicationProcessStatus) { + // Eligibility of all applications has to be decided. + if (NULL === $this->statusInfo->isEligibleStatus($applicationProcessStatus->getStatus())) { + return FALSE; + } + + if (TRUE === $this->statusInfo->isEligibleStatus($applicationProcessStatus->getStatus())) { + // There has to be a clearing process for every eligible application that is either accepted or rejected. + $clearingProcess = $this->clearingProcessManager->getByApplicationProcessId($applicationProcessId); + if (NULL === $clearingProcess || !in_array($clearingProcess->getStatus(), ['accepted', 'rejected'], TRUE)) { + return FALSE; + } + } + } + + return TRUE; } } diff --git a/ang/crmFundingHiH/hihApplicationEditor.template.html b/ang/crmFundingHiH/hihApplicationEditor.template.html deleted file mode 100644 index ef14ac7c3..000000000 --- a/ang/crmFundingHiH/hihApplicationEditor.template.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
-
- -
-
- {{ ts('Validation failed') }} - - -
- -
-

{{ ts('Reviewers') }}

- - -

{{ ts('General') }}

-
- - {{ applicationProcess.identifier }} -
-
- - {{ statusOptions[applicationProcess.status].label || ts('Unknown') }} - -
-
- - {{ reviewStatusLabels[applicationProcess.is_review_content] }} -
-
- - {{ reviewStatusLabels[applicationProcess.is_review_calculative] }} -
-
- - {{ applicationProcess.creation_date|fundingDate }} -
-
- - {{ applicationProcess.modification_date|fundingDate }} -
-
- - {{ recipientContact.display_name }} -
-
- - {{ applicationProcess.amount_requested }} {{ currency }} -
- - - -
-
diff --git a/ang/crmFundingHiH/hihApplicationEditor.directive.js b/ang/crmFundingHiH/hihApplicationSidebar.directive.js similarity index 70% rename from ang/crmFundingHiH/hihApplicationEditor.directive.js rename to ang/crmFundingHiH/hihApplicationSidebar.directive.js index b00569309..5812471fd 100644 --- a/ang/crmFundingHiH/hihApplicationEditor.directive.js +++ b/ang/crmFundingHiH/hihApplicationSidebar.directive.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 SYSTOPIA GmbH + * Copyright (C) 2024 SYSTOPIA GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -16,10 +16,14 @@ 'use strict'; -fundingHiHModule.directive('fundingHiHApplicationEditor', function() { +fundingModule.directive('fundingHihApplicationSidebar', function() { return { restrict: 'AE', scope: false, - templateUrl: '~/crmFundingHiH/hihApplicationEditor.template.html', + templateUrl: '~/crmFundingHiH/hihApplicationSidebar.template.html', + controllerAs: '$ctrl', + controller: ['$scope', function ($scope) { + this.ts = CRM.ts('funding'); + }], }; }); diff --git a/ang/crmFundingHiH/hihApplicationSidebar.template.html b/ang/crmFundingHiH/hihApplicationSidebar.template.html new file mode 100644 index 000000000..76d830293 --- /dev/null +++ b/ang/crmFundingHiH/hihApplicationSidebar.template.html @@ -0,0 +1,13 @@ + + {{ $ctrl.ts('Start Review') }} + {{ $ctrl.ts('Release for Advisory') }} + {{ $ctrl.ts('Approve') }} + {{ $ctrl.ts('Reject') }} + {{ $ctrl.ts('Request Change') }} + {{ $ctrl.ts('Add Comment') }} + + + + {{ $ctrl.ts('Save') }} + + From bce0a6247441211b7ae5a26bf9c2e584f669dfbd Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Thu, 21 Nov 2024 16:56:56 +0100 Subject: [PATCH 2/7] HiH: Provide possible application status options --- ...ibleApplicationProcessStatusSubscriber.php | 56 +++++++++++++++++++ services/z_hih.php | 11 ++++ 2 files changed, 67 insertions(+) create mode 100644 Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php new file mode 100644 index 000000000..698e05c61 --- /dev/null +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php @@ -0,0 +1,56 @@ +. + */ + +declare(strict_types = 1); + +namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\EventSubscriber; + +use Civi\Funding\Event\ApplicationProcess\GetPossibleApplicationProcessStatusEvent; +use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\HiHConstants; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use CRM_Funding_ExtensionUtil as E; + +final class HiHPossibleApplicationProcessStatusSubscriber implements EventSubscriberInterface { + + /** + * @inheritDoc + */ + public static function getSubscribedEvents(): array { + return [GetPossibleApplicationProcessStatusEvent::class => 'onGetPossibleApplicationProcessStatus']; + } + + public function onGetPossibleApplicationProcessStatus(GetPossibleApplicationProcessStatusEvent $event): void { + if (HiHConstants::FUNDING_CASE_TYPE_NAME === $event->getFundingCaseTypeName()) { + $optionNames = ['new', 'draft', 'withdrawn', 'applied', 'review', 'rejected', 'eligible', 'complete']; + $options = array_filter( + $event->getOptions(), + fn (array $option) => in_array($option['name'], $optionNames, TRUE) + ); + $event->setOptions($options); + + $event->addOption([ + 'id' => 'advisory', + 'name' => 'advisory', + 'label' => E::ts('Advisory'), + 'icon' => 'fa-eye', + ]); + + $event->stopPropagation(); + } + } + +} diff --git a/services/z_hih.php b/services/z_hih.php index eba344dd6..879dcd6da 100644 --- a/services/z_hih.php +++ b/services/z_hih.php @@ -20,6 +20,7 @@ // phpcs:disable Drupal.Commenting.DocComment.ContentAfterOpen /** @var \Symfony\Component\DependencyInjection\ContainerBuilder $container */ +use Civi\Funding\DependencyInjection\Util\ServiceRegistrator; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationActionsDeterminer; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationActionStatusInfo; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationStatusDeterminer; @@ -29,6 +30,7 @@ use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\UiSchema\HiHApplicationUiSchemaFactory; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\FundingCase\Actions\HiHCaseActionsDeterminer; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\FundingCase\HiHPossibleRecipientsForChangeLoader; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; $container->autowire(HiHApplicationActionsDeterminer::class) ->addTag(HiHApplicationActionsDeterminer::SERVICE_TAG); @@ -57,3 +59,12 @@ $container->autowire(HiHPossibleRecipientsForChangeLoader::class) ->addTag(HiHPossibleRecipientsForChangeLoader::SERVICE_TAG); + +ServiceRegistrator::autowireAllImplementing( + $container, + __DIR__ . '/../Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber', + 'Civi\\Funding\\FundingCaseTypes\\BSH\\HiHAktion\\EventSubscriber', + EventSubscriberInterface::class, + ['kernel.event_subscriber' => []], + ['lazy' => 'auto'], +); From 5c17b4c0d62b2e85b05d1b9930b8d11353d48a22 Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Tue, 26 Nov 2024 15:29:07 +0100 Subject: [PATCH 3/7] HiH: Update status model --- .../HiHApplicationActionsDeterminer.php | 5 +- .../HiHApplicationStatusDeterminer.php | 4 +- ...ibleApplicationProcessStatusSubscriber.php | 56 ------------------- services/z_hih.php | 9 --- 4 files changed, 4 insertions(+), 70 deletions(-) delete mode 100644 Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php index 4ac29c223..f701dcd17 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationActionsDeterminer.php @@ -55,14 +55,13 @@ final class HiHApplicationActionsDeterminer extends AbstractApplicationProcessAc 'review_application' => ['add-comment'], ], 'advisory' => [ - 'advisor' => ['approve', 'reject', 'add-comment'], + 'advisor' => ['add-comment'], + 'review_application' => ['update', 'reject', 'add-comment'], ], 'eligible' => [ - 'advisor' => ['add-comment'], 'review_application' => ['add-comment'], ], 'complete' => [ - 'advisor' => ['add-comment'], 'review_application' => ['add-comment'], ], ]; diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php index c16e533ce..724e7a0ce 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationStatusDeterminer.php @@ -90,7 +90,7 @@ protected function getIsReviewCalculative(FullApplicationProcessStatus $currentS } if ('reject' === $action) { - return FALSE; + return $currentStatus->getIsReviewCalculative() ?? FALSE; } return $currentStatus->getIsReviewCalculative(); @@ -106,7 +106,7 @@ protected function getIsReviewContent(FullApplicationProcessStatus $currentStatu } if ('reject' === $action) { - return FALSE; + return $currentStatus->getIsReviewContent() ?? FALSE; } return $currentStatus->getIsReviewContent(); diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php deleted file mode 100644 index 698e05c61..000000000 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber/HiHPossibleApplicationProcessStatusSubscriber.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -declare(strict_types = 1); - -namespace Civi\Funding\FundingCaseTypes\BSH\HiHAktion\EventSubscriber; - -use Civi\Funding\Event\ApplicationProcess\GetPossibleApplicationProcessStatusEvent; -use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\HiHConstants; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use CRM_Funding_ExtensionUtil as E; - -final class HiHPossibleApplicationProcessStatusSubscriber implements EventSubscriberInterface { - - /** - * @inheritDoc - */ - public static function getSubscribedEvents(): array { - return [GetPossibleApplicationProcessStatusEvent::class => 'onGetPossibleApplicationProcessStatus']; - } - - public function onGetPossibleApplicationProcessStatus(GetPossibleApplicationProcessStatusEvent $event): void { - if (HiHConstants::FUNDING_CASE_TYPE_NAME === $event->getFundingCaseTypeName()) { - $optionNames = ['new', 'draft', 'withdrawn', 'applied', 'review', 'rejected', 'eligible', 'complete']; - $options = array_filter( - $event->getOptions(), - fn (array $option) => in_array($option['name'], $optionNames, TRUE) - ); - $event->setOptions($options); - - $event->addOption([ - 'id' => 'advisory', - 'name' => 'advisory', - 'label' => E::ts('Advisory'), - 'icon' => 'fa-eye', - ]); - - $event->stopPropagation(); - } - } - -} diff --git a/services/z_hih.php b/services/z_hih.php index 879dcd6da..841339dbe 100644 --- a/services/z_hih.php +++ b/services/z_hih.php @@ -59,12 +59,3 @@ $container->autowire(HiHPossibleRecipientsForChangeLoader::class) ->addTag(HiHPossibleRecipientsForChangeLoader::SERVICE_TAG); - -ServiceRegistrator::autowireAllImplementing( - $container, - __DIR__ . '/../Civi/Funding/FundingCaseTypes/BSH/HiHAktion/EventSubscriber', - 'Civi\\Funding\\FundingCaseTypes\\BSH\\HiHAktion\\EventSubscriber', - EventSubscriberInterface::class, - ['kernel.event_subscriber' => []], - ['lazy' => 'auto'], -); From 1c267c6722c5c9cf5679482c4f2b24bc26b9702e Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Tue, 26 Nov 2024 15:41:43 +0100 Subject: [PATCH 4/7] Remove unused imports --- services/z_hih.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/z_hih.php b/services/z_hih.php index 841339dbe..eba344dd6 100644 --- a/services/z_hih.php +++ b/services/z_hih.php @@ -20,7 +20,6 @@ // phpcs:disable Drupal.Commenting.DocComment.ContentAfterOpen /** @var \Symfony\Component\DependencyInjection\ContainerBuilder $container */ -use Civi\Funding\DependencyInjection\Util\ServiceRegistrator; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationActionsDeterminer; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationActionStatusInfo; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\Actions\HiHApplicationStatusDeterminer; @@ -30,7 +29,6 @@ use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\Application\UiSchema\HiHApplicationUiSchemaFactory; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\FundingCase\Actions\HiHCaseActionsDeterminer; use Civi\Funding\FundingCaseTypes\BSH\HiHAktion\FundingCase\HiHPossibleRecipientsForChangeLoader; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; $container->autowire(HiHApplicationActionsDeterminer::class) ->addTag(HiHApplicationActionsDeterminer::SERVICE_TAG); From d23c1a3801fd861b8319d81ffade314787284e42 Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Tue, 26 Nov 2024 15:59:34 +0100 Subject: [PATCH 5/7] HiH: Update strings --- .../Actions/HiHApplicationSubmitActionsContainer.php | 2 +- ang/crmFundingHiH/hihApplicationSidebar.template.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php index 6e298ff63..e7c68ea7c 100644 --- a/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php +++ b/Civi/Funding/FundingCaseTypes/BSH/HiHAktion/Application/Actions/HiHApplicationSubmitActionsContainer.php @@ -40,7 +40,7 @@ public function __construct() { ->add('delete', E::ts('Delete'), E::ts('Do you really want to delete the application?')) // Reviewer actions. ->add('review', E::ts('Start Review'), NULL, ['needsFormData' => FALSE]) - ->add('release', E::ts('Release for Advisory'), NULL, ['needsFormData' => FALSE]) + ->add('release', 'Für Beirat freigeben', NULL, ['needsFormData' => FALSE]) ->add('request-change', E::ts('Request Change'), NULL, ['needsFormData' => FALSE]) // Reviewer and advisor actions. ->add('reject', E::ts('Reject'), NULL, ['needsFormData' => FALSE]) diff --git a/ang/crmFundingHiH/hihApplicationSidebar.template.html b/ang/crmFundingHiH/hihApplicationSidebar.template.html index 76d830293..002a85f82 100644 --- a/ang/crmFundingHiH/hihApplicationSidebar.template.html +++ b/ang/crmFundingHiH/hihApplicationSidebar.template.html @@ -1,6 +1,6 @@ {{ $ctrl.ts('Start Review') }} - {{ $ctrl.ts('Release for Advisory') }} + Für Beirat freigeben {{ $ctrl.ts('Approve') }} {{ $ctrl.ts('Reject') }} {{ $ctrl.ts('Request Change') }} From 2fdd1a5ee43ed9e279aaeb8dcc2909aa6ba83a91 Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Fri, 6 Dec 2024 14:32:53 +0100 Subject: [PATCH 6/7] =?UTF-8?q?HiH:=20Show=20"NDR-Berichterstattung"=20and?= =?UTF-8?q?=20"Priorit=C3=A4t"=20in=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/applicationProcess.factory.js | 1 + .../hihApplicationSidebar.directive.js | 41 ++++++++++++++++++- .../hihApplicationSidebar.template.html | 18 ++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/ang/crmFunding/application/applicationProcess.factory.js b/ang/crmFunding/application/applicationProcess.factory.js index 1cfba02fc..d830292ea 100644 --- a/ang/crmFunding/application/applicationProcess.factory.js +++ b/ang/crmFunding/application/applicationProcess.factory.js @@ -60,6 +60,7 @@ fundingModule.factory('fundingApplicationProcessService', ['crmApi4', function(c return { get: (id) => crmApi4('FundingApplicationProcess', 'get', { + select: ['*', 'custom.*'], where: [['id', '=', id]], }).then(function (result) { return result[0] || null; diff --git a/ang/crmFundingHiH/hihApplicationSidebar.directive.js b/ang/crmFundingHiH/hihApplicationSidebar.directive.js index 5812471fd..a97334618 100644 --- a/ang/crmFundingHiH/hihApplicationSidebar.directive.js +++ b/ang/crmFundingHiH/hihApplicationSidebar.directive.js @@ -22,8 +22,47 @@ fundingModule.directive('fundingHihApplicationSidebar', function() { scope: false, templateUrl: '~/crmFundingHiH/hihApplicationSidebar.template.html', controllerAs: '$ctrl', - controller: ['$scope', function ($scope) { + controller: ['$scope', 'crmApi4', 'crmStatus', function ($scope, crmApi4, crmStatus) { this.ts = CRM.ts('funding'); + + $scope.prioritaetOptions = {}; + crmApi4('FundingApplicationProcess', 'getFields', { + loadOptions: true, + where: [['name', '=', 'bsh_funding_application_extra.prioritaet']], + select: ["options"] + }).then(function(fields) { + $scope.prioritaetOptions = fields[0].options; + }); + + $scope.updateNdrBerichterstattung = function(data) { + return crmStatus({}, crmApi4('FundingApplicationProcess', 'setNdrBerichterstattung', { + id: $scope.applicationProcess.id, + berichterstattung: data, + })); + }; + + $scope.showNdrBerichterstattung = function() { + if ($scope.applicationProcess['bsh_funding_application_extra.ndr_berichterstattung']) { + return 'Ja'; + } + + if ($scope.applicationProcess['bsh_funding_application_extra.ndr_berichterstattung'] === false) { + return 'Nein'; + } + + return 'unbekannt'; + }; + + $scope.updatePrioritaet = function(data) { + return crmStatus({}, crmApi4('FundingApplicationProcess', 'setBshPrioritaet', { + id: $scope.applicationProcess.id, + prioritaet: data, + })); + }; + + $scope.showPrioritaet = function() { + return $scope.prioritaetOptions[$scope.applicationProcess['bsh_funding_application_extra.prioritaet']] || 'nicht definiert'; + }; }], }; }); diff --git a/ang/crmFundingHiH/hihApplicationSidebar.template.html b/ang/crmFundingHiH/hihApplicationSidebar.template.html index 002a85f82..ec3e5df09 100644 --- a/ang/crmFundingHiH/hihApplicationSidebar.template.html +++ b/ang/crmFundingHiH/hihApplicationSidebar.template.html @@ -1,3 +1,21 @@ +
+ + + {{ showNdrBerichterstattung() }} + +
+ +
+ + + {{ showPrioritaet() }} + +
+ {{ $ctrl.ts('Start Review') }} Für Beirat freigeben From 1d20014a78c71918bb1ea07880a31e02eeb3717c Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Fri, 6 Dec 2024 14:55:49 +0100 Subject: [PATCH 7/7] =?UTF-8?q?HiH:=20Rename=20"Priorit=C3=A4t"=20to=20"Pr?= =?UTF-8?q?iorisierung"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hihApplicationSidebar.directive.js | 16 ++++++++-------- .../hihApplicationSidebar.template.html | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ang/crmFundingHiH/hihApplicationSidebar.directive.js b/ang/crmFundingHiH/hihApplicationSidebar.directive.js index a97334618..3a0b8ba49 100644 --- a/ang/crmFundingHiH/hihApplicationSidebar.directive.js +++ b/ang/crmFundingHiH/hihApplicationSidebar.directive.js @@ -25,13 +25,13 @@ fundingModule.directive('fundingHihApplicationSidebar', function() { controller: ['$scope', 'crmApi4', 'crmStatus', function ($scope, crmApi4, crmStatus) { this.ts = CRM.ts('funding'); - $scope.prioritaetOptions = {}; + $scope.priorisierungOptions = {}; crmApi4('FundingApplicationProcess', 'getFields', { loadOptions: true, - where: [['name', '=', 'bsh_funding_application_extra.prioritaet']], + where: [['name', '=', 'bsh_funding_application_extra.priorisierung']], select: ["options"] }).then(function(fields) { - $scope.prioritaetOptions = fields[0].options; + $scope.priorisierungOptions = fields[0].options; }); $scope.updateNdrBerichterstattung = function(data) { @@ -53,15 +53,15 @@ fundingModule.directive('fundingHihApplicationSidebar', function() { return 'unbekannt'; }; - $scope.updatePrioritaet = function(data) { - return crmStatus({}, crmApi4('FundingApplicationProcess', 'setBshPrioritaet', { + $scope.updatePriorisierung = function(data) { + return crmStatus({}, crmApi4('FundingApplicationProcess', 'setBshPriorisierung', { id: $scope.applicationProcess.id, - prioritaet: data, + priorisierung: data, })); }; - $scope.showPrioritaet = function() { - return $scope.prioritaetOptions[$scope.applicationProcess['bsh_funding_application_extra.prioritaet']] || 'nicht definiert'; + $scope.showPriorisierung = function() { + return $scope.priorisierungOptions[$scope.applicationProcess['bsh_funding_application_extra.priorisierung']] || 'nicht definiert'; }; }], }; diff --git a/ang/crmFundingHiH/hihApplicationSidebar.template.html b/ang/crmFundingHiH/hihApplicationSidebar.template.html index ec3e5df09..026cd6680 100644 --- a/ang/crmFundingHiH/hihApplicationSidebar.template.html +++ b/ang/crmFundingHiH/hihApplicationSidebar.template.html @@ -8,11 +8,11 @@
- - - {{ showPrioritaet() }} + + + {{ showPriorisierung() }}