Skip to content

Commit

Permalink
Merge pull request #37 from sherlockode/fix/search-page-results
Browse files Browse the repository at this point in the history
Update search page style
  • Loading branch information
Vowow authored Jan 14, 2019
2 parents 6b648a3 + d053ee4 commit 483995a
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 11 deletions.
21 changes: 11 additions & 10 deletions DependencyInjection/SherlockodeSonataModularExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ public function prepend(ContainerBuilder $container)
if (isset($bundles['SonataAdminBundle'])) {
$config = [
'templates' => [
'list' => 'SherlockodeSonataModularBundle:CRUD:list.html.twig',
'show' => 'SherlockodeSonataModularBundle:CRUD:show.html.twig',
'edit' => 'SherlockodeSonataModularBundle:CRUD:edit.html.twig',
'layout' => 'SherlockodeSonataModularBundle::standard_layout.html.twig',
'knp_menu_template' => 'SherlockodeSonataModularBundle:Menu:sonata_menu.html.twig',
'button_create' => 'SherlockodeSonataModularBundle:Button:create_button.html.twig',
'button_edit' => 'SherlockodeSonataModularBundle:Button:edit_button.html.twig',
'button_show' => 'SherlockodeSonataModularBundle:Button:show_button.html.twig',
'button_list' => 'SherlockodeSonataModularBundle:Button:list_button.html.twig',
'pager_links' => 'SherlockodeSonataModularBundle:Pager:links.html.twig',
'list' => '@SherlockodeSonataModular/CRUD/list.html.twig',
'show' => '@SherlockodeSonataModular/CRUD/show.html.twig',
'edit' => '@SherlockodeSonataModular/CRUD/edit.html.twig',
'layout' => '@SherlockodeSonataModular/standard_layout.html.twig',
'knp_menu_template' => '@SherlockodeSonataModular/Menu/sonata_menu.html.twig',
'button_create' => '@SherlockodeSonataModular/Button/create_button.html.twig',
'button_edit' => '@SherlockodeSonataModular/Button/edit_button.html.twig',
'button_show' => '@SherlockodeSonataModular/Button/show_button.html.twig',
'button_list' => '@SherlockodeSonataModular/Button/list_button.html.twig',
'pager_links' => '@SherlockodeSonataModular/Pager/links.html.twig',
'search_result_block' => '@SherlockodeSonataModular:Block:block_search_result.html.twig',
],
'assets' => [
'stylesheets' => [
Expand Down
30 changes: 30 additions & 0 deletions Resources/public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
body,
.btn,
.form-control {
font-size: 0.875rem;
}

.breadcrumb {
padding: 0;
margin: 0;
Expand Down Expand Up @@ -133,3 +139,27 @@
.btn.sonata-collection-add {
color: initial;
}

.btn-box-tool {
color: #97a0b3;
margin-bottom: 0;
}

.box-tools {
font-size: 0.75rem;
}

.box-tools .badge {
color: #fff;
background-color: #777;
font-size: inherit;
}

.sonata-search-result-show .list-group-item {
border: none;
border-top: 1px solid rgba(0, 0, 0, 0.125);
}

.sonata-search-result-show .list-group-item:first-child {
border: none;
}
1 change: 1 addition & 0 deletions Resources/views/Block/block_base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% block block %}EMPTY CONTENT{% endblock %}
67 changes: 67 additions & 0 deletions Resources/views/Block/block_search_result.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}

{% extends '@SherlockodeSonataModular/Block/block_base.html.twig' %}

{% block block %}
{% set show_empty_boxes = sonata_admin.adminPool.container.getParameter('sonata.admin.configuration.global_search.empty_boxes') %}
{% set visibility_class = 'sonata-search-result-' ~ show_empty_boxes %}
{% if pager and pager.getResults()|length %}
{% set visibility_class = 'sonata-search-result-show' %}
{% endif %}

<div class="col-lg-4 col-md-6 search-box-item {{ visibility_class }}">
<div class="box box-solid {{ visibility_class }}">
<div class="box-header with-border {{ visibility_class }}">
{% set icon = settings.icon|default('') %}
{{ icon|raw }}
<h3 class="box-title">
{{ admin.label|trans({}, admin.translationdomain) }}
</h3>

<div class="box-tools pull-right">
{% if pager and pager.getNbResults() > 0 %}
<span class="badge">{{ pager.getNbResults() }}</span>
{% elseif admin.hasRoute('create') and admin.hasAccess('create') %}
<a href="{{ admin.generateUrl('create') }}" class="btn btn-box-tool">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
{% endif %}
{% if admin.hasRoute('list') and admin.hasAccess('list') %}
<a href="{{ admin.generateUrl('list') }}" class="btn btn-box-tool">
<i class="fa fa-list" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</div>
{% if pager and pager.getResults()|length %}
<div class="box-body no-padding">
<div class="list-group">
{% for result in pager.getResults() %}
{% set link = admin.getSearchResultLink(result) %}
{% if link %}
<a href="{{ link }}" class="list-group-item list-group-item-action">{{ admin.toString(result) }}</a>
{% else %}
<a href="#" class="list-group-item list-group-item-action">{{ admin.toString(result) }}</a>
{% endif %}
{% endfor %}
</div>
</div>
{% else %}
<div class="box-body">
<p>
<em>{{ 'no_results_found'|trans({}, 'SonataAdminBundle') }}</em>
</p>
</div>
{% endif %}
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion Resources/views/standard_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ file that was distributed with this source code.
<form action="{{ path('sonata_admin_search') }}" method="GET" role="search">
<div class="input-container">
<i class="fa fa-search"></i>
<input type="search" placeholder="Search">
<input type="search" name="q" value="{{ app.request.get('q') }}" placeholder="{{ 'search_placeholder'|trans({}, 'SonataAdminBundle') }}">
<div class="underline"></div>
</div>
</form>
Expand Down

0 comments on commit 483995a

Please sign in to comment.