From f35dbbd8c1e6c3e04ff33429f68bd1e8eb4642c9 Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Thu, 2 Dec 2021 16:37:17 +0000 Subject: [PATCH] [COMPONENTS][Search] Polished template [COMPONENTS][Search] Fix event typo --- components/Search/Controller/Search.php | 2 +- components/Search/Search.php | 7 +-- .../Search/templates/search/show.html.twig | 50 +++++++++++++------ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/components/Search/Controller/Search.php b/components/Search/Controller/Search.php index 621faafa8f..f49ed3bce8 100644 --- a/components/Search/Controller/Search.php +++ b/components/Search/Controller/Search.php @@ -40,7 +40,7 @@ class Search extends Controller $actor_qb = DB::createQueryBuilder(); $note_qb->select('note')->from('App\Entity\Note', 'note'); $actor_qb->select('actor')->from('App\Entity\Actor', 'actor'); - Event::handle('SeachQueryAddJoins', [&$note_qb, &$actor_qb]); + Event::handle('SearchQueryAddJoins', [&$note_qb, &$actor_qb]); $notes = $actors = []; if (!\is_null($note_criteria)) { $note_qb->addCriteria($note_criteria); diff --git a/components/Search/Search.php b/components/Search/Search.php index 0c15ca6df0..76e27163b0 100644 --- a/components/Search/Search.php +++ b/components/Search/Search.php @@ -41,12 +41,13 @@ class Search extends Component /** * Add the search form to the site header + * @throws RedirectException */ public function onAddExtraHeaderForms(Request $request, array &$elements) { $form = Form::create([ - ['query', TextType::class, [ - 'attr' => ['placeholder' => _m('Search tags...')], + ['search_tags', TextType::class, [ + 'attr' => ['placeholder' => _m('Input desired query...')], ]], [$form_name = 'submit_search', SubmitType::class, [ @@ -63,7 +64,7 @@ class Search extends Component $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); - throw new RedirectException('search', ['q' => $data['query']]); + throw new RedirectException('search', ['q' => $data['search_tags']]); } } diff --git a/components/Search/templates/search/show.html.twig b/components/Search/templates/search/show.html.twig index 1ab99275f9..fa9ad08d49 100644 --- a/components/Search/templates/search/show.html.twig +++ b/components/Search/templates/search/show.html.twig @@ -1,20 +1,42 @@ -{% extends 'base.html.twig' %} - +{% extends 'stdgrid.html.twig' %} {% import '/cards/note/view.html.twig' as noteView %} +{% block title %}{% if page_title is defined %}{{ page_title | trans }}{% endif %}{% endblock %} + +{% block stylesheets %} + {{ parent() }} + +{% endblock stylesheets %} + {% block body %} - {% for note in notes %} - {% block current_note %} -
- {{ noteView.macro_note(note) }} -
- {% endblock current_note %} - {% endfor %} + {% if error %} + + {% endif %} - {% for actor in actors %} - {% include 'actor/view.html.twig' with {'actor': actor} %} - {% endfor %} + {# Backwards compatibility with hAtom 0.1 #} +
+
+ {% if notes is defined and notes is not empty %} + {% for note in notes %} + {% block current_note %} +
+ {{ noteView.macro_note(note) }} +
+
+ {% endblock current_note %} + {% endfor %} + {% else %} +

{% trans %}No notes here.{% endtrans %}

+ {% endif %} +
+
- {{ "Page: " ~ page }} -{% endblock %} + {% for actor in actors %} + {% include 'actor/view.html.twig' with {'actor': actor} %} + {% endfor %} + + {{ "Page: " ~ page }} +{% endblock body %}