Skip to content

Commit

Permalink
Merge pull request #342 from City-of-Helsinki/UHF-8478_Remove_field_c…
Browse files Browse the repository at this point in the history
…opied

UHF-8478: Remove deprecated helfi_rekry_job_search module
  • Loading branch information
xkhaven authored Nov 16, 2023
2 parents 206fc5f + a422331 commit 2bf98e3
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -99,13 +98,6 @@ content:
rows: 5
placeholder: ''
third_party_settings: { }
field_copied:
type: boolean_checkbox
weight: 42
region: content
settings:
display_label: true
third_party_settings: { }
field_employment:
type: entity_reference_autocomplete
weight: 20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -243,7 +242,6 @@ content:
region: content
hidden:
field_anonymous: true
field_copied: true
field_jobs: true
field_last_changed_remote: true
field_original_language: true
Expand Down
2 changes: 0 additions & 2 deletions conf/cmi/core.entity_view_display.node.job_listing.teaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -77,7 +76,6 @@ hidden:
field_address: true
field_anonymous: true
field_contacts: true
field_copied: true
field_employment: true
field_image: true
field_job_description_override: true
Expand Down
1 change: 0 additions & 1 deletion conf/cmi/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ module:
helfi_proxy: 0
helfi_react_search: 0
helfi_rekry_content: 0
helfi_rekry_job_search: 0
helfi_toc: 0
helfi_tunnistamo: 0
helfi_user_roles: 0
Expand Down
29 changes: 0 additions & 29 deletions conf/cmi/field.field.node.job_listing.field_copied.yml

This file was deleted.

18 changes: 0 additions & 18 deletions conf/cmi/field.storage.node.field_copied.yml

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 7 additions & 16 deletions conf/cmi/search_api.index.job_listings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ langcode: en
status: true
dependencies:
config:
- field.storage.node.field_original_language
- field.storage.node.field_task_area
- field.storage.taxonomy_term.field_external_id
- field.storage.node.field_copied
- field.storage.node.field_employment_type
- field.storage.node.field_employment
- field.storage.taxonomy_term.field_search_id
- field.storage.node.field_employment_type
- field.storage.taxonomy_term.field_external_id
- field.storage.node.field_job_duration
- field.storage.node.field_publication_starts
- field.storage.node.field_organization_name
- field.storage.node.field_organization
- field.storage.node.field_jobs
- field.storage.node.field_organization
- field.storage.node.field_organization_name
- field.storage.node.field_original_language
- field.storage.node.field_postal_area
- field.storage.node.field_promoted
- field.storage.node.field_publication_starts
- field.storage.node.field_recruitment_id
- field.storage.node.field_recruitment_type
- field.storage.node.field_task_area
- search_api.server.elastic_rekry
module:
- taxonomy
Expand Down Expand Up @@ -66,14 +65,6 @@ field_settings:
label: 'Entity type'
property_path: search_api_entity_type
type: string
field_copied:
label: 'Copied from another language'
datasource_id: 'entity:node'
property_path: field_copied
type: boolean
dependencies:
config:
- field.storage.node.field_copied
field_employment:
label: 'Employment » Taxonomy term » Name'
datasource_id: 'entity:node'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -99,13 +98,6 @@ content:
rows: 5
placeholder: ''
third_party_settings: { }
field_copied:
type: boolean_checkbox
weight: 42
region: content
settings:
display_label: true
third_party_settings: { }
field_employment:
type: entity_reference_autocomplete
weight: 20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -243,7 +242,6 @@ content:
region: content
hidden:
field_anonymous: true
field_copied: true
field_jobs: true
field_last_changed_remote: true
field_original_language: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- field.field.node.job_listing.field_address
- field.field.node.job_listing.field_anonymous
- field.field.node.job_listing.field_contacts
- field.field.node.job_listing.field_copied
- field.field.node.job_listing.field_employment
- field.field.node.job_listing.field_employment_type
- field.field.node.job_listing.field_image
Expand Down Expand Up @@ -77,7 +76,6 @@ hidden:
field_address: true
field_anonymous: true
field_contacts: true
field_copied: true
field_employment: true
field_image: true
field_job_description_override: true
Expand Down

This file was deleted.

This file was deleted.

101 changes: 99 additions & 2 deletions public/modules/custom/helfi_rekry_content/helfi_rekry_content.module
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare(strict_types = 1);
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\helfi_platform_config\DTO\ParagraphTypeCollection;
use Drupal\helfi_rekry_content\Entity\JobListing;
use Drupal\media\OEmbed\ProviderException;
use Drupal\media\OEmbed\ResourceException;
Expand Down Expand Up @@ -67,7 +68,6 @@ function helfi_rekry_content_form_node_job_listing_edit_form_alter(array &$form,
'field_employment',
'field_image',
'field_video',
'field_copied',
'field_original_language',
'field_anonymous',
];
Expand Down Expand Up @@ -308,7 +308,6 @@ function helfi_rekry_content_preprocess_field(&$variables) {
if (
!$node instanceof NodeInterface ||
$node->getType() !== 'job_listing' ||
($node->hasField('field_copied') && $node->get('field_copied')->isEmpty()) ||
($node->hasField('field_original_language') && $node->get('field_original_language')->isEmpty())
) {
return;
Expand Down Expand Up @@ -567,3 +566,101 @@ function helfi_rekry_content_page_attachments(array &$attachments) : void {
];
}
}

/**
* Implements hook_page_attachments_alter().
*
* Update job search's task area pages metadata.
*/
function helfi_rekry_content_page_attachments_alter(array &$attachments) {
$queryParams = \Drupal::request()->query->all();

if (!array_key_exists('task_areas', $queryParams)) {
return;
}

// Only task_area and page paramaters allowed.
foreach ($queryParams as $queryParam => $queryParamValue) {
if ($queryParam !== 'task_areas' && $queryParam !== 'page') {
return;
}
}

// Only one task_area category allowed.
if (substr_count(\Drupal::request()->getRequestUri(), 'task_areas') > 1) {
return;
}

$currentUri = \Drupal::request()->getUri();
$langcode = \Drupal::languageManager()
->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
->getId();
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties([
'vid' => 'task_area',
'field_external_id' => $queryParams['task_areas'],
]);

$term = reset($term);
if ($term && $term->hasTranslation($langcode)) {
$term = $term->getTranslation($langcode);
}

if ($term && $term->hasField('field_meta_description') && !$term->get('field_meta_description')->isEmpty()) {
$description = [
'#tag' => 'meta',
'#attributes' => [
'name' => 'description',
'content' => $term->get('field_meta_description')->getString(),
],
];

$attachments['#attached']['html_head'][] = [$description, 'description'];
}

foreach ($attachments['#attached']['html_head'] as $key => $head) {
switch ($head[1]) {
case 'canonical_url':
$attachments['#attached']['html_head'][$key][0]['#attributes']['href'] = $currentUri;
break;

case 'og_url':
case 'twitter_cards_page_url':
$attachments['#attached']['html_head'][$key][0]['#attributes']['content'] = $currentUri;
break;

case 'og_title':
case 'twitter_cards_title':
if ($term && $term->hasField('field_metadata') && !$term->get('field_metadata')->isEmpty()) {
$attachments['#attached']['html_head'][$key][0]['#attributes']['content'] = $term->get('field_metadata')->getString();
}
break;
}
}
}

/**
* Implements hook_helfi_paragraph_types().
*/
function helfi_rekry_content_helfi_paragraph_types() : array {
$entities = [
'node' => [
'landing_page' => [
'field_content' => [
'job_search',
],
],
],
];

$enabled = [];
foreach ($entities as $entityTypeId => $bundles) {
foreach ($bundles as $bundle => $fields) {
foreach ($fields as $field => $paragraphTypes) {
foreach ($paragraphTypes as $paragraphType) {
$enabled[] = new ParagraphTypeCollection($entityTypeId, $bundle, $field, $paragraphType);
}
}
}
}
return $enabled;
}
Loading

0 comments on commit 2bf98e3

Please sign in to comment.