Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Behat/Context/CRUDContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ public function popoverWithFieldInFormShouldAppear($newsTitle)
expect($popover->findField('Title')->getValue())->toBe($newsTitle);
}

/**
* @Then /^popover with empty date field in form should appear$/
*/
public function popoverWithEmptyDateFieldInFormShouldAppear()
{
$popover = $this->getPage('News list')->getPopover();
expect($popover->isVisible())->toBe(true);
expect($popover->findField('Date')->getValue())->toBe('');
}

/**
* @When /^I click X at popover$/
*/
Expand Down
4 changes: 4 additions & 0 deletions Behat/Context/DataContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\ORM\Tools\SchemaTool;
use Faker\Factory;
use Faker\ORM\Doctrine\Populator;
use FSi\Component\DataSource\Driver\Collection\Extension\Core\Field\DateTime;
use FSi\FixturesBundle\Entity\News;
use Symfony\Component\HttpKernel\KernelInterface;

Expand Down Expand Up @@ -78,6 +79,9 @@ public function followingNewsExistInDatabase(TableNode $table)
}

$news->setTitle($newsNode['Title']);
if (isset($newsNode['Date']) && $newsNode['Date']) {
$news->setDate(\DateTime::createFromFormat('Y-m-d', $newsNode['Date']));
}
$news->setCreatedAt($generator->dateTime());
$news->setVisible($generator->boolean());
$news->setCreatorEmail($generator->email());
Expand Down
1 change: 0 additions & 1 deletion Behat/Context/Page/NewsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function getPopover()
protected function verifyPage()
{
if (!$this->has('css', 'h3#page-header:contains("List of elements")')) {
echo $this->getHtml();
throw new BehaviorException(sprintf("%s page is missing \"List of elements\" header", $this->path));
}
}
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/FSiAdminBundle.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ crud:
confirm: Ok
datagrid:
editable:
empty: Edit
title: Edit
save: Save
reset: Reset
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/FSiAdminBundle.pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ crud:
confirm: Ok
datagrid:
editable:
empty: Edytuj
title: Edytuj
save: Zapisz
reset: Zresetuj
Expand Down
8 changes: 7 additions & 1 deletion Resources/views/CRUD/datagrid.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
{% if cell.getAttribute('form').vars.valid == false %}
{% set class = class ~ ' has-error' %}
{% endif %}
<a href="#" class="{{ class }}" data-toggle="popover" data-html="true" data-content="{{ datagrid_column_cell_form_widget(cell)|escape }}">{{ cell.value|raw }}</a>
<a href="#" class="{{ class }}" data-toggle="popover" data-html="true" data-content="{{ datagrid_column_cell_form_widget(cell)|escape }}">
{% if cell.value is empty %}
{{ 'crud.list.datagrid.editable.empty'|trans({}, 'FSiAdminBundle') }}
{% else %}
{{ cell.value|raw }}
{% endif %}
</a>
{% else %}
{{ cell.value|raw }}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions features/crud_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Feature: List of elements
| Column name |
| Batch |
| Title |
| Date |
| Created at |
| Visible |
| Creator email |
Expand Down
1 change: 1 addition & 0 deletions features/crud_list_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Feature: Creating new object
And I should see form with following fields
| Field name |
| Title |
| Date |
| Created at |
| Visible |
| Creator email |
Expand Down
1 change: 1 addition & 0 deletions features/crud_list_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Feature: Editing existing object
And I should see form with following fields
| Field name |
| Title |
| Date |
| Created at |
| Visible |
| Creator email |
Expand Down
10 changes: 8 additions & 2 deletions features/crud_list_edit_at_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Feature: Editing news title directly from list of elements

Background:
Given the following news exist in database
| Title |
| News 1 |
| Title | Date |
| News 1 | |
| News 2 | 2013-12-31 |
And I am on the "News list" page
And "Title" column is editable

Expand All @@ -15,6 +16,11 @@ Feature: Editing news title directly from list of elements
When I click "News 1" in "Title" column in first row
Then popover with "News 1" field in form should appear

@javascript
Scenario: Display popover with news date when date is not set
When I click "Edit" in "Date" column in first row
Then popover with empty date field in form should appear

@javascript
Scenario: Hide popover with news title edit form
Given I clicked "News 1" in "Title" column in first row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ admin:
name: News
list:
title: Title
date: Date
created_at: Created at
created_at_from: Created at from
created_at_to: Created at to
Expand Down
13 changes: 13 additions & 0 deletions features/fixtures/project/src/FSi/FixturesBundle/Admin/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ protected function initDataGrid(DataGridFactoryInterface $factory)
'label' => 'admin.news.list.title',
'editable' => true
));
$datagrid->addColumn('date', 'datetime', array(
'label' => 'admin.news.list.date',
'datetime_format' => 'Y-m-d',
'editable' => true,
'form_type' => array('date' => 'date'),
'form_options' => array(
'date' => array('widget' => 'single_text')
)
));
$datagrid->addColumn('created_at', 'datetime', array(
'label' => 'admin.news.list.created_at'
));
Expand Down Expand Up @@ -107,6 +116,10 @@ protected function initForm(FormFactoryInterface $factory, $data = null)
$builder->add('title', 'text', array(
'label' => 'admin.news.list.title',
));
$builder->add('date', 'date', array(
'label' => 'admin.news.list.date',
'widget' => 'single_text'
));
$builder->add('created_at', 'date', array(
'label' => 'admin.news.list.created_at',
'widget' => 'single_text'
Expand Down
21 changes: 21 additions & 0 deletions features/fixtures/project/src/FSi/FixturesBundle/Entity/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class News
*/
protected $title;

/**
* @ORM\Column(type="date", nullable=true)
*/
protected $date;

/**
* @ORM\Column(type="boolean")
*/
Expand Down Expand Up @@ -103,6 +108,22 @@ public function getTitle()
return $this->title;
}

/**
* @param mixed $date
*/
public function setDate($date)
{
$this->date = $date;
}

/**
* @return mixed
*/
public function getDate()
{
return $this->date;
}

/**
* @param mixed $visible
* @return News
Expand Down