resolve code review comments

This commit is contained in:
Ivo Valchev
2020-01-08 13:39:41 +01:00
parent 503fc7db84
commit e726850fc5
4 changed files with 72 additions and 2 deletions
+1
View File
@@ -17,6 +17,7 @@ parameters:
-
message: '#Unreachable statement - code above always terminates#'
path: %currentWorkingDirectory%/src/*
# false positive: TranslationInterface does not know about FieldTranslation::getValue(). Skip this error.
-
message: '#Call to an undefined method Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface#'
path: %currentWorkingDirectory%/src/*
+5
View File
@@ -173,6 +173,11 @@ class Field implements FieldInterface, TranslatableInterface
return $this->translate($this->getCurrentLocale())->getValue();
}
/**
* like getValue() but returns single value for single value fields
*
* @return array|mixed|null
*/
public function getParsedValue()
{
$value = $this->getValue();
-2
View File
@@ -7,7 +7,6 @@ namespace Bolt\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
@@ -25,7 +24,6 @@ class FieldTranslation implements TranslationInterface
/**
* @ORM\Column(type="json")
* @Groups("get_field")
*/
protected $value = [];
+66
View File
@@ -204,3 +204,69 @@ Feature: Edit record
Then I should be on "/bolt/edit/43#sets"
And the field with css "#sets > div > div:nth-child(2) > div > input" should contain "Foo"
And the field with css "#sets > div > div:nth-child(3) > div > textarea" should contain "Bar"
@javascript-disabled
Scenario: As an Admin I want to fill in a Collection
Given I am logged in as "admin"
And I am on "/bolt/edit/43"
Then I should see "Collections" in the ".editor__tabbar" element
When I follow "Collections"
Then I should be on "/bolt/edit/43#collections"
And I should see "Collection:" in the "label[for='field-collection']" element
#templates dropdown
When I click "#multiselect-undefined > div > div.multiselect__select"
Then I should see "Set" in the "#multiselect-undefined > div > div.multiselect__content-wrapper > ul > li:nth-child(1) > span" element
And I should see "Textarea" in the "#multiselect-undefined > div > div.multiselect__content-wrapper > ul > li:nth-child(2) > span" element
When I click "#multiselect-undefined > div > div.multiselect__content-wrapper > ul > li:nth-child(2) > span"
And I press "Add item"
Then I should see an ".collection-item" element
And I should see an ".trumbowyg-editor" element
And I should see "Textarea:" in the "#collections > div > div > div:nth-child(2) > div > label" element
And the ".action-move-up-collection-item" button should be disabled
And the ".action-move-down-collection-item" button should be enabled
When I scroll "#multiselect-undefined > div > div.multiselect__select" into view
And I click "#multiselect-undefined > div > div.multiselect__select"
And I scroll "#multiselect-undefined > div > div.multiselect__content-wrapper > ul > li:nth-child(1)" into view
And I click "#multiselect-undefined > div > div.multiselect__content-wrapper > ul > li:nth-child(1)"
And I press "Add item"
Then I should see 4 ".collection-item" elements
#And I should see an "#collections .collection-item:nth-of-type(4) #field-title" element
#And I should see "Set:" in the "#collections .collection-item:nth-of-type(4) label" element
When I fill "#collections .collection-item:nth-of-type(3) textarea" element with "Bye, Bolt"
And I fill "#collections .collection-item:nth-of-type(4) input[type='text']" element with "Hey, Bolt"
#First move down
And I scroll "#collections .collection-item:nth-of-type(3) button.action-move-down-collection-item.btn.btn-secondary" into view
And I click "#collections .collection-item:nth-of-type(3) button.action-move-down-collection-item.btn.btn-secondary"
Then I should see "Set:" in the "#collections .collection-item:nth-of-type(3)" element
And I should see "Textarea:" in the "#collections .collection-item:nth-of-type(4)" element
When I scroll "#editcontent > div.record-actions > button" into view
And I press "Save changes"
Then I should be on "/bolt/edit/43#collections"
And the field with css "#collections .collection-item:nth-of-type(3) input[type='text']" should contain "Hey, Bolt"
And the field with css "#collections .collection-item:nth-of-type(4) textarea" should contain "Bye, Bolt"
#remove both
When I scroll "#collections .collection-item:nth-of-type(3) button.action-remove-collection-item.btn.btn-hidden-danger" into view
And I click "#collections .collection-item:nth-of-type(3) button.action-remove-collection-item.btn.btn-hidden-danger"
#4th becomes 3rd on prev removal
And I click "#collections .collection-item:nth-of-type(3) button.action-remove-collection-item.btn.btn-hidden-danger"
Then I should see 2 ".collection-item" elements
When I scroll "#editcontent > div.record-actions > button" into view
And I press "Save changes"
Then I should see 2 ".collection-item" elements
And I should not see "Hey, Bolt"
And I should not see "Bye, Bolt"