Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7018 from GSadee/grid-date-filter
[Grid][Admin][Order] Date filter on orders' list
- Loading branch information
Showing
18 changed files
with
537 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
features/order/managing_orders/filtering_orders_by_date.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@managing_orders | ||
Feature: Filtering orders | ||
In order to filter orders in specific period of time | ||
As an Administrator | ||
I want to be able to filter orders on the list | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has customer "Mike Ross" with email "ross@teammike.com" | ||
And this customer has placed an order "#00000001" at "2016-12-05 08:00:00" | ||
And this customer has also placed an order "#00000002" at "2016-12-05 09:00:00" | ||
And this customer has also placed an order "#00000003" at "2016-12-05 10:00:00" | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Filtering orders by date from | ||
When I browse orders | ||
And I specify filter date from as "2016-12-05 08:30:00" | ||
And I filter | ||
Then I should see 2 orders in the list | ||
And I should see an order with "#00000002" number | ||
And I should see an order with "#00000003" number | ||
But I should not see an order with "#00000001" number | ||
|
||
@ui | ||
Scenario: Filtering orders by date to | ||
When I browse orders | ||
And I specify filter date to as "2016-12-05 09:30:00" | ||
And I filter | ||
Then I should see 2 orders in the list | ||
And I should see an order with "#00000001" number | ||
And I should see an order with "#00000002" number | ||
But I should not see an order with "#00000003" number | ||
|
||
@ui | ||
Scenario: Filtering orders by date from to | ||
When I browse orders | ||
And I specify filter date from as "2016-12-05 08:30:00" | ||
And I specify filter date to as "2016-12-05 09:30:00" | ||
And I filter | ||
Then I should see a single order in the list | ||
And I should see an order with "#00000002" number | ||
But I should not see an order with "#00000001" number | ||
And I should not see an order with "#00000003" number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Behat\Page\Admin\Order; | ||
|
||
use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage; | ||
|
||
/** | ||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com> | ||
*/ | ||
class IndexPage extends BaseIndexPage implements IndexPageInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function specifyFilterDateFrom(\DateTime $dateTime) | ||
{ | ||
$timestamp = $dateTime->getTimestamp(); | ||
|
||
$this->getDocument()->fillField('criteria_date_from_date', date('Y-m-d', $timestamp)); | ||
$this->getDocument()->fillField('criteria_date_from_time', date('H:i', $timestamp)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function specifyFilterDateTo(\DateTime $dateTime) | ||
{ | ||
$timestamp = $dateTime->getTimestamp(); | ||
|
||
$this->getDocument()->fillField('criteria_date_to_date', date('Y-m-d', $timestamp)); | ||
$this->getDocument()->fillField('criteria_date_to_time', date('H:i', $timestamp)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Behat\Page\Admin\Order; | ||
|
||
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface as BaseIndexPageInterface; | ||
|
||
/** | ||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com> | ||
*/ | ||
interface IndexPageInterface extends BaseIndexPageInterface | ||
{ | ||
/** | ||
* @param \DateTime $dateTime | ||
*/ | ||
public function specifyFilterDateFrom(\DateTime $dateTime); | ||
|
||
/** | ||
* @param \DateTime $dateTime | ||
*/ | ||
public function specifyFilterDateTo(\DateTime $dateTime); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/Sylius/Bundle/GridBundle/Form/Type/Filter/DateFilterType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Bundle\GridBundle\Form\Type\Filter; | ||
|
||
use Sylius\Component\Grid\Filter\StringFilter; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com> | ||
*/ | ||
final class DateFilterType extends AbstractType | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('from', DateTimeType::class, [ | ||
'label' => 'sylius.ui.from', | ||
'date_widget' => 'single_text', | ||
'time_widget' => 'single_text', | ||
'required' => false, | ||
]) | ||
->add('to', DateTimeType::class, [ | ||
'label' => 'sylius.ui.to', | ||
'date_widget' => 'single_text', | ||
'time_widget' => 'single_text', | ||
'required' => false, | ||
]) | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver | ||
->setDefaults([ | ||
'data_class' => null, | ||
]) | ||
->setDefined('field') | ||
->setAllowedTypes('field', 'string') | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBlockPrefix() | ||
{ | ||
return 'sylius_grid_filter_date'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.