diff --git a/conf/cmi/views.view.job_listing_search.yml b/conf/cmi/views.view.job_listing_search.yml index b05cea64..4d07641d 100644 --- a/conf/cmi/views.view.job_listing_search.yml +++ b/conf/cmi/views.view.job_listing_search.yml @@ -158,7 +158,44 @@ display: label: '' field_identifier: '' exposed: false - arguments: { } + arguments: + field_task_area_target_id: + id: field_task_area_target_id + table: node__field_task_area + field: field_task_area_target_id + relationship: none + group_type: group + admin_label: '' + plugin_id: numeric + default_action: default + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: query_parameter + default_argument_options: + query_param: task_areas + fallback: all + multiple: and + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + override: false + items_per_page: 25 + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + break_phrase: false + not: false filters: status: id: status @@ -182,6 +219,7 @@ display: plugin_id: bundle value: job_listing: job_listing + group: 1 expose: operator_limit_selection: false operator_list: { } @@ -227,6 +265,10 @@ display: default_group: All default_group_multiple: { } group_items: { } + filter_groups: + operator: AND + groups: + 1: AND style: type: default row: @@ -251,6 +293,7 @@ display: contexts: - 'languages:language_content' - 'languages:language_interface' + - url - url.query_args - 'user.node_grants:view' - user.permissions @@ -267,6 +310,7 @@ display: contexts: - 'languages:language_content' - 'languages:language_interface' + - url - url.query_args - 'user.node_grants:view' - user.permissions diff --git a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module index a263ead1..deab53ab 100644 --- a/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module +++ b/public/modules/custom/helfi_rekry_content/helfi_rekry_content.module @@ -16,6 +16,8 @@ use Drupal\media\OEmbed\ResourceException; use Drupal\migrate\MigrateSkipRowException; use Drupal\node\NodeInterface; use Drupal\paragraphs\ParagraphInterface; +use Drupal\views\Plugin\views\query\QueryPluginBase; +use Drupal\views\ViewExecutable; /** * Implements hook_entity_bundle_info_alter(). @@ -448,6 +450,37 @@ function helfi_rekry_content_preprocess_block(&$variables) { } } +/** + * Implements hook_views_query_alter(). + */ +function helfi_rekry_content_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { + if ($view->id() !== 'job_listing_search') { + return; + } + + if (!isset($query->where[0]["conditions"][0])) { + return; + } + + $task_area_external_id = $query + ->where[0]["conditions"][0]["value"][":node__field_task_area_field_task_area_target_id"]; + + if (!$task_area_external_id) { + return; + } + + /** @var \Drupal\taxonomy\Entity\Term $term */ + $terms = \Drupal::entityTypeManager() + ->getStorage('taxonomy_term') + ->loadByProperties(['field_external_id' => $task_area_external_id]); + if (!$terms) { + return; + } + + $term = reset($terms); + $query->where[0]["conditions"][0]["value"][":node__field_task_area_field_task_area_target_id"] = $term->id(); +} + /** * Implements hook_page_attachments(). */