Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DEMO-113: [Product] - Card View (ezsystems#82)
  • Loading branch information
damianz5 committed Mar 23, 2018
1 parent 3fbe478 commit f6092ba
Show file tree
Hide file tree
Showing 11 changed files with 742 additions and 1 deletion.
27 changes: 27 additions & 0 deletions app/Resources/views/themes/tastefulplanet/card/product.html.twig
@@ -0,0 +1,27 @@
<div class="product-list-item">
{% set url = path(location) %}
<a href="{{ url }}">
{{ ez_render_field(content, 'image', {
parameters: {
alias: 'product_card',
class: 'img-fluid'
}
}) }}
</a>

<div class="product-list-item-info">
<div class="product-list-item-title">
<a href="{{ url }}">
{{ ez_render_field(content, 'title') }}
</a>
</div>
<div class="product-list-item-elements">
<div class="product-list-item-price">$ {{ ez_field_value(content, 'price').value|number_format(2, '.') }}</div>
<div class="product-list-item-add-button">
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addModal">
<i class="fa fa-shopping-basket fa-lg"></i> {{ 'Add to cart'|trans }}
</button>
</div>
</div>
</div>
</div>
162 changes: 162 additions & 0 deletions app/Resources/views/themes/tastefulplanet/full/product_list.html.twig
@@ -0,0 +1,162 @@
{% extends "@ezdesign/pagelayout.html.twig" %}

{% block page_head %}
{% set title = ez_content_name(content) %}
{{ parent() }}
{% endblock %}

{% form_theme form _self %}

{%- block choice_widget_expanded -%}
<div {{ block('widget_container_attributes') }}>
{%- for child in form %}
<div class="element">
{{- form_widget(child) -}}
{{- form_label(child, null, {translation_domain: choice_translation_domain}) -}}
</div>
{% endfor -%}
</div>
{%- endblock choice_widget_expanded -%}

{% block content %}
{% include '@ezdesign/parts/product_modal_dialog.html.twig' %}

<section class="content-type-product-list full-view">
<div class="banner-image">
<div class="thumbnail text-center">
{{ ez_render_field(content, 'banner', {
'parameters': {'alias': 'original', 'class': 'img-fluid w-100'}
}) }}
<div class="title">
<h1 class="field-title">{{ ez_render_field(content, 'description') }}</h1>
</div>
</div>
</div>

<div class="container product-container">
<div class="col-md-12 section-spacer">
<span>{{ 'What is on our menu'|trans }}</span>
</div>

<div class="row">
<div class="col-md-10 offset-md-1">
{{ form_start(form, { 'action': path(location) }) }}

<div class="col-md-12 section-search">
<div class="input-group">
{{ form_widget(form.searchText, {'attr': {'class': 'search', 'placeholder': 'Search Recipes...'}}) }}
{{ form_widget(form.save, {'attr': {'class': 'btn btn-search'}}) }}
<div class="filter-button">
<button class="btn btn-filters">{{ 'Filters'|trans }} <span class="fa fa-filter"></span></button>
</div>
</div>
</div>

<div class="col-md-12 section-filter">
<div class="filters">
<div class="filter-container">
<div class="column">
<b>{{ 'Allergies'|trans }}:</b>
{{ form_row(form.dairy) }}
{{ form_row(form.egg) }}
{{ form_row(form.nuts) }}
{{ form_row(form.seafood) }}
{{ form_row(form.gluten) }}
</div>
<div class="column">
<b>{{ 'Spicyness'|trans }}: </b>
{{ form_widget(form.spicy) }}
</div>
<div class="column">
<b>{{ 'Servings'|trans }}: </b>
{{ form_widget(form.serving) }}
</div>
</div>
<div class="buttons">
<button class="btn btn-apply" type="submit">{{ 'Apply filters'|trans }}</button>
<span class="btn btn-clear">{{ 'Clear all'|trans }}</span>
</div>
</div>
</div>

{{ form_end(form) }}
</div>
</div>

<div class="col-md-10 offset-md-1 product-items">
{% if children|length > 0 %}
{% for content in children %}
{{ render_esi(controller('ez_content:viewAction', {
'locationId': content.contentInfo.mainLocationId,
'viewType': view_type
})) }}
{% endfor %}

{% if children.currentPageResults|length < children.maxPerPage %}
{% set missingItems = children.maxPerPage - children.currentPageResults|length %}
{% for item in 1..missingItems %}
<div class="product-list-item"></div>
{% endfor %}
{% endif %}
{% else %}
<div class="warning">
<h2>{{ 'No results were found.'|trans }}</h2>
<div class="well">
<p>Search tips</p>
<ul>
<li>{{ 'Check spelling of keywords.'|trans }}</li>
<li>{{ 'Try changing some keywords (eg, "car" instead of "cars").'|trans }}</li>
<li>{{ 'Try searching with less specific keywords.'|trans }}</li>
<li>{{ 'Reduce number of keywords to get more results.'|trans }}</li>
<li>{{ 'Change the filters.'|trans }}</li>
</ul>
</div>
</div>
{% endif %}
</div>

<div class="container">
<div class="col-md-12 space-bottom text-center">
{% if children.haveToPaginate() %}
{{ pagerfanta(children, 'twitter_bootstrap4_translated', {
routeName: location,
routeParams: ezpublish.requestStack.masterRequest.query.all
}) }}
{% endif %}
</div>
</div>
</div>
</section>


<script>
$(function () {
var checkedCheckboxes,
countCheckedCheckboxes = function () {
checkedCheckboxes = $('.filters input:checkbox:checked').length;
$('.section-search .btn-filters .badge').html(checkedCheckboxes > 0 ? checkedCheckboxes : '');
return checkedCheckboxes;
};
$('.filter-container input[type="checkbox"]').click(function () {
countCheckedCheckboxes();
});
$('.btn-filters').click(function () {
$('.filters, .filter-button > .arrow').toggle();
$('.section-header').toggleClass('section-filter');
return false;
});
$('.filters .btn-clear').click(function () {
$('.filter-container input[type="checkbox"]').attr('checked', false);
countCheckedCheckboxes();
return false;
});
if (countCheckedCheckboxes()) {
$('.btn-filters').trigger('click');
}
})
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion app/config/default_parameters.yml
Expand Up @@ -84,7 +84,7 @@ parameters:

# Top menu parameters
app.top_menu.parent_location_id: 2
app.top_menu.includedContentTypeIdentifier: ["folder", "article", "place_list", "blog", "about"]
app.top_menu.includedContentTypeIdentifier: ["folder", "article", "place_list", "product_list", "blog", "about"]

# locationIds used for fetching items on home page
app.home.place_list_location_id: 219
Expand Down
1 change: 1 addition & 0 deletions app/config/ezplatform.yml
Expand Up @@ -105,6 +105,7 @@ assetic:
- 'assets/css/place.css'
- 'assets/css/place_list.css'
- 'assets/css/product.css'
- 'assets/css/product_list.css'
- 'assets/css/blog.css'
- 'assets/css/blog_post.css'
- 'assets/css/subscribe.css'
Expand Down
8 changes: 8 additions & 0 deletions app/config/image_variations.yml
Expand Up @@ -6,6 +6,7 @@ ezpublish:
reference: null
filters:
- { name: geometry/scaledownonly, params: [970, 600] }

search_result_item:
reference: null
filters:
Expand All @@ -15,7 +16,14 @@ ezpublish:
reference: null
filters:
- {name: geometry/scaleexact, params: [505, 400]}

product_large:
reference: null
filters:
- {name: geometry/scaleexact, params: [633, 500]}

product_card:
reference: null
filters:
- {name: geometry/scalewidth, params: [281]}
- {name: geometry/crop, params: [281, 181, 0, 0]}
8 changes: 8 additions & 0 deletions app/config/services.yml
Expand Up @@ -40,6 +40,14 @@ services:
- '@templating'
- '@hautelook.router.template'

app.controller.product_list_controller:
class: AppBundle\Controller\ProductListController
public: true
arguments:
- '@ezpublish.query_type_content_view_mapper'
- '@ezpublish.api.service.search'
- '@form.factory'

app.mail.sender:
class: AppBundle\Mail\Sender
public: true
Expand Down
19 changes: 19 additions & 0 deletions app/config/views.yml
Expand Up @@ -93,6 +93,20 @@ ezpublish:
match:
Identifier\ContentType: [product]

product_list:
controller: "app.controller.product_list_controller:contentQueryPaginationAction"
params:
page_limit: 12
view_type: card
query:
query_type: "AppBundle:Children"
parameters:
parent_location_id: '@=location.id'
assign_results_to: children
template: "@ezdesign/full/product_list.html.twig"
match:
Identifier\ContentType: [product_list]

home:
place_list:
controller: 'ez_query:ContentQueryAction'
Expand Down Expand Up @@ -137,6 +151,11 @@ ezpublish:
match:
Identifier\ContentType: [place]

product:
template: "@ezdesign/card/product.html.twig"
match:
Identifier\ContentType: [product]

featured:
article:
template: "@ezdesign/featured/article.html.twig"
Expand Down

0 comments on commit f6092ba

Please sign in to comment.