Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FAU-448] Allow users to specify search fields #50

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Keywords are indexed for searching.
- Introduce "Also search in text" option.

## [2.1.0] - 2024-09-06

Expand Down
Binary file modified languages/fau-degree-program-output-de_DE.mo
Binary file not shown.
15 changes: 10 additions & 5 deletions languages/fau-degree-program-output-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ msgid ""
msgstr ""
"Project-Id-Version: FAU Degree Program Output 0.0.4\n"
"Report-Msgid-Bugs-To: https://github.com/RRZE-Webteam/FAU-Studium-Embed\n"
"POT-Creation-Date: 2024-07-18T12:59:56+00:00\n"
"PO-Revision-Date: 2024-07-18 16:07+0300\n"
"POT-Creation-Date: 2024-12-23T06:39:22+00:00\n"
"PO-Revision-Date: 2024-12-23 08:42+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"
"X-Generator: Poedit 3.5\n"
"X-Domain: fau-degree-program-output\n"

#. Plugin Name of the plugin
Expand Down Expand Up @@ -527,16 +527,21 @@ msgstr ""
"Die Studiengangsdaten werden gerade verarbeitet. Bitte versuche es in ein "
"paar Minuten erneut."

#: templates/search/text-input-search.php:39
#: templates/search/text-input-search.php:41
msgctxt "frontoffice: degree programs search form"
msgid "Please enter search term..."
msgstr "Bitte Suchbegriff eingeben…"

#: templates/search/text-input-search.php:47
#: templates/search/text-input-search.php:49
msgctxt "frontoffice: degree programs search form"
msgid "Search"
msgstr "Suchen"

#: templates/search/text-input-search.php:69
msgctxt "frontoffice: degree programs search form"
msgid "Also search in text"
msgstr "Auch im Text suchen"

#: templates/single-degree-program-short.php:37
#: templates/single-degree-program/details.php:25
msgctxt "frontoffice: single view"
Expand Down
Binary file modified languages/fau-degree-program-output-de_DE_formal.mo
Binary file not shown.
15 changes: 10 additions & 5 deletions languages/fau-degree-program-output-de_DE_formal.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ msgid ""
msgstr ""
"Project-Id-Version: FAU Degree Program Output 0.0.4\n"
"Report-Msgid-Bugs-To: https://github.com/RRZE-Webteam/FAU-Studium-Embed\n"
"POT-Creation-Date: 2024-07-18T12:59:56+00:00\n"
"PO-Revision-Date: 2024-07-18 16:06+0300\n"
"POT-Creation-Date: 2024-12-23T06:39:22+00:00\n"
"PO-Revision-Date: 2024-12-23 08:42+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"
"X-Generator: Poedit 3.5\n"
"X-Domain: fau-degree-program-output\n"

#. Plugin Name of the plugin
Expand Down Expand Up @@ -527,16 +527,21 @@ msgstr ""
"Die Studiengangsdaten werden gerade verarbeitet. Bitte versuchen Sie es in "
"ein paar Minuten erneut."

#: templates/search/text-input-search.php:39
#: templates/search/text-input-search.php:41
msgctxt "frontoffice: degree programs search form"
msgid "Please enter search term..."
msgstr "Bitte Suchbegriff eingeben…"

#: templates/search/text-input-search.php:47
#: templates/search/text-input-search.php:49
msgctxt "frontoffice: degree programs search form"
msgid "Search"
msgstr "Suchen"

#: templates/search/text-input-search.php:69
msgctxt "frontoffice: degree programs search form"
msgid "Also search in text"
msgstr "Auch im Text suchen"

#: templates/single-degree-program-short.php:37
#: templates/single-degree-program/details.php:25
msgctxt "frontoffice: single view"
Expand Down
13 changes: 9 additions & 4 deletions languages/fau-degree-program-output.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL-2.0-or-later.
msgid ""
msgstr ""
"Project-Id-Version: FAU Degree Program Output 2.0.0-beta.5\n"
"Project-Id-Version: FAU Degree Program Output 2.1.0\n"
"Report-Msgid-Bugs-To: https://github.com/RRZE-Webteam/FAU-Studium-Embed\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-07-18T12:59:56+00:00\n"
"POT-Creation-Date: 2024-12-23T06:39:22+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.9.0\n"
"X-Domain: fau-degree-program-output\n"
Expand Down Expand Up @@ -517,16 +517,21 @@ msgctxt "frontoffice: degree programs search form"
msgid "The degree program data is being processed. Please try again in a few minutes."
msgstr ""

#: templates/search/text-input-search.php:39
#: templates/search/text-input-search.php:41
msgctxt "frontoffice: degree programs search form"
msgid "Please enter search term..."
msgstr ""

#: templates/search/text-input-search.php:47
#: templates/search/text-input-search.php:49
msgctxt "frontoffice: degree programs search form"
msgid "Search"
msgstr ""

#: templates/search/text-input-search.php:69
msgctxt "frontoffice: degree programs search form"
msgid "Also search in text"
msgstr ""

#: templates/single-degree-program-short.php:37
#: templates/single-degree-program/details.php:25
msgctxt "frontoffice: single view"
Expand Down
4 changes: 4 additions & 0 deletions resources/scss/components/search/_search-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
display: flex;
}

&__options {
margin-top: 10px;
}

&__search-icon {
width: 28px;
height: 28px;
Expand Down
7 changes: 5 additions & 2 deletions resources/ts/filters/filters-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { updateDegreeProgramOverviewDataset } from '../degree-program-overview/d
const FILTER_SELECTOR = '.c-filter-checkbox';
export const LANGUAGE_SKILLS_INPUT =
'german-language-skills-for-international-students';
const EXTENDED_INPUT = 'extended';

const filters = document.querySelectorAll< HTMLElement >( FILTER_SELECTOR );

Expand Down Expand Up @@ -68,8 +69,10 @@ filters.forEach( ( filterControl ) => {
}

checkbox?.addEventListener( 'change', ( e ) => {
toggleActiveFilter( filterControl, checkbox );
updateFiltersCount( checkbox );
if ( ! checkbox.name.startsWith( EXTENDED_INPUT ) ) {
toggleActiveFilter( filterControl, checkbox );
updateFiltersCount( checkbox );
}

if ( checkbox.name.startsWith( LANGUAGE_SKILLS_INPUT ) ) {
languageCertificateCheckedCheckboxes += checkbox.checked ? 1 : -1;
Expand Down
22 changes: 21 additions & 1 deletion src/Infrastructure/Search/SearchableContentUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
final class SearchableContentUpdater
{
public const SEARCHABLE_CONTENT_KEY = 'fau_degree_program_searchable_content';
public const SEARCHABLE_CONTENT_EXTENDED_KEY = 'fau_degree_program_searchable_content_extended';

public function __construct(
private DegreeProgramCollectionRepository $degreeProgramCollectionRepository,
Expand Down Expand Up @@ -68,6 +69,11 @@ private function update(CollectionCriteria $criteria): void
self::SEARCHABLE_CONTENT_KEY . '_' . $code,
$this->buildSearchableContent($rawView, $code)
);
update_post_meta(
$rawView->id()->asInt(),
self::SEARCHABLE_CONTENT_EXTENDED_KEY . '_' . $code,
$this->buildSearchableContentExtended($rawView, $code)
);
}
}
}
Expand All @@ -83,10 +89,24 @@ private function buildSearchableContent(
$parts = [
$rawView->title()->asString($languageCode),
$rawView->subtitle()->asString($languageCode),
$rawView->content()->about()->description()->asString($languageCode),
...array_values($rawView->keywords()->asArrayOfStrings($languageCode)->getArrayCopy()),
];

return implode(' ', $parts);
}

/**
* @psalm-param LanguageCodes $languageCode
*/
private function buildSearchableContentExtended(
DegreeProgramViewRaw $rawView,
string $languageCode
): string {

$parts = [
$rawView->content()->about()->description()->asString($languageCode),
];
zhyian marked this conversation as resolved.
Show resolved Hide resolved

return implode(' ', $parts);
}
}
19 changes: 19 additions & 0 deletions templates/search/text-input-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Fau\DegreeProgram\Common\Infrastructure\TemplateRenderer\Renderer;
use Fau\DegreeProgram\Output\Infrastructure\Component\Component;
use Fau\DegreeProgram\Output\Infrastructure\Component\Icon;

Expand All @@ -13,6 +14,7 @@
* name: string,
* } $data
* @var array $data
* @var Renderer $renderer
*/

[
Expand Down Expand Up @@ -58,4 +60,21 @@ class="c-degree-programs-searchform__input"
) ?>
</button>
</div>
<div class="c-degree-programs-searchform__options">
<?php // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?= $renderer->render(
'search/filter/checkbox-item',
[
'filterId' => 'extended',
'label' => esc_html_x(
'Also search in text',
'frontoffice: degree programs search form',
'fau-degree-program-output'
),
'value' => 'enable',
'isSelected' => false,
]
) ?>
<?php // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
Loading