mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 17:11:07 +00:00
Fix createdAt date range filter
- hiddenName has been disabled in order to fix the missing date range values when using the material theme - data format has been changed to 'Y-m-d' in order to comply with the browser date input default format - tests: date() and strtotime have been replaced with DateTime-related objects Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
ef81e3c89b
commit
8ee7b1603d
6 changed files with 28 additions and 16 deletions
|
@ -57,9 +57,9 @@ $(document).ready(() => {
|
||||||
$('.datepicker').pickadate({
|
$('.datepicker').pickadate({
|
||||||
selectMonths: true,
|
selectMonths: true,
|
||||||
selectYears: 15,
|
selectYears: 15,
|
||||||
formatSubmit: 'dd/mm/yyyy',
|
formatSubmit: 'yyyy-mm-dd',
|
||||||
hiddenName: true,
|
hiddenName: false,
|
||||||
format: 'dd/mm/yyyy',
|
format: 'yyyy-mm-dd',
|
||||||
container: 'body',
|
container: 'body',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -552,7 +552,7 @@ class Entry
|
||||||
*
|
*
|
||||||
* @return Entry
|
* @return Entry
|
||||||
*/
|
*/
|
||||||
public function setCreatedAt(\DateTime $createdAt)
|
public function setCreatedAt(\DateTimeInterface $createdAt)
|
||||||
{
|
{
|
||||||
$this->createdAt = $createdAt;
|
$this->createdAt = $createdAt;
|
||||||
|
|
||||||
|
|
|
@ -75,16 +75,16 @@ class EntryFilterType extends AbstractType
|
||||||
->add('createdAt', DateRangeFilterType::class, [
|
->add('createdAt', DateRangeFilterType::class, [
|
||||||
'left_date_options' => [
|
'left_date_options' => [
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'placeholder' => 'dd/mm/yyyy',
|
'placeholder' => 'yyyy-mm-dd',
|
||||||
],
|
],
|
||||||
'format' => 'dd/MM/yyyy',
|
'format' => 'yyyy-MM-dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
],
|
],
|
||||||
'right_date_options' => [
|
'right_date_options' => [
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'placeholder' => 'dd/mm/yyyy',
|
'placeholder' => 'yyyy-mm-dd',
|
||||||
],
|
],
|
||||||
'format' => 'dd/MM/yyyy',
|
'format' => 'yyyy-MM-dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
],
|
],
|
||||||
'label' => 'entry.filters.created_at.label',
|
'label' => 'entry.filters.created_at.label',
|
||||||
|
|
|
@ -822,13 +822,25 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getClient();
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$em = $this->getEntityManager();
|
||||||
|
|
||||||
|
$today = new \DateTimeImmutable();
|
||||||
|
$tomorrow = $today->add(new \DateInterval('P1D'));
|
||||||
|
$yesterday = $today->sub(new \DateInterval('P1D'));
|
||||||
|
|
||||||
|
$entry = new Entry($this->getLoggedInUser());
|
||||||
|
$entry->setUrl('http://0.0.0.0/testFilterOnCreationDate');
|
||||||
|
$entry->setCreatedAt($yesterday);
|
||||||
|
$em->persist($entry);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/unread/list');
|
$crawler = $client->request('GET', '/unread/list');
|
||||||
|
|
||||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
|
'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
|
||||||
'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
|
'entry_filter[createdAt][right_date]' => $tomorrow->format('Y-m-d'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$crawler = $client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
|
@ -836,8 +848,8 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
|
'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
|
||||||
'entry_filter[createdAt][right_date]' => date('d/m/Y'),
|
'entry_filter[createdAt][right_date]' => $today->format('Y-m-d'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$crawler = $client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
|
@ -845,8 +857,8 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'entry_filter[createdAt][left_date]' => '01/01/1970',
|
'entry_filter[createdAt][left_date]' => '1970-01-01',
|
||||||
'entry_filter[createdAt][right_date]' => '01/01/1970',
|
'entry_filter[createdAt][right_date]' => '1970-01-01',
|
||||||
];
|
];
|
||||||
|
|
||||||
$crawler = $client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue