From 2eb2dce9862a7e9a26c6a09a4eaab7639bc04498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 7 May 2024 07:47:46 +0300 Subject: [PATCH 01/65] UHF-9287: Frontend module sans React front. Subscribe still bugs for some reason --- ...est.resource.helfi_hakuvahti_subscribe.yml | 8 + .../helfi_hakuvahti/helfi_hakuvahti.info.yml | 14 ++ .../helfi_hakuvahti.routing.yml | 28 ++++ .../HelfiHakuvahtiConfirmController.php | 152 +++++++++++++++++ .../HelfiHakuvahtiSubscribeController.php | 89 ++++++++++ .../HelfiHakuvahtiUnsubscribeController.php | 155 ++++++++++++++++++ 6 files changed, 446 insertions(+) create mode 100644 public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml create mode 100644 public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml create mode 100644 public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml create mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php create mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php create mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php diff --git a/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml b/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml new file mode 100644 index 00000000..b34ae0da --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml @@ -0,0 +1,8 @@ +id: helfi_hakuvahti_subscribe_config +plugin_id: helfi_hakuvahti_subscribe +granularity: method +configuration: + POST: + supported_formats: + - json + diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml new file mode 100644 index 00000000..9abd5474 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml @@ -0,0 +1,14 @@ +name: 'HELfi Hakuvahti' +type: module +description: 'Drupal-integraatio hakuvahtiin.' +package: 'Custom' +core_version_requirement: ^10 +# admin: +# helfi_hakuvahti_settings: +# parent: 'admin' +# weight: 10 +# title: 'Helfi Hakuvahti' +# form: +# id: helfi_hakuvahti.settings_form +# class: Drupal\helfi_hakuvahti\Form\HelfiHakuvahtiSettingsForm +# path: 'admin/helfi_hakuvahti/settings' diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml new file mode 100644 index 00000000..35198834 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -0,0 +1,28 @@ +helfi_hakuvahti.subscribe: + path: '/hakuvahti/subscribe' + defaults: + _title: 'Subscribe' + _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiSubscribeController::post' + requirements: + _permission: 'access content' +helfi_hakuvahti.confirm: + path: '/hakuvahti/confirm' + defaults: + _title: 'Vahvista hakuvahti' + _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' + requirements: + _permission: 'access content' +helfi_hakuvahti.unsubscribe: + path: '/hakuvahti/unsubscribe' + defaults: + _title: 'Peruuta hakuvahti' + _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiUnsubscribeController' + requirements: + _permission: 'access content' +# helfi_hakuvahti.confirm_form: +# path: '/hakuvahti/confirm-form' +# defaults: +# _controller: '\Drupal\helfi_hakuvahti\Form\HelfiHakuvahtiConfirmForm' +# _title: 'Vahvista hakuvahti' +# requirements: +# _permission: 'access content' diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php new file mode 100644 index 00000000..8d934566 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -0,0 +1,152 @@ +httpClient = $http_client; + $this->requestStack = $request_stack; + $this->tokenService = $token_service; + $this->user = $user; + } + + public function getFormId() { + return 'hakuvahti_confirm_form'; + } + + public function __invoke(): array { + $build = []; + + $request = $this->requestStack->getCurrentRequest(); + $hash = $request->query->get('hash'); + $subscription = $request->query->get('subscription'); + + if ($this->isFormSubmitted()) { + if($this->sendConfirmationRequest($hash, $subscription)) { + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Hakuvahtitilaus vahvistettu.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + } else { + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Hakuvahtitilauksen vahvistus epäonnistui. Yritä uudelleen.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + } + } else { + $build['form'] = [ + '#type' => 'form', + '#attributes' => [ + 'class' => ['page-title'], + ], + '#id' => $this->getFormId(), + '#form_id' => $this->getFormId(), + '#action' => $this->getFormActionUrl(), + '#method' => 'POST', + ]; + + $build['form']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Vahvista hakuvahdin tilaus alla olevasta painikkeesta.'), + ]; + + $build['form']['button'] = [ + '#type' => 'submit', + '#value' => $this->t('Vahvista hakuvahti'), + '#attributes' => [ + 'class' => ['my-button'], + ], + ]; + } + + return $build; + } + + + protected function getFormActionUrl(): string { + return $this->requestStack->getCurrentRequest()->getUri(); + } + + protected function isFormSubmitted(): bool { + $request = $this->requestStack->getCurrentRequest(); + return $request->isMethod('POST'); + } + + protected function sendConfirmationRequest($hash, $subscription): bool { + $expectedToken = \Drupal::service('csrf_token')->get('session'); + + $httpClient = new Client(); + $options = [ + 'headers' => [ + 'Content-Type' => 'application/json', + 'token' => $expectedToken + ], + ]; + + $hakuvahtiServer = getenv('HAKUVAHTI_URL') ? getenv('HAKUVAHTI_URL') : 'http://helfi-rekry.docker.so:3000'; + + try { + $target_url = $hakuvahtiServer . '/subscription/confirm/' . $subscription . '/' . $hash; + $response = $httpClient->get($target_url, $options); + $responseBody = $response->getBody()->getContents(); + + error_log($responseBody); + + return true; + } + catch (RequestException $exception) { + error_log($exception->getMessage()); + } + + return false; + } + +} \ No newline at end of file diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php new file mode 100644 index 00000000..c24195cd --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -0,0 +1,89 @@ +requestStack = $requestStack; + $this->languageManager = $languageManager; + } + + public function post(): JsonResponse { + $request = $this->requestStack->getCurrentRequest(); + $method = $request->getMethod(); + $currentLanguage = $this->languageManager->getCurrentLanguage(); + + if ($method !== 'POST') { + return new JsonResponse(['success' => false], Response::HTTP_METHOD_NOT_ALLOWED); + } + + $body = $request->getContent(false); + $bodyObj = json_decode($body); + $bodyObj->lang = $currentLanguage->getId(); + + foreach ($bodyObj as $key => $value) { + $jsonArray[$key] = $value; + } + + if (!$body) { + throw new \LogicException('Expected request body to be non-null'); + } + + $client = new Client(); + try { + $token = $request->headers->get('token'); + // FIXME: token is different in backend for some reason? + // TODO: validate token when mismatch is fixed + // $expectedToken = \Drupal::service('csrf_token')->get('session'); + + $json = json_encode($bodyObj, JSON_PRETTY_PRINT); + $requestOpts[RequestOptions::JSON] = $jsonArray; + $requestOpts[RequestOptions::HEADERS] = [ + 'token' => $token, + 'Content-Type' => 'application/json', + ]; + $response = $client->request('POST', 'http://helfi-rekry.docker.so:3000/subscription', $requestOpts); + + } catch (\GuzzleHttp\Exception\GuzzleException $e) { + error_log($e->getMessage()); + + throw new \RuntimeException('Unexpected exception from Guzzle', 0, $e); + } + + $statusCode = $response->getStatusCode(); + $content = $response->getBody()->getContents(); + + if ($statusCode >= 200 && $statusCode < 300) { + return new JsonResponse(['success' => true], Response::HTTP_OK); + } else { + error_log($content); + + return new JsonResponse(['success' => false, 'error' => $content], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php new file mode 100644 index 00000000..d55f8139 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -0,0 +1,155 @@ +httpClient = $http_client; + $this->requestStack = $request_stack; + $this->tokenService = $token_service; + $this->user = $user; + } + + public function getFormId() { + return 'hakuvahti_unsubscribe_form'; + } + + /** + * Builds the response. + */ + public function __invoke(): array { + $build = []; + + $request = $this->requestStack->getCurrentRequest(); + $hash = $request->query->get('hash'); + $subscription = $request->query->get('subscription'); + + if ($this->isFormSubmitted()) { + if($this->sendUnsubscribeRequest($hash, $subscription)) { + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Hakuvahtitilaus peruutettu.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + } else { + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Hakuvahtitilauksen peruutus epäonnistui. Yritä uudelleen.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + } + } else { + $build['form'] = [ + '#type' => 'form', + '#attributes' => [ + 'class' => ['page-title'], + ], + '#id' => $this->getFormId(), + '#form_id' => $this->getFormId(), + '#action' => $this->getFormActionUrl(), + '#method' => 'POST', + ]; + + $build['form']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Vahvista hakuvahdin peruutus alla olevasta painikkeesta.'), + ]; + + $build['form']['button'] = [ + '#type' => 'submit', + '#value' => $this->t('Peruuta hakuvahti'), + '#attributes' => [ + 'class' => ['my-button'], + ], + ]; + } + + return $build; + } + + + protected function getFormActionUrl(): string { + return $this->requestStack->getCurrentRequest()->getUri(); + } + + protected function isFormSubmitted(): bool { + $request = $this->requestStack->getCurrentRequest(); + return $request->isMethod('POST'); + } + + protected function sendUnsubscribeRequest($hash, $subscription): bool { + $expectedToken = \Drupal::service('csrf_token')->get('session'); + + $httpClient = new Client(); + $options = [ + 'headers' => [ + 'Content-Type' => 'application/json', + 'token' => $expectedToken + ], + ]; + + $hakuvahtiServer = getenv('HAKUVAHTI_URL') ? getenv('HAKUVAHTI_URL') : 'http://helfi-rekry.docker.so:3000'; + + try { + $target_url = $hakuvahtiServer . '/subscription/delete/' . $subscription . '/' . $hash; + $response = $httpClient->delete($target_url, $options); + $responseBody = $response->getBody()->getContents(); + + error_log($responseBody); + + return true; + } + catch (RequestException $exception) { + error_log($exception->getMessage()); + } + + return false; + } + +} \ No newline at end of file From d4b4964801a61f2c5ffa9ce6ecbfca256274b80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 7 May 2024 07:49:33 +0300 Subject: [PATCH 02/65] UHF-9287: Not needed --- .../install/rest.resource.helfi_hakuvahti_subscribe.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml diff --git a/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml b/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml deleted file mode 100644 index b34ae0da..00000000 --- a/public/modules/custom/helfi_hakuvahti/config/install/rest.resource.helfi_hakuvahti_subscribe.yml +++ /dev/null @@ -1,8 +0,0 @@ -id: helfi_hakuvahti_subscribe_config -plugin_id: helfi_hakuvahti_subscribe -granularity: method -configuration: - POST: - supported_formats: - - json - From 14b7a6f6a5b04fa49870be5318544da5941c0004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 7 May 2024 08:52:22 +0300 Subject: [PATCH 03/65] UHF-9287: Correct translation strings --- .../helfi_hakuvahti.routing.yml | 4 +- .../HelfiHakuvahtiConfirmController.php | 8 +-- .../HelfiHakuvahtiUnsubscribeController.php | 70 +++++++++++++------ 3 files changed, 53 insertions(+), 29 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index 35198834..e7c889a6 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -8,14 +8,14 @@ helfi_hakuvahti.subscribe: helfi_hakuvahti.confirm: path: '/hakuvahti/confirm' defaults: - _title: 'Vahvista hakuvahti' + _title: 'Confirm saved search' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' requirements: _permission: 'access content' helfi_hakuvahti.unsubscribe: path: '/hakuvahti/unsubscribe' defaults: - _title: 'Peruuta hakuvahti' + _title: 'Are you sure you wish to delete the saved search?' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiUnsubscribeController' requirements: _permission: 'access content' diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 8d934566..4dc14288 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -65,7 +65,7 @@ public function __invoke(): array { $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Hakuvahtitilaus vahvistettu.'), + '#value' => $this->t('Saved search confirmed.'), '#attributes' => [ 'class' => ['page-title'], ], @@ -74,7 +74,7 @@ public function __invoke(): array { $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Hakuvahtitilauksen vahvistus epäonnistui. Yritä uudelleen.'), + '#value' => $this->t('Confirming saved search failed. Please try again.'), '#attributes' => [ 'class' => ['page-title'], ], @@ -95,12 +95,12 @@ public function __invoke(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Vahvista hakuvahdin tilaus alla olevasta painikkeesta.'), + '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.'), ]; $build['form']['button'] = [ '#type' => 'submit', - '#value' => $this->t('Vahvista hakuvahti'), + '#value' => $this->t('Confirm saved search'), '#attributes' => [ 'class' => ['my-button'], ], diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index d55f8139..133d7a86 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -12,7 +12,8 @@ use Drupal\Core\Utility\Token; use Drupal\Core\Session\AccountInterface; -final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { +final class HelfiHakuvahtiUnsubscribeController extends ControllerBase +{ /** * The http client. @@ -40,23 +41,26 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { * * @var \Drupal\Core\Session\AccountInterface */ - protected $user; + protected $user; - public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { + public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) + { $this->httpClient = $http_client; $this->requestStack = $request_stack; $this->tokenService = $token_service; - $this->user = $user; + $this->user = $user; } - public function getFormId() { + public function getFormId() + { return 'hakuvahti_unsubscribe_form'; } /** * Builds the response. */ - public function __invoke(): array { + public function __invoke(): array + { $build = []; $request = $this->requestStack->getCurrentRequest(); @@ -64,24 +68,42 @@ public function __invoke(): array { $subscription = $request->query->get('subscription'); if ($this->isFormSubmitted()) { - if($this->sendUnsubscribeRequest($hash, $subscription)) { + if ($this->sendUnsubscribeRequest($hash, $subscription)) { $build['confirmation'] = [ + '#title' => $this->t('Saved search deleted'), + ]; + + $build['confirmation']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('The saved search has been deleted'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + $build['confirmation']['paragraph2'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Hakuvahtitilaus peruutettu.'), + '#value' => $this->t('You can save more searches at any time.'), '#attributes' => [ 'class' => ['page-title'], ], - ]; + ]; + $build['confirmation']['link'] = [ + '#type' => 'link', + '#tag' => 'a', + '#title' => $this->t('Return to open jobs front page'), + '#url' => '/', + ]; } else { - $build['confirmation'] = [ + $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Hakuvahtitilauksen peruutus epäonnistui. Yritä uudelleen.'), + '#value' => $this->t('Deleting saved search failed. Please try again.'), '#attributes' => [ 'class' => ['page-title'], ], - ]; + ]; } } else { $build['form'] = [ @@ -98,12 +120,13 @@ public function __invoke(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Vahvista hakuvahdin peruutus alla olevasta painikkeesta.'), + '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved + on the City website, this link will not delete them.'), ]; $build['form']['button'] = [ '#type' => 'submit', - '#value' => $this->t('Peruuta hakuvahti'), + '#value' => $this->t('Delete saved search'), '#attributes' => [ 'class' => ['my-button'], ], @@ -114,16 +137,19 @@ public function __invoke(): array { } - protected function getFormActionUrl(): string { + protected function getFormActionUrl(): string + { return $this->requestStack->getCurrentRequest()->getUri(); - } + } - protected function isFormSubmitted(): bool { + protected function isFormSubmitted(): bool + { $request = $this->requestStack->getCurrentRequest(); return $request->isMethod('POST'); } - protected function sendUnsubscribeRequest($hash, $subscription): bool { + protected function sendUnsubscribeRequest($hash, $subscription): bool + { $expectedToken = \Drupal::service('csrf_token')->get('session'); $httpClient = new Client(); @@ -135,7 +161,7 @@ protected function sendUnsubscribeRequest($hash, $subscription): bool { ]; $hakuvahtiServer = getenv('HAKUVAHTI_URL') ? getenv('HAKUVAHTI_URL') : 'http://helfi-rekry.docker.so:3000'; - + try { $target_url = $hakuvahtiServer . '/subscription/delete/' . $subscription . '/' . $hash; $response = $httpClient->delete($target_url, $options); @@ -144,12 +170,10 @@ protected function sendUnsubscribeRequest($hash, $subscription): bool { error_log($responseBody); return true; - } - catch (RequestException $exception) { + } catch (RequestException $exception) { error_log($exception->getMessage()); } return false; } - -} \ No newline at end of file +} From 62ab74083c62bea181e5c8034bad1f51bc1283ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 9 May 2024 13:12:37 +0300 Subject: [PATCH 04/65] UHF-9287: Translation stuff, doesn't load for some reason --- .../helfi_hakuvahti/helfi_hakuvahti.info.yml | 11 +---- .../translations/helfi_hakuvahti.fi.po | 49 +++++++++++++++++++ .../translations/helfi_hakuvahti.sv.po | 49 +++++++++++++++++++ 3 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po create mode 100644 public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml index 9abd5474..79a0a989 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml @@ -3,12 +3,5 @@ type: module description: 'Drupal-integraatio hakuvahtiin.' package: 'Custom' core_version_requirement: ^10 -# admin: -# helfi_hakuvahti_settings: -# parent: 'admin' -# weight: 10 -# title: 'Helfi Hakuvahti' -# form: -# id: helfi_hakuvahti.settings_form -# class: Drupal\helfi_hakuvahti\Form\HelfiHakuvahtiSettingsForm -# path: 'admin/helfi_hakuvahti/settings' +'interface translation project': helfi_hakuvahti +'interface translation server pattern': modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.%language.po diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po new file mode 100644 index 00000000..35fad324 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po @@ -0,0 +1,49 @@ +# Finnish translations of City of Helsinki Hakuvahti +# +# Use this translation file for missing translations that are not found in +# localize.drupal.org. +# +msgid "" +msgstr "" + +msgid "Saved search deleted" +msgstr "Hakuvahti on poistettu" + +msgid "The saved search has been deleted" +msgstr "Hakuvahti on poistettu" + +msgid "You can save more searches at any time." +msgstr "Voit koska tahansa tilata uusia hakuvahteja." + +msgid "Return to open jobs front page" +msgstr "Palaa avoimien työpaikkojen etusivulle." + +msgid "Deleting saved search failed. Please try again." +msgstr "Hakuvahdin poisto epäonnistui. Yritä uudelleen." + +msgid "Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them." +msgstr "Vahvista, että haluat poistaa tämän hakuvahdin. Jos olet tehnyt muita hakuvahteja kaupungin verkkosivustolla, tämä ei poista niitä." + +msgid "Delete saved search" +msgstr "Poista hakuvahti" + +msgid "Saved search confirmed." +msgstr "Hakuvahti vahvistettu." + +msgid "Confirming saved search failed. Please try again." +msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." + +msgid "Please confirm the saved search to receive notifications. Click on the button below." +msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta." + +msgid "Confirm saved search" +msgstr "Vahvista hakuvahti" + +msgid "Subscribe" +msgstr "" + +msgid "Confirm saved search" +msgstr "Vahvista hakuvahti" + +msgid "Are you sure you wish to delete the saved search?" +msgstr "Haluatko varmasti poistaa hakuvahdin?" diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po new file mode 100644 index 00000000..4830af58 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po @@ -0,0 +1,49 @@ +# Swedish translations of City of Helsinki Hakuvahti +# +# Use this translation file for missing translations that are not found in +# localize.drupal.org. +# +msgid "" +msgstr "" + +msgid "Saved search deleted" +msgstr "" + +msgid "The saved search has been deleted" +msgstr "" + +msgid "You can save more searches at any time." +msgstr "" + +msgid "Return to open jobs front page" +msgstr "" + +msgid "Deleting saved search failed. Please try again." +msgstr "" + +msgid "Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them." +msgstr "" + +msgid "Delete saved search" +msgstr "" + +msgid "Saved search confirmed." +msgstr "" + +msgid "Confirming saved search failed. Please try again." +msgstr "" + +msgid "Please confirm the saved search to receive notifications. Click on the button below." +msgstr "" + +msgid "Confirm saved search" +msgstr "" + +msgid "Subscribe" +msgstr "" + +msgid "Confirm saved search" +msgstr "Bekräfta sökvakten" + +msgid "Are you sure you wish to delete the saved search?" +msgstr "" From 49de3782f7c862226c6677c9f2ca90b8992fe2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 9 May 2024 13:12:55 +0300 Subject: [PATCH 05/65] UHF-9287: String fix --- .../src/Controller/HelfiHakuvahtiUnsubscribeController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 133d7a86..970fcf4e 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -120,8 +120,7 @@ public function __invoke(): array $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved - on the City website, this link will not delete them.'), + '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.'), ]; $build['form']['button'] = [ From 781a53fc2ea6b4644178ca422a86d38d8788fd3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 9 May 2024 13:17:20 +0300 Subject: [PATCH 06/65] UHF-9287: Hakuvahti url --- .env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env b/.env index 57eb642e..ac8ed93a 100644 --- a/.env +++ b/.env @@ -29,3 +29,5 @@ HELBIT_CLIENT_ID= # URL for Elasticsearch (for job search) ELASTIC_PROXY_URL=https://elastic-helfi-rekry.docker.so + +HAKUVAHTI_URL="http://${DRUPAL_HOSTNAME}:3000" From 3633039affe97a1aa3ed66cdf24806340af67c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 13 May 2024 11:23:25 +0300 Subject: [PATCH 07/65] UHF-9287: Cleanups and refactoring --- .../HelfiHakuvahtiConfirmController.php | 33 ++++++------- .../HelfiHakuvahtiSubscribeController.php | 46 ++++--------------- .../HelfiHakuvahtiUnsubscribeController.php | 12 ++--- 3 files changed, 26 insertions(+), 65 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 4dc14288..d3b43172 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -120,33 +120,26 @@ protected function isFormSubmitted(): bool { return $request->isMethod('POST'); } - protected function sendConfirmationRequest($hash, $subscription): bool { + protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool + { $expectedToken = \Drupal::service('csrf_token')->get('session'); - - $httpClient = new Client(); - $options = [ + $httpClient = new Client([ 'headers' => [ 'Content-Type' => 'application/json', - 'token' => $expectedToken + 'token' => $expectedToken, ], - ]; - - $hakuvahtiServer = getenv('HAKUVAHTI_URL') ? getenv('HAKUVAHTI_URL') : 'http://helfi-rekry.docker.so:3000'; - - try { - $target_url = $hakuvahtiServer . '/subscription/confirm/' . $subscription . '/' . $hash; - $response = $httpClient->get($target_url, $options); - $responseBody = $response->getBody()->getContents(); + ]); - error_log($responseBody); + $hakuvahtiServer = getenv('HAKUVAHTI_URL') ?: 'http://helfi-rekry.docker.so:3000'; + $targetUrl = $hakuvahtiServer . '/subscription/confirm/' . $subscriptionId . '/' . $subscriptionHash; - return true; - } - catch (RequestException $exception) { - error_log($exception->getMessage()); + try { + $response = $httpClient->get($targetUrl); + return $response->getBody()->getContents() !== ''; + } catch (RequestException $exception) { + return false; } - - return false; } + } \ No newline at end of file diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index c24195cd..109bd2ce 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -34,55 +34,29 @@ public function __construct(RequestStack $requestStack, LanguageManagerInterface public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); - $method = $request->getMethod(); - $currentLanguage = $this->languageManager->getCurrentLanguage(); - - if ($method !== 'POST') { - return new JsonResponse(['success' => false], Response::HTTP_METHOD_NOT_ALLOWED); - } - $body = $request->getContent(false); $bodyObj = json_decode($body); - $bodyObj->lang = $currentLanguage->getId(); + $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); - foreach ($bodyObj as $key => $value) { - $jsonArray[$key] = $value; - } - - if (!$body) { - throw new \LogicException('Expected request body to be non-null'); - } + $json = json_encode($bodyObj, JSON_THROW_ON_ERROR); + $token = $request->headers->get('token'); $client = new Client(); - try { - $token = $request->headers->get('token'); - // FIXME: token is different in backend for some reason? - // TODO: validate token when mismatch is fixed - // $expectedToken = \Drupal::service('csrf_token')->get('session'); - - $json = json_encode($bodyObj, JSON_PRETTY_PRINT); - $requestOpts[RequestOptions::JSON] = $jsonArray; - $requestOpts[RequestOptions::HEADERS] = [ + $hakuvahtiServer = getenv('HAKUVAHTI_URL') ?: 'http://helfi-rekry.docker.so:3000'; + $response = $client->request('POST', $hakuvahtiServer . '/subscription', [ + RequestOptions::JSON => $bodyObj, + RequestOptions::HEADERS => [ 'token' => $token, 'Content-Type' => 'application/json', - ]; - $response = $client->request('POST', 'http://helfi-rekry.docker.so:3000/subscription', $requestOpts); - - } catch (\GuzzleHttp\Exception\GuzzleException $e) { - error_log($e->getMessage()); - - throw new \RuntimeException('Unexpected exception from Guzzle', 0, $e); - } + ], + ]); $statusCode = $response->getStatusCode(); - $content = $response->getBody()->getContents(); if ($statusCode >= 200 && $statusCode < 300) { return new JsonResponse(['success' => true], Response::HTTP_OK); } else { - error_log($content); - - return new JsonResponse(['success' => false, 'error' => $content], Response::HTTP_INTERNAL_SERVER_ERROR); + return new JsonResponse(['success' => false, 'error' => $response->getBody()->getContents()], Response::HTTP_INTERNAL_SERVER_ERROR); } } diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 970fcf4e..a26262ef 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -135,7 +135,6 @@ public function __invoke(): array return $build; } - protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); @@ -147,7 +146,7 @@ protected function isFormSubmitted(): bool return $request->isMethod('POST'); } - protected function sendUnsubscribeRequest($hash, $subscription): bool + protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { $expectedToken = \Drupal::service('csrf_token')->get('session'); @@ -164,15 +163,10 @@ protected function sendUnsubscribeRequest($hash, $subscription): bool try { $target_url = $hakuvahtiServer . '/subscription/delete/' . $subscription . '/' . $hash; $response = $httpClient->delete($target_url, $options); - $responseBody = $response->getBody()->getContents(); - - error_log($responseBody); - return true; + return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300; } catch (RequestException $exception) { - error_log($exception->getMessage()); + return false; } - - return false; } } From 8a55597ba0717db00a2dede1cb3dfda59626896b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 14 May 2024 09:56:17 +0300 Subject: [PATCH 08/65] UHF-9287: Cleanup --- .../custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index e7c889a6..96c65327 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -19,10 +19,3 @@ helfi_hakuvahti.unsubscribe: _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiUnsubscribeController' requirements: _permission: 'access content' -# helfi_hakuvahti.confirm_form: -# path: '/hakuvahti/confirm-form' -# defaults: -# _controller: '\Drupal\helfi_hakuvahti\Form\HelfiHakuvahtiConfirmForm' -# _title: 'Vahvista hakuvahti' -# requirements: -# _permission: 'access content' From a8aac7f484c5413c793cf5c367be38da30ef026f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 14 May 2024 09:57:09 +0300 Subject: [PATCH 09/65] UHF-9287: Enable extension --- conf/cmi/core.extension.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/cmi/core.extension.yml b/conf/cmi/core.extension.yml index 542bd09e..80f6e8a8 100644 --- a/conf/cmi/core.extension.yml +++ b/conf/cmi/core.extension.yml @@ -45,6 +45,7 @@ module: helfi_ckeditor: 0 helfi_eu_cookie_compliance: 0 helfi_global_announcement: 0 + helfi_hakuvahti: 0 helfi_image_styles: 0 helfi_media: 0 helfi_media_chart: 0 From fb511ae1b9e6f526ed24e37e01b17805a27dc289 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 14 May 2024 16:46:41 +0300 Subject: [PATCH 10/65] UHF-9287: Fixed some PHPCS --- .../HelfiHakuvahtiConfirmController.php | 42 +++++++-------- .../HelfiHakuvahtiSubscribeController.php | 18 +++---- .../HelfiHakuvahtiUnsubscribeController.php | 51 +++++++++---------- 3 files changed, 54 insertions(+), 57 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index d3b43172..2d83b7e0 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -5,25 +5,25 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Utility\Token; +use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use Symfony\Component\HttpFoundation\RequestStack; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Client; -use Drupal\Core\Utility\Token; -use Drupal\Core\Session\AccountInterface; +use Symfony\Component\HttpFoundation\RequestStack; final class HelfiHakuvahtiConfirmController extends ControllerBase { /** * The http client. - * + * * @var \GuzzleHttp\ClientInterface */ protected $httpClient; /** * The request stack. - * + * * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $requestStack; @@ -40,13 +40,13 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { * * @var \Drupal\Core\Session\AccountInterface */ - protected $user; + protected $user; public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { $this->httpClient = $http_client; $this->requestStack = $request_stack; $this->tokenService = $token_service; - $this->user = $user; + $this->user = $user; } public function getFormId() { @@ -61,7 +61,7 @@ public function __invoke(): array { $subscription = $request->query->get('subscription'); if ($this->isFormSubmitted()) { - if($this->sendConfirmationRequest($hash, $subscription)) { + if ($this->sendConfirmationRequest($hash, $subscription)) { $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -69,8 +69,9 @@ public function __invoke(): array { '#attributes' => [ 'class' => ['page-title'], ], - ]; - } else { + ]; + } + else { $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -78,9 +79,10 @@ public function __invoke(): array { '#attributes' => [ 'class' => ['page-title'], ], - ]; + ]; } - } else { + } + else { $build['form'] = [ '#type' => 'form', '#attributes' => [ @@ -110,18 +112,16 @@ public function __invoke(): array { return $build; } - protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); - } + } protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); return $request->isMethod('POST'); } - protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool - { + protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { $expectedToken = \Drupal::service('csrf_token')->get('session'); $httpClient = new Client([ 'headers' => [ @@ -136,10 +136,10 @@ protected function sendConfirmationRequest(string $subscriptionHash, string $sub try { $response = $httpClient->get($targetUrl); return $response->getBody()->getContents() !== ''; - } catch (RequestException $exception) { - return false; + } + catch (RequestException $exception) { + return FALSE; } } - -} \ No newline at end of file +} diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 109bd2ce..66692039 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -5,13 +5,12 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; -use \Drupal\Core\Language\LanguageManagerInterface; +use Drupal\Core\Language\LanguageManagerInterface; +use GuzzleHttp\Client; +use GuzzleHttp\RequestOptions; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; -use GuzzleHttp\Client; -use GuzzleHttp\RequestOptions; -use stdClass; /** * Returns responses for Hakuvahti routes. @@ -26,7 +25,7 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { * @var \Drupal\Core\Language\LanguageManagerInterface */ protected $languageManager; - + public function __construct(RequestStack $requestStack, LanguageManagerInterface $languageManager) { $this->requestStack = $requestStack; $this->languageManager = $languageManager; @@ -34,7 +33,7 @@ public function __construct(RequestStack $requestStack, LanguageManagerInterface public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); - $body = $request->getContent(false); + $body = $request->getContent(FALSE); $bodyObj = json_decode($body); $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); @@ -54,9 +53,10 @@ public function post(): JsonResponse { $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 300) { - return new JsonResponse(['success' => true], Response::HTTP_OK); - } else { - return new JsonResponse(['success' => false, 'error' => $response->getBody()->getContents()], Response::HTTP_INTERNAL_SERVER_ERROR); + return new JsonResponse(['success' => TRUE], Response::HTTP_OK); + } + else { + return new JsonResponse(['success' => FALSE, 'error' => $response->getBody()->getContents()], Response::HTTP_INTERNAL_SERVER_ERROR); } } diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index a26262ef..8a985560 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -5,26 +5,25 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Utility\Token; +use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use Symfony\Component\HttpFoundation\RequestStack; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Client; -use Drupal\Core\Utility\Token; -use Drupal\Core\Session\AccountInterface; +use Symfony\Component\HttpFoundation\RequestStack; -final class HelfiHakuvahtiUnsubscribeController extends ControllerBase -{ +final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { /** * The http client. - * + * * @var \GuzzleHttp\ClientInterface */ protected $httpClient; /** * The request stack. - * + * * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $requestStack; @@ -43,24 +42,21 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase */ protected $user; - public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) - { + public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { $this->httpClient = $http_client; $this->requestStack = $request_stack; $this->tokenService = $token_service; $this->user = $user; } - public function getFormId() - { + public function getFormId() { return 'hakuvahti_unsubscribe_form'; } /** * Builds the response. */ - public function __invoke(): array - { + public function __invoke(): array { $build = []; $request = $this->requestStack->getCurrentRequest(); @@ -79,7 +75,7 @@ public function __invoke(): array '#value' => $this->t('The saved search has been deleted'), '#attributes' => [ 'class' => ['page-title'], - ], + ], ]; $build['confirmation']['paragraph2'] = [ '#type' => 'html_tag', @@ -88,14 +84,15 @@ public function __invoke(): array '#attributes' => [ 'class' => ['page-title'], ], - ]; + ]; $build['confirmation']['link'] = [ '#type' => 'link', '#tag' => 'a', '#title' => $this->t('Return to open jobs front page'), '#url' => '/', ]; - } else { + } + else { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -105,7 +102,8 @@ public function __invoke(): array ], ]; } - } else { + } + else { $build['form'] = [ '#type' => 'form', '#attributes' => [ @@ -135,26 +133,23 @@ public function __invoke(): array return $build; } - protected function getFormActionUrl(): string - { + protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); } - protected function isFormSubmitted(): bool - { + protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); return $request->isMethod('POST'); } - protected function sendUnsubscribeRequest(string $hash, string $subscription): bool - { + protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { $expectedToken = \Drupal::service('csrf_token')->get('session'); $httpClient = new Client(); $options = [ 'headers' => [ 'Content-Type' => 'application/json', - 'token' => $expectedToken + 'token' => $expectedToken, ], ]; @@ -165,8 +160,10 @@ protected function sendUnsubscribeRequest(string $hash, string $subscription): b $response = $httpClient->delete($target_url, $options); return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300; - } catch (RequestException $exception) { - return false; + } + catch (RequestException $exception) { + return FALSE; } } + } From f2897e72ede447746d95d9cc2fceaf732e5b2f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 09:36:18 +0300 Subject: [PATCH 11/65] UHF-9287: Add class+function docblocks --- .../HelfiHakuvahtiConfirmController.php | 43 +++++++++++++++++++ .../HelfiHakuvahtiSubscribeController.php | 13 +++++- .../HelfiHakuvahtiUnsubscribeController.php | 38 +++++++++++++++- 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 2d83b7e0..08519823 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -12,6 +12,9 @@ use GuzzleHttp\Exception\RequestException; use Symfony\Component\HttpFoundation\RequestStack; +/** + * Confirms a subscription. + */ final class HelfiHakuvahtiConfirmController extends ControllerBase { /** @@ -42,6 +45,18 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { */ protected $user; + /** + * Constructor for HelfiHakuvahtiConfirmController. + * + * @param \GuzzleHttp\ClientInterface $http_client + * The HTTP client. + * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * The request stack. + * @param \Drupal\Core\Utility\Token $token_service + * The token service. + * @param \Drupal\Core\Session\AccountInterface $user + * The user account. + */ public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { $this->httpClient = $http_client; $this->requestStack = $request_stack; @@ -49,10 +64,20 @@ public function __construct(ClientInterface $http_client, RequestStack $request_ $this->user = $user; } + /** + * Returns the form ID for the confirmation form. + * + * @return string + */ public function getFormId() { return 'hakuvahti_confirm_form'; } + /** + * Executes the confirmation process for a saved search. + * + * @return array The build array containing the confirmation form or the saved search form. + */ public function __invoke(): array { $build = []; @@ -112,15 +137,33 @@ public function __invoke(): array { return $build; } + /** + * Retrieves the form action URL from the current request. + * + * @return string The URL of the current request. + */ protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); } + /** + * Checks if the form is submitted via POST method. + * + * @return bool + */ protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); return $request->isMethod('POST'); } + /** + * Sends a confirmation request to the Hakuvahti server. + * + * @param string $subscriptionHash The subscription hash. + * @param string $subscriptionId The subscription ID. + * @throws Some_Exception_Class Description of the exception. + * @return bool Returns TRUE if the confirmation request is successful, FALSE otherwise. + */ protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { $expectedToken = \Drupal::service('csrf_token')->get('session'); $httpClient = new Client([ diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 66692039..7f602768 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Response; /** - * Returns responses for Hakuvahti routes. + * Creates new subscription. */ final class HelfiHakuvahtiSubscribeController extends ControllerBase { @@ -26,11 +26,22 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { */ protected $languageManager; + /** + * Constructor for the HelfiHakuvahtiSubscribeController class. + * + * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack The request stack. + * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager The language manager. + */ public function __construct(RequestStack $requestStack, LanguageManagerInterface $languageManager) { $this->requestStack = $requestStack; $this->languageManager = $languageManager; } + /** + * A method to handle the POST request for subscription. + * + * @return JsonResponse The JSON response based on the subscription request. + */ public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); $body = $request->getContent(FALSE); diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 8a985560..358fa15f 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -12,6 +12,9 @@ use GuzzleHttp\Exception\RequestException; use Symfony\Component\HttpFoundation\RequestStack; +/** + * Unsubscribes from a subscription. + */ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { /** @@ -42,6 +45,14 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { */ protected $user; + /** + * Constructor for the class. + * + * @param ClientInterface $http_client The HTTP client. + * @param RequestStack $request_stack The request stack. + * @param Token $token_service The token service. + * @param AccountInterface $user The current user. + */ public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { $this->httpClient = $http_client; $this->requestStack = $request_stack; @@ -49,12 +60,19 @@ public function __construct(ClientInterface $http_client, RequestStack $request_ $this->user = $user; } + /** + * Returns the form ID for unsubscribing from a subscription. + * + * @return string + */ public function getFormId() { return 'hakuvahti_unsubscribe_form'; } /** - * Builds the response. + * Builds the response for unsubscribing from a subscription. + * + * @return array */ public function __invoke(): array { $build = []; @@ -133,15 +151,33 @@ public function __invoke(): array { return $build; } + /** + * Returns the URL for the current form action. + * + * @return string The URL for the current form action. + */ protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); } + /** + * Checks if the form is submitted via the POST method. + * + * @return bool Whether the form is submitted via the POST method. + */ protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); return $request->isMethod('POST'); } + /** + * Sends an unsubscribe request to the server. + * + * @param string $hash The hash of the subscription. + * @param string $subscription The subscription ID. + * @throws RequestException Description of the request exception. + * @return bool Returns TRUE if the request is successful, FALSE otherwise. + */ protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { $expectedToken = \Drupal::service('csrf_token')->get('session'); From d0986751fcac114d834c1ee79d2bf1f83338b09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 10:15:47 +0300 Subject: [PATCH 12/65] UHF-9287: Fix linter problems --- .../HelfiHakuvahtiConfirmController.php | 41 +++++++++++++++---- .../HelfiHakuvahtiSubscribeController.php | 16 +++++--- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 08519823..7388c985 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -10,6 +10,7 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -45,11 +46,20 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { */ protected $user; + /** + * The CSRF token service. + * + * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface + */ + protected $csrfTokenService; + /** * Constructor for HelfiHakuvahtiConfirmController. * * @param \GuzzleHttp\ClientInterface $http_client * The HTTP client. + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack. * @param \Drupal\Core\Utility\Token $token_service @@ -57,8 +67,15 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { * @param \Drupal\Core\Session\AccountInterface $user * The user account. */ - public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { + public function __construct( + ClientInterface $http_client, + ContainerInterface $container, + RequestStack $request_stack, + Token $token_service, + AccountInterface $user, + ) { $this->httpClient = $http_client; + $this->csrfTokenService = $container->get('csrf_token'); $this->requestStack = $request_stack; $this->tokenService = $token_service; $this->user = $user; @@ -68,6 +85,7 @@ public function __construct(ClientInterface $http_client, RequestStack $request_ * Returns the form ID for the confirmation form. * * @return string + * The Form name */ public function getFormId() { return 'hakuvahti_confirm_form'; @@ -76,7 +94,9 @@ public function getFormId() { /** * Executes the confirmation process for a saved search. * - * @return array The build array containing the confirmation form or the saved search form. + * @return array + * The build array containing the confirmation form or the + * saved search form. */ public function __invoke(): array { $build = []; @@ -140,7 +160,8 @@ public function __invoke(): array { /** * Retrieves the form action URL from the current request. * - * @return string The URL of the current request. + * @return string + * The URL of the current request. */ protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); @@ -150,6 +171,7 @@ protected function getFormActionUrl(): string { * Checks if the form is submitted via POST method. * * @return bool + * Whether the form is submitted via POST method. */ protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); @@ -159,13 +181,16 @@ protected function isFormSubmitted(): bool { /** * Sends a confirmation request to the Hakuvahti server. * - * @param string $subscriptionHash The subscription hash. - * @param string $subscriptionId The subscription ID. - * @throws Some_Exception_Class Description of the exception. - * @return bool Returns TRUE if the confirmation request is successful, FALSE otherwise. + * @param string $subscriptionHash + * The subscription hash. + * @param string $subscriptionId + * The subscription ID. + * + * @return bool + * Returns TRUE if the confirmation request is successful, FALSE otherwise. */ protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { - $expectedToken = \Drupal::service('csrf_token')->get('session'); + $expectedToken = $this->csrfTokenService->get('session'); $httpClient = new Client([ 'headers' => [ 'Content-Type' => 'application/json', diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 7f602768..50059d6c 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -17,6 +17,11 @@ */ final class HelfiHakuvahtiSubscribeController extends ControllerBase { + /** + * The request stack. + * + * @var \Symfony\Component\HttpFoundation\RequestStack + */ protected $requestStack; /** @@ -29,8 +34,10 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { /** * Constructor for the HelfiHakuvahtiSubscribeController class. * - * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack The request stack. - * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager The language manager. + * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack + * The request stack. + * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager + * The language manager. */ public function __construct(RequestStack $requestStack, LanguageManagerInterface $languageManager) { $this->requestStack = $requestStack; @@ -40,15 +47,14 @@ public function __construct(RequestStack $requestStack, LanguageManagerInterface /** * A method to handle the POST request for subscription. * - * @return JsonResponse The JSON response based on the subscription request. + * @return \Symfony\Component\HttpFoundation\JsonResponse + * The JSON response based on the subscription request. */ public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); $body = $request->getContent(FALSE); $bodyObj = json_decode($body); $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); - - $json = json_encode($bodyObj, JSON_THROW_ON_ERROR); $token = $request->headers->get('token'); $client = new Client(); From 75dc4e60888c876b454829d940f4b3e7c2adc21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 10:23:21 +0300 Subject: [PATCH 13/65] UHF-9287: Fix linter problems --- .../HelfiHakuvahtiUnsubscribeController.php | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 358fa15f..ab04f0ca 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -10,6 +10,7 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -45,16 +46,30 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { */ protected $user; + /** + * The CSRF token service. + * + * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface + */ + protected $csrfTokenService; + /** * Constructor for the class. * - * @param ClientInterface $http_client The HTTP client. - * @param RequestStack $request_stack The request stack. - * @param Token $token_service The token service. - * @param AccountInterface $user The current user. + * @param \GuzzleHttp\ClientInterface $http_client + * The HTTP client. + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container. + * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * The request stack. + * @param \App\Services\Token $token_service + * The token service. + * @param \App\Interfaces\AccountInterface $user + * The current user. */ - public function __construct(ClientInterface $http_client, RequestStack $request_stack, Token $token_service, AccountInterface $user) { + public function __construct(ClientInterface $http_client, ContainerInterface $container, RequestStack $request_stack, Token $token_service, AccountInterface $user) { $this->httpClient = $http_client; + $this->csrfTokenService = $container->get('csrf_token'); $this->requestStack = $request_stack; $this->tokenService = $token_service; $this->user = $user; @@ -64,6 +79,7 @@ public function __construct(ClientInterface $http_client, RequestStack $request_ * Returns the form ID for unsubscribing from a subscription. * * @return string + * The Form name */ public function getFormId() { return 'hakuvahti_unsubscribe_form'; @@ -73,6 +89,7 @@ public function getFormId() { * Builds the response for unsubscribing from a subscription. * * @return array + * The form */ public function __invoke(): array { $build = []; @@ -154,7 +171,8 @@ public function __invoke(): array { /** * Returns the URL for the current form action. * - * @return string The URL for the current form action. + * @return string + * The URL for the current form action. */ protected function getFormActionUrl(): string { return $this->requestStack->getCurrentRequest()->getUri(); @@ -163,7 +181,8 @@ protected function getFormActionUrl(): string { /** * Checks if the form is submitted via the POST method. * - * @return bool Whether the form is submitted via the POST method. + * @return bool + * Whether the form is submitted via the POST method. */ protected function isFormSubmitted(): bool { $request = $this->requestStack->getCurrentRequest(); @@ -173,13 +192,16 @@ protected function isFormSubmitted(): bool { /** * Sends an unsubscribe request to the server. * - * @param string $hash The hash of the subscription. - * @param string $subscription The subscription ID. - * @throws RequestException Description of the request exception. - * @return bool Returns TRUE if the request is successful, FALSE otherwise. + * @param string $hash + * The hash of the subscription. + * @param string $subscription + * The subscription ID. + * + * @return bool + * Returns TRUE if the request is successful, FALSE otherwise. */ protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { - $expectedToken = \Drupal::service('csrf_token')->get('session'); + $expectedToken = $this->csrfTokenService->get('session'); $httpClient = new Client(); $options = [ From cf146ddcb0b486b926ca88b58dbf13b39bd31e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 11:18:51 +0300 Subject: [PATCH 14/65] UHF-9287: Add note about tokens --- .../HelfiHakuvahtiSubscribeController.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 50059d6c..1f6dfdba 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -8,6 +8,7 @@ use Drupal\Core\Language\LanguageManagerInterface; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; @@ -31,15 +32,25 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { */ protected $languageManager; + /** + * The CSRF token service. + * + * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface + */ + protected $csrfTokenService; + /** * Constructor for the HelfiHakuvahtiSubscribeController class. * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager * The language manager. */ - public function __construct(RequestStack $requestStack, LanguageManagerInterface $languageManager) { + public function __construct(ContainerInterface $container, RequestStack $requestStack, LanguageManagerInterface $languageManager) { + $this->csrfTokenService = $container->get('csrf_token'); $this->requestStack = $requestStack; $this->languageManager = $languageManager; } @@ -57,6 +68,13 @@ public function post(): JsonResponse { $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); $token = $request->headers->get('token'); + // FIXME: somehow, we would need to validate token from + // /session/token from react + // side, but there's just no way to match it at backend?! + // $expectedToken = $this->csrfTokenService->get('session'); + // if ($this->csrfTokenService->validate($token, 'session') === FALSE) { + // + // }. $client = new Client(); $hakuvahtiServer = getenv('HAKUVAHTI_URL') ?: 'http://helfi-rekry.docker.so:3000'; $response = $client->request('POST', $hakuvahtiServer . '/subscription', [ From cff995f4c5be179f15e2e071c707bd4ba49d9261 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 15 May 2024 12:19:12 +0300 Subject: [PATCH 15/65] UHF-9287: Styled the search monitor accordion a bit --- .../themes/custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- public/themes/custom/hdbt_subtheme/package-lock.json | 6 +++--- .../06_components/paragraphs/_job-listing-search.scss | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index c2b81b4a..65ae7285 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} diff --git a/public/themes/custom/hdbt_subtheme/package-lock.json b/public/themes/custom/hdbt_subtheme/package-lock.json index 86ad78ed..27238d36 100644 --- a/public/themes/custom/hdbt_subtheme/package-lock.json +++ b/public/themes/custom/hdbt_subtheme/package-lock.json @@ -3343,9 +3343,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001596", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001596.tgz", - "integrity": "sha512-zpkZ+kEr6We7w63ORkoJ2pOfBwBkY/bJrG/UZ90qNb45Isblu8wzDgevEOrRL1r9dWayHjYiiyCMEXPn4DweGQ==", + "version": "1.0.30001618", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz", + "integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==", "funding": [ { "type": "opencollective", diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index d73a9cee..9871a5b4 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -159,6 +159,14 @@ button.job-search-form__remove-selection-button:not(:disabled) { --focus-outline-color: var(--hdbt-color-black); } +.job-search-form__search-monitor { + margin-bottom: $spacing-double; + + div[role=heading] { + flex: 0 1 auto; + } +} + .job-search__results-stats { margin-bottom: $spacing-double; margin-left: $spacing; From f29a7d285380a81074821429f5da04dc792b61eb Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 15 May 2024 14:15:02 +0300 Subject: [PATCH 16/65] UHF-9287: Add border above the search monitor --- public/themes/custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- .../src/scss/06_components/paragraphs/_job-listing-search.scss | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 65ae7285..59f03540 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{border-top:1px solid var(--color-black-20);margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index 9871a5b4..fe9e50c2 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -160,6 +160,7 @@ button.job-search-form__remove-selection-button:not(:disabled) { } .job-search-form__search-monitor { + border-top: 1px solid var(--color-black-20); margin-bottom: $spacing-double; div[role=heading] { From c4bbdfe73f147dd5a1798cac87918b345b0075b1 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 15 May 2024 17:03:21 +0300 Subject: [PATCH 17/65] UHF-9287: Minor layout adjustments to search monitor --- public/themes/custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- .../src/scss/06_components/paragraphs/_job-listing-search.scss | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 59f03540..65ae7285 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{border-top:1px solid var(--color-black-20);margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index fe9e50c2..9871a5b4 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -160,7 +160,6 @@ button.job-search-form__remove-selection-button:not(:disabled) { } .job-search-form__search-monitor { - border-top: 1px solid var(--color-black-20); margin-bottom: $spacing-double; div[role=heading] { From bc97819e2b4be1e465e916127fac5c11efcfb0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 17:49:01 +0300 Subject: [PATCH 18/65] UHF-9287: Fix local hakuvahti url --- .env | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env b/.env index ac8ed93a..8d49631d 100644 --- a/.env +++ b/.env @@ -30,4 +30,5 @@ HELBIT_CLIENT_ID= # URL for Elasticsearch (for job search) ELASTIC_PROXY_URL=https://elastic-helfi-rekry.docker.so -HAKUVAHTI_URL="http://${DRUPAL_HOSTNAME}:3000" +# Hakuvahti URL +HAKUVAHTI_URL=http://helfi-rekry.docker.so:3000 From 44214f431cc74f26cd952930024aaae895ebe592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 15 May 2024 17:57:08 +0300 Subject: [PATCH 19/65] UHF-9287: Update env var url, remove useless local one --- .../src/Controller/HelfiHakuvahtiConfirmController.php | 2 +- .../Controller/HelfiHakuvahtiSubscribeController.php | 10 +++++++++- .../Controller/HelfiHakuvahtiUnsubscribeController.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 7388c985..e08bb36a 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -198,7 +198,7 @@ protected function sendConfirmationRequest(string $subscriptionHash, string $sub ], ]); - $hakuvahtiServer = getenv('HAKUVAHTI_URL') ?: 'http://helfi-rekry.docker.so:3000'; + $hakuvahtiServer = getenv('HAKUVAHTI_URL'); $targetUrl = $hakuvahtiServer . '/subscription/confirm/' . $subscriptionId . '/' . $subscriptionHash; try { diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 1f6dfdba..4847e853 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -55,6 +55,12 @@ public function __construct(ContainerInterface $container, RequestStack $request $this->languageManager = $languageManager; } + private function getSearchDescriptionTaxonomies(string $elastic_query): string { + error_log($elastic_query); + + return ""; + } + /** * A method to handle the POST request for subscription. * @@ -66,6 +72,8 @@ public function post(): JsonResponse { $body = $request->getContent(FALSE); $bodyObj = json_decode($body); $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); + $bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj->elastic_query); + $token = $request->headers->get('token'); // FIXME: somehow, we would need to validate token from @@ -76,7 +84,7 @@ public function post(): JsonResponse { // // }. $client = new Client(); - $hakuvahtiServer = getenv('HAKUVAHTI_URL') ?: 'http://helfi-rekry.docker.so:3000'; + $hakuvahtiServer = getenv('HAKUVAHTI_URL'); $response = $client->request('POST', $hakuvahtiServer . '/subscription', [ RequestOptions::JSON => $bodyObj, RequestOptions::HEADERS => [ diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index ab04f0ca..aeab1d78 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -211,7 +211,7 @@ protected function sendUnsubscribeRequest(string $hash, string $subscription): b ], ]; - $hakuvahtiServer = getenv('HAKUVAHTI_URL') ? getenv('HAKUVAHTI_URL') : 'http://helfi-rekry.docker.so:3000'; + $hakuvahtiServer = getenv('HAKUVAHTI_URL'); try { $target_url = $hakuvahtiServer . '/subscription/delete/' . $subscription . '/' . $hash; From 54b08f0f4c4cc7bf8bc2a74056987848d79e530a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 08:09:35 +0300 Subject: [PATCH 20/65] UHF-9287: Hakuvahti url to preflight checks --- public/sites/default/all.settings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/public/sites/default/all.settings.php b/public/sites/default/all.settings.php index 72eb307b..62194a23 100644 --- a/public/sites/default/all.settings.php +++ b/public/sites/default/all.settings.php @@ -64,6 +64,7 @@ 'ELASTIC_PASSWORD', 'SENTRY_DSN_REACT', 'HELBIT_CLIENT_ID', + 'HAKUVAHTI_URL', ]; foreach ($additionalEnvVars as $var) { $preflight_checks['environmentVariables'][] = $var; From 20b1b9c30e2a6ce815e0dc6cfd1f7388890dee43 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 10:43:25 +0300 Subject: [PATCH 21/65] UHF-10004: Adjusting translations for the Drupal module --- .../helfi_hakuvahti/helfi_hakuvahti.info.yml | 8 ++-- .../HelfiHakuvahtiConfirmController.php | 24 ++++-------- .../HelfiHakuvahtiUnsubscribeController.php | 32 +++------------- .../{helfi_hakuvahti.fi.po => fi.po} | 37 ++++++++++--------- .../{helfi_hakuvahti.sv.po => sv.po} | 5 --- 5 files changed, 37 insertions(+), 69 deletions(-) rename public/modules/custom/helfi_hakuvahti/translations/{helfi_hakuvahti.fi.po => fi.po} (59%) rename public/modules/custom/helfi_hakuvahti/translations/{helfi_hakuvahti.sv.po => sv.po} (85%) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml index 79a0a989..b4659746 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.info.yml @@ -1,7 +1,7 @@ -name: 'HELfi Hakuvahti' +name: helfi_hakuvahti type: module -description: 'Drupal-integraatio hakuvahtiin.' -package: 'Custom' +description: 'Drupal-integration for hakuvahti.' +package: Custom core_version_requirement: ^10 'interface translation project': helfi_hakuvahti -'interface translation server pattern': modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.%language.po +'interface translation server pattern': modules/custom/helfi_hakuvahti/translations/%language.po diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index e08bb36a..c7bd17ea 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -108,31 +108,26 @@ public function __invoke(): array { if ($this->isFormSubmitted()) { if ($this->sendConfirmationRequest($hash, $subscription)) { $build['confirmation'] = [ + '#title' => $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']), + ]; + + $build['confirmation']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Saved search confirmed.'), - '#attributes' => [ - 'class' => ['page-title'], - ], + '#value' => $this->t('You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages.', [], ['context' => 'Hakuvahti']), ]; } else { $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Confirming saved search failed. Please try again.'), - '#attributes' => [ - 'class' => ['page-title'], - ], + '#value' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; } } else { $build['form'] = [ '#type' => 'form', - '#attributes' => [ - 'class' => ['page-title'], - ], '#id' => $this->getFormId(), '#form_id' => $this->getFormId(), '#action' => $this->getFormActionUrl(), @@ -142,15 +137,12 @@ public function __invoke(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.'), + '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below:', [], ['context' => 'Hakuvahti']), ]; $build['form']['button'] = [ '#type' => 'submit', - '#value' => $this->t('Confirm saved search'), - '#attributes' => [ - 'class' => ['my-button'], - ], + '#value' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), ]; } diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index aeab1d78..c3713424 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -101,29 +101,18 @@ public function __invoke(): array { if ($this->isFormSubmitted()) { if ($this->sendUnsubscribeRequest($hash, $subscription)) { $build['confirmation'] = [ - '#title' => $this->t('Saved search deleted'), + '#title' => $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']), ]; $build['confirmation']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('The saved search has been deleted'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - $build['confirmation']['paragraph2'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('You can save more searches at any time.'), - '#attributes' => [ - 'class' => ['page-title'], - ], + '#value' => $this->t('You can save more searches at any time.', [], ['context' => 'Hakuvahti']), ]; $build['confirmation']['link'] = [ '#type' => 'link', '#tag' => 'a', - '#title' => $this->t('Return to open jobs front page'), + '#title' => $this->t('Return to open jobs front page', [], ['context' => 'Hakuvahti']), '#url' => '/', ]; } @@ -131,19 +120,13 @@ public function __invoke(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Deleting saved search failed. Please try again.'), - '#attributes' => [ - 'class' => ['page-title'], - ], + '#value' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; } } else { $build['form'] = [ '#type' => 'form', - '#attributes' => [ - 'class' => ['page-title'], - ], '#id' => $this->getFormId(), '#form_id' => $this->getFormId(), '#action' => $this->getFormActionUrl(), @@ -153,15 +136,12 @@ public function __invoke(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.'), + '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), ]; $build['form']['button'] = [ '#type' => 'submit', - '#value' => $this->t('Delete saved search'), - '#attributes' => [ - 'class' => ['my-button'], - ], + '#value' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), ]; } diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po similarity index 59% rename from public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po rename to public/modules/custom/helfi_hakuvahti/translations/fi.po index 35fad324..f753bf7a 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -1,49 +1,50 @@ -# Finnish translations of City of Helsinki Hakuvahti -# -# Use this translation file for missing translations that are not found in -# localize.drupal.org. -# msgid "" msgstr "" -msgid "Saved search deleted" -msgstr "Hakuvahti on poistettu" - +msgctxt "Hakuvahti" msgid "The saved search has been deleted" msgstr "Hakuvahti on poistettu" +msgctxt "Hakuvahti" msgid "You can save more searches at any time." msgstr "Voit koska tahansa tilata uusia hakuvahteja." +msgctxt "Hakuvahti" msgid "Return to open jobs front page" msgstr "Palaa avoimien työpaikkojen etusivulle." +msgctxt "Hakuvahti" msgid "Deleting saved search failed. Please try again." msgstr "Hakuvahdin poisto epäonnistui. Yritä uudelleen." +msgctxt "Hakuvahti" msgid "Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them." msgstr "Vahvista, että haluat poistaa tämän hakuvahdin. Jos olet tehnyt muita hakuvahteja kaupungin verkkosivustolla, tämä ei poista niitä." +msgctxt "Hakuvahti" msgid "Delete saved search" msgstr "Poista hakuvahti" -msgid "Saved search confirmed." -msgstr "Hakuvahti vahvistettu." +msgctxt "Hakuvahti" +msgid "Search saved successfully" +msgstr "Hakuvahdin tilaus onnistui" + +msgctxt "Hakuvahti" +msgid "You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages." +msgstr "Saat sähköpostia hakuvahdin uusista osumista. Voit halutessasi poistaa hakuvahdin sähköpostien peruutuslinkeistä." +msgctxt "Hakuvahti" msgid "Confirming saved search failed. Please try again." msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." -msgid "Please confirm the saved search to receive notifications. Click on the button below." -msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta." +msgctxt "Hakuvahti" +msgid "Please confirm the saved search to receive notifications. Click on the button below:" +msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa linkkiä:" +msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Vahvista hakuvahti" -msgid "Subscribe" -msgstr "" - +msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Vahvista hakuvahti" - -msgid "Are you sure you wish to delete the saved search?" -msgstr "Haluatko varmasti poistaa hakuvahdin?" diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po similarity index 85% rename from public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po rename to public/modules/custom/helfi_hakuvahti/translations/sv.po index 4830af58..37f690d5 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -1,8 +1,3 @@ -# Swedish translations of City of Helsinki Hakuvahti -# -# Use this translation file for missing translations that are not found in -# localize.drupal.org. -# msgid "" msgstr "" From a42edeab6a38a533533cfb9adb970d02a689da11 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 11:29:53 +0300 Subject: [PATCH 22/65] UHF-9287: Add hakuvahti url to compose.yml --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index 344033c2..63a7bf5a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -33,6 +33,7 @@ services: DRUPAL_VARNISH_PORT: 6081 REDIS_HOST: redis PROJECT_NAME: "${PROJECT_NAME}" + HAKUVAHTI_URL: "${HAKUVAHTI_URL}" extra_hosts: - "host.docker.internal:host-gateway" - "${DRUPAL_HOSTNAME}:host-gateway" From 4a0868d80ce7891a0473937a30ae93cbcc9743fd Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 13:06:47 +0300 Subject: [PATCH 23/65] UHF-10004: Change the language variable check to the url from session --- .../src/Controller/HelfiHakuvahtiSubscribeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 4847e853..964ec85f 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -71,7 +71,7 @@ public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); $body = $request->getContent(FALSE); $bodyObj = json_decode($body); - $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); + $bodyObj->lang = substr($bodyObj->query, 1, 2); $bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj->elastic_query); $token = $request->headers->get('token'); From b9d45285fde0b528cf1eb2b56d8e35a49dad9508 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 13:48:41 +0300 Subject: [PATCH 24/65] UHF-10004: Add Swedish translations --- .../custom/helfi_hakuvahti/translations/fi.po | 6 +-- .../custom/helfi_hakuvahti/translations/sv.po | 46 ++++++++++--------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index f753bf7a..adc7240b 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -39,11 +39,7 @@ msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." msgctxt "Hakuvahti" msgid "Please confirm the saved search to receive notifications. Click on the button below:" -msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa linkkiä:" - -msgctxt "Hakuvahti" -msgid "Confirm saved search" -msgstr "Vahvista hakuvahti" +msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevasta painikkeesta:" msgctxt "Hakuvahti" msgid "Confirm saved search" diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index 37f690d5..c0017114 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -1,44 +1,46 @@ msgid "" msgstr "" -msgid "Saved search deleted" -msgstr "" - +msgctxt "Hakuvahti" msgid "The saved search has been deleted" -msgstr "" +msgstr "Sökvakten har raderats" +msgctxt "Hakuvahti" msgid "You can save more searches at any time." -msgstr "" +msgstr "Du kan när som helst beställa nya sökvakter." +msgctxt "Hakuvahti" msgid "Return to open jobs front page" -msgstr "" +msgstr "Gå tillbaka till startsidan för lediga jobb." +msgctxt "Hakuvahti" msgid "Deleting saved search failed. Please try again." msgstr "" +msgctxt "Hakuvahti" msgid "Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them." -msgstr "" +msgstr "Bekräfta att du vill ta bort den här sökvakten. Om du har skapat andra sökvakter på stadens webbplats tar denna åtgärd inte bort dem." +msgctxt "Hakuvahti" msgid "Delete saved search" -msgstr "" +msgstr "Radera sökvakten" -msgid "Saved search confirmed." -msgstr "" +msgctxt "Hakuvahti" +msgid "Search saved successfully" +msgstr "Beställningen av sökvakten lyckades" -msgid "Confirming saved search failed. Please try again." -msgstr "" - -msgid "Please confirm the saved search to receive notifications. Click on the button below." -msgstr "" +msgctxt "Hakuvahti" +msgid "You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages." +msgstr "Du får e-post om sökvaktens nya träffar. Du kan ta bort sökvakten via avbeställningslänkarna i e-postmeddelandena." -msgid "Confirm saved search" +msgctxt "Hakuvahti" +msgid "Confirming saved search failed. Please try again." msgstr "" -msgid "Subscribe" -msgstr "" +msgctxt "Hakuvahti" +msgid "Please confirm the saved search to receive notifications. Click on the button below:" +msgstr "Bekräfta beställningen av sökvakten genom att klicka på knappen nedan:" +msgctxt "Hakuvahti" msgid "Confirm saved search" -msgstr "Bekräfta sökvakten" - -msgid "Are you sure you wish to delete the saved search?" -msgstr "" +msgstr "Bekräfta beställningen av en sökvakt" From 1ba097ae0782d91387460730435460ae2ac52fb2 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 13:50:38 +0300 Subject: [PATCH 25/65] UHF-10004: Adjust translations a bit --- public/modules/custom/helfi_hakuvahti/translations/fi.po | 2 +- public/modules/custom/helfi_hakuvahti/translations/sv.po | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index adc7240b..c2e54eac 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -39,7 +39,7 @@ msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." msgctxt "Hakuvahti" msgid "Please confirm the saved search to receive notifications. Click on the button below:" -msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevasta painikkeesta:" +msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta:" msgctxt "Hakuvahti" msgid "Confirm saved search" diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index c0017114..f8579a15 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -43,4 +43,4 @@ msgstr "Bekräfta beställningen av sökvakten genom att klicka på knappen neda msgctxt "Hakuvahti" msgid "Confirm saved search" -msgstr "Bekräfta beställningen av en sökvakt" +msgstr "Bekräfta sökvakten" From afe53ff1ea5c1a3816effe3abfdb913602ec54ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 14:02:02 +0300 Subject: [PATCH 26/65] UHF-9287: This fixes missing HAKUVAHTI_URL env variable --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index 344033c2..63a7bf5a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -33,6 +33,7 @@ services: DRUPAL_VARNISH_PORT: 6081 REDIS_HOST: redis PROJECT_NAME: "${PROJECT_NAME}" + HAKUVAHTI_URL: "${HAKUVAHTI_URL}" extra_hosts: - "host.docker.internal:host-gateway" - "${DRUPAL_HOSTNAME}:host-gateway" From 1da8d85007caecb062f0f88843ddedf180814255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 14:03:06 +0300 Subject: [PATCH 27/65] UHF-9287: Fixes Ristos commits about constructors --- .../HelfiHakuvahtiConfirmController.php | 56 +++---------------- .../HelfiHakuvahtiSubscribeController.php | 41 ++++---------- .../HelfiHakuvahtiUnsubscribeController.php | 52 +++-------------- 3 files changed, 27 insertions(+), 122 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index e08bb36a..41b6ba3b 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -18,41 +18,6 @@ */ final class HelfiHakuvahtiConfirmController extends ControllerBase { - /** - * The http client. - * - * @var \GuzzleHttp\ClientInterface - */ - protected $httpClient; - - /** - * The request stack. - * - * @var \Symfony\Component\HttpFoundation\RequestStack - */ - protected $requestStack; - - /** - * The token service. - * - * @var \Drupal\Core\Utility\Token - */ - protected $tokenService; - - /** - * The current user. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $user; - - /** - * The CSRF token service. - * - * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface - */ - protected $csrfTokenService; - /** * Constructor for HelfiHakuvahtiConfirmController. * @@ -68,18 +33,12 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { * The user account. */ public function __construct( - ClientInterface $http_client, - ContainerInterface $container, - RequestStack $request_stack, - Token $token_service, - AccountInterface $user, - ) { - $this->httpClient = $http_client; - $this->csrfTokenService = $container->get('csrf_token'); - $this->requestStack = $request_stack; - $this->tokenService = $token_service; - $this->user = $user; - } + protected ClientInterface $httpClient, + protected ContainerInterface $container, + protected RequestStack $requestStack, + protected Token $tokenService, + protected AccountInterface $user, + ) { } /** * Returns the form ID for the confirmation form. @@ -190,7 +149,8 @@ protected function isFormSubmitted(): bool { * Returns TRUE if the confirmation request is successful, FALSE otherwise. */ protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { - $expectedToken = $this->csrfTokenService->get('session'); + $csrfTokenService = $this->container->get('csrf_token'); + $expectedToken = $csrfTokenService->get('session'); $httpClient = new Client([ 'headers' => [ 'Content-Type' => 'application/json', diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 4847e853..c42fa6fe 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -18,27 +18,6 @@ */ final class HelfiHakuvahtiSubscribeController extends ControllerBase { - /** - * The request stack. - * - * @var \Symfony\Component\HttpFoundation\RequestStack - */ - protected $requestStack; - - /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** - * The CSRF token service. - * - * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface - */ - protected $csrfTokenService; - /** * Constructor for the HelfiHakuvahtiSubscribeController class. * @@ -49,16 +28,15 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager * The language manager. */ - public function __construct(ContainerInterface $container, RequestStack $requestStack, LanguageManagerInterface $languageManager) { - $this->csrfTokenService = $container->get('csrf_token'); - $this->requestStack = $requestStack; - $this->languageManager = $languageManager; - } + public function __construct( + protected ContainerInterface $container, + protected RequestStack $requestStack, + protected LanguageManagerInterface $languageManager + ) { } - private function getSearchDescriptionTaxonomies(string $elastic_query): string { - error_log($elastic_query); + private function getSearchDescriptionTaxonomies($obj): string { - return ""; + return "-"; } /** @@ -72,14 +50,15 @@ public function post(): JsonResponse { $body = $request->getContent(FALSE); $bodyObj = json_decode($body); $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); - $bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj->elastic_query); + $bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj); $token = $request->headers->get('token'); // FIXME: somehow, we would need to validate token from // /session/token from react // side, but there's just no way to match it at backend?! - // $expectedToken = $this->csrfTokenService->get('session'); + // $csrfTokenService = $this->container->get('csrf_token'); + // $expectedToken = $csrfTokenService->get('session'); // if ($this->csrfTokenService->validate($token, 'session') === FALSE) { // // }. diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index aeab1d78..021edb7c 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -18,41 +18,6 @@ */ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { - /** - * The http client. - * - * @var \GuzzleHttp\ClientInterface - */ - protected $httpClient; - - /** - * The request stack. - * - * @var \Symfony\Component\HttpFoundation\RequestStack - */ - protected $requestStack; - - /** - * The token service. - * - * @var \Drupal\Core\Utility\Token - */ - protected $tokenService; - - /** - * The current user. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $user; - - /** - * The CSRF token service. - * - * @var \Drupal\Core\CsrfToken\CsrfTokenManagerInterface - */ - protected $csrfTokenService; - /** * Constructor for the class. * @@ -67,13 +32,13 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { * @param \App\Interfaces\AccountInterface $user * The current user. */ - public function __construct(ClientInterface $http_client, ContainerInterface $container, RequestStack $request_stack, Token $token_service, AccountInterface $user) { - $this->httpClient = $http_client; - $this->csrfTokenService = $container->get('csrf_token'); - $this->requestStack = $request_stack; - $this->tokenService = $token_service; - $this->user = $user; - } + public function __construct( + protected ClientInterface $httpClient, + protected ContainerInterface $container, + protected RequestStack $requestStack, + protected Token $tokenService, + protected AccountInterface $user + ) { } /** * Returns the form ID for unsubscribing from a subscription. @@ -201,7 +166,8 @@ protected function isFormSubmitted(): bool { * Returns TRUE if the request is successful, FALSE otherwise. */ protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { - $expectedToken = $this->csrfTokenService->get('session'); + $csrfTokenService = $this->container->get('csrf_token'); + $expectedToken = $csrfTokenService->get('session'); $httpClient = new Client(); $options = [ From 72fd7855fb5194915925d905f048117150fc7d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 14:15:16 +0300 Subject: [PATCH 28/65] UHF-9287: We dont need language manager here anymore --- .../src/Controller/HelfiHakuvahtiSubscribeController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index c42fa6fe..b3db63fa 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -5,7 +5,6 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Language\LanguageManagerInterface; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -25,13 +24,10 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { * The container. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. - * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager - * The language manager. */ public function __construct( protected ContainerInterface $container, - protected RequestStack $requestStack, - protected LanguageManagerInterface $languageManager + protected RequestStack $requestStack ) { } private function getSearchDescriptionTaxonomies($obj): string { @@ -49,7 +45,7 @@ public function post(): JsonResponse { $request = $this->requestStack->getCurrentRequest(); $body = $request->getContent(FALSE); $bodyObj = json_decode($body); - $bodyObj->lang = $this->languageManager->getCurrentLanguage()->getId(); + $bodyObj->lang = substr($bodyObj->query, 1, 2); $bodyObj->search_description = $this->getSearchDescriptionTaxonomies($bodyObj); $token = $request->headers->get('token'); From 714d456a751202e1347a46c3dac6b35d291bc90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 15:54:20 +0300 Subject: [PATCH 29/65] UHF-9287: Implement search description --- .../HelfiHakuvahtiSubscribeController.php | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index b3db63fa..3895ae52 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; +use Drupal\taxonomy\Entity\Term; /** * Creates new subscription. @@ -30,9 +31,41 @@ public function __construct( protected RequestStack $requestStack ) { } - private function getSearchDescriptionTaxonomies($obj): string { + /** + * Retrieves search description taxonomies from the provided object. + * + * @param mixed $obj The object containing elastic query data. + * @return string The concatenated search description taxonomies. + */ + private function getSearchDescriptionTaxonomies($obj): string + { + $terms = []; + $taxonomyIds = []; + + $elasticQuery = base64_decode($obj->elastic_query); + $elasticQueryObject = json_decode($elasticQuery); + + // Free text search + $query = $elasticQueryObject->query->bool->must[1]->bool->should[1]->combined_fields->query ?? null; + // Task area + $taxonomyIds = array_merge($taxonomyIds, $elasticQueryObject->query->bool->must[2]->terms->task_area_external_id ?? []); + // Type of employment + $taxonomyIds = array_merge($taxonomyIds, $elasticQueryObject->query->bool->must[3]->bool->should[1]->terms->employment_type_id ?? []); + + if (!empty($taxonomyIds)) { + $terms = array_map(function ($term) { + return $term->label(); + }, Term::loadMultiple($taxonomyIds)); + } + + // We need to send just *something* if nothing is selected in filters. + if (empty($terms) && empty($query)) { + $terms[] = '*'; + } + + array_unshift($terms, $query); - return "-"; + return implode(', ', array_filter($terms)); } /** From 1876b6f72eb53ac6156b191f06b9937f1111e830 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 16 May 2024 16:11:00 +0300 Subject: [PATCH 30/65] UHF-10004: Add hiding styles for the search monitor content --- public/themes/custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- .../scss/06_components/paragraphs/_job-listing-search.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 65ae7285..802565ae 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}}.job-search-form__search-monitor__content[aria-hidden=true]{display:none} diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index 9871a5b4..bafe7e30 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -178,3 +178,7 @@ button.job-search-form__remove-selection-button:not(:disabled) { justify-content: space-between; } } + +.job-search-form__search-monitor__content[aria-hidden='true'] { + display: none; +} From f3565917b36699a896b31f7d08ceaac989c378db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 16:32:50 +0300 Subject: [PATCH 31/65] UHF-9287: Take language in account when getting term label --- .../src/Controller/HelfiHakuvahtiSubscribeController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 3895ae52..104816cf 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -53,7 +53,12 @@ private function getSearchDescriptionTaxonomies($obj): string $taxonomyIds = array_merge($taxonomyIds, $elasticQueryObject->query->bool->must[3]->bool->should[1]->terms->employment_type_id ?? []); if (!empty($taxonomyIds)) { - $terms = array_map(function ($term) { + $language = $obj->lang; + $terms = array_map(function ($term) use ($language) { + if ($term->hasTranslation($language)) { + $translated_term = $term->getTranslation($language); + return $translated_term->label(); + } return $term->label(); }, Term::loadMultiple($taxonomyIds)); } From 726fdf68cf1422c8ede9e096d6f61b5ccbe427c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 16:49:36 +0300 Subject: [PATCH 32/65] UHF-9287: Rewrite the form logic without nesting. Fix linter things. --- .../HelfiHakuvahtiUnsubscribeController.php | 207 +++++++++++------- 1 file changed, 132 insertions(+), 75 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 021edb7c..91f88e6c 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -6,6 +6,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Url; use Drupal\Core\Utility\Token; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; @@ -21,24 +22,24 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { /** * Constructor for the class. * - * @param \GuzzleHttp\ClientInterface $http_client + * @param \GuzzleHttp\ClientInterface $httpClient * The HTTP client. * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The container. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. - * @param \App\Services\Token $token_service + * @param \App\Services\Token $tokenService * The token service. * @param \App\Interfaces\AccountInterface $user * The current user. */ public function __construct( - protected ClientInterface $httpClient, - protected ContainerInterface $container, - protected RequestStack $requestStack, - protected Token $tokenService, + protected ClientInterface $httpClient, + protected ContainerInterface $container, + protected RequestStack $requestStack, + protected Token $tokenService, protected AccountInterface $user - ) { } + ) {} /** * Returns the form ID for unsubscribing from a subscription. @@ -51,85 +52,141 @@ public function getFormId() { } /** - * Builds the response for unsubscribing from a subscription. + * Executes the confirmation process for a saved search. * * @return array - * The form + * The build array containing the confirmation form or the + * saved search form. */ public function __invoke(): array { - $build = []; - $request = $this->requestStack->getCurrentRequest(); $hash = $request->query->get('hash'); $subscription = $request->query->get('subscription'); if ($this->isFormSubmitted()) { - if ($this->sendUnsubscribeRequest($hash, $subscription)) { - $build['confirmation'] = [ - '#title' => $this->t('Saved search deleted'), - ]; - - $build['confirmation']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('The saved search has been deleted'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - $build['confirmation']['paragraph2'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('You can save more searches at any time.'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - $build['confirmation']['link'] = [ - '#type' => 'link', - '#tag' => 'a', - '#title' => $this->t('Return to open jobs front page'), - '#url' => '/', - ]; - } - else { - $build['form']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Deleting saved search failed. Please try again.'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - } + return $this->handleFormSubmission($hash, $subscription); } - else { - $build['form'] = [ - '#type' => 'form', - '#attributes' => [ - 'class' => ['page-title'], - ], - '#id' => $this->getFormId(), - '#form_id' => $this->getFormId(), - '#action' => $this->getFormActionUrl(), - '#method' => 'POST', - ]; - - $build['form']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.'), - ]; - - $build['form']['button'] = [ - '#type' => 'submit', - '#value' => $this->t('Delete saved search'), - '#attributes' => [ - 'class' => ['my-button'], - ], - ]; + + return $this->buildForm(); + } + + /** + * Handles the form submission for unsubscribing from a subscription. + * + * @param string $hash + * Description of the hash parameter. + * @param string $subscription + * Description of the subscription parameter. + * + * @return array + * The build array containing the confirmation form + * or the failed submission form. + */ + private function handleFormSubmission(string $hash, string $subscription): array { + if ($this->sendUnsubscribeRequest($hash, $subscription)) { + return $this->buildConfirmation(); } + return $this->buildFailedSubmission(); + } + + /** + * Builds the form for deleting a saved search. + * + * @return array + * The build array containing the form + * structure for deleting a saved search. + */ + private function buildForm(): array { + $build = []; + + $build['form'] = [ + '#type' => 'form', + '#attributes' => [ + 'class' => ['page-title'], + ], + '#id' => $this->getFormId(), + '#form_id' => $this->getFormId(), + '#action' => $this->getFormActionUrl(), + '#method' => 'POST', + ]; + + $build['form']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.'), + ]; + + $build['form']['button'] = [ + '#type' => 'submit', + '#value' => $this->t('Delete saved search'), + '#attributes' => [ + 'class' => ['my-button'], + ], + ]; + + return $build; + } + + /** + * Builds the confirmation array for the saved search deletion. + * + * @return array + * The build array containing the confirmation details. + */ + private function buildConfirmation(): array { + $build = []; + + $build['confirmation'] = [ + '#title' => $this->t('Saved search deleted'), + ]; + + $build['confirmation']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('The saved search has been deleted'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + + $build['confirmation']['paragraph2'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('You can save more searches at any time.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + + $build['confirmation']['link'] = [ + '#type' => 'link', + '#tag' => 'a', + '#title' => $this->t('Return to open jobs front page'), + '#url' => Url::fromUri('internal:/'), + ]; + + return $build; + } + + /** + * Builds the form for a failed submission when deleting a saved search. + * + * @return array + * The build array containing the form structure for a failed submission. + */ + private function buildFailedSubmission(): array { + $build = []; + + $build['form']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Deleting saved search failed. Please try again.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + return $build; } From c2beff0754f5cd01f787c459ee74bf8123814e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 17:00:47 +0300 Subject: [PATCH 33/65] UHF-9287: Also rewrite confirm form without nesting --- .../HelfiHakuvahtiConfirmController.php | 154 ++++++++++++------ 1 file changed, 103 insertions(+), 51 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 41b6ba3b..da64dfed 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -21,13 +21,13 @@ final class HelfiHakuvahtiConfirmController extends ControllerBase { /** * Constructor for HelfiHakuvahtiConfirmController. * - * @param \GuzzleHttp\ClientInterface $http_client + * @param \GuzzleHttp\ClientInterface $httpClient * The HTTP client. * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The container. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. - * @param \Drupal\Core\Utility\Token $token_service + * @param \Drupal\Core\Utility\Token $tokenService * The token service. * @param \Drupal\Core\Session\AccountInterface $user * The user account. @@ -38,7 +38,7 @@ public function __construct( protected RequestStack $requestStack, protected Token $tokenService, protected AccountInterface $user, - ) { } + ) {} /** * Returns the form ID for the confirmation form. @@ -58,61 +58,113 @@ public function getFormId() { * saved search form. */ public function __invoke(): array { - $build = []; - $request = $this->requestStack->getCurrentRequest(); $hash = $request->query->get('hash'); $subscription = $request->query->get('subscription'); if ($this->isFormSubmitted()) { - if ($this->sendConfirmationRequest($hash, $subscription)) { - $build['confirmation'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Saved search confirmed.'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - } - else { - $build['confirmation'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Confirming saved search failed. Please try again.'), - '#attributes' => [ - 'class' => ['page-title'], - ], - ]; - } + return $this->handleFormSubmission($hash, $subscription); } - else { - $build['form'] = [ - '#type' => 'form', - '#attributes' => [ - 'class' => ['page-title'], - ], - '#id' => $this->getFormId(), - '#form_id' => $this->getFormId(), - '#action' => $this->getFormActionUrl(), - '#method' => 'POST', - ]; - - $build['form']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.'), - ]; - - $build['form']['button'] = [ - '#type' => 'submit', - '#value' => $this->t('Confirm saved search'), - '#attributes' => [ - 'class' => ['my-button'], - ], - ]; + + return $this->buildForm(); + } + + /** + * Handles the form submission for confirming a subscription. + * + * @param mixed $hash + * The hash parameter. + * @param mixed $subscription + * The subscription parameter. + * + * @return array + * The build array containing the confirmation success or failure. + */ + private function handleFormSubmission($hash, $subscription): array { + if ($this->sendConfirmationRequest($hash, $subscription)) { + return $this->buildConfirmationSuccess(); } + return $this->buildConfirmationFailure(); + } + + /** + * Builds the form for confirming a saved search. + * + * @return array + * The build array containing the form structure + * for confirming a saved search. + */ + private function buildForm(): array { + $build = []; + + $build['form'] = [ + '#type' => 'form', + '#attributes' => [ + 'class' => ['page-title'], + ], + '#id' => $this->getFormId(), + '#form_id' => $this->getFormId(), + '#action' => $this->getFormActionUrl(), + '#method' => 'POST', + ]; + + $build['form']['paragraph'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.'), + ]; + + $build['form']['button'] = [ + '#type' => 'submit', + '#value' => $this->t('Confirm saved search'), + '#attributes' => [ + 'class' => ['my-button'], + ], + ]; + + return $build; + } + + /** + * Builds the confirmation array for a successful saved search confirmation. + * + * @return array + * Success form + */ + private function buildConfirmationSuccess(): array { + $build = []; + + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Saved search confirmed.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + + return $build; + } + + /** + * Builds the confirmation array for a failed saved search confirmation. + * + * @return array + * Failure form + */ + private function buildConfirmationFailure(): array { + $build = []; + + $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + '#value' => $this->t('Confirming saved search failed. Please try again.'), + '#attributes' => [ + 'class' => ['page-title'], + ], + ]; + return $build; } From 3da4c74b8e5de55c3005601c496214cf54c4b893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Thu, 16 May 2024 17:11:02 +0300 Subject: [PATCH 34/65] UHF-9287: Fix linter, mostly --- .../HelfiHakuvahtiSubscribeController.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 104816cf..4ae6440a 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -5,13 +5,13 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\taxonomy\Entity\Term; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; -use Drupal\taxonomy\Entity\Term; /** * Creates new subscription. @@ -27,29 +27,31 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { * The request stack. */ public function __construct( - protected ContainerInterface $container, + protected ContainerInterface $container, protected RequestStack $requestStack - ) { } + ) {} /** * Retrieves search description taxonomies from the provided object. * - * @param mixed $obj The object containing elastic query data. - * @return string The concatenated search description taxonomies. + * @param mixed $obj + * The object containing elastic query data. + * + * @return string + * The concatenated search description taxonomies. */ - private function getSearchDescriptionTaxonomies($obj): string - { + private function getSearchDescriptionTaxonomies($obj): string { $terms = []; $taxonomyIds = []; $elasticQuery = base64_decode($obj->elastic_query); $elasticQueryObject = json_decode($elasticQuery); - // Free text search - $query = $elasticQueryObject->query->bool->must[1]->bool->should[1]->combined_fields->query ?? null; - // Task area + // Free text search. + $query = $elasticQueryObject->query->bool->must[1]->bool->should[1]->combined_fields->query ?? NULL; + // Task area. $taxonomyIds = array_merge($taxonomyIds, $elasticQueryObject->query->bool->must[2]->terms->task_area_external_id ?? []); - // Type of employment + // Type of employment. $taxonomyIds = array_merge($taxonomyIds, $elasticQueryObject->query->bool->must[3]->bool->should[1]->terms->employment_type_id ?? []); if (!empty($taxonomyIds)) { From b153e07a5f34ff2ddb5c104578c12adb9f71f32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Fri, 17 May 2024 09:42:46 +0300 Subject: [PATCH 35/65] UHF-9287: Linter fixes, these show up in pipeline but not on local for some reason --- .../Controller/HelfiHakuvahtiSubscribeController.php | 2 +- .../Controller/HelfiHakuvahtiUnsubscribeController.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 4ae6440a..7cb3fb4f 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -28,7 +28,7 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { */ public function __construct( protected ContainerInterface $container, - protected RequestStack $requestStack + protected RequestStack $requestStack, ) {} /** diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 91f88e6c..2a6dde6a 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -34,11 +34,11 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { * The current user. */ public function __construct( - protected ClientInterface $httpClient, - protected ContainerInterface $container, - protected RequestStack $requestStack, - protected Token $tokenService, - protected AccountInterface $user + protected ClientInterface $httpClient, + protected ContainerInterface $container, + protected RequestStack $requestStack, + protected Token $tokenService, + protected AccountInterface $user ) {} /** From 86a71372a6665b263d6a4e8a17dd5b0acf7d9a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Fri, 17 May 2024 13:03:27 +0300 Subject: [PATCH 36/65] UHF-9287: Eliminate static Term:: call --- .../src/Controller/HelfiHakuvahtiSubscribeController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php index 7cb3fb4f..b0fbdb60 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiSubscribeController.php @@ -5,7 +5,7 @@ namespace Drupal\helfi_hakuvahti\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\taxonomy\Entity\Term; +use Drupal\Core\Entity\EntityTypeManagerInterface; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -25,10 +25,13 @@ final class HelfiHakuvahtiSubscribeController extends ControllerBase { * The container. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $_entityTypeManager + * The entity type manager. */ public function __construct( protected ContainerInterface $container, protected RequestStack $requestStack, + protected EntityTypeManagerInterface $_entityTypeManager, ) {} /** @@ -62,7 +65,7 @@ private function getSearchDescriptionTaxonomies($obj): string { return $translated_term->label(); } return $term->label(); - }, Term::loadMultiple($taxonomyIds)); + }, $this->_entityTypeManager->getStorage('taxonomy_term')->loadMultiple($taxonomyIds)); } // We need to send just *something* if nothing is selected in filters. From 2f9ed4219086f82c7fb240759974cd5efaaa4e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Fri, 17 May 2024 13:25:48 +0300 Subject: [PATCH 37/65] UHF-9287: Add some translation strings --- .../translations/helfi_hakuvahti.fi.po | 5 ++++- .../translations/helfi_hakuvahti.sv.po | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po index 35fad324..fa6470e7 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.fi.po @@ -40,10 +40,13 @@ msgid "Confirm saved search" msgstr "Vahvista hakuvahti" msgid "Subscribe" -msgstr "" +msgstr "Tilaa hakuvahti" msgid "Confirm saved search" msgstr "Vahvista hakuvahti" msgid "Are you sure you wish to delete the saved search?" msgstr "Haluatko varmasti poistaa hakuvahdin?" + +msgid "Receive search results by email" +msgstr "Tilaa hakuvahti sähköpostiisi" diff --git a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po index 4830af58..6fabb6b3 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/helfi_hakuvahti.sv.po @@ -13,19 +13,19 @@ msgid "The saved search has been deleted" msgstr "" msgid "You can save more searches at any time." -msgstr "" +msgstr "Du kan när som helst beställa nya sökvakter." msgid "Return to open jobs front page" -msgstr "" +msgstr "Gå tillbaka till startsidan för lediga jobb." msgid "Deleting saved search failed. Please try again." msgstr "" msgid "Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them." -msgstr "" +msgstr "Bekräfta att du vill ta bort den här sökvakten. Om du har skapat andra sökvakter på stadens webbplats tar denna åtgärd inte bort dem." msgid "Delete saved search" -msgstr "" +msgstr "Radera sökvakten" msgid "Saved search confirmed." msgstr "" @@ -47,3 +47,6 @@ msgstr "Bekräfta sökvakten" msgid "Are you sure you wish to delete the saved search?" msgstr "" + +msgid "Receive search results by email" +msgstr "Beställ sökvakten till din e-post" From 81c6956b7687994a4a3a19ec18c3f6c7408806e1 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 17 May 2024 14:50:07 +0300 Subject: [PATCH 38/65] UHF-9287: Fix PHPCS --- .../src/Controller/HelfiHakuvahtiUnsubscribeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 2a6dde6a..b7ebe959 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -38,7 +38,7 @@ public function __construct( protected ContainerInterface $container, protected RequestStack $requestStack, protected Token $tokenService, - protected AccountInterface $user + protected AccountInterface $user, ) {} /** From 6d42b087604749a4b0c10f73418846107c702c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Fri, 17 May 2024 15:33:49 +0300 Subject: [PATCH 39/65] UHF-9287: Fix PHPStan errors --- .../src/Controller/HelfiHakuvahtiUnsubscribeController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 2a6dde6a..03643f1d 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -28,9 +28,9 @@ final class HelfiHakuvahtiUnsubscribeController extends ControllerBase { * The container. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. - * @param \App\Services\Token $tokenService + * @param \Drupal\Core\Utility\Token $tokenService * The token service. - * @param \App\Interfaces\AccountInterface $user + * @param \Drupal\Core\Session\AccountInterface $user * The current user. */ public function __construct( From f4dae630cf7375266536a496732e20cf0ca2f817 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 17 May 2024 16:14:36 +0300 Subject: [PATCH 40/65] UHF-10004: Add some missing translations for routes --- .../helfi_hakuvahti/helfi_hakuvahti.routing.yml | 4 ++-- .../modules/custom/helfi_hakuvahti/translations/fi.po | 9 +++++++++ .../modules/custom/helfi_hakuvahti/translations/sv.po | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index 96c65327..88137239 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -1,7 +1,7 @@ helfi_hakuvahti.subscribe: path: '/hakuvahti/subscribe' defaults: - _title: 'Subscribe' + _title: 'Subscribe saved search' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiSubscribeController::post' requirements: _permission: 'access content' @@ -11,7 +11,7 @@ helfi_hakuvahti.confirm: _title: 'Confirm saved search' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' requirements: - _permission: 'access content' + _permission: 'access content' helfi_hakuvahti.unsubscribe: path: '/hakuvahti/unsubscribe' defaults: diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index c2e54eac..70c3752f 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -44,3 +44,12 @@ msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta:" msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Vahvista hakuvahti" + +msgid "Subscribe saved search" +msgstr "Tilaa hakuvahti" + +msgid "Confirm saved search" +msgstr "Vahvista hakuvahti" + +msgid "Are you sure you wish to delete the saved search?" +msgstr "Haluatko varmasti poistaa hakuvahdin?" diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index f8579a15..f9f9af9b 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -35,7 +35,7 @@ msgstr "Du får e-post om sökvaktens nya träffar. Du kan ta bort sökvakten vi msgctxt "Hakuvahti" msgid "Confirming saved search failed. Please try again." -msgstr "" +msgstr "Bekräftelse av sparad sökning misslyckades. Försök igen." msgctxt "Hakuvahti" msgid "Please confirm the saved search to receive notifications. Click on the button below:" @@ -44,3 +44,12 @@ msgstr "Bekräfta beställningen av sökvakten genom att klicka på knappen neda msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Bekräfta sökvakten" + +msgid "Subscribe saved search" +msgstr "Beställ sökvakten" + +msgid "Confirm saved search" +msgstr "Bekräfta sökvakten" + +msgid "Are you sure you wish to delete the saved search?" +msgstr "Är du säker på att du vill ta bort sökvakten?" From fc6c6e9ea3314da7a0b84238cd27b084869e2585 Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Mon, 20 May 2024 17:02:38 +0300 Subject: [PATCH 41/65] UHF-10080: added hakuvahti external network for drupal --- compose.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compose.yaml b/compose.yaml index e2bc345c..34fbc55c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -37,6 +37,7 @@ services: networks: - internal - stonehenge-network + - hakuvahti_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" @@ -145,6 +146,8 @@ networks: external: false stonehenge-network: external: true + hakuvahti_hav-network: + external: true volumes: db_volume: From dcc2b063ad625dad2ff531fde955d131ab894591 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 21 May 2024 11:12:43 +0300 Subject: [PATCH 42/65] UHF-10004: Change translation and remove unused text from the unsubscription form --- .../src/Controller/HelfiHakuvahtiUnsubscribeController.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 453744f5..1177cafd 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -134,14 +134,10 @@ private function buildForm(): array { private function buildConfirmation(): array { $build = []; - $build['confirmation'] = [ - '#title' => $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']), - ]; - $build['confirmation']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('The saved search has been deleted'), + '#value' => $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']), '#attributes' => [ 'class' => ['page-title'], ], From e7cd496aafca13828d6fc764f37773722a440baa Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 22 May 2024 17:24:08 +0300 Subject: [PATCH 43/65] UHF-10005: Styled and adjusted the dom on hakuvahti form and confirmation functionality --- .../helfi_hakuvahti.routing.yml | 2 +- .../HelfiHakuvahtiConfirmController.php | 70 ++++++++++++++++++- .../custom/helfi_hakuvahti/translations/fi.po | 4 +- .../custom/helfi_hakuvahti/translations/sv.po | 4 +- .../hdbt_subtheme/dist/css/styles.min.css | 2 +- .../custom/hdbt_subtheme/package-lock.json | 6 +- .../src/scss/06_components/__index.scss | 1 + .../src/scss/06_components/forms/__index.scss | 1 + .../forms/_hakuvahti-confirmation.scss | 25 +++++++ .../paragraphs/_job-listing-search.scss | 33 +++++++-- .../form--hakuvahti-confirm-form.html.twig | 27 +++++++ 11 files changed, 160 insertions(+), 15 deletions(-) create mode 100644 public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/__index.scss create mode 100644 public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/_hakuvahti-confirmation.scss create mode 100644 public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index 88137239..1fb14ac6 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -8,7 +8,7 @@ helfi_hakuvahti.subscribe: helfi_hakuvahti.confirm: path: '/hakuvahti/confirm' defaults: - _title: 'Confirm saved search' + _title_callback: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController::getTitle' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' requirements: _permission: 'access content' diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index e2fdab73..08813254 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -69,6 +69,16 @@ public function __invoke(): array { return $this->buildForm(); } + /** + * Returns the page title. + * + * @return string + * The page title + */ + public function getTitle() { + return t('Confirm saved search', [], ['context' => 'Hakuvahti']); + } + /** * Handles the form submission for confirming a subscription. * @@ -109,7 +119,15 @@ private function buildForm(): array { $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', - '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below:', [], ['context' => 'Hakuvahti']), + '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.', [], ['context' => 'Hakuvahti']), + ]; + + $build['form']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], ]; $build['form']['button'] = [ @@ -130,17 +148,41 @@ private function buildConfirmationSuccess(): array { $build = []; $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'article', + '#attributes' => [ + 'class' => ['hakuvahti-confirmation'], + ], + ]; + + $build['confirmation']['components'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['components'], + ], + ]; + + $build['confirmation']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']), ]; - $build['confirmation']['paragraph'] = [ + $build['confirmation']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages.', [], ['context' => 'Hakuvahti']), ]; + $build['confirmation']['components']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + return $build; } @@ -154,11 +196,35 @@ private function buildConfirmationFailure(): array { $build = []; $build['confirmation'] = [ + '#type' => 'html_tag', + '#tag' => 'article', + '#attributes' => [ + 'class' => ['hakuvahti-confirmation'], + ], + ]; + + $build['confirmation']['components'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['components'], + ], + ]; + + $build['confirmation']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; + $build['confirmation']['components']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + return $build; } diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index 70c3752f..4ec1a099 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -38,8 +38,8 @@ msgid "Confirming saved search failed. Please try again." msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." msgctxt "Hakuvahti" -msgid "Please confirm the saved search to receive notifications. Click on the button below:" -msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta:" +msgid "Please confirm the saved search to receive notifications. Click on the button below." +msgstr "Vahvista hakuvahdin tilaus klikkaamalla alla olevaa painiketta." msgctxt "Hakuvahti" msgid "Confirm saved search" diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index f9f9af9b..203c0d89 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -38,8 +38,8 @@ msgid "Confirming saved search failed. Please try again." msgstr "Bekräftelse av sparad sökning misslyckades. Försök igen." msgctxt "Hakuvahti" -msgid "Please confirm the saved search to receive notifications. Click on the button below:" -msgstr "Bekräfta beställningen av sökvakten genom att klicka på knappen nedan:" +msgid "Please confirm the saved search to receive notifications. Click on the button below." +msgstr "Bekräfta beställningen av sökvakten genom att klicka på knappen nedan." msgctxt "Hakuvahti" msgid "Confirm saved search" diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 802565ae..54179f1c 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}}.job-search-form__search-monitor__content[aria-hidden=true]{display:none} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search-form__search-monitor{background-color:var(--color-fog-light);padding:32px}.job-search-form__search-monitor__heading{margin-top:0}.job-search-form__search-monitor__content>p{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-search-form__search-monitor__content[aria-hidden=true]{display:none}.job-search-form__search-monitor__content__heading{margin-top:32px}.job-search-form__search-monitor__terms::after{content:"*";margin-left:8px}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}}.hakuvahti-confirmation .components{margin-top:24px}.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height)}@media(min-width: 992px){.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.375rem;font-weight:400}}.hakuvahti-confirmation p:first-child{margin-top:0}.hakuvahti-confirmation .page-divider{padding-left:0}.hakuvahti-confirmation .form-submit{margin-top:32px}@media(min-width: 768px){.hakuvahti-confirmation .form-submit{margin-top:64px}} diff --git a/public/themes/custom/hdbt_subtheme/package-lock.json b/public/themes/custom/hdbt_subtheme/package-lock.json index 27238d36..41dc7916 100644 --- a/public/themes/custom/hdbt_subtheme/package-lock.json +++ b/public/themes/custom/hdbt_subtheme/package-lock.json @@ -3343,9 +3343,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001618", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz", - "integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==", + "version": "1.0.30001621", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001621.tgz", + "integrity": "sha512-+NLXZiviFFKX0fk8Piwv3PfLPGtRqJeq2TiNoUff/qB5KJgwecJTvCXDpmlyP/eCI/GUEmp/h/y5j0yckiiZrA==", "funding": [ { "type": "opencollective", diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/__index.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/__index.scss index 336d7260..884e9cda 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/__index.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/__index.scss @@ -1,3 +1,4 @@ @import 'pages/_index'; @import 'block/_index'; @import 'paragraphs/_index'; +@import 'forms/_index'; diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/__index.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/__index.scss new file mode 100644 index 00000000..494772fc --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/__index.scss @@ -0,0 +1 @@ +@import 'hakuvahti-confirmation'; diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/_hakuvahti-confirmation.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/_hakuvahti-confirmation.scss new file mode 100644 index 00000000..3f3ae7da --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/forms/_hakuvahti-confirmation.scss @@ -0,0 +1,25 @@ +.hakuvahti-confirmation { + .components { + margin-top: $spacing-and-half; + } + + p { + @include font('lead'); + } + + p:first-child { + margin-top: 0; + } + + .page-divider { + padding-left: 0; + } + + .form-submit { + margin-top: $spacing-double; + + @include breakpoint($breakpoint-m) { + margin-top: $spacing-quadruple; + } + } +} diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index bafe7e30..0ab64f43 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -167,6 +167,35 @@ button.job-search-form__remove-selection-button:not(:disabled) { } } +.job-search-form__search-monitor { + background-color: var(--color-fog-light); + padding: $spacing-double; +} + +.job-search-form__search-monitor__heading { + margin-top: 0; +} + +.job-search-form__search-monitor__content { + > p { + @include font('body'); + } + + &[aria-hidden='true'] { + display: none; + } +} + +.job-search-form__search-monitor__content__heading { + margin-top: $spacing-double; +} + +// The terms are required but there is no indicator on the label. This is why the '*' is added here. +.job-search-form__search-monitor__terms::after { + content: '*'; + margin-left: $spacing-half; +} + .job-search__results-stats { margin-bottom: $spacing-double; margin-left: $spacing; @@ -178,7 +207,3 @@ button.job-search-form__remove-selection-button:not(:disabled) { justify-content: space-between; } } - -.job-search-form__search-monitor__content[aria-hidden='true'] { - display: none; -} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig new file mode 100644 index 00000000..b79e4d15 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Theme override for a 'form' element. + * + * Available variables + * - attributes: A list of HTML attributes for the wrapper element. + * - children: The child elements of the form. + * + * @see template_preprocess_form() + */ +#} +
+
+ {% embed "@hdbt/misc/component.twig" with + { + component_classes: 'component--hakuvahti-form' + } + %} + {% block component_content %} + + {{ children }} + + {% endblock component_content %} + {% endembed %} +
+
From c40dc4a968ea14fa864e75f33ed9176e3500cbb2 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 23 May 2024 11:29:47 +0300 Subject: [PATCH 44/65] UHF-10005: Add dynamic title for the hakuvahti confirmation process --- .../helfi_hakuvahti.routing.yml | 2 +- .../HelfiHakuvahtiConfirmController.php | 18 +++++++++++------- .../custom/helfi_hakuvahti/translations/fi.po | 4 ++++ .../custom/helfi_hakuvahti/translations/sv.po | 4 ++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index 1fb14ac6..88137239 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -8,7 +8,7 @@ helfi_hakuvahti.subscribe: helfi_hakuvahti.confirm: path: '/hakuvahti/confirm' defaults: - _title_callback: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController::getTitle' + _title: 'Confirm saved search' _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' requirements: _permission: 'access content' diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 08813254..38f4ece9 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -6,6 +6,8 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Utility\Token; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; @@ -18,6 +20,8 @@ */ final class HelfiHakuvahtiConfirmController extends ControllerBase { + use StringTranslationTrait; + /** * Constructor for HelfiHakuvahtiConfirmController. * @@ -76,7 +80,7 @@ public function __invoke(): array { * The page title */ public function getTitle() { - return t('Confirm saved search', [], ['context' => 'Hakuvahti']); + return $this->dynamicTitle; } /** @@ -116,6 +120,8 @@ private function buildForm(): array { '#method' => 'POST', ]; + $build['#title'] = $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']); + $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -147,6 +153,8 @@ private function buildForm(): array { private function buildConfirmationSuccess(): array { $build = []; + $build['#title'] = $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']); + $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'article', @@ -163,12 +171,6 @@ private function buildConfirmationSuccess(): array { ], ]; - $build['confirmation']['components']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']), - ]; - $build['confirmation']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -195,6 +197,8 @@ private function buildConfirmationSuccess(): array { private function buildConfirmationFailure(): array { $build = []; + $build['#title'] = $this->t('Confirmation failed', [], ['context' => 'Hakuvahti']); + $build['confirmation'] = [ '#type' => 'html_tag', '#tag' => 'article', diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index 4ec1a099..f09497aa 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -33,6 +33,10 @@ msgctxt "Hakuvahti" msgid "You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages." msgstr "Saat sähköpostia hakuvahdin uusista osumista. Voit halutessasi poistaa hakuvahdin sähköpostien peruutuslinkeistä." +msgctxt "Hakuvahti" +msgid "Confirmation failed" +msgstr "Vahvistus epäonnistui." + msgctxt "Hakuvahti" msgid "Confirming saved search failed. Please try again." msgstr "Hakuvahdin vahvistus epäonnistui. Yritä uudelleen." diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index 203c0d89..79c055a8 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -33,6 +33,10 @@ msgctxt "Hakuvahti" msgid "You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages." msgstr "Du får e-post om sökvaktens nya träffar. Du kan ta bort sökvakten via avbeställningslänkarna i e-postmeddelandena." +msgctxt "Hakuvahti" +msgid "Confirmation failed" +msgstr "Bekräftelse misslyckades" + msgctxt "Hakuvahti" msgid "Confirming saved search failed. Please try again." msgstr "Bekräftelse av sparad sökning misslyckades. Försök igen." From 89a64051c1ba573c09737045aed0c3a8b9930a28 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 23 May 2024 12:36:58 +0300 Subject: [PATCH 45/65] UHF-10005: Style unsubscribe form and add translations --- .../HelfiHakuvahtiUnsubscribeController.php | 76 ++++++++++++++++--- .../custom/helfi_hakuvahti/translations/fi.po | 8 ++ .../custom/helfi_hakuvahti/translations/sv.po | 8 ++ .../form--hakuvahti-confirm-form.html.twig | 28 +------ ...form--hakuvahti-unsubscribe-form.html.twig | 1 + .../templates/form/hakuvahti-form.twig | 27 +++++++ 6 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig create mode 100644 public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 1177cafd..05f4eeb9 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -100,6 +100,8 @@ private function handleFormSubmission(string $hash, string $subscription): array private function buildForm(): array { $build = []; + $build['#title'] = $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']); + $build['form'] = [ '#type' => 'form', '#id' => $this->getFormId(), @@ -108,18 +110,24 @@ private function buildForm(): array { '#method' => 'POST', ]; + $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), ]; + $build['form']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + $build['form']['button'] = [ '#type' => 'submit', '#value' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), - '#attributes' => [ - 'class' => ['my-button'], - ], ]; return $build; @@ -134,28 +142,50 @@ private function buildForm(): array { private function buildConfirmation(): array { $build = []; - $build['confirmation']['paragraph'] = [ + $build['#title'] = $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']); + + $build['confirmation'] = [ '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']), + '#tag' => 'article', '#attributes' => [ - 'class' => ['page-title'], + 'class' => ['hakuvahti-confirmation'], ], ]; - $build['confirmation']['paragraph2'] = [ + $build['confirmation']['components'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['components'], + ], + ]; + + $build['confirmation']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('You can save more searches at any time.', [], ['context' => 'Hakuvahti']), ]; - $build['confirmation']['link'] = [ + $build['confirmation']['components']['paragraph2'] = [ + '#type' => 'html_tag', + '#tag' => 'p', + ]; + + $build['confirmation']['components']['paragraph2']['link'] = [ '#type' => 'link', '#tag' => 'a', '#title' => $this->t('Return to open jobs front page', [], ['context' => 'Hakuvahti']), '#url' => Url::fromUri('internal:/'), ]; + $build['confirmation']['components']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + return $build; } @@ -168,12 +198,38 @@ private function buildConfirmation(): array { private function buildFailedSubmission(): array { $build = []; - $build['form']['paragraph'] = [ + $build['#title'] = $this->t('Deleting failed', [], ['context' => 'Hakuvahti']); + + $build['form'] = [ + '#type' => 'html_tag', + '#tag' => 'article', + '#attributes' => [ + 'class' => ['hakuvahti-confirmation'], + ], + ]; + + $build['form']['components'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['components'], + ], + ]; + + $build['form']['components']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; + $build['form']['components']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + return $build; } diff --git a/public/modules/custom/helfi_hakuvahti/translations/fi.po b/public/modules/custom/helfi_hakuvahti/translations/fi.po index f09497aa..e2b023bc 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/fi.po +++ b/public/modules/custom/helfi_hakuvahti/translations/fi.po @@ -49,6 +49,14 @@ msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Vahvista hakuvahti" +msgctxt "Hakuvahti" +msgid "Are you sure you wish to delete the saved search?" +msgstr "Haluatko varmasti poistaa hakuvahdin?" + +msgctxt "Hakuvahti" +msgid "Deleting failed" +msgstr "Poistaminen epäonnistui" + msgid "Subscribe saved search" msgstr "Tilaa hakuvahti" diff --git a/public/modules/custom/helfi_hakuvahti/translations/sv.po b/public/modules/custom/helfi_hakuvahti/translations/sv.po index 79c055a8..acd7651c 100644 --- a/public/modules/custom/helfi_hakuvahti/translations/sv.po +++ b/public/modules/custom/helfi_hakuvahti/translations/sv.po @@ -49,6 +49,14 @@ msgctxt "Hakuvahti" msgid "Confirm saved search" msgstr "Bekräfta sökvakten" +msgctxt "Hakuvahti" +msgid "Are you sure you wish to delete the saved search?" +msgstr "Är du säker på att du vill ta bort sökvakten?" + +msgctxt "Hakuvahti" +msgid "Deleting failed" +msgstr "Radering misslyckades" + msgid "Subscribe saved search" msgstr "Beställ sökvakten" diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig index b79e4d15..833d6a29 100644 --- a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig @@ -1,27 +1 @@ -{# -/** - * @file - * Theme override for a 'form' element. - * - * Available variables - * - attributes: A list of HTML attributes for the wrapper element. - * - children: The child elements of the form. - * - * @see template_preprocess_form() - */ -#} -
-
- {% embed "@hdbt/misc/component.twig" with - { - component_classes: 'component--hakuvahti-form' - } - %} - {% block component_content %} - - {{ children }} - - {% endblock component_content %} - {% endembed %} -
-
+{% include "@hdbt_subtheme/form/hakuvahti-form.twig" %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig new file mode 100644 index 00000000..833d6a29 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig @@ -0,0 +1 @@ +{% include "@hdbt_subtheme/form/hakuvahti-form.twig" %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig new file mode 100644 index 00000000..b79e4d15 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Theme override for a 'form' element. + * + * Available variables + * - attributes: A list of HTML attributes for the wrapper element. + * - children: The child elements of the form. + * + * @see template_preprocess_form() + */ +#} +
+
+ {% embed "@hdbt/misc/component.twig" with + { + component_classes: 'component--hakuvahti-form' + } + %} + {% block component_content %} + + {{ children }} + + {% endblock component_content %} + {% endembed %} +
+
From a6366dd8ed434512b6b230cf06b2b6c64d869f3b Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 23 May 2024 12:42:51 +0300 Subject: [PATCH 46/65] UHF-10005: Style the hakuvahti notifications --- public/themes/custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- .../scss/06_components/paragraphs/_job-listing-search.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 54179f1c..96cd17ca 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search-form__search-monitor{background-color:var(--color-fog-light);padding:32px}.job-search-form__search-monitor__heading{margin-top:0}.job-search-form__search-monitor__content>p{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-search-form__search-monitor__content[aria-hidden=true]{display:none}.job-search-form__search-monitor__content__heading{margin-top:32px}.job-search-form__search-monitor__terms::after{content:"*";margin-left:8px}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}}.hakuvahti-confirmation .components{margin-top:24px}.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height)}@media(min-width: 992px){.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.375rem;font-weight:400}}.hakuvahti-confirmation p:first-child{margin-top:0}.hakuvahti-confirmation .page-divider{padding-left:0}.hakuvahti-confirmation .form-submit{margin-top:32px}@media(min-width: 768px){.hakuvahti-confirmation .form-submit{margin-top:64px}} +.job-listing__organization-name{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:flex;margin-top:16px}@media(min-width: 768px){.job-listing__organization-name{margin-top:24px}}.organization{display:flex;margin-right:8px;position:relative}.organization::after{content:","}.organization:last-child{margin-right:0}.organization:last-child::after{display:none}.job-listing__item{padding-left:16px;padding-right:16px}@media(min-width: 768px){.job-listing__item{padding-left:32px;padding-right:32px}}.job-listing__link-wrapper{margin-top:16px}@media(min-width: 768px){.job-listing__link-wrapper{margin-top:24px}}.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:32px}@media(min-width: 768px){.job-listing__link-wrapper.job-listing__link-wrapper--last{margin-top:48px}}.job-listing__link{width:100%}@media(min-width: 768px){.job-listing__link{width:auto}}.job-listing__job-description{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);margin-top:16px}@media(min-width: 768px){.job-listing__job-description{margin-top:48px}}.job-listing__job-description p:first-child{margin-top:0}.job-listing__salary-class__content{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-listing__sidebar{background-color:var(--hdbt-color-palette--secondary)}.job-listing__organization-information,.job-listing__city-description{padding:24px}.job-listing__image img{display:block;height:auto;max-width:100%;overflow:hidden}.job-listing__image .image-placeholder{padding-bottom:66.67%}.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-top:0}@media(min-width: 992px){.job-listing__organization,.job-listing__city-description-title{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-listing__organization-description,.job-listing__city-description-text{--line-height: 1.5;font-size:1rem;font-weight:400;line-height:var(--line-height);margin-top:8px}.job-listing__organization-description p:first-child,.job-listing__city-description-text p:first-child{margin-top:0}.node--type-job-listing .component--remote-video{margin-top:32px}@media(min-width: 992px){.node--type-job-listing .component--remote-video{margin-top:48px}}.node--type-job-listing.node--view-mode-full .content-tags{margin-top:24px}.block--of-interest{background-color:#e6e6e6;padding:80px 0;margin-top:64px;margin-bottom:calc((50px + 48px)*-1)}.block--of-interest .block--of-interest__content-container{max-width:1296px;padding-left:16px;padding-right:16px;margin:auto}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{max-width:1328px}}@media(min-width: 768px){.block--of-interest .block--of-interest__content-container{padding-left:32px;padding-right:32px}}.block--of-interest h2{margin-bottom:48px;margin-top:0}.block--of-interest .block--of-interest__more-link{margin-top:48px}.component--job-listing-search{background-color:#f7f7f8}.layout-main-wrapper>*:last-child .component--job-listing-search:last-child{margin-bottom:-115px;padding-bottom:55px}.job-listing-search__result-actions{align-items:flex-end;display:flex;justify-content:space-between}.component--job-listing-search .component__container{padding-bottom:32px;padding-top:32px}@media(min-width: 768px){.component--job-listing-search .component__container{padding-bottom:64px;padding-top:64px}}.job-listing-search__count-container{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-listing-search__count-container{--line-height: 1.5;font-size:1.375rem;font-weight:400}}@media(min-width: 992px){.job-listing-search__count-container{margin-bottom:0}}.job-listing-search__count-container .job-listing-search__count{font-weight:700}.job-listing-search__sort{min-width:283px}.job-listing-search__result--list{margin-top:24px}@media(min-width: 768px){.job-listing-search__result--list{margin-top:32px}}.job-search-form{margin-bottom:32px}.job-search-form__title{margin-bottom:32px}@media(min-width: 992px){.job-search-form__dropdowns__upper{margin-left:-12px;margin-right:-12px;display:flex}.job-search-form__dropdowns__upper>*{margin-left:12px;margin-right:12px}}.job-search-form__dropdown li+li{margin-top:0}@media(min-width: 992px){.job-search-form__dropdown--upper{width:50%}}.job-search-form__filter{margin-bottom:16px;width:100%}@media(min-width: 992px){.job-search-form__filter{margin-bottom:24px}}.job-search-form__checkboxes{border:none;margin-bottom:16px;padding:0}@media(min-width: 992px){.job-search-form__checkboxes{display:flex}}fieldset .job-search-form__checkbox{--background-selected: var(--hdbt-color-black)}fieldset .job-search-form__checkbox:not(:first-of-type){margin-top:32px}@media(min-width: 992px){fieldset .job-search-form__checkbox:not(:first-of-type){margin-left:16px;margin-top:0}}.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5;font-size:1rem;font-weight:700;line-height:var(--line-height);margin-bottom:16px}@media(min-width: 992px){.job-search-form__checkboxes-legend,.job-search__no-results__heading{--line-height: 1.5555555556;font-size:1.125rem;font-weight:700}}.job-search-form__selections-container{list-style-type:none}button.job-search-form__remove-selection-button:not(:disabled){background-color:rgba(0,0,0,0);border:1px solid #000;border-radius:48px;padding:12px 20px 12px;--color-hover-focus: var(--hdbt-text-color);color:var(--hdbt-color-black)}button.job-search-form__remove-selection-button:not(:disabled):hover,button.job-search-form__remove-selection-button:not(:disabled):active{background-color:#000;border-color:#000;color:#fff}button.job-search-form__remove-selection-button:not(:disabled):focus,button.job-search-form__remove-selection-button:not(:disabled):active{border-color:#000;outline:2px solid #000;outline-offset:2px}.job-search-form__remove-selection-button span{padding:0}.job-search-form__selections-wrapper button.job-search-form__remove-selection-button>div{margin-right:0}.job-search-form__clear-all{margin-top:0}.job-search-form__clear-all .job-search-form__clear-all-button{--background-color-hover: transparent;--background-color-focus: transparent;--background-color-hover-focus: transparent;--border-color-hover: var(--hdbt-color-black);--border-color-focus: var(--hdbt-color-black);--border-color-hover-focus: var(--hdbt-color-black);--color: var(--hdbt-color-black);--color-hover: var(--hdbt-color-black);--color-focus: var(--hdbt-color-black);--color-hover-focus: var(--hdbt-color-black);--focus-outline-color: var(--hdbt-color-black)}.job-search-form__search-monitor{margin-bottom:32px}.job-search-form__search-monitor div[role=heading]{flex:0 1 auto}.job-search-form__search-monitor{background-color:var(--color-fog-light);padding:32px}.job-search-form__search-monitor__heading{margin-top:0}.job-search-form__search-monitor__content>p{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.job-search-form__search-monitor__content[aria-hidden=true]{display:none}.job-search-form__search-monitor__content__heading{margin-top:32px}.job-search-form__search-monitor__terms::after{content:"*";margin-left:8px}.job-search-form__search-monitor__error{margin-top:32px}.job-search__results-stats{margin-bottom:32px;margin-left:16px;margin-right:16px}@media(min-width: 992px){.job-search__results-stats{align-items:flex-end;display:flex;justify-content:space-between}}.hakuvahti-confirmation .components{margin-top:24px}.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.25rem;font-weight:400;line-height:var(--line-height)}@media(min-width: 992px){.hakuvahti-confirmation p{--line-height: 1.5;font-size:1.375rem;font-weight:400}}.hakuvahti-confirmation p:first-child{margin-top:0}.hakuvahti-confirmation .page-divider{padding-left:0}.hakuvahti-confirmation .form-submit{margin-top:32px}@media(min-width: 768px){.hakuvahti-confirmation .form-submit{margin-top:64px}} diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss index 0ab64f43..2e8428fa 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/paragraphs/_job-listing-search.scss @@ -196,6 +196,10 @@ button.job-search-form__remove-selection-button:not(:disabled) { margin-left: $spacing-half; } +.job-search-form__search-monitor__error { + margin-top: $spacing-double; +} + .job-search__results-stats { margin-bottom: $spacing-double; margin-left: $spacing; From d536b07005d68a7b3669e62ea6dd0c5663dfa65d Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 23 May 2024 13:13:37 +0300 Subject: [PATCH 47/65] UHF-10005: Add missing component wrapper to all confirmation messages --- .../HelfiHakuvahtiConfirmController.php | 34 +++++++++------ .../HelfiHakuvahtiUnsubscribeController.php | 43 +++++++++++++------ 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index 38f4ece9..e2c5bea4 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -73,16 +73,6 @@ public function __invoke(): array { return $this->buildForm(); } - /** - * Returns the page title. - * - * @return string - * The page title - */ - public function getTitle() { - return $this->dynamicTitle; - } - /** * Handles the form submission for confirming a subscription. * @@ -171,13 +161,21 @@ private function buildConfirmationSuccess(): array { ], ]; - $build['confirmation']['components']['paragraph'] = [ + $build['confirmation']['components']['component'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['component'], + ], + ]; + + $build['confirmation']['components']['component']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages.', [], ['context' => 'Hakuvahti']), ]; - $build['confirmation']['components']['divider'] = [ + $build['confirmation']['components']['component']['divider'] = [ '#type' => 'html_tag', '#tag' => 'div', '#attributes' => [ @@ -215,13 +213,21 @@ private function buildConfirmationFailure(): array { ], ]; - $build['confirmation']['components']['paragraph'] = [ + $build['confirmation']['components']['component'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['component'], + ], + ]; + + $build['confirmation']['components']['component']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; - $build['confirmation']['components']['divider'] = [ + $build['confirmation']['components']['component']['divider'] = [ '#type' => 'html_tag', '#tag' => 'div', '#attributes' => [ diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 05f4eeb9..64aeb770 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -160,32 +160,41 @@ private function buildConfirmation(): array { ], ]; - $build['confirmation']['components']['paragraph'] = [ + $build['confirmation']['components']['component'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['component'], + ], + ]; + + + $build['confirmation']['components']['component']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('You can save more searches at any time.', [], ['context' => 'Hakuvahti']), ]; - $build['confirmation']['components']['paragraph2'] = [ + $build['confirmation']['components']['component']['divider'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['page-divider'], + ], + ]; + + $build['confirmation']['components']['component']['paragraph2'] = [ '#type' => 'html_tag', '#tag' => 'p', ]; - $build['confirmation']['components']['paragraph2']['link'] = [ + $build['confirmation']['components']['component']['paragraph2']['link'] = [ '#type' => 'link', '#tag' => 'a', '#title' => $this->t('Return to open jobs front page', [], ['context' => 'Hakuvahti']), '#url' => Url::fromUri('internal:/'), ]; - $build['confirmation']['components']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - return $build; } @@ -216,13 +225,21 @@ private function buildFailedSubmission(): array { ], ]; - $build['form']['components']['paragraph'] = [ + $build['form']['components']['component'] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => [ + 'class' => ['component'], + ], + ]; + + $build['form']['components']['component']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', '#value' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; - $build['form']['components']['divider'] = [ + $build['form']['components']['component']['divider'] = [ '#type' => 'html_tag', '#tag' => 'div', '#attributes' => [ From 53f2e7ed404da9bfbbd02634d61b2aa88b0900d2 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 23 May 2024 13:18:18 +0300 Subject: [PATCH 48/65] UHF-10005: Fix PHPCS --- .../src/Controller/HelfiHakuvahtiConfirmController.php | 1 - .../src/Controller/HelfiHakuvahtiUnsubscribeController.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php index e2c5bea4..cbd85ba5 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php @@ -7,7 +7,6 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Utility\Token; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php index 64aeb770..088f2fd8 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php @@ -110,7 +110,6 @@ private function buildForm(): array { '#method' => 'POST', ]; - $build['form']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', @@ -168,7 +167,6 @@ private function buildConfirmation(): array { ], ]; - $build['confirmation']['components']['component']['paragraph'] = [ '#type' => 'html_tag', '#tag' => 'p', From 3caa1068cc093d8dada1bd8e27b52ce19d9198a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 18:42:29 +0300 Subject: [PATCH 49/65] Add new unified controller for confirm + unsubscribe and move layout to twig templates. --- .../helfi_hakuvahti/helfi_hakuvahti.module | 33 ++ .../Controller/HelfiHakuvahtiController.php | 281 ++++++++++++++++++ .../hakuvahti-confirmation.html.twig | 11 + .../hakuvahti-failed-submission.html.twig | 8 + .../templates/hakuvahti-form.html.twig | 9 + 5 files changed, 342 insertions(+) create mode 100644 public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module create mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php create mode 100644 public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig create mode 100644 public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig create mode 100644 public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module new file mode 100644 index 00000000..cd2f58c6 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module @@ -0,0 +1,33 @@ + [ + 'variables' => [ + 'title' => NULL, + 'paragraph' => NULL, + 'button_text' => NULL, + 'action_url' => NULL, + 'id' => NULL, + 'form_id' => NULL, + ], + ], + 'hakuvahti_confirmation' => [ + 'variables' => [ + 'title' => NULL, + 'message' => NULL, + 'link_text' => NULL, + 'link_url' => NULL, + ], + ], + 'hakuvahti_failed_submission' => [ + 'variables' => [ + 'title' => NULL, + 'message' => NULL, + ], + ], + ]; +} diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php new file mode 100644 index 00000000..4d6bc377 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -0,0 +1,281 @@ +requestStack->getCurrentRequest(); + $hash = $request->query->get('hash'); + $subscription = $request->query->get('subscription'); + + return $this->isFormSubmitted() + ? $this->handleConfirmFormSubmission($hash, $subscription) + : $this->buildConfirmForm(); + } + + /** + * Handles the form submission for confirming a subscription. + * + * @param string $hash + * The hash parameter. + * @param string $subscription + * The subscription parameter. + * + * @return array + * A render array for the confirmation result. + */ + private function handleConfirmFormSubmission(string $hash, string $subscription): array { + return $this->sendConfirmationRequest($hash, $subscription) + ? $this->buildConfirmationSuccess() + : $this->buildConfirmationFailure(); + } + + /** + * Builds the form for confirming a saved search. + * + * @return array + * A render array for the confirmation form. + */ + private function buildConfirmForm(): array { + return [ + '#type' => 'form', + '#id' => 'hakuvahti_confirm_form', + '#form_id' => 'hakuvahti_confirm_form', + '#theme' => 'hakuvahti_form', + '#title' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), + '#paragraph' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.', [], ['context' => 'Hakuvahti']), + '#button_text' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), + '#action_url' => $this->getFormActionUrl(), + ]; + } + + /** + * Builds the confirmation success message. + * + * @return array + * A render array for the confirmation success message. + */ + private function buildConfirmationSuccess(): array { + return [ + '#theme' => 'hakuvahti_confirmation', + '#title' => $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages.', [], ['context' => 'Hakuvahti']), + ]; + } + + /** + * Builds the confirmation failure message. + * + * @return array + * A render array for the confirmation failure message. + */ + private function buildConfirmationFailure(): array { + return [ + '#theme' => 'hakuvahti_failed_submission', + '#title' => $this->t('Confirmation failed', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), + ]; + } + + /** + * Sends a confirmation request to the Hakuvahti server. + * + * @param string $subscriptionHash + * The subscription hash. + * @param string $subscriptionId + * The subscription ID. + * + * @return bool + * TRUE if the confirmation request was successful, FALSE otherwise. + */ + protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { + $csrfTokenService = $this->container->get('csrf_token'); + $httpClient = new Client([ + 'headers' => [ + 'Content-Type' => 'application/json', + 'token' => $csrfTokenService->get('session'), + ], + ]); + + try { + $response = $httpClient->get(getenv('HAKUVAHTI_URL') . "/subscription/confirm/{$subscriptionId}/{$subscriptionHash}"); + return $response->getBody()->getContents() !== ''; + } catch (RequestException $exception) { + return FALSE; + } + } + + /** + * Handles the unsubscription from a saved search. + * + * @return array + * A render array for the unsubscription form. + */ + public function unsubscribe(): array { + $request = $this->requestStack->getCurrentRequest(); + $hash = $request->query->get('hash'); + $subscription = $request->query->get('subscription'); + + return $this->isFormSubmitted() + ? $this->handleUnsubscribeFormSubmission($hash, $subscription) + : $this->buildUnsubscribeForm(); + } + + /** + * Handles the form submission for unsubscribing from a subscription. + * + * @param string $hash + * The hash parameter. + * @param string $subscription + * The subscription parameter. + * + * @return array + * A render array for the unsubscription result. + */ + private function handleUnsubscribeFormSubmission(string $hash, string $subscription): array { + return $this->sendUnsubscribeRequest($hash, $subscription) + ? $this->buildUnsubscribeConfirmation() + : $this->buildUnsubscribeFailedSubmission(); + } + + /** + * Builds the form for unsubscribing from a saved search. + * + * @return array + * A render array for the unsubscription form. + */ + private function buildUnsubscribeForm(): array { + return [ + '#theme' => 'hakuvahti_form', + '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), + '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), + '#button_text' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), + '#action_url' => $this->getFormActionUrl(), + ]; + } + + /** + * Builds the unsubscription confirmation message. + * + * @return array + * A render array for the unsubscription confirmation message. + */ + private function buildUnsubscribeConfirmation(): array { + return [ + '#theme' => 'hakuvahti_confirmation', + '#title' => $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('You can save more searches at any time.', [], ['context' => 'Hakuvahti']), + '#link_text' => $this->t('Return to open jobs front page', [], ['context' => 'Hakuvahti']), + '#link_url' => Url::fromUri('internal:/'), + ]; + } + + /** + * Builds the unsubscription failure message. + * + * @return array + * A render array for the unsubscription failure message. + */ + private function buildUnsubscribeFailedSubmission(): array { + return [ + '#theme' => 'hakuvahti_failed_submission', + '#title' => $this->t('Deleting failed', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), + ]; + } + + /** + * Sends an unsubscribe request to the Hakuvahti server. + * + * @param string $hash + * The hash parameter. + * @param string $subscription + * The subscription parameter. + * + * @return bool + * TRUE if the unsubscription request was successful, FALSE otherwise. + */ + protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { + $csrfTokenService = $this->container->get('csrf_token'); + $httpClient = new Client([ + 'headers' => [ + 'Content-Type' => 'application/json', + 'token' => $csrfTokenService->get('session'), + ], + ]); + + try { + $response = $httpClient->delete(getenv('HAKUVAHTI_URL') . "/subscription/delete/{$subscription}/{$hash}"); + return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300; + } catch (RequestException $exception) { + return FALSE; + } + } + + /** + * Gets the form action URL. + * + * @return string + * The form action URL. + */ + protected function getFormActionUrl(): string { + return $this->requestStack->getCurrentRequest()->getUri(); + } + + /** + * Checks if the form is submitted. + * + * @return bool + * TRUE if the form is submitted, FALSE otherwise. + */ + protected function isFormSubmitted(): bool { + return $this->requestStack->getCurrentRequest()->isMethod('POST'); + } +} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig new file mode 100644 index 00000000..c3c9a8da --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig @@ -0,0 +1,11 @@ +{% block content %} +
+
+

{{ message }}

+
+ {% if link_text and link_url %} + {{ link_text }} + {% endif %} +
+
+{% endblock %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig new file mode 100644 index 00000000..fbda51b8 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig @@ -0,0 +1,8 @@ +{% block content %} +
+
+

{{ message }}

+
+
+
+{% endblock %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig new file mode 100644 index 00000000..1ae7f3e0 --- /dev/null +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig @@ -0,0 +1,9 @@ +{% block content %} +
+

{{ paragraph }}

+
+
+ +
+
+{% endblock %} From 58f1a23b4b476deaf21063a75c0c9a9143c947ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 18:42:45 +0300 Subject: [PATCH 50/65] Update routing to point to the new module. --- .../custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml index 88137239..2332fc4f 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.routing.yml @@ -9,13 +9,13 @@ helfi_hakuvahti.confirm: path: '/hakuvahti/confirm' defaults: _title: 'Confirm saved search' - _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiConfirmController' + _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiController::confirm' requirements: _permission: 'access content' helfi_hakuvahti.unsubscribe: path: '/hakuvahti/unsubscribe' defaults: _title: 'Are you sure you wish to delete the saved search?' - _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiUnsubscribeController' + _controller: '\Drupal\helfi_hakuvahti\Controller\HelfiHakuvahtiController::unsubscribe' requirements: _permission: 'access content' From 9175b44fab2adb6320e50fd03d464a1e14ca7eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 18:52:08 +0300 Subject: [PATCH 51/65] Linter fixes --- .../custom/helfi_hakuvahti/helfi_hakuvahti.module | 9 +++++++++ .../src/Controller/HelfiHakuvahtiController.php | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module index cd2f58c6..bae11ceb 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module @@ -1,5 +1,14 @@ query->get('hash'); $subscription = $request->query->get('subscription'); - return $this->isFormSubmitted() + return $this->isFormSubmitted() ? $this->handleConfirmFormSubmission($hash, $subscription) : $this->buildConfirmForm(); } @@ -147,7 +147,8 @@ protected function sendConfirmationRequest(string $subscriptionHash, string $sub try { $response = $httpClient->get(getenv('HAKUVAHTI_URL') . "/subscription/confirm/{$subscriptionId}/{$subscriptionHash}"); return $response->getBody()->getContents() !== ''; - } catch (RequestException $exception) { + } + catch (RequestException $exception) { return FALSE; } } @@ -254,7 +255,8 @@ protected function sendUnsubscribeRequest(string $hash, string $subscription): b try { $response = $httpClient->delete(getenv('HAKUVAHTI_URL') . "/subscription/delete/{$subscription}/{$hash}"); return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300; - } catch (RequestException $exception) { + } + catch (RequestException $exception) { return FALSE; } } @@ -278,4 +280,5 @@ protected function getFormActionUrl(): string { protected function isFormSubmitted(): bool { return $this->requestStack->getCurrentRequest()->isMethod('POST'); } + } From 1763126de0684121e5ee2f7d61f5600bd984eb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 18:53:16 +0300 Subject: [PATCH 52/65] Remove old controllers --- .../HelfiHakuvahtiConfirmController.php | 294 ----------------- .../HelfiHakuvahtiUnsubscribeController.php | 308 ------------------ 2 files changed, 602 deletions(-) delete mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php delete mode 100644 public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php deleted file mode 100644 index cbd85ba5..00000000 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiConfirmController.php +++ /dev/null @@ -1,294 +0,0 @@ -requestStack->getCurrentRequest(); - $hash = $request->query->get('hash'); - $subscription = $request->query->get('subscription'); - - if ($this->isFormSubmitted()) { - return $this->handleFormSubmission($hash, $subscription); - } - - return $this->buildForm(); - } - - /** - * Handles the form submission for confirming a subscription. - * - * @param mixed $hash - * The hash parameter. - * @param mixed $subscription - * The subscription parameter. - * - * @return array - * The build array containing the confirmation success or failure. - */ - private function handleFormSubmission($hash, $subscription): array { - if ($this->sendConfirmationRequest($hash, $subscription)) { - return $this->buildConfirmationSuccess(); - } - - return $this->buildConfirmationFailure(); - } - - /** - * Builds the form for confirming a saved search. - * - * @return array - * The build array containing the form structure - * for confirming a saved search. - */ - private function buildForm(): array { - $build = []; - - $build['form'] = [ - '#type' => 'form', - '#id' => $this->getFormId(), - '#form_id' => $this->getFormId(), - '#action' => $this->getFormActionUrl(), - '#method' => 'POST', - ]; - - $build['#title'] = $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']); - - $build['form']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.', [], ['context' => 'Hakuvahti']), - ]; - - $build['form']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - $build['form']['button'] = [ - '#type' => 'submit', - '#value' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), - ]; - - return $build; - } - - /** - * Builds the confirmation array for a successful saved search confirmation. - * - * @return array - * Success form - */ - private function buildConfirmationSuccess(): array { - $build = []; - - $build['#title'] = $this->t('Search saved successfully', [], ['context' => 'Hakuvahti']); - - $build['confirmation'] = [ - '#type' => 'html_tag', - '#tag' => 'article', - '#attributes' => [ - 'class' => ['hakuvahti-confirmation'], - ], - ]; - - $build['confirmation']['components'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['components'], - ], - ]; - - $build['confirmation']['components']['component'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['component'], - ], - ]; - - $build['confirmation']['components']['component']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('You will receive an email notification of any new results matching your saved search criteria. You can delete the saved search via the cancellation link in the email messages.', [], ['context' => 'Hakuvahti']), - ]; - - $build['confirmation']['components']['component']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - return $build; - } - - /** - * Builds the confirmation array for a failed saved search confirmation. - * - * @return array - * Failure form - */ - private function buildConfirmationFailure(): array { - $build = []; - - $build['#title'] = $this->t('Confirmation failed', [], ['context' => 'Hakuvahti']); - - $build['confirmation'] = [ - '#type' => 'html_tag', - '#tag' => 'article', - '#attributes' => [ - 'class' => ['hakuvahti-confirmation'], - ], - ]; - - $build['confirmation']['components'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['components'], - ], - ]; - - $build['confirmation']['components']['component'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['component'], - ], - ]; - - $build['confirmation']['components']['component']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), - ]; - - $build['confirmation']['components']['component']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - return $build; - } - - /** - * Retrieves the form action URL from the current request. - * - * @return string - * The URL of the current request. - */ - protected function getFormActionUrl(): string { - return $this->requestStack->getCurrentRequest()->getUri(); - } - - /** - * Checks if the form is submitted via POST method. - * - * @return bool - * Whether the form is submitted via POST method. - */ - protected function isFormSubmitted(): bool { - $request = $this->requestStack->getCurrentRequest(); - return $request->isMethod('POST'); - } - - /** - * Sends a confirmation request to the Hakuvahti server. - * - * @param string $subscriptionHash - * The subscription hash. - * @param string $subscriptionId - * The subscription ID. - * - * @return bool - * Returns TRUE if the confirmation request is successful, FALSE otherwise. - */ - protected function sendConfirmationRequest(string $subscriptionHash, string $subscriptionId): bool { - $csrfTokenService = $this->container->get('csrf_token'); - $expectedToken = $csrfTokenService->get('session'); - $httpClient = new Client([ - 'headers' => [ - 'Content-Type' => 'application/json', - 'token' => $expectedToken, - ], - ]); - - $hakuvahtiServer = getenv('HAKUVAHTI_URL'); - $targetUrl = $hakuvahtiServer . '/subscription/confirm/' . $subscriptionId . '/' . $subscriptionHash; - - try { - $response = $httpClient->get($targetUrl); - return $response->getBody()->getContents() !== ''; - } - catch (RequestException $exception) { - return FALSE; - } - } - -} diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php deleted file mode 100644 index 088f2fd8..00000000 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiUnsubscribeController.php +++ /dev/null @@ -1,308 +0,0 @@ -requestStack->getCurrentRequest(); - $hash = $request->query->get('hash'); - $subscription = $request->query->get('subscription'); - - if ($this->isFormSubmitted()) { - return $this->handleFormSubmission($hash, $subscription); - } - - return $this->buildForm(); - } - - /** - * Handles the form submission for unsubscribing from a subscription. - * - * @param string $hash - * Description of the hash parameter. - * @param string $subscription - * Description of the subscription parameter. - * - * @return array - * The build array containing the confirmation form - * or the failed submission form. - */ - private function handleFormSubmission(string $hash, string $subscription): array { - if ($this->sendUnsubscribeRequest($hash, $subscription)) { - return $this->buildConfirmation(); - } - - return $this->buildFailedSubmission(); - } - - /** - * Builds the form for deleting a saved search. - * - * @return array - * The build array containing the form - * structure for deleting a saved search. - */ - private function buildForm(): array { - $build = []; - - $build['#title'] = $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']); - - $build['form'] = [ - '#type' => 'form', - '#id' => $this->getFormId(), - '#form_id' => $this->getFormId(), - '#action' => $this->getFormActionUrl(), - '#method' => 'POST', - ]; - - $build['form']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), - ]; - - $build['form']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - $build['form']['button'] = [ - '#type' => 'submit', - '#value' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), - ]; - - return $build; - } - - /** - * Builds the confirmation array for the saved search deletion. - * - * @return array - * The build array containing the confirmation details. - */ - private function buildConfirmation(): array { - $build = []; - - $build['#title'] = $this->t('The saved search has been deleted', [], ['context' => 'Hakuvahti']); - - $build['confirmation'] = [ - '#type' => 'html_tag', - '#tag' => 'article', - '#attributes' => [ - 'class' => ['hakuvahti-confirmation'], - ], - ]; - - $build['confirmation']['components'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['components'], - ], - ]; - - $build['confirmation']['components']['component'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['component'], - ], - ]; - - $build['confirmation']['components']['component']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('You can save more searches at any time.', [], ['context' => 'Hakuvahti']), - ]; - - $build['confirmation']['components']['component']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - $build['confirmation']['components']['component']['paragraph2'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - ]; - - $build['confirmation']['components']['component']['paragraph2']['link'] = [ - '#type' => 'link', - '#tag' => 'a', - '#title' => $this->t('Return to open jobs front page', [], ['context' => 'Hakuvahti']), - '#url' => Url::fromUri('internal:/'), - ]; - - return $build; - } - - /** - * Builds the form for a failed submission when deleting a saved search. - * - * @return array - * The build array containing the form structure for a failed submission. - */ - private function buildFailedSubmission(): array { - $build = []; - - $build['#title'] = $this->t('Deleting failed', [], ['context' => 'Hakuvahti']); - - $build['form'] = [ - '#type' => 'html_tag', - '#tag' => 'article', - '#attributes' => [ - 'class' => ['hakuvahti-confirmation'], - ], - ]; - - $build['form']['components'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['components'], - ], - ]; - - $build['form']['components']['component'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['component'], - ], - ]; - - $build['form']['components']['component']['paragraph'] = [ - '#type' => 'html_tag', - '#tag' => 'p', - '#value' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), - ]; - - $build['form']['components']['component']['divider'] = [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => [ - 'class' => ['page-divider'], - ], - ]; - - return $build; - } - - /** - * Returns the URL for the current form action. - * - * @return string - * The URL for the current form action. - */ - protected function getFormActionUrl(): string { - return $this->requestStack->getCurrentRequest()->getUri(); - } - - /** - * Checks if the form is submitted via the POST method. - * - * @return bool - * Whether the form is submitted via the POST method. - */ - protected function isFormSubmitted(): bool { - $request = $this->requestStack->getCurrentRequest(); - return $request->isMethod('POST'); - } - - /** - * Sends an unsubscribe request to the server. - * - * @param string $hash - * The hash of the subscription. - * @param string $subscription - * The subscription ID. - * - * @return bool - * Returns TRUE if the request is successful, FALSE otherwise. - */ - protected function sendUnsubscribeRequest(string $hash, string $subscription): bool { - $csrfTokenService = $this->container->get('csrf_token'); - $expectedToken = $csrfTokenService->get('session'); - - $httpClient = new Client(); - $options = [ - 'headers' => [ - 'Content-Type' => 'application/json', - 'token' => $expectedToken, - ], - ]; - - $hakuvahtiServer = getenv('HAKUVAHTI_URL'); - - try { - $target_url = $hakuvahtiServer . '/subscription/delete/' . $subscription . '/' . $hash; - $response = $httpClient->delete($target_url, $options); - - return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300; - } - catch (RequestException $exception) { - return FALSE; - } - } - -} From ab7233ec747e070d483bd6d17e28e01c738a6433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 19:17:22 +0300 Subject: [PATCH 53/65] Attempt to fix the layout --- .../src/Controller/HelfiHakuvahtiController.php | 3 +++ .../helfi_hakuvahti/templates/hakuvahti-form.html.twig | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index 6e9471c8..ddd7d2e0 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -194,6 +194,9 @@ private function handleUnsubscribeFormSubmission(string $hash, string $subscript */ private function buildUnsubscribeForm(): array { return [ + '#type' => 'form', + '#id' => 'hakuvahti_unsubscribe_form', + '#form_id' => 'hakuvahti_unsubscribe_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig index 1ae7f3e0..6d341123 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig @@ -1,9 +1,11 @@ {% block content %}
-

{{ paragraph }}

-
+
+

{{ paragraph }}

- - +
+ +
+
{% endblock %} From f59e9da441bb427325722b381167cfd6df81d617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 19:24:34 +0300 Subject: [PATCH 54/65] Try to please sonarcloud --- .../src/Controller/HelfiHakuvahtiController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index ddd7d2e0..836ca9ad 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -199,7 +199,10 @@ private function buildUnsubscribeForm(): array { '#form_id' => 'hakuvahti_unsubscribe_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), - '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), + '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', + [], + ['context' => 'Hakuvahti'] + ), '#button_text' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), '#action_url' => $this->getFormActionUrl(), ]; From ae15e50d60e4bbad02ac711273f8ad17705d5bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 19:29:46 +0300 Subject: [PATCH 55/65] Try to please sonarcloud --- .../src/Controller/HelfiHakuvahtiController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index 836ca9ad..dccdd3b1 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -199,10 +199,9 @@ private function buildUnsubscribeForm(): array { '#form_id' => 'hakuvahti_unsubscribe_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), - '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', - [], - ['context' => 'Hakuvahti'] - ), + '#paragraph' => $this->t('Please confirm that you wish to delete the ' . + 'saved search. If you have other searches saved on the City website, ' . + 'this link will not delete them.', [], ['context' => 'Hakuvahti']), '#button_text' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), '#action_url' => $this->getFormActionUrl(), ]; From abfa7c2c91959f26e7673d3ed7089d369c76ea94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Mon, 27 May 2024 19:33:01 +0300 Subject: [PATCH 56/65] Well it doesn't work that way... --- .../src/Controller/HelfiHakuvahtiController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index dccdd3b1..ddd7d2e0 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -199,9 +199,7 @@ private function buildUnsubscribeForm(): array { '#form_id' => 'hakuvahti_unsubscribe_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), - '#paragraph' => $this->t('Please confirm that you wish to delete the ' . - 'saved search. If you have other searches saved on the City website, ' . - 'this link will not delete them.', [], ['context' => 'Hakuvahti']), + '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), '#button_text' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), '#action_url' => $this->getFormActionUrl(), ]; From 0443ee324a822b2d019b8b5107b0953888a371ed Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 13:54:19 +0300 Subject: [PATCH 57/65] Adjust templates for hakuvahti confirmation after refactoring changes --- .../helfi_hakuvahti/helfi_hakuvahti.module | 2 +- .../Controller/HelfiHakuvahtiController.php | 4 +-- .../hakuvahti-confirmation.html.twig | 18 +++++-------- .../hakuvahti-failed-submission.html.twig | 9 +------ .../templates/hakuvahti-form.html.twig | 13 +++------ .../form--hakuvahti-confirm-form.html.twig | 2 +- ...form--hakuvahti-unsubscribe-form.html.twig | 2 +- .../form/hakuvahti-confirmation-wrapper.twig | 16 +++++++++++ .../templates/form/hakuvahti-form.twig | 27 ------------------- 9 files changed, 33 insertions(+), 60 deletions(-) create mode 100644 public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig delete mode 100644 public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module index bae11ceb..ff4b91f6 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module @@ -17,7 +17,7 @@ function helfi_hakuvahti_theme() { 'hakuvahti_form' => [ 'variables' => [ 'title' => NULL, - 'paragraph' => NULL, + 'message' => NULL, 'button_text' => NULL, 'action_url' => NULL, 'id' => NULL, diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index ddd7d2e0..0cbf4f57 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -90,7 +90,7 @@ private function buildConfirmForm(): array { '#form_id' => 'hakuvahti_confirm_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), - '#paragraph' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('Please confirm the saved search to receive notifications. Click on the button below.', [], ['context' => 'Hakuvahti']), '#button_text' => $this->t('Confirm saved search', [], ['context' => 'Hakuvahti']), '#action_url' => $this->getFormActionUrl(), ]; @@ -199,7 +199,7 @@ private function buildUnsubscribeForm(): array { '#form_id' => 'hakuvahti_unsubscribe_form', '#theme' => 'hakuvahti_form', '#title' => $this->t('Are you sure you wish to delete the saved search?', [], ['context' => 'Hakuvahti']), - '#paragraph' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), + '#message' => $this->t('Please confirm that you wish to delete the saved search. If you have other searches saved on the City website, this link will not delete them.', [], ['context' => 'Hakuvahti']), '#button_text' => $this->t('Delete saved search', [], ['context' => 'Hakuvahti']), '#action_url' => $this->getFormActionUrl(), ]; diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig index c3c9a8da..5b12630c 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig @@ -1,11 +1,7 @@ -{% block content %} -
-
-

{{ message }}

-
- {% if link_text and link_url %} - {{ link_text }} - {% endif %} -
-
-{% endblock %} +{% if link_text and link_url %} + {% set link %} + {{ link_text }} + {% endset %} +{% endif %} + +{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { message: message, content: link, } %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig index fbda51b8..9a836e4d 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig @@ -1,8 +1 @@ -{% block content %} -
-
-

{{ message }}

-
-
-
-{% endblock %} +{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { message: message } %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig index 6d341123..22c7600c 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig +++ b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig @@ -1,11 +1,6 @@ {% block content %} -
-
-

{{ paragraph }}

-
-
- -
-
-
+ {% include "@hdbt_subtheme/form/hakuvahti-message-wrapper.twig" with { message: message } %} +
+ +
{% endblock %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig index 833d6a29..8b224904 100644 --- a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig @@ -1 +1 @@ -{% include "@hdbt_subtheme/form/hakuvahti-form.twig" %} +{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig index 833d6a29..8b224904 100644 --- a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig @@ -1 +1 @@ -{% include "@hdbt_subtheme/form/hakuvahti-form.twig" %} +{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig new file mode 100644 index 00000000..923e78a3 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig @@ -0,0 +1,16 @@ +
+
+ {% embed "@hdbt/misc/component.twig" with + { + component_classes: 'component--hakuvahti-form' + } + %} + {% block component_content %} + {% if message %} + {% include "@hdbt_subtheme/form/hakuvahti-message-wrapper.twig" with { message: message } %} + {% endif %} + {{ content }} + {% endblock component_content %} + {% endembed %} +
+
diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig deleted file mode 100644 index b79e4d15..00000000 --- a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-form.twig +++ /dev/null @@ -1,27 +0,0 @@ -{# -/** - * @file - * Theme override for a 'form' element. - * - * Available variables - * - attributes: A list of HTML attributes for the wrapper element. - * - children: The child elements of the form. - * - * @see template_preprocess_form() - */ -#} -
-
- {% embed "@hdbt/misc/component.twig" with - { - component_classes: 'component--hakuvahti-form' - } - %} - {% block component_content %} - - {{ children }} - - {% endblock component_content %} - {% endembed %} -
-
From 3229b28452b0faf9e4d67b1980221da8bc711b97 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 14:02:11 +0300 Subject: [PATCH 58/65] Add missing template for hakuvahti message wrapper --- .../hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig new file mode 100644 index 00000000..6a851581 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig @@ -0,0 +1,2 @@ +

{{ message }}

+
From 7d1889593c172d25463f827b5043a57c177d7e90 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 14:17:50 +0300 Subject: [PATCH 59/65] Move all templates under hdbt_subtheme, refactor templates to smaller number --- .../modules/custom/helfi_hakuvahti/helfi_hakuvahti.module | 6 ------ .../src/Controller/HelfiHakuvahtiController.php | 4 ++-- .../templates/hakuvahti-failed-submission.html.twig | 1 - .../templates/form/form--hakuvahti-confirm-form.html.twig | 1 - .../form/form--hakuvahti-unsubscribe-form.html.twig | 1 - .../helfi_hakuvahti/form--hakuvahti-confirm-form.html.twig | 1 + .../form--hakuvahti-unsubscribe-form.html.twig | 1 + .../helfi_hakuvahti/hakuvahti-action-wrapper.twig} | 2 +- .../helfi_hakuvahti}/hakuvahti-confirmation.html.twig | 2 +- .../module/helfi_hakuvahti}/hakuvahti-form.html.twig | 2 +- .../helfi_hakuvahti}/hakuvahti-message-wrapper.twig | 0 11 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig delete mode 100644 public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig delete mode 100644 public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig create mode 100644 public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-confirm-form.html.twig create mode 100644 public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-unsubscribe-form.html.twig rename public/themes/custom/hdbt_subtheme/templates/{form/hakuvahti-confirmation-wrapper.twig => module/helfi_hakuvahti/hakuvahti-action-wrapper.twig} (75%) rename public/{modules/custom/helfi_hakuvahti/templates => themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti}/hakuvahti-confirmation.html.twig (50%) rename public/{modules/custom/helfi_hakuvahti/templates => themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti}/hakuvahti-form.html.twig (60%) rename public/themes/custom/hdbt_subtheme/templates/{form => module/helfi_hakuvahti}/hakuvahti-message-wrapper.twig (100%) diff --git a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module index ff4b91f6..b9086c6a 100644 --- a/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module +++ b/public/modules/custom/helfi_hakuvahti/helfi_hakuvahti.module @@ -32,11 +32,5 @@ function helfi_hakuvahti_theme() { 'link_url' => NULL, ], ], - 'hakuvahti_failed_submission' => [ - 'variables' => [ - 'title' => NULL, - 'message' => NULL, - ], - ], ]; } diff --git a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php index 0cbf4f57..5bbf5a81 100644 --- a/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php +++ b/public/modules/custom/helfi_hakuvahti/src/Controller/HelfiHakuvahtiController.php @@ -118,7 +118,7 @@ private function buildConfirmationSuccess(): array { */ private function buildConfirmationFailure(): array { return [ - '#theme' => 'hakuvahti_failed_submission', + '#theme' => 'hakuvahti_confirmation', '#title' => $this->t('Confirmation failed', [], ['context' => 'Hakuvahti']), '#message' => $this->t('Confirming saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; @@ -229,7 +229,7 @@ private function buildUnsubscribeConfirmation(): array { */ private function buildUnsubscribeFailedSubmission(): array { return [ - '#theme' => 'hakuvahti_failed_submission', + '#theme' => 'hakuvahti_confirmation', '#title' => $this->t('Deleting failed', [], ['context' => 'Hakuvahti']), '#message' => $this->t('Deleting saved search failed. Please try again.', [], ['context' => 'Hakuvahti']), ]; diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig b/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig deleted file mode 100644 index 9a836e4d..00000000 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-failed-submission.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { message: message } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig deleted file mode 100644 index 8b224904..00000000 --- a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-confirm-form.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig deleted file mode 100644 index 8b224904..00000000 --- a/public/themes/custom/hdbt_subtheme/templates/form/form--hakuvahti-unsubscribe-form.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-confirm-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-confirm-form.html.twig new file mode 100644 index 00000000..d5db4b6e --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-confirm-form.html.twig @@ -0,0 +1 @@ +{% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-unsubscribe-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-unsubscribe-form.html.twig new file mode 100644 index 00000000..d5db4b6e --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/form--hakuvahti-unsubscribe-form.html.twig @@ -0,0 +1 @@ +{% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig" with { content: children } %} diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig similarity index 75% rename from public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig rename to public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig index 923e78a3..8159a6af 100644 --- a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-confirmation-wrapper.twig +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig @@ -7,7 +7,7 @@ %} {% block component_content %} {% if message %} - {% include "@hdbt_subtheme/form/hakuvahti-message-wrapper.twig" with { message: message } %} + {% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-message-wrapper.twig" with { message: message } %} {% endif %} {{ content }} {% endblock component_content %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig similarity index 50% rename from public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig rename to public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig index 5b12630c..887f7ff3 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-confirmation.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig @@ -4,4 +4,4 @@ {% endset %} {% endif %} -{% include "@hdbt_subtheme/form/hakuvahti-confirmation-wrapper.twig" with { message: message, content: link, } %} +{% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig" with { message: message, content: link, } %} diff --git a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-form.html.twig similarity index 60% rename from public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig rename to public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-form.html.twig index 22c7600c..04141008 100644 --- a/public/modules/custom/helfi_hakuvahti/templates/hakuvahti-form.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-form.html.twig @@ -1,5 +1,5 @@ {% block content %} - {% include "@hdbt_subtheme/form/hakuvahti-message-wrapper.twig" with { message: message } %} + {% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-message-wrapper.twig" with { message: message } %}
diff --git a/public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-message-wrapper.twig similarity index 100% rename from public/themes/custom/hdbt_subtheme/templates/form/hakuvahti-message-wrapper.twig rename to public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-message-wrapper.twig From f0822af3cb6691fa1edd7ccf71c9546f5d235a30 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 14:37:16 +0300 Subject: [PATCH 60/65] Wrap the back-link to paragraph tag --- .../module/helfi_hakuvahti/hakuvahti-confirmation.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig index 887f7ff3..384d6aa0 100644 --- a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-confirmation.html.twig @@ -1,6 +1,6 @@ {% if link_text and link_url %} {% set link %} - {{ link_text }} +

{{ link_text }}

{% endset %} {% endif %} From daa1f3f64ef9fe6acab2c07b330b32f884e40104 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 14:41:06 +0300 Subject: [PATCH 61/65] Streamline the action wrapper template a bit --- .../module/helfi_hakuvahti/hakuvahti-action-wrapper.twig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig index 8159a6af..191d5060 100644 --- a/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig +++ b/public/themes/custom/hdbt_subtheme/templates/module/helfi_hakuvahti/hakuvahti-action-wrapper.twig @@ -1,10 +1,6 @@
- {% embed "@hdbt/misc/component.twig" with - { - component_classes: 'component--hakuvahti-form' - } - %} + {% embed "@hdbt/misc/component.twig" with { component_classes: 'component--hakuvahti-form'} %} {% block component_content %} {% if message %} {% include "@hdbt_subtheme/module/helfi_hakuvahti/hakuvahti-message-wrapper.twig" with { message: message } %} From 0d99f5ee63190f74f53ea612c9cdf28d6f425b3f Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Tue, 28 May 2024 14:48:08 +0300 Subject: [PATCH 62/65] Change the network name to correct one --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 99e98d75..6d03ff95 100644 --- a/compose.yaml +++ b/compose.yaml @@ -38,7 +38,7 @@ services: networks: - internal - stonehenge-network - - hakuvahti_hav-network + - helfi-hakuvahti_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" @@ -147,7 +147,7 @@ networks: external: false stonehenge-network: external: true - hakuvahti_hav-network: + helfi-hakuvahti_hav-network: external: true volumes: From 7cd5fe584844000ea1a76995dcf189e17f9de36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Tue, 28 May 2024 18:33:44 +0300 Subject: [PATCH 63/65] Hopefully fix docker connection to HAV --- compose.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 6d03ff95..2acae435 100644 --- a/compose.yaml +++ b/compose.yaml @@ -38,7 +38,7 @@ services: networks: - internal - stonehenge-network - - helfi-hakuvahti_hav-network + - helfi-hav_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" @@ -113,6 +113,7 @@ services: networks: - internal - stonehenge-network + - helfi-hav_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.entrypoints=https" @@ -147,7 +148,7 @@ networks: external: false stonehenge-network: external: true - helfi-hakuvahti_hav-network: + helfi-hav_hav-network: external: true volumes: From 1df6b4bd576c88d63b315f06fd10bfc33fca4104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 29 May 2024 11:32:02 +0300 Subject: [PATCH 64/65] Network naming fix --- compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index 2acae435..2458acee 100644 --- a/compose.yaml +++ b/compose.yaml @@ -38,7 +38,7 @@ services: networks: - internal - stonehenge-network - - helfi-hav_hav-network + - helfi-hakuvahti_helfi-hav_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" @@ -113,7 +113,7 @@ services: networks: - internal - stonehenge-network - - helfi-hav_hav-network + - helfi-hakuvahti_helfi-hav_hav-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.entrypoints=https" @@ -148,7 +148,7 @@ networks: external: false stonehenge-network: external: true - helfi-hav_hav-network: + helfi-hakuvahti_helfi-hav_hav-network: external: true volumes: From e65f59fcbb6ba9727c765174045da3e6c45dc380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20Sundstr=C3=B6m?= Date: Wed, 29 May 2024 11:39:55 +0300 Subject: [PATCH 65/65] Network naming fix --- compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index 2458acee..bd855043 100644 --- a/compose.yaml +++ b/compose.yaml @@ -38,7 +38,7 @@ services: networks: - internal - stonehenge-network - - helfi-hakuvahti_helfi-hav_hav-network + - helfi-hakuvahti_helfi-hakuvahti-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" @@ -113,7 +113,7 @@ services: networks: - internal - stonehenge-network - - helfi-hakuvahti_helfi-hav_hav-network + - helfi-hakuvahti_helfi-hakuvahti-network labels: - "traefik.enable=true" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.entrypoints=https" @@ -148,7 +148,7 @@ networks: external: false stonehenge-network: external: true - helfi-hakuvahti_helfi-hav_hav-network: + helfi-hakuvahti_helfi-hakuvahti-network: external: true volumes: