Skip to content

Commit

Permalink
Merge pull request #695 from helsingborg-stad/feat/manual-input-free-…
Browse files Browse the repository at this point in the history
…text-filtering

feat: manual-input-free-text-filtering
  • Loading branch information
NiclasNorin authored Nov 15, 2024
2 parents d955709 + 6a42e22 commit c7e7785
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 15 deletions.
28 changes: 28 additions & 0 deletions source/php/AcfFields/json/mod-manual-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,34 @@
"ui_off_text": "",
"ui": 1
},
{
"key": "field_67289fa6dfea3",
"label": "Free text filtering",
"name": "free_text_filtering",
"aria-label": "",
"type": "true_false",
"instructions": "Enables filtering using a input field.",
"required": 0,
"conditional_logic": [
[
{
"field": "field_656f4b44999e9",
"operator": "==",
"value": "accordion"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "",
"default_value": 0,
"ui_on_text": "",
"ui_off_text": "",
"ui": 1
},
{
"key": "field_650067ed6cc3c",
"label": "Column marking",
Expand Down
40 changes: 34 additions & 6 deletions source/php/AcfFields/php/mod-manual-input.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,34 @@
'ui' => 1,
),
3 => array(
'key' => 'field_67289fa6dfea3',
'label' => __('Free text filtering', 'modularity'),
'name' => 'free_text_filtering',
'aria-label' => '',
'type' => 'true_false',
'instructions' => __('Enables filtering using a input field.', 'modularity'),
'required' => 0,
'conditional_logic' => array(
0 => array(
0 => array(
'field' => 'field_656f4b44999e9',
'operator' => '==',
'value' => 'accordion',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
'ui' => 1,
),
4 => array(
'key' => 'field_650067ed6cc3c',
'label' => __('Column marking', 'modularity'),
'name' => 'accordion_column_marking',
Expand Down Expand Up @@ -114,7 +142,7 @@
'prepend' => '',
'append' => '',
),
4 => array(
5 => array(
'key' => 'field_65005968bbc75',
'label' => __('Column titles', 'modularity'),
'name' => 'accordion_column_titles',
Expand Down Expand Up @@ -168,7 +196,7 @@
),
),
),
5 => array(
6 => array(
'key' => 'field_65001d039d4c4',
'label' => __('Columns', 'modularity'),
'name' => 'columns',
Expand Down Expand Up @@ -216,7 +244,7 @@
'allow_custom' => 0,
'search_placeholder' => '',
),
6 => array(
7 => array(
'key' => 'field_663372f4922a5',
'label' => __('Highlight first input', 'modularity'),
'name' => 'highlight_first_input',
Expand Down Expand Up @@ -258,7 +286,7 @@
'ui_on_text' => '',
'ui_off_text' => '',
),
7 => array(
8 => array(
'key' => 'field_6641de045ab9d',
'label' => __('Image position', 'modularity'),
'name' => 'image_position',
Expand Down Expand Up @@ -291,7 +319,7 @@
'layout' => 'horizontal',
'save_other_choice' => 0,
),
8 => array(
9 => array(
'key' => 'field_65016a6f0a085',
'label' => __('Ratio', 'modularity'),
'name' => 'ratio',
Expand Down Expand Up @@ -335,7 +363,7 @@
'allow_custom' => 0,
'search_placeholder' => '',
),
9 => array(
10 => array(
'key' => 'field_64ff22b2d91b7',
'label' => __('Manual inputs', 'modularity'),
'name' => 'manual_inputs',
Expand Down
18 changes: 11 additions & 7 deletions source/php/Module/ManualInput/ManualInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ public function data(): array
$displayAs = $this->getTemplateToUse($fields);
$this->template = $displayAs;

$data['manualInputs'] = [];
$data['ID'] = $this->ID;
$data['columns'] = !empty($fields['columns']) ? $fields['columns'] . '@md' : 'o-grid-4@md';
$data['context'] = ['module.manual-input.' . $this->template];
$data['ratio'] = !empty($fields['ratio']) ? $fields['ratio'] : '4:3';
$data['imagePosition'] = !empty($fields['image_position']) ? true : false;
$imageSize = $this->getImageSize($displayAs);
$data['manualInputs'] = [];
$data['ID'] = $this->ID;
$data['columns'] = !empty($fields['columns']) ? $fields['columns'] . '@md' : 'o-grid-4@md';
$data['context'] = ['module.manual-input.' . $this->template];
$data['ratio'] = !empty($fields['ratio']) ? $fields['ratio'] : '4:3';
$data['imagePosition'] = !empty($fields['image_position']) ? true : false;
$imageSize = $this->getImageSize($displayAs);
$data['freeTextFiltering'] = !empty($fields['free_text_filtering']) ? true : false;
$data['lang'] = [
'search' => __('Search', 'modularity'),
];

$data['accordionColumnTitles'] = $this->createAccordionTitles(
isset($fields['accordion_column_titles']) ? $fields['accordion_column_titles'] : [],
Expand Down
9 changes: 7 additions & 2 deletions source/php/Module/ManualInput/views/accordion.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="o-grid{{ !empty($stretch) ? ' o-grid--stretch' : '' }}">
<div class="o-grid{{ !empty($stretch) ? ' o-grid--stretch' : '' }}" {{!empty($freeTextFiltering) ? 'js-filter-container=' . $ID : ''}}>
@card([
'context' => $context
])
Expand All @@ -8,6 +8,7 @@
</div>
@endif
<div>
@includeWhen(!empty($freeTextFiltering), 'partials.search-field')
@if (!empty($accordionColumnTitles))
<header class="accordion-table__head">
@foreach ($accordionColumnTitles as $title)
Expand All @@ -24,7 +25,11 @@
@foreach ($manualInputs as $input)
@accordion__item([
'heading' => $input['accordionColumnValues'],
'attributeList' => $input['attributeList'] ?? [],
'attributeList' => array_merge([
'js-filter-item' => '',
'js-filter-data' => ''
],
$input['attributeList'] ?? []),
'classList' => $input['classList'] ?? []
])
{!! $input['content'] !!}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="c-card__body" aria-label="{{ $lang['search'] }}">
@field([
'type' => 'search',
'name' => 'search',
'label' => $lang['search'],
'hideLabel' => true,
'attributeList' => [
'js-filter-input' => $ID
],
'placeholder' => $lang['search']
])
@endfield
</div>

0 comments on commit c7e7785

Please sign in to comment.