Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ field_name: field_event_location
entity_type: paragraph
bundle: event_list
label: 'Event location'
description: 'Show "event location" filter. The API URL field should include all location IDs, otherwise this list will display all active locations.'
description: 'Show "event location" filter. If Event location is selected, you cannot use the Remote Events filter.'
required: false
translatable: false
default_value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ field_name: field_remote_events
entity_type: paragraph
bundle: event_list
label: 'Remote events'
description: 'Show "list only remote events" filter.'
description: 'Show "list only remote events" filter. If Event location is selected, you cannot use the Remote Events filter.'
required: false
translatable: false
default_value:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
label: Tapahtumapaikka
description: 'Näytä "tapahtumapaikka" -suodatin.Tapahtumapaikat pitää valita tapahtumakalenterista ennen kuin kopioit linkin.'
description: 'Näytä "tapahtumapaikka" -suodatin. Jos Tapahtumapaikka on valittuna, et voi käyttää Etätapahtumat-suodatinta.'
settings:
on_label: Kyllä
off_label: Ei
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
label: Etätapahtumat
description: 'Näytä "näytä vain etätapahtumat" -suodatin.'
description: 'Näytä "näytä vain etätapahtumat" -suodatin. Jos Tapahtumapaikka on valittuna, et voi käyttää Etätapahtumat-suodatinta.'
settings:
on_label: Kyllä
off_label: Ei
27 changes: 19 additions & 8 deletions modules/helfi_react_search/helfi_react_search.module
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,29 @@ function helfi_react_search_field_widget_single_element_paragraphs_form_alter(ar
return;
}

$type_select = ':input[name="' . $context['items']->getName() . '[' . $element['#delta'] . '][subform][field_event_list_type]"]';

$select = fn (string $prefix) => ':input[name="' . $context['items']->getName() . '[' . $element['#delta'] . '][subform]' . $prefix . '"]';
$states = [
'field_event_list_category_event' => 'hobbies',
'field_event_list_category_hobby' => 'events',
'field_event_list_category_event' => [
'state' => 'invisible',
'condition' => [$select('[field_event_list_type]') => ['value' => 'hobbies']],
],
'field_event_list_category_hobby' => [
'state' => 'invisible',
'condition' => [$select('[field_event_list_type]') => ['value' => 'events']],
],
'field_event_location' => [
'state' => 'disabled',
'condition' => [$select('[field_remote_events][value]') => ['checked' => TRUE]],
],
'field_remote_events' => [
'state' => 'disabled',
'condition' => [$select('[field_event_location][value]') => ['checked' => TRUE]],
],
];

foreach ($states as $field => $condition) {
foreach ($states as $field => ['state' => $state, 'condition' => $condition]) {
$element['subform'][$field]['#states'] = [
'invisible' => [
[$type_select => ['value' => $condition]],
],
$state => [$condition],
];
}
}
Expand Down