Skip to content

Commit 1a926c8

Browse files
committed
Merge branch 'feature/allow-search-in-case-view'
2 parents 8bb6b98 + 505e41c commit 1a926c8

File tree

9 files changed

+191
-12
lines changed

9 files changed

+191
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ about writing changes to this log.
1010

1111
## [Unreleased]
1212

13+
## [1.10.0] - 2026-03-02
14+
15+
- [PR-415](https://github.com/itk-dev/naevnssekretariatet/pull/415)
16+
- Adds search functionality in the already existing filtering on `/case`.
17+
- Adds Taskfile.
18+
1319
## [1.9.0] - 2025-01-22
1420

1521
- Switched to [Gotenberg](https://github.com/gotenberg/gotenberg) for docx
@@ -376,7 +382,8 @@ Fixed error in unescaped characters in filename
376382
- [TVIST1-604](https://jira.itkdev.dk/browse/TVIST1-604):
377383
Resolved issue regarding time formats.
378384

379-
[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.9.0...HEAD
385+
[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.10.0...HEAD
386+
[1.10.0]: https://github.com/itk-dev/naevnssekretariatet/compare/1.9.0...1.10.0
380387
[1.9.0]: https://github.com/itk-dev/naevnssekretariatet/compare/1.8.0...1.9.0
381388
[1.8.0]: https://github.com/itk-dev/naevnssekretariatet/compare/1.7.1...1.8.0
382389
[1.7.1]: https://github.com/itk-dev/naevnssekretariatet/compare/1.7.0...1.7.1

Taskfile.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
version: '3'
2+
3+
dotenv: [".task.env", ".env"]
4+
5+
vars:
6+
DOCKER_COMPOSE: '{{ .TASK_DOCKER_COMPOSE | default "docker compose" }}'
7+
# https://taskfile.dev/reference/templating/
8+
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default ""}}'
9+
10+
tasks:
11+
compose:
12+
desc: "Run `docker compose` command. Example: task compose -- up --detach"
13+
cmds:
14+
- '{{ .DOCKER_COMPOSE }} {{ .CLI_ARGS }}'
15+
16+
compose-exec:
17+
desc: "Run `docker compose exec` command handling content on stdin. Example: task compose-exec -- phpfpm php -v"
18+
cmds:
19+
# Check if we have content on stdin (cf.
20+
# https://unix.stackexchange.com/questions/762992/bash-check-if-the-standard-input-contains-anything)
21+
- if [[ ! -t 0 ]]; then task compose -- exec --no-TTY {{ .CLI_ARGS }}; else task compose -- exec {{ .CLI_ARGS }}; fi
22+
silent: true
23+
24+
composer:
25+
desc: "Run composer command. Example: task composer -- install"
26+
cmds:
27+
- task compose-exec -- phpfpm composer {{ .CLI_ARGS }}
28+
silent: true
29+
30+
console:
31+
desc: "Run console command"
32+
cmds:
33+
- task compose-exec -- phpfpm bin/console {{ .CLI_ARGS }}
34+
35+
start:
36+
desc: "Start docker compose stuff and install composer stuff"
37+
cmds:
38+
- task compose -- pull
39+
- task compose -- up --detach --build --remove-orphans
40+
- task composer -- install
41+
- task run-build
42+
- task migrate
43+
silent: true
44+
45+
46+
start:local:
47+
desc: "Start and apply fixtures"
48+
cmds:
49+
- task start
50+
- task fixtures
51+
silent: true
52+
53+
site-url:
54+
desc: "Show site URL"
55+
cmds:
56+
- echo {{.URL}}
57+
vars:
58+
URL:
59+
# Compute base URL if not set.
60+
sh: if [ ! -z "{{.BASE_URL}}" ]; then echo "https://{{.BASE_URL}}"; else echo "http://$(task compose -- port nginx 8080)"; fi
61+
silent: true
62+
63+
check-code:
64+
desc: "Check coding standards"
65+
cmds:
66+
- task compose -- run --rm node yarn coding-standards-check/markdownlint
67+
- task composer -- validate composer.json --strict
68+
# @todo enable this
69+
# - task composer -- code-analysis
70+
- task composer -- coding-standards-check
71+
72+
coding-standards-apply:
73+
desc: "Apply coding standards"
74+
cmds:
75+
- task composer -- coding-standards-apply
76+
77+
run-dev:
78+
desc: "Build assets"
79+
cmds:
80+
- task compose -- run --rm node yarn run dev
81+
82+
run-watch:
83+
desc: "Build and watch assets"
84+
cmds:
85+
- task compose -- run --rm node yarn run watch
86+
87+
run-build:
88+
desc: "Build assets for production"
89+
cmds:
90+
- task compose -- run --rm node yarn run build
91+
92+
migrate:
93+
desc: "Run migrations with no interaction"
94+
cmds:
95+
- task console -- doctrine:migrations:migrate --no-interaction
96+
97+
fixtures:
98+
desc: "Apply fixtures"
99+
cmds:
100+
- task console -- hautelook:fixtures:load --no-bundles --purge-with-truncate --no-interaction
101+
102+
login:
103+
desc: "Get login url for user with email. Example: task login -- admin@example.com"
104+
requires:
105+
vars: [ CLI_ARGS ]
106+
cmds:
107+
- task console -- itk-dev:openid-connect:login {{.CLI_ARGS}}
108+
109+
update:translations:
110+
desc: "Update translations"
111+
cmds:
112+
- task compose-exec -- phpfpm composer update-translations
113+
- task compose-exec -- phpfpm bin/console cache:clear
114+

src/Form/CaseFilterType.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use App\Service\CaseDeadlineStatuses;
1313
use App\Service\CaseSpecialFilterStatuses;
1414
use App\Service\FilterHelper;
15+
use App\Service\SearchService;
1516
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type as Filters;
1617
use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
1718
use Symfony\Component\Form\AbstractType;
@@ -25,7 +26,7 @@
2526

2627
class CaseFilterType extends AbstractType
2728
{
28-
public function __construct(private BoardRepository $boardRepository, private CaseEntityRepository $caseEntityRepository, private FilterHelper $filterHelper, private TranslatorInterface $translator, private UserRepository $userRepository)
29+
public function __construct(private BoardRepository $boardRepository, private CaseEntityRepository $caseEntityRepository, private FilterHelper $filterHelper, private TranslatorInterface $translator, private UserRepository $userRepository, private SearchService $searchService)
2930
{
3031
}
3132

@@ -276,5 +277,39 @@ function (FormEvent $event) use ($formModifier) {
276277
'label' => false,
277278
'placeholder' => $this->translator->trans('Select a general status filter', [], 'case'),
278279
]);
280+
281+
$builder->add('searchFilter', Filters\TextFilterType::class, [
282+
'label' => false,
283+
'attr' => [
284+
'placeholder' => $this->translator->trans('Search', [], 'case'),
285+
],
286+
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
287+
$searchValue = $values['value'] ?? null;
288+
if (empty($searchValue)) {
289+
return null;
290+
}
291+
292+
$escapedSearch = $this->searchService->escapeStringForLike($searchValue, '\\');
293+
294+
$qb = $filterQuery->getQueryBuilder();
295+
$paramName = 'search_query';
296+
297+
// Start with base search conditions
298+
$expression = $filterQuery->getExpr()->orX(
299+
$filterQuery->getExpr()->like('c.caseNumber', ':'.$paramName),
300+
$filterQuery->getExpr()->like('c.sortingAddress', ':'.$paramName)
301+
);
302+
303+
// Check if value matches the pattern (e.g., 12.34.56)
304+
if (preg_match('/^\d{2}\.\d{2}\.\d{2}$/', $searchValue)) {
305+
$qb->leftJoin('c.complaintCategories', 'cc');
306+
$expression->add($filterQuery->getExpr()->like('cc.kle', ':'.$paramName));
307+
}
308+
309+
$parameters = ['search_query' => '%'.$escapedSearch.'%'];
310+
311+
return $filterQuery->createCondition($expression, $parameters);
312+
},
313+
]);
279314
}
280315
}

templates/case/index.html.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
{% block header %}
88
<h1>{% trans %}Cases{% endtrans %}</h1>
9+
<div class="row">
10+
<div class="col">
11+
<p class="text-muted"><small>{% trans %}You can search for case number, KLE-numbers or parts of an address.{% endtrans %}</small></p>
12+
</div>
13+
</div>
914
<div class="row">
1015
<div class="col-3">
1116
{{ form(municipality_form) }}
1217
</div>
13-
1418
</div>
1519
{% endblock %}
1620

@@ -39,6 +43,9 @@
3943
<div class="col-auto ms-2">
4044
{{ form_widget(filter_form.activeFilter, {'attr': {'class': 'form-select'}}) }}
4145
</div>
46+
<div class="col-auto ms-2">
47+
{{ form_widget(filter_form.searchFilter, {'attr': {'class': 'form'}}) }}
48+
</div>
4249
<div class="col-auto ms-2">
4350
{# Todo: Just reset filter rather than refresh page although it yields the same result #}
4451
<a class="btn btn-secondary" href="{{ path('case_index') }}" role="button">{% trans %}Reset{% endtrans %}</a>

templates/search/index.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="row">
99
<div class="col">
1010
<h1>{% trans %}Search results{% endtrans %}</h1>
11-
<p class="text-muted"><small>{% trans %}You can search for case number, address or parts of an address.{% endtrans %}</small></p>
11+
<p class="text-muted"><small>{% trans %}You can search for case number, KLE-numbers or parts of an address.{% endtrans %}</small></p>
1212
</div>
1313
</div>
1414
{% endblock %}

translations/case+intl-icu.da.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,14 @@
14411441
<source>Some recipients cannot receive digital post. Attach at most &lt;strong&gt;{max_size}&lt;/strong&gt;.</source>
14421442
<target state="translated"><![CDATA[Nogle modtagere kan ikke modtage digital post. Vedhæft højst <strong>{max_size}</strong>.]]></target>
14431443
</trans-unit>
1444+
<trans-unit id="ScJmuqq" resname="Search">
1445+
<source>Search</source>
1446+
<target state="translated">Søg</target>
1447+
</trans-unit>
1448+
<trans-unit id="ZGtytiL" resname="You can search for case number, KLE-numbers or parts of an address.">
1449+
<source>You can search for case number, KLE-numbers or parts of an address.</source>
1450+
<target state="translated">Der kan søges på sagsnummer, KLE-nummer eller dele af en adresse.</target>
1451+
</trans-unit>
14441452
</body>
14451453
</file>
14461454
</xliff>

translations/case+intl-icu.en.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,14 @@
14411441
<source>Some recipients cannot receive digital post. Attach at most &lt;strong&gt;{max_size}&lt;/strong&gt;.</source>
14421442
<target><![CDATA[Some recipients cannot receive digital post. Attach at most <strong>{max_size}</strong>.]]></target>
14431443
</trans-unit>
1444+
<trans-unit id="ScJmuqq" resname="Search">
1445+
<source>Search</source>
1446+
<target>Search</target>
1447+
</trans-unit>
1448+
<trans-unit id="ZGtytiL" resname="You can search for case number, KLE-numbers or parts of an address.">
1449+
<source>You can search for case number, KLE-numbers or parts of an address.</source>
1450+
<target>You can search for case number, KLE-numbers or parts of an address.</target>
1451+
</trans-unit>
14441452
</body>
14451453
</file>
14461454
</xliff>

translations/search+intl-icu.da.xlf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<source>Search results</source>
1414
<target>Søgeresultater</target>
1515
</trans-unit>
16-
<trans-unit id="EFMlZtd" resname="You can search for case number, address or parts of an address.">
17-
<source>You can search for case number, address or parts of an address.</source>
18-
<target>Der kan søges på sagsnummer, adresse eller dele af en adresse.</target>
19-
</trans-unit>
2016
<trans-unit id="IY9ECBk" resname="No results for {searchTerm}">
2117
<source>No results for {searchTerm}</source>
2218
<target>Søgning på {searchTerm} gav ingen resultater.</target>
2319
</trans-unit>
20+
<trans-unit id="ZGtytiL" resname="You can search for case number, KLE-numbers or parts of an address.">
21+
<source>You can search for case number, KLE-numbers or parts of an address.</source>
22+
<target state="translated">Der kan søges på sagsnummer, KLE-nummer eller dele af en adresse.</target>
23+
</trans-unit>
2424
</body>
2525
</file>
2626
</xliff>

translations/search+intl-icu.en.xlf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<source>Search results</source>
1414
<target>Search results</target>
1515
</trans-unit>
16-
<trans-unit id="EFMlZtd" resname="You can search for case number, address or parts of an address.">
17-
<source>You can search for case number, address or parts of an address.</source>
18-
<target>You can search for case number, address or parts of an address.</target>
19-
</trans-unit>
2016
<trans-unit id="IY9ECBk" resname="No results for {searchTerm}">
2117
<source>No results for {searchTerm}</source>
2218
<target>No results for {searchTerm}</target>
2319
</trans-unit>
20+
<trans-unit id="ZGtytiL" resname="You can search for case number, KLE-numbers or parts of an address.">
21+
<source>You can search for case number, KLE-numbers or parts of an address.</source>
22+
<target>You can search for case number, KLE-numbers or parts of an address.</target>
23+
</trans-unit>
2424
</body>
2525
</file>
2626
</xliff>

0 commit comments

Comments
 (0)