1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-22 17:18:37 +00:00

filters: implement status filter and a new view (to display all entries)

This commit is contained in:
Nicolas Lœuillet 2015-08-20 15:59:47 +02:00
parent 109d67dbb1
commit 89659c9eae
7 changed files with 77 additions and 15 deletions

View file

@ -101,6 +101,48 @@ class EntryController extends Controller
));
}
/**
* Shows all entries for current user.
*
* @param Request $request
* @param int $page
*
* @Route("/all/list/{page}", name="all", defaults={"page" = "1"})
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function showAllAction(Request $request, $page)
{
$form = $this->get('form.factory')->create(new EntryFilterType());
$filterBuilder = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
->findAllByUser($this->getUser()->getId());
if ($request->query->has($form->getName())) {
// manually bind values from the request
$form->submit($request->query->get($form->getName()));
// build the query from the given form object
$this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
}
$pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
$entries = new Pagerfanta($pagerAdapter);
$entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
$entries->setCurrentPage($page);
return $this->render(
'WallabagCoreBundle:Entry:entries.html.twig',
array(
'form' => $form->createView(),
'entries' => $entries,
'currentPage' => $page,
)
);
}
/**
* Shows unread entries for current user.
*

View file

@ -39,7 +39,9 @@ class EntryFilterType extends AbstractType
return $filterQuery->createCondition($expression);
},
));
))
->add('isArchived', 'filter_checkbox')
->add('isStarred', 'filter_checkbox');
}
public function getName()

View file

@ -71,7 +71,8 @@
<li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
<li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
<li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
<li><a href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li><a href="{{ path('all') }}"}>{% trans %}all{% endtrans %}</a></li>
<li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li>
<li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
<div id="search-form" class="messages info popup-form">

View file

@ -7,6 +7,8 @@
{% trans %}Starred{% endtrans %}
{% elseif currentRoute == 'archive' %}
{% trans %}Archive{% endtrans %}
{% elseif currentRoute == 'all' %}
{% trans %}Filtered{% endtrans %}
{% else %}
{% trans %}Unread{% endtrans %}
{% endif %}
@ -59,12 +61,26 @@
<!-- Filters -->
<div id="filters" class="side-nav fixed right-aligned">
<form>
<form action="{{ path('all') }}">
<h4 class="center">{% trans %}Filters{% endtrans %}</h1>
<div class="row">
<div class="col s12">
<label>{% trans %}Status{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.isArchived) }}
<label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.isStarred) }}
<label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label>
</div>
<div class="col s12">
<label>{% trans %}Reading time in minutes{% endtrans %}</label>
</div>
@ -77,7 +93,6 @@
<label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }}
<label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label>

View file

@ -42,6 +42,7 @@
<li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li>
<li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>

View file

@ -5,6 +5,7 @@ function init_filters() {
$('.button-collapse-right').sideNav({ edge: 'right' });
$('#clear_form_filters').on('click', function(){
$('#filters input').val('');
$('#filters :checked').removeAttr('checked');
return false;
});
}