Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][Shop][Admin] Tweak product reviews UI and routing #6527

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Ui/Shop/ProductContext.php
Expand Up @@ -410,7 +410,7 @@ public function iShouldNotSeeReviewTitledInTheList($title)
public function iShouldBeNotifiedThatThereAreNoReviews()
{
Assert::true(
$this->productReviewsIndexPage->hasNoReviewMessage(),
$this->productReviewsIndexPage->hasNoReviewsMessage(),
'There should be message about no reviews but there is not.'
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Page/Admin/ProductReview/UpdatePage.php
Expand Up @@ -57,15 +57,15 @@ public function getRating()
*/
public function getProductName()
{
return $this->getElement('review_subject')->getHtml();
return $this->getElement('product_name')->getHtml();
}

/**
* {@inheritdoc}
*/
public function getCustomerName()
{
return $this->getElement('author')->getHtml();
return $this->getElement('customer_name')->getHtml();
}

/**
Expand All @@ -74,11 +74,11 @@ public function getCustomerName()
protected function getDefinedElements()
{
return array_merge(parent::getDefinedElements(), [
'author' => '#author-name > .header',
'checked_rating' => 'input[checked="checked"]',
'comment' => '#sylius_product_review_comment',
'rating' => '#sylius_product_review_rating_%position%',
'review_subject' => '#review-subject-name > .header',
'customer_name' => '.sylius-customer-name',
'product_name' => '.sylius-product-name',
'title' => '#sylius_product_review_title',
]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Page/Shop/ProductReview/CreatePage.php
Expand Up @@ -23,31 +23,31 @@ class CreatePage extends SymfonyPage implements CreatePageInterface
*/
public function getRouteName()
{
return 'sylius_shop_product_reviews_create';
return 'sylius_shop_product_review_create';
}

/**
* {@inheritdoc}
*/
public function titleReview($title)
{
$this->getDocument()->fillField('Title', $title);
$this->getElement('author')->setValue($title);
}

/**
* {@inheritdoc}
*/
public function setComment($comment)
{
$this->getDocument()->fillField('sylius_product_review_comment', $comment);
$this->getElement('comment')->setValue($comment);
}

/**
* {@inheritdoc}
*/
public function setAuthor($author)
{
$this->getDocument()->fillField('Author', $author);
$this->getElement('author')->setValue($author);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Page/Shop/ProductReview/IndexPage.php
Expand Up @@ -23,7 +23,7 @@ class IndexPage extends SymfonyPage implements IndexPageInterface
*/
public function getRouteName()
{
return 'sylius_shop_product_reviews_index';
return 'sylius_shop_product_review_index';
}

/**
Expand All @@ -45,9 +45,9 @@ public function hasReviewTitled($title)
/**
* {@inheritdoc}
*/
public function hasNoReviewMessage()
public function hasNoReviewsMessage()
{
return 'There are no reviews' === $this->getElement('reviews')->find('css', '.comments')->getText();
return 'There are no reviews' === $this->getElement('reviews')->find('css', '.message')->getText();
}

/**
Expand Down
Expand Up @@ -33,5 +33,5 @@ public function hasReviewTitled($title);
/**
* @return bool
*/
public function hasNoReviewMessage();
public function hasNoReviewsMessage();
}
Expand Up @@ -5,20 +5,32 @@ sylius_grid:
name: doctrine/orm
options:
class: "%sylius.model.product_review.class%"
sorting:
date: desc
fields:
date:
type: datetime
label: sylius.ui.date
path: createdAt
sortable: createdAt
options:
format: d-m-Y H:i:s
title:
type: string
label: sylius.ui.title
sortable: ~
rating:
type: string
label: sylius.ui.rating
sortable: ~
status:
type: twig
label: sylius.ui.status
sortable: ~
options:
template: SyliusAdminBundle:Grid/Field:state.html.twig
template: @SyliusAdmin/Grid/Field/state.html.twig
vars:
labels: SyliusAdminBundle:ProductReview/Label/Status
labels: @SyliusAdmin/ProductReview/Label/Status
reviewSubject:
type: string
label: sylius.ui.product
Expand Down
@@ -0,0 +1,22 @@
<div class="ui fluid card" id="customer">
<div class="content">
<a href="{{ path('sylius_admin_customer_update', {'id': customer.id}) }}" class="header sylius-customer-name">{{ customer.fullName }}</a>
<div class="meta">
<span class="date">{{ 'sylius.ui.customer_since'|trans }} {{ customer.createdAt|format_date }}.</span>
</div>
</div>
<div class="extra content">
<a href="mailto: {{ customer.email }}">
<i class="envelope icon"></i>
{{ customer.email }}
</a>
</div>
{% if customer.phoneNumber is not empty %}
<div class="extra content">
<span>
<i class="phone icon"></i>
{{ customer.phoneNumber }}
</span>
</div>
{% endif %}
</div>
@@ -1,22 +1 @@
<div class="ui fluid card" id="customer">
<div class="content">
<a href="{{ path('sylius_admin_customer_update', {'id': customer.id}) }}" class="header">{{ customer.fullName }}</a>
<div class="meta">
<span class="date">{{ 'sylius.ui.customer_since'|trans }} {{ customer.createdAt|format_date }}.</span>
</div>
</div>
<div class="extra content">
<a href="mailto: {{ customer.email }}">
<i class="envelope icon"></i>
{{ customer.email }}
</a>
</div>
{% if customer.phoneNumber is not empty %}
<div class="extra content">
<span>
<i class="phone icon"></i>
{{ customer.phoneNumber }}
</span>
</div>
{% endif %}
</div>
{% include '@SyliusAdmin/Common/_customer.html.twig' %}
@@ -1,17 +1 @@
<div class="ui fluid card">
<div class="content">
<div class="ui sub header">{{ 'sylius.ui.author'|trans }}</div>
</div>
<div class="content" id="author-name">
<a href="{{ path('sylius_admin_customer_show', {'id': resource.author.id}) }}" class="header">{{ resource.author.fullName }}</a>
<div class="meta">
<span class="date">{{ 'sylius.ui.customer_since'|trans }} {{ resource.author.createdAt|format_date }}.</span>
</div>
</div>
<div class="extra content">
<a href="mailto: {{ resource.author.email }}">
<i class="envelope icon"></i>
{{ resource.author.email }}
</a>
</div>
</div>
{% include '@SyliusAdmin/Common/_customer.html.twig' with {'customer': product_review.author} %}
Expand Up @@ -8,7 +8,7 @@
</div>
</div>
<div class="four wide column">
{% include '@SyliusAdmin/ProductReview/_reviewSubject.html.twig' %}
{% include '@SyliusAdmin/ProductReview/_product.html.twig' %}
{% include '@SyliusAdmin/ProductReview/_author.html.twig' %}
</div>
</div>
@@ -0,0 +1,8 @@
{% set product = product_review.reviewSubject %}

<h4 class="ui top attached styled header">
{{ 'sylius.ui.product'|trans }}
</h4>
<div class="ui attached segment">
<a href="{{ path('sylius_admin_product_update', {'id': product.id}) }}" class="header sylius-product-name">{{ product.name }}</a>
</div>

This file was deleted.

Expand Up @@ -24,15 +24,15 @@ class ProductReviewRepository extends EntityRepository implements ProductReviewR
/**
* {@inheritdoc}
*/
public function findLatestByProductId($productId)
public function findLatestByProductId($productId, $count = 3)
{
return $this->createQueryBuilder('o')
->where('o.reviewSubject = :productId')
->andWhere('o.status = :status')
->setParameter('productId', $productId)
->setParameter('status', ReviewInterface::STATUS_ACCEPTED)
->orderBy('o.createdAt', 'desc')
->setMaxResults(3)
->setMaxResults($count)
->getQuery()
->getResult()
;
Expand Down
3 changes: 2 additions & 1 deletion src/Sylius/Bundle/ShopBundle/Resources/config/routing.yml
Expand Up @@ -15,8 +15,9 @@ sylius_shop_taxon:
sylius_shop_product:
resource: "@SyliusShopBundle/Resources/config/routing/product.yml"

sylius_shop_product_reviews:
sylius_shop_product_review:
resource: "@SyliusShopBundle/Resources/config/routing/product_review.yml"
prefix: /products/{slug}/reviews

sylius_shop_provinces:
resource: "@SyliusShopBundle/Resources/config/routing/provinces.yml"
Expand Down
Expand Up @@ -5,6 +5,10 @@ sylius_shop_partial_product:
resource: "@SyliusShopBundle/Resources/config/routing/partial/product.yml"
prefix: /products

sylius_shop_partial_product_review:
resource: "@SyliusShopBundle/Resources/config/routing/partial/product_review.yml"
prefix: /products/{productId}/reviews

sylius_shop_partial_taxon:
resource: "@SyliusShopBundle/Resources/config/routing/partial/taxon.yml"
prefix: /taxons
Expand Down
Expand Up @@ -15,7 +15,7 @@ sylius_shop_partial_product_index_latest:
- $count

sylius_shop_partial_product_index_by_taxon_code:
path: /{code}
path: /by-taxon-code/{code}
methods: [GET]
defaults:
_controller: sylius.controller.product:indexAction
Expand Down Expand Up @@ -49,13 +49,13 @@ sylius_shop_partial_product_reviews_latest:
arguments:
- $productId

sylius_shop_product_simple_show:
path: /{slug}/simple-show
sylius_shop_partial_product_show:
path: /{slug}
methods: [GET]
defaults:
_controller: sylius.controller.product:showAction
_sylius:
template: SyliusShopBundle:Product:_simpleBox.html.twig
template: $template
repository:
method: findOneBySlugAndChannel
arguments:
Expand Down
@@ -0,0 +1,14 @@
sylius_shop_partial_product_review_latest:
path: /latest/{count}
methods: [GET]
defaults:
count: 3

_controller: sylius.controller.product_review:indexAction
_sylius:
template: $template
repository:
method: findLatestByProductId
arguments:
- $productId
- $count
@@ -1,5 +1,5 @@
sylius_shop_product_reviews_index:
path: /products/{slug}/reviews
sylius_shop_product_review_index:
path: /
methods: [GET]
defaults:
_controller: sylius.controller.product_review:indexAction
Expand All @@ -12,8 +12,8 @@ sylius_shop_product_reviews_index:
- '%locale%'
- 'expr:service("sylius.context.channel").getChannel()'

sylius_shop_product_reviews_create:
path: /products/{slug}/reviews/new
sylius_shop_product_review_create:
path: /new
methods: [GET, POST]
defaults:
_controller: sylius.controller.product_review:createAction
Expand Down
@@ -0,0 +1,20 @@
<div class="field">
<div class="ui huge star rating" data-rating="0" data-max-rating="5"></div>
<br/>
{{ form_errors(form.rating) }}
{{ form_widget(form.rating, {'attr': {'style': 'display: none'} }) }}
</div>
<div class="field">
{{ form_widget(form.title, {'attr': {'placeholder': 'sylius.ui.title'|trans} }) }}
{{ form_errors(form.title) }}
</div>
<div class="field">
{{ form_widget(form.comment, {'attr': {'placeholder': 'sylius.ui.write_your_own_review'|trans} }) }}
{{ form_errors(form.comment) }}
</div>
{% if not is_granted("IS_AUTHENTICATED_FULLY") %}
<div class="field">
{{ form_widget(form.author.email, {'attr': {'placeholder': 'sylius.ui.email'|trans}}) }}
{{ form_errors(form.author.email) }}
</div>
{% endif %}