Skip to content

Commit

Permalink
Merge pull request #868 from UN-OCHA/release-versions/v1.6.5
Browse files Browse the repository at this point in the history
release versions/v1.6.5
  • Loading branch information
berliner authored Dec 7, 2023
2 parents aba7c11 + 4496713 commit 40facc3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"Issue #2958568: Add a search api processor for view unpublished": "./patches/2958568-view-unpublished-search-api-access-17.patch"
},
"drupal/webp": {
"Issue #3325808: Webp Image not generated for styles using original image.": "https://www.drupal.org/files/issues/2022-12-19/webp-3325808-2.patch",
"Issue #3325808: Webp Image not generated for styles using original image.": "https://www.drupal.org/files/issues/2023-12-07/webp-3325808-11.patch",
"Issue #3281606: Rendering duplicate images when the original images have the same name but different extension": "https://git.drupalcode.org/project/webp/-/merge_requests/30.patch",
"Issue #3153137: Using Image Widget Crop in responsive images does not refresh webp image": "./patches/3153137-custom-fix-3281606.patch"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,18 @@ public static function processEntityAttachmentSelect(array &$element, FormStateI
],
];

// Remove invalid ids from the entity_ids passed in via #default_value.
$context = $element['#element_context'];
$plan_id = $context['plan_object']->get('field_original_id')->value;
$plan_entities = self::getPlanEntitiesQuery($plan_id)->getPlanEntities($context['base_object']);
$valid_entity_ids = [$plan_id] + array_keys($plan_entities);
$defaults['entities']['entity_ids'] = array_filter($defaults['entities']['entity_ids'] ?? [], function ($_entity_id) use ($valid_entity_ids) {
return in_array($_entity_id, $valid_entity_ids);
});

$form_state->set('entities', $defaults['entities']);
$triggering_element = $form_state->getTriggeringElement();
$action = $triggering_element ? end($form_state->getTriggeringElement()['#parents']) : NULL;
$action = $triggering_element && array_key_exists('#parents', $triggering_element) ? end($triggering_element['#parents']) : NULL;
$actions_map = [
'select_entities' => 'select_attachments',
'change_entities' => 'select_entities',
Expand Down Expand Up @@ -183,7 +192,7 @@ public static function processEntityAttachmentSelect(array &$element, FormStateI
'wrapper' => $wrapper_id,
],
'#attributes' => [
'class' => [$current_action != 'select_entities' ? 'visually-hidden' : NULL],
'class' => $current_action != 'select_entities' ? ['visually-hidden'] : [],
],
];
$element['actions']['change_entities'] = [
Expand All @@ -195,8 +204,10 @@ public static function processEntityAttachmentSelect(array &$element, FormStateI
'wrapper' => $wrapper_id,
],
'#attributes' => [
'class' => [$current_action != 'select_attachments' ? 'visually-hidden' : NULL],
'class' => $current_action != 'select_attachments' ? ['visually-hidden'] : [],
],
'#limit_validation_errors' => [],
'#submit' => [],
];
$element['actions']['select_attachments'] = [
'#type' => 'submit',
Expand All @@ -207,7 +218,7 @@ public static function processEntityAttachmentSelect(array &$element, FormStateI
'wrapper' => $wrapper_id,
],
'#attributes' => [
'class' => [$current_action != 'select_attachments' ? 'visually-hidden' : NULL],
'class' => $current_action != 'select_attachments' ? ['visually-hidden'] : [],
],
];
if (!empty($element['#next_step']) && !empty($element['#container_wrapper'])) {
Expand All @@ -233,4 +244,29 @@ public static function preRenderEntityAttachmentSelect(array $element) {
return $element;
}

/**
* Get the endpoint query manager service.
*
* @return \Drupal\hpc_api\Query\EndpointQueryManager
* The endpoint query manager service.
*/
private static function getEndpointQueryManager() {
return \Drupal::service('plugin.manager.endpoint_query_manager');
}

/**
* Get the plan entities query service.
*
* @param int $plan_id
* The plan id for which a query should be build.
*
* @return \Drupal\ghi_plans\Plugin\EndpointQuery\PlanEntitiesQuery
* The plan entities query plugin.
*/
public static function getPlanEntitiesQuery($plan_id) {
$query_handler = self::getEndpointQueryManager()->createInstance('plan_entities_query');
$query_handler->setPlaceholder('plan_id', $plan_id);
return $query_handler;
}

}

0 comments on commit 40facc3

Please sign in to comment.