Skip to content

Commit

Permalink
Merge pull request #796 from USEPA/EPAD8-1266-dynamic-lists-sort-options
Browse files Browse the repository at this point in the history
[EPAD8-1266] - adding sorts to daymic event and faq list views, updat…
  • Loading branch information
azinck authored Nov 14, 2022
2 parents 17d6630 + c9ae569 commit 4c89006
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 10 deletions.
53 changes: 51 additions & 2 deletions services/drupal/config/sync/views.view.dynamic_event_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ display:
plugin_id: date
order: ASC
expose:
label: ''
label: 'Date - Start'
field_identifier: field_daterange_value
exposed: false
exposed: true
granularity: second
arguments: { }
filters:
Expand Down Expand Up @@ -815,6 +815,8 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'url.query_args:sort_by'
- 'url.query_args:sort_order'
- user
- 'user.node_grants:view'
- user.permissions
Expand All @@ -825,6 +827,50 @@ display:
display_plugin: block
position: 1
display_options:
sorts:
field_daterange_value:
id: field_daterange_value
table: node__field_daterange
field: field_daterange_value
relationship: none
group_type: group
admin_label: ''
plugin_id: date
order: ASC
expose:
label: 'Event Date'
field_identifier: field_daterange_value
exposed: true
granularity: second
field_last_published_value:
id: field_last_published_value
table: node__field_last_published
field: field_last_published_value
relationship: none
group_type: group
admin_label: ''
plugin_id: datetime
order: ASC
expose:
label: 'Publication Date'
field_identifier: field_last_published_value
exposed: true
granularity: second
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: title
plugin_id: standard
order: ASC
expose:
label: Title
field_identifier: title
exposed: true
style:
type: epa_core_uswds_collection
options:
Expand All @@ -837,6 +883,7 @@ display:
defaults:
style: false
row: false
sorts: false
display_description: ''
display_extenders:
views_ajax_get:
Expand All @@ -847,6 +894,8 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'url.query_args:sort_by'
- 'url.query_args:sort_order'
- user
- 'user.node_grants:view'
- user.permissions
Expand Down
39 changes: 37 additions & 2 deletions services/drupal/config/sync/views.view.dynamic_faq_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ display:
plugin_id: datetime
order: DESC
expose:
label: 'Last published'
label: 'Last published (field_last_published)'
field_identifier: field_last_published_value
exposed: false
exposed: true
granularity: second
arguments: { }
filters:
Expand Down Expand Up @@ -714,6 +714,8 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'url.query_args:sort_by'
- 'url.query_args:sort_order'
- user
- 'user.node_grants:view'
- user.permissions
Expand All @@ -724,6 +726,36 @@ display:
display_plugin: block
position: 1
display_options:
sorts:
field_last_published_value:
id: field_last_published_value
table: node__field_last_published
field: field_last_published_value
relationship: none
group_type: group
admin_label: ''
plugin_id: datetime
order: DESC
expose:
label: 'Publication Date'
field_identifier: field_last_published_value
exposed: true
granularity: second
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: title
plugin_id: standard
order: ASC
expose:
label: Title
field_identifier: title
exposed: true
style:
type: epa_core_uswds_collection
options:
Expand All @@ -736,6 +768,7 @@ display:
defaults:
style: false
row: false
sorts: false
display_description: ''
display_extenders:
views_ajax_get:
Expand All @@ -746,6 +779,8 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'url.query_args:sort_by'
- 'url.query_args:sort_order'
- user
- 'user.node_grants:view'
- user.permissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ function epa_viewsreference_field_widget_form_alter(array &$element, FormStateIn
$element["options"]["exposed_filters"]["vr_exposed_filters_visible"]['#access'] = FALSE;
}

// Make "DESC" be the default sort order for Perspectives.
if (isset($element["target_id"]["#default_value"]) && $element["target_id"]["#default_value"] === 'dynamic_list_perspectives' && isset($element['options']['exposed_sorts']['sort_order']['#options'])) {
$element['options']['exposed_sorts']['sort_order']['#options'] = [
'DESC' => t('Desc'),
'ASC' => t('Asc'),
];
// Make "DESC" be the default sort order for Perspectives and FAQ List.
$view_types = ['dynamic_faq_list', 'dynamic_list_perspectives'];
if (in_array($element["target_id"]["#default_value"], $view_types)) {
$data = $context['items'][0]->getValue('data');
$data_values = unserialize($data['data']);
$sort_order = $data_values['exposed_sorts']['sort_order'];
if (empty($sort_order)) {
$element["options"]["exposed_sorts"]["sort_order"]["#default_value"] = 'DESC';
}
}
}
}

0 comments on commit 4c89006

Please sign in to comment.