Commit 872e83f1 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-5210-ebremner-opportunity-layout-builder-block' into '1.0.x'

Feature/istwcms 5210 ebremner opportunity layout builder block

See merge request !10
parents aa737dab 3e405bc4
......@@ -21,7 +21,6 @@ dependencies:
- field.field.node.uw_ct_opportunity.layout_builder__layout
- node.type.uw_ct_opportunity
module:
- content_moderation
- datetime
- field_group
- link
......
......@@ -18,12 +18,17 @@ dependencies:
- field.storage.node.field_uw_opportunity_start_date
- field.storage.node.field_uw_opportunity_type
- node.type.uw_ct_opportunity
- taxonomy.vocabulary.uw_vocab_opportunity_employment
- taxonomy.vocabulary.uw_vocab_opportunity_payrate
- taxonomy.vocabulary.uw_vocab_opportunity_type
module:
- better_exposed_filters
- datetime
- link
- node
- options
- smart_date
- taxonomy
- text
- user
id: uw_view_opportunities
......@@ -620,6 +625,441 @@ display:
- 'config:field.storage.node.field_uw_opportunity_deadline'
- 'config:field.storage.node.field_uw_opportunity_pos_number'
- 'config:field.storage.node.field_uw_opportunity_type'
block_1:
display_plugin: block
id: block_1
display_title: Block
position: 3
display_options:
display_extenders:
metatag_display_extender: { }
allow:
items_per_page: true
customizable_exposed_filters:
- field_uw_opportunity_type_target_id
- field_uw_opportunity_employment_target_id
- field_uw_opportunity_pay_type_target_id
pager:
type: some
options:
items_per_page: 3
offset: 0
defaults:
pager: false
filters: false
filter_groups: false
style: false
row: false
arguments: false
exposed_form: false
use_ajax: false
title: false
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
group: 1
type:
id: type
table: node_field_data
field: type
value:
uw_ct_opportunity: uw_ct_opportunity
entity_type: node
entity_field: type
plugin_id: bundle
expose:
operator_limit_selection: false
operator_list: { }
group: 1
field_uw_opportunity_date_value:
id: field_uw_opportunity_date_value
table: node__field_uw_opportunity_date
field: field_uw_opportunity_date_value
relationship: none
group_type: group
admin_label: ''
operator: '<='
value:
min: ''
max: ''
value: now
type: offset
group: 1
exposed: false
expose:
operator_id: field_uw_opportunity_date_value_op
label: 'Date posted/application open'
description: ''
use_operator: false
operator: field_uw_opportunity_date_value_op
operator_limit_selection: false
operator_list: { }
identifier: field_uw_opportunity_date_value
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
administrator: '0'
anonymous: '0'
uw_role_site_owner: '0'
uw_role_site_manager: '0'
uw_role_content_author: '0'
uw_role_content_editor: '0'
uw_role_form_editor: '0'
uw_role_form_results_access: '0'
placeholder: ''
min_placeholder: ''
max_placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: datetime
field_uw_opportunity_type_target_id:
id: field_uw_opportunity_type_target_id
table: node__field_uw_opportunity_type
field: field_uw_opportunity_type_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_uw_opportunity_type_target_id_op
label: 'Opportunity type'
description: ''
use_operator: false
operator: field_uw_opportunity_type_target_id_op
operator_limit_selection: false
operator_list: { }
identifier: opportunity_type
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
administrator: '0'
anonymous: '0'
uw_role_site_owner: '0'
uw_role_site_manager: '0'
uw_role_content_author: '0'
uw_role_content_editor: '0'
uw_role_form_editor: '0'
uw_role_form_results_access: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
type: select
limit: true
vid: uw_vocab_opportunity_type
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
field_uw_opportunity_employment_target_id:
id: field_uw_opportunity_employment_target_id
table: node__field_uw_opportunity_employment
field: field_uw_opportunity_employment_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_uw_opportunity_employment_target_id_op
label: 'Employment type'
description: ''
use_operator: false
operator: field_uw_opportunity_employment_target_id_op
operator_limit_selection: false
operator_list: { }
identifier: employment_type
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
administrator: '0'
anonymous: '0'
uw_role_site_owner: '0'
uw_role_site_manager: '0'
uw_role_content_author: '0'
uw_role_content_editor: '0'
uw_role_form_editor: '0'
uw_role_form_results_access: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
type: select
limit: true
vid: uw_vocab_opportunity_employment
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
field_uw_opportunity_pay_type_target_id:
id: field_uw_opportunity_pay_type_target_id
table: node__field_uw_opportunity_pay_type
field: field_uw_opportunity_pay_type_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_uw_opportunity_pay_type_target_id_op
label: 'Rate of pay type'
description: ''
use_operator: false
operator: field_uw_opportunity_pay_type_target_id_op
operator_limit_selection: false
operator_list: { }
identifier: rate_pay_type
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
administrator: '0'
anonymous: '0'
uw_role_site_owner: '0'
uw_role_site_manager: '0'
uw_role_content_author: '0'
uw_role_content_editor: '0'
uw_role_form_editor: '0'
uw_role_form_results_access: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
type: select
limit: true
vid: uw_vocab_opportunity_payrate
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
field_uw_opportunity_deadline_value:
id: field_uw_opportunity_deadline_value
table: node__field_uw_opportunity_deadline
field: field_uw_opportunity_deadline_value
relationship: none
group_type: group
admin_label: ''
operator: '>='
value:
min: ''
max: ''
value: now
type: offset
group: 2
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
placeholder: ''
min_placeholder: ''
max_placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: datetime
field_uw_opportunity_deadline_value_1:
id: field_uw_opportunity_deadline_value_1
table: node__field_uw_opportunity_deadline
field: field_uw_opportunity_deadline_value
relationship: none
group_type: group
admin_label: ''
operator: empty
value:
min: ''
max: ''
value: ''
type: offset
group: 2
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
placeholder: ''
min_placeholder: ''
max_placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: datetime
filter_groups:
operator: AND
groups:
1: AND
2: OR
style:
type: default
options: { }
row:
type: 'entity:node'
options:
relationship: none
view_mode: teaser
arguments: { }
exposed_form:
type: bef
options:
submit_button: Apply
reset_button: true
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
text_input_required: 'Select any filter and click on Apply to see results'
text_input_required_format: uw_tf_standard
bef:
general:
autosubmit: false
autosubmit_exclude_textfield: false
autosubmit_textfield_delay: 500
autosubmit_hide: false
input_required: false
allow_secondary: false
secondary_label: 'Advanced options'
secondary_open: false
filter:
field_uw_opportunity_type_target_id:
plugin_id: default
advanced:
sort_options: false
rewrite:
filter_rewrite_values: ''
collapsible: false
is_secondary: false
field_uw_opportunity_employment_target_id:
plugin_id: default
advanced:
sort_options: false
rewrite:
filter_rewrite_values: ''
collapsible: false
is_secondary: false
field_uw_opportunity_pay_type_target_id:
plugin_id: default
advanced:
sort_options: false
rewrite:
filter_rewrite_values: ''
collapsible: false
is_secondary: false
use_ajax: true
title: 'Opportunity list'
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user
- 'user.node_grants:view'
- user.permissions
tags:
- 'config:field.storage.node.field_uw_opportunity_date'
- 'config:field.storage.node.field_uw_opportunity_deadline'
- 'config:field.storage.node.field_uw_opportunity_pos_number'
- 'config:field.storage.node.field_uw_opportunity_type'
opportunities_feed:
display_plugin: feed
id: opportunities_feed
......
......@@ -6,6 +6,7 @@
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
/**
* Implements hook_form_alter().
......@@ -51,43 +52,13 @@ function uw_ct_opportunities_form_alter(array &$form, FormStateInterface $form_s
}
/**
* Ajax callback function.
* Implements hook_views_pre_render().
*/
function _uw_ct_opportunities_node_form_callback(array &$form, FormStateInterface $form_state): array {
function uw_ct_opportunities_views_pre_render(ViewExecutable $view) {
// Get the tid value from opportunity type field.
$opportunity_type_selected = $form_state->getValue('field_uw_opportunity_type');
// Get the tids from uw_vocab_opportunity_type
// which show payment field is checked.
$opportunity_type_show_payment_tids = _uw_ct_opportunities_get_terms('uw_vocab_opportunity_type');
// Two fields (Rate of pay and Rate of pay type) only visible
// when selected opportunity type has "show payment fields" checked.
if (!(in_array($opportunity_type_selected[0]['target_id'], $opportunity_type_show_payment_tids))) {
unset($form['field_uw_opportunity_pay_rate']);
unset($form['field_uw_opportunity_pay_type']);
}
return $form;
}
/**
* The help function to get tids from vid.
*/
function _uw_ct_opportunities_get_terms($vid) {
// Get taxonomy term objects from vid.
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
foreach ($terms as $term) {
// Load each tid to get term object.
$term_obj = Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($term->tid);
// Get the value of field_uw_opportunity_type_show.
// 1 means checked, 0 means un-checked.
$show_payment = $term_obj->get('field_uw_opportunity_type_show')->getvalue();
// Get tids when field_uw_opportunity_type_show is checked.
if ($show_payment[0]['value'] == 1) {
$tids[] = $term->tid;
}
// Remove exposed filters on block listing view.
if ($view->id() == 'uw_view_opportunities' &&
$view->getTitle() == 'Opportunity list') {
unset($view->exposed_widgets);
}
return $tids;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment