mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-15 21:41:06 +00:00
Merge pull request #1385 from wallabag/v2-status-filter
filters: implement status filter and a new view (to display all entries)
This commit is contained in:
commit
f506da40e2
9 changed files with 88 additions and 6 deletions
|
@ -101,6 +101,21 @@ 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)
|
||||||
|
{
|
||||||
|
return $this->showEntries('all', $request, $page);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows unread entries for current user.
|
* Shows unread entries for current user.
|
||||||
*
|
*
|
||||||
|
@ -173,6 +188,10 @@ class EntryController extends Controller
|
||||||
$qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
|
$qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'all':
|
||||||
|
$qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
|
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,9 @@ class EntryFilterType extends AbstractType
|
||||||
|
|
||||||
return $filterQuery->createCondition($expression);
|
return $filterQuery->createCondition($expression);
|
||||||
},
|
},
|
||||||
));
|
))
|
||||||
|
->add('isArchived', 'filter_checkbox')
|
||||||
|
->add('isStarred', 'filter_checkbox');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
|
|
|
@ -24,6 +24,20 @@ class EntryRepository extends EntityRepository
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all entries for a user.
|
||||||
|
*
|
||||||
|
* @param int $userId
|
||||||
|
*
|
||||||
|
* @return QueryBuilder
|
||||||
|
*/
|
||||||
|
public function getBuilderForAllByUser($userId)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->getBuilderByUser($userId)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves unread entries for a user.
|
* Retrieves unread entries for a user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
{% if entries is empty %}
|
{% if entries is empty %}
|
||||||
<div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div>
|
<div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div><form>{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
|
<div><form action="{{ path('all') }}">{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<div id="entry-{{ entry.id|e }}" class="entry">
|
<div id="entry-{{ entry.id|e }}" class="entry">
|
||||||
<h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2>
|
<h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2>
|
||||||
|
|
|
@ -71,7 +71,8 @@
|
||||||
<li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
|
<li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
|
||||||
<li><a href="{{ path('starred') }}">{% trans %}favorites{% 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('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><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>
|
<li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
|
||||||
<div id="search-form" class="messages info popup-form">
|
<div id="search-form" class="messages info popup-form">
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
{% trans %}Starred{% endtrans %}
|
{% trans %}Starred{% endtrans %}
|
||||||
{% elseif currentRoute == 'archive' %}
|
{% elseif currentRoute == 'archive' %}
|
||||||
{% trans %}Archive{% endtrans %}
|
{% trans %}Archive{% endtrans %}
|
||||||
|
{% elseif currentRoute == 'all' %}
|
||||||
|
{% trans %}Filtered{% endtrans %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans %}Unread{% endtrans %}
|
{% trans %}Unread{% endtrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -59,12 +61,26 @@
|
||||||
|
|
||||||
<!-- Filters -->
|
<!-- Filters -->
|
||||||
<div id="filters" class="side-nav fixed right-aligned">
|
<div id="filters" class="side-nav fixed right-aligned">
|
||||||
<form>
|
<form action="{{ path('all') }}">
|
||||||
|
|
||||||
<h4 class="center">{% trans %}Filters{% endtrans %}</h1>
|
<h4 class="center">{% trans %}Filters{% endtrans %}</h1>
|
||||||
|
|
||||||
<div class="row">
|
<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">
|
<div class="col s12">
|
||||||
<label>{% trans %}Reading time in minutes{% endtrans %}</label>
|
<label>{% trans %}Reading time in minutes{% endtrans %}</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,7 +93,6 @@
|
||||||
<label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
|
<label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="input-field col s6">
|
<div class="input-field col s6">
|
||||||
{{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }}
|
{{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }}
|
||||||
<label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label>
|
<label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label>
|
||||||
|
|
|
@ -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 == '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 == '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 == '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 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 == '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>
|
<li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
|
||||||
|
|
|
@ -5,6 +5,7 @@ function init_filters() {
|
||||||
$('.button-collapse-right').sideNav({ edge: 'right' });
|
$('.button-collapse-right').sideNav({ edge: 'right' });
|
||||||
$('#clear_form_filters').on('click', function(){
|
$('#clear_form_filters').on('click', function(){
|
||||||
$('#filters input').val('');
|
$('#filters input').val('');
|
||||||
|
$('#filters :checked').removeAttr('checked');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
|
|
||||||
$crawler = $client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
|
|
||||||
$this->assertCount(4, $crawler->filter('div[class=entry]'));
|
$this->assertCount(5, $crawler->filter('div[class=entry]'));
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'entry_filter[createdAt][left_date]' => '01/01/1970',
|
'entry_filter[createdAt][left_date]' => '01/01/1970',
|
||||||
|
@ -307,6 +307,14 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$crawler = $client->request('GET', 'unread/list'.$parameters);
|
$crawler = $client->request('GET', 'unread/list'.$parameters);
|
||||||
|
|
||||||
$this->assertContains($parameters, $client->getResponse()->getContent());
|
$this->assertContains($parameters, $client->getResponse()->getContent());
|
||||||
|
|
||||||
|
// reset pagination
|
||||||
|
$crawler = $client->request('GET', '/config');
|
||||||
|
$form = $crawler->filter('button[id=config_save]')->form();
|
||||||
|
$data = array(
|
||||||
|
'config[items_per_page]' => '12',
|
||||||
|
);
|
||||||
|
$client->submit($form, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterOnDomainName()
|
public function testFilterOnDomainName()
|
||||||
|
@ -331,4 +339,25 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$crawler = $client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
$this->assertCount(0, $crawler->filter('div[class=entry]'));
|
$this->assertCount(0, $crawler->filter('div[class=entry]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFilterOnStatus()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/unread/list');
|
||||||
|
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||||
|
$form['entry_filter[isArchived]']->tick();
|
||||||
|
$form['entry_filter[isStarred]']->untick();
|
||||||
|
|
||||||
|
$crawler = $client->submit($form);
|
||||||
|
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||||
|
|
||||||
|
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||||
|
$form['entry_filter[isArchived]']->untick();
|
||||||
|
$form['entry_filter[isStarred]']->tick();
|
||||||
|
|
||||||
|
$crawler = $client->submit($form);
|
||||||
|
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue