Skip to content

Commit

Permalink
Merge pull request #1505 from GSA/b-release-v0.4.1.beta.1
Browse files Browse the repository at this point in the history
Release v0.4.1.beta.1
  • Loading branch information
scottqueen-bixal authored Jun 26, 2024
2 parents 4efe680 + 74c2645 commit f474ff9
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 21 deletions.
4 changes: 2 additions & 2 deletions benefit-finder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benefit-finder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "benefit-finder",
"version": "0.4.0.beta.1",
"version": "0.4.1.beta.1",
"private": true,
"engines": {
"node": "20.x.x"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`loads intro 1`] = `
<div
class="benefit-finder "
data-testid="app"
data-version="0.4.0.beta.1"
data-version="0.4.1.beta.1"
>
<div
class="bf-intro"
Expand Down Expand Up @@ -270,7 +270,7 @@ exports[`loads window query scenario 1 1`] = `
<div
class="benefit-finder "
data-testid="app"
data-version="0.4.0.beta.1"
data-version="0.4.1.beta.1"
>
<div
class="bf-result-view"
Expand Down Expand Up @@ -7026,7 +7026,7 @@ exports[`loads window query scenario 2 1`] = `
<div
class="benefit-finder "
data-testid="app"
data-version="0.4.0.beta.1"
data-version="0.4.1.beta.1"
>
<div
class="bf-result-view"
Expand Down
12 changes: 12 additions & 0 deletions restore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Finding the service instance details...
Setting up SSH tunnel...
SSH tunnel created.
Skipping call to client CLI. Connection information:

Host: localhost
Port: 44265
Username: u1pqgr5amf7bbsm3
Password: o95jv0wxlkynbk5qx7fxbmc6o
Name: cgawsbrokerprodoly1e52tnaanm56

Leave this terminal open while you want to use the SSH tunnel. Press Control-C to stop.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ status: true
dependencies:
config:
- field.field.node.bears_life_event.field_b_id
- field.field.node.bears_life_event.field_b_search_title
- field.field.node.bears_life_event.field_draft_json_data_file
- field.field.node.bears_life_event.field_draft_json_data_file_path
- field.field.node.bears_life_event.field_header_html
Expand All @@ -28,7 +29,7 @@ mode: default
content:
created:
type: datetime_timestamp
weight: 9
weight: 10
region: content
settings: { }
third_party_settings: { }
Expand All @@ -40,24 +41,32 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
field_b_search_title:
type: string_textfield
weight: 7
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_draft_json_data_file:
type: file_generic
weight: 20
weight: 21
region: content
settings:
progress_indicator: throbber
third_party_settings: { }
field_draft_json_data_file_path:
type: string_textfield
weight: 18
weight: 19
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_header_html:
type: text_textarea
weight: 21
weight: 22
region: content
settings:
rows: 5
Expand All @@ -68,14 +77,14 @@ content:
hide_guidelines: '0'
field_json_data_file:
type: file_generic
weight: 19
weight: 20
region: content
settings:
progress_indicator: throbber
third_party_settings: { }
field_json_data_file_path:
type: string_textfield
weight: 17
weight: 18
region: content
settings:
size: 60
Expand Down Expand Up @@ -117,7 +126,7 @@ content:
third_party_settings: { }
field_summary:
type: string_textarea
weight: 7
weight: 8
region: content
settings:
rows: 5
Expand All @@ -132,38 +141,38 @@ content:
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 15
weight: 16
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 12
weight: 13
region: content
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
weight: 10
weight: 11
region: content
settings:
display_label: true
third_party_settings: { }
simple_sitemap:
weight: 14
weight: 15
region: content
settings: { }
third_party_settings: { }
status:
type: boolean_checkbox
weight: 16
weight: 17
region: content
settings:
display_label: true
third_party_settings: { }
sticky:
type: boolean_checkbox
weight: 11
weight: 12
region: content
settings:
display_label: true
Expand All @@ -183,7 +192,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 8
weight: 9
region: content
settings:
match_operator: CONTAINS
Expand All @@ -192,7 +201,7 @@ content:
placeholder: ''
third_party_settings: { }
url_redirects:
weight: 13
weight: 14
region: content
settings: { }
third_party_settings: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ status: true
dependencies:
config:
- field.field.node.bears_life_event.field_b_id
- field.field.node.bears_life_event.field_b_search_title
- field.field.node.bears_life_event.field_draft_json_data_file
- field.field.node.bears_life_event.field_draft_json_data_file_path
- field.field.node.bears_life_event.field_header_html
Expand Down Expand Up @@ -37,6 +38,14 @@ content:
third_party_settings: { }
weight: 2
region: content
field_b_search_title:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 12
region: content
field_draft_json_data_file:
type: file_default
label: above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.bears_life_event.field_b_id
- field.field.node.bears_life_event.field_b_search_title
- field.field.node.bears_life_event.field_draft_json_data_file
- field.field.node.bears_life_event.field_draft_json_data_file_path
- field.field.node.bears_life_event.field_header_html
Expand Down Expand Up @@ -35,6 +36,7 @@ content:
region: content
hidden:
field_b_id: true
field_b_search_title: true
field_draft_json_data_file: true
field_draft_json_data_file_path: true
field_header_html: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: 4cfe5edb-4b13-42ac-98b0-3cd6416cd289
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_b_search_title
- node.type.bears_life_event
id: node.bears_life_event.field_b_search_title
field_name: field_b_search_title
entity_type: node
bundle: bears_life_event
label: 'Search Title'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
uuid: ee685fe0-3e6b-4b9a-8c8a-d1733cd1dabd
langcode: en
status: true
dependencies:
module:
- field_permissions
- node
third_party_settings:
field_permissions:
permission_type: public
id: node.field_b_search_title
field_name: field_b_search_title
entity_type: node
type: string
settings:
max_length: 255
case_sensitive: false
is_ascii: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,92 @@ function _usagov_benefit_finder_content_check_criteria_usage_in_benefit(int $nid

return $return;
}

/**
* Implements hook_form_FORM_ID_alter().
*
* @param array $form
* Form array.
* @param FormStateInterface $form_state
* Form state object.
*/
function usagov_benefit_finder_content_form_node_bears_criteria_edit_form_alter(array &$form, FormStateInterface $form_state) {
$form['#validate'][] = '_usagov_benefit_finder_content_node_bears_criteria_edit_form_validate';
}

/**
* Validates criteria edit form hasChild field.
*
* @param array $form
* Form array.
* @param FormStateInterface $form_state
* Form state object.
*/
function _usagov_benefit_finder_content_node_bears_criteria_edit_form_validate(array $form, FormStateInterface $form_state) {
$errors = [];
$error_count = 0;

$has_child = $form_state->getValue('field_b_has_child');

if ($has_child['value']) {
return;
}

$node = \Drupal::routeMatch()->getParameter('node');
$nid = $node->id();

$result = _usagov_benefit_finder_content_check_criteria_has_child($nid);
if (!empty($result)) {
foreach ($result as $row) {
$errors[] = t("Can not uncheck \"Has Child\" field. There are related child values in the Life event form: $row[title] ($row[nid])");
}
}

if (!empty($errors)) {
foreach ($errors as $error) {
$form_state->setErrorByName((string) ++$error_count, $error);
}
}
}

/**
* It checks if criteria has child.
*
* @param int $nid
* Node ID of given criteria.
*/
function _usagov_benefit_finder_content_check_criteria_has_child(int $nid) {
$return = [];

$connection = Database::getConnection();

$query = $connection->select('paragraph__field_b_children', 't');
$query->fields('t', ['entity_id']);
$query->condition('t.bundle', 'b_levent_elg_criteria');
$result = $query->execute();

$entity_ids = [];
foreach ($result as $row) {
$entity_ids[] = $row->entity_id;
}

if (empty($entity_ids)) {
return $return;
}

$query = $connection->select('node_field_data', 't1');
$query->join('node__field_b_sections_elg_criteria', 't2', 't1.nid = t2.entity_id');
$query->join('paragraph__field_b_criterias', 't3', 't2.field_b_sections_elg_criteria_target_id = t3.entity_id');
$query->join('paragraph__field_b_criteria_key', 't4', 't3.field_b_criterias_target_id = t4.entity_id');
$query->fields('t1', ['title', 'nid']);
$query->condition('t4.field_b_criteria_key_target_id', $nid);
$query->condition('t3.field_b_criterias_target_id', $entity_ids, 'IN');
$query->orderBy('title');
$result = $query->execute();

foreach ($result as $row) {
$return[] = ['nid' => $row->nid, 'title' => $row->title];
}

return $return;
}

0 comments on commit f474ff9

Please sign in to comment.