Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UHF-10817: Make loading of submissions better. Fix ID63 form same time. Also title loading for new applications. #1539

Merged
merged 19 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
50f7919
UHF-10537: Update document dl function
jiisuominen Oct 21, 2024
1f1593d
UHF-10537: Set processed file types to static
jiisuominen Oct 21, 2024
4d4bbc4
UHF-10537: Load application types via webform.
jiisuominen Oct 21, 2024
49a7f97
UHF-10537: Add new example applications.
jiisuominen Oct 21, 2024
b7b43e4
UHF-10537: New configs
jiisuominen Oct 21, 2024
1c52f58
UHF-10537: PHPCS
jiisuominen Oct 21, 2024
63d84be
UHF-10537: Add check for nonexistent UUID
jiisuominen Oct 21, 2024
3cf9726
Comment out parent_loadData in storage controller
jiisuominen Oct 31, 2024
3d5c5d9
UHF-10537: Merge branch 'dev' into feature/UHF-10537-example-forms
jiisuominen Oct 31, 2024
cfb3f0c
Comment out parent_loadData in storage controller
jiisuominen Oct 31, 2024
a17fbc3
UHF-10877: Add rest queries for testing race condition things. Sugges…
jiisuominen Oct 29, 2024
1187974
UHF-10537: Refactor to support webform title usage.
jiisuominen Oct 31, 2024
b15d7bc
UHF-10817: Merge branch 'feature/UHF-10537-example-forms' into UHF-10817
jiisuominen Oct 31, 2024
1596852
UHF-10817: PHPCS
jiisuominen Oct 31, 2024
2c9f55e
UHF-10817: Refactor ApplicationController.
jiisuominen Oct 31, 2024
660adf6
UHF-10817: Remove base Exception throwing.
jiisuominen Oct 31, 2024
4bf644e
UHF-10817: A bit more refactoring to remove static methods & calls.
jiisuominen Nov 1, 2024
db530fb
UHF-10817: Merge branch 'dev' into UHF-10817
jiisuominen Nov 4, 2024
785c020
UHF-10817: Fix copy form button in admin UI.
jiisuominen Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 58 additions & 60 deletions conf/examples/esimerkki_70_KUVAERILLIS.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,62 +208,62 @@
]
]
},
"customQuestionsInfo": {
"customQuestionsArray": [
{
"ID": "a",
"label": "Label a",
"value": "Value a",
"valueType": "string"
},
{
"ID": "b",
"label": "LABEL B",
"value": "Value B",
"valueType": "string"
}
]
},
"budgetInfo": {
"incomeGroupsArrayStatic": [
{
"incomeGroupName": "general",
"otherIncomeRowsArrayStatic": [
{
"ID": "a",
"label": "Kioskimyynti",
"value": "300.00",
"valueType": "double"
},
{
"ID": "b",
"label": "Parkkitulot",
"value": "50.00",
"valueType": "double"
}
]
}
],
"costGroupsArrayStatic": [
{
"costGroupName": "general",
"otherCostRowsArrayStatic": [
{
"ID": "a",
"label": "Kioskiostot",
"value": "100.00",
"valueType": "double"
},
{
"ID": "b",
"label": "Jätemaksut",
"value": "50.00",
"valueType": "double"
}
]
}
]
},
"customQuestionsInfo": {
"customQuestionsArray": [
{
"ID": "a",
"label": "Label a",
"value": "Value a",
"valueType": "string"
},
{
"ID": "b",
"label": "LABEL B",
"value": "Value B",
"valueType": "string"
}
]
},
"budgetInfo": {
"incomeGroupsArrayStatic": [
{
"incomeGroupName": "general",
"otherIncomeRowsArrayStatic": [
{
"ID": "a",
"label": "Kioskimyynti",
"value": "300.00",
"valueType": "double"
},
{
"ID": "b",
"label": "Parkkitulot",
"value": "50.00",
"valueType": "double"
}
]
}
],
"costGroupsArrayStatic": [
{
"costGroupName": "general",
"otherCostRowsArrayStatic": [
{
"ID": "a",
"label": "Kioskiostot",
"value": "100.00",
"valueType": "double"
},
{
"ID": "b",
"label": "Jätemaksut",
"value": "50.00",
"valueType": "double"
}
]
}
]
},
"otherCompensationsInfo": {
"otherCompensationsArray": [
[
Expand Down Expand Up @@ -299,7 +299,7 @@
}
]
],
"otherAppliedCompensationsArray": [
"otherAppliedCompensationsArray": [
[
{
"ID": "issuer",
Expand Down Expand Up @@ -368,8 +368,6 @@
}
]
},


"attachmentsInfo": {
"attachmentsArray": [
[
Expand Down Expand Up @@ -405,4 +403,4 @@
]
},
"formUpdate": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public function fixAttachmentsOnApplication(AtvDocument $atvDoc): AtvDocument {
// Get the events from the content.
$events = $content['events'];
// Get the attachment info from the content.
$attachmentInfo = $content['attachmentsInfo']['attachmentsArray'];
$attachmentInfo = $content['attachmentsInfo']['attachmentsArray'] ?? NULL;

// Loop attachments and if attachment is not ok, update the integration ID.
foreach ($attachments as $attachment) {
if ($this->areAttachmentsOk($events, $attachment, $attachmentInfo, $appEnv)['form'] === FALSE) {
if ($attachmentInfo && $this->areAttachmentsOk($events, $attachment, $attachmentInfo, $appEnv)['form'] === FALSE) {
$this->updateIntegrationIdForAttachment($attachment, $attachmentInfo, $appEnv);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public static function getAttachmentFieldNames(string $applicationNumber, $preve
// This could probably be done just by parsing the application number,
// however this more futureproof.
$webform = ApplicationHelpers::getWebformFromApplicationNumber($applicationNumber);

if (!$webform) {
return [];
}
Expand Down
23 changes: 17 additions & 6 deletions public/modules/custom/grants_handler/grants_handler.module
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ function grants_handler_preprocess_webform_submission_data(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function grants_handler_preprocess_webform_submission(&$variables) {
function grants_handler_preprocess_webform_submission(&$variables): void {

// Get submission object.
/** @var \Drupal\webform\Entity\WebformSubmission $submission */
$submission = $variables['webform_submission'];
Expand Down Expand Up @@ -1361,7 +1362,6 @@ function grants_handler_preprocess_application_list(&$variables) {
* Implements hook_preprocess_HOOK().
*/
function grants_handler_preprocess_application_list_item(&$variables): void {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$tOpts = ['context' => 'grants_handler'];

// Get status service and get listed statuses.
Expand All @@ -1377,9 +1377,20 @@ function grants_handler_preprocess_application_list_item(&$variables): void {
return;
}

$applicationTypes = Helpers::getApplicationTypes();
if (!isset($submissionData["metadata"]["form_uuid"])) {
\Drupal::logger('grants_handler')
->error('No form uuid found for submission @submissionId',
['@submissionId' => $submissionData["application_number"]]);
return;
}

/** @var \Drupal\grants_handler\ApplicationGetterService $applicationGetterService */
$applicationGetterService = \Drupal::service('grants_handler.application_getter_service');

$variables['applicationFormName'] = $applicationTypes[$submissionData["application_type"]][$language];
// Get webform.
$webform = $applicationGetterService->getWebformFromApplicationNumber($submissionData["application_number"]);
// Set webform title.
$variables['applicationFormName'] = $webform->label();

$variables['applicationNumber'] = $submissionData["application_number"];

Expand Down Expand Up @@ -1503,8 +1514,8 @@ function grants_handler_preprocess_application_list_item(&$variables): void {

$status = $applicationStatusService->getWebformStatus($webform);

$variables['openStartDate'] = strtotime($thirdPartySettings['applicationOpen']);
$variables['openEndDate'] = strtotime($thirdPartySettings['applicationClose']);
$variables['openStartDate'] = $thirdPartySettings['applicationOpen'] ? strtotime($thirdPartySettings['applicationOpen']) : '';
$variables['openEndDate'] = $thirdPartySettings['applicationClose'] ? strtotime($thirdPartySettings['applicationClose']) : '';
$variables['isContinuous'] = $thirdPartySettings['applicationContinuous'] != 0;
if (!$variables['isContinuous'] && ($variables['openStartDate'] > time() || $variables['openEndDate'] < time())) {
$variables['errorType'] = 'NOT_OPEN';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ grants_handler.copy_application_modal:
requirements:
_custom_access: '\Drupal\grants_handler\Controller\ApplicationController::accessByApplicationNumber'

grants_handler.print_application_atv:
grants_handler.atv_print_view:
path: '/hakemus/{submission_id}/tulosta'
defaults:
_title_callback: '\Drupal\grants_handler\Controller\ApplicationController::getTitle'
_controller: '\Drupal\grants_handler\Controller\ApplicationController::printViewAtv'
_controller: '\Drupal\grants_handler\Controller\AtvPrintViewController'
requirements:
_custom_access: '\Drupal\grants_handler\Controller\ApplicationController::accessByApplicationNumber'
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ services:
'@messenger',
'@grants_handler.application_getter_service',
'@helfi_helsinki_profiili.userdata',
'@grants_attachments.attachment_fixer_service'
'@grants_attachments.attachment_fixer_service',
'@current_user',
'@database'
]

grants_handler.application_access_handler:
class: Drupal\grants_handler\ApplicationAccessHandler
arguments: ['@grants_profile.service']
arguments: [
'@grants_profile.service',
'@grants_handler.application_getter_service'
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Drupal\grants_mandate\CompanySelectException;
use Drupal\grants_profile\GrantsProfileService;
use Drupal\helfi_atv\AtvDocumentNotFoundException;
use Drupal\webform\Entity\WebformSubmission;

/**
Expand All @@ -19,6 +18,7 @@
*/
public function __construct(
private GrantsProfileService $grantsProfileService,
private ApplicationGetterService $applicationGetterService,
) {}

/**
Expand All @@ -30,7 +30,8 @@ public function __construct(
* @return bool
* Access status
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Drupal\grants_profile\GrantsProfileException
* @throws \Drupal\grants_mandate\CompanySelectException
*/
public function singleSubmissionAccess(WebformSubmission $webform_submission): bool {

Expand All @@ -51,12 +52,12 @@ public function singleSubmissionAccess(WebformSubmission $webform_submission): b
return FALSE;
}

try {
$atvDoc = ApplicationHelpers::atvDocumentFromApplicationNumber($webformData['application_number']);
}
catch (AtvDocumentNotFoundException $e) {
$atvDoc = $this->applicationGetterService->getAtvDocument($webformData['application_number']);

if (!$atvDoc) {
return FALSE;
}

$atvMetadata = $atvDoc->getMetadata();
// Mismatch between profile and application applicant type.
if ($companyType !== $webformData['hakijan_tiedot']['applicantType']) {
Expand Down
Loading