Skip to content

Commit

Permalink
Merge pull request PrestaShop#8489 from mickaelandrieu/bogoss/refacto…
Browse files Browse the repository at this point in the history
…r-product-page

Improved Product pages templates management
  • Loading branch information
Quetzacoalt91 authored Dec 14, 2017
2 parents b5dd70c + b2042a1 commit 26e9e56
Show file tree
Hide file tree
Showing 47 changed files with 2,414 additions and 2,005 deletions.
6 changes: 4 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ twig:
strict_variables: "%kernel.debug%"
form_themes:
- 'PrestaShopBundle:Admin/TwigTemplateForm:bootstrap_3_horizontal_layout.html.twig'
globals:
webpack_server: false
paths:
'%admin_page%/Product': Product
'%admin_page%/TwigTemplateForm': Twig
'%admin_page%/Configure/AdvancedParameters': AdvancedParameters
globals:
webpack_server: false

# Doctrine Configuration
doctrine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function attributesGeneratorAction(Request $request)
$combinationDataProvider->getFormCombination($combination['id_product_attribute'])
);
$result['form'] .= $this->renderView(
'PrestaShopBundle:Admin/Product/Include:form_combination.html.twig',
'@Product/ProductPage/Forms/form_combination.html.twig',
array(
'form' => $form->createView(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function generateCombinationFormAction($combinationIds)
$combinationDataProvider->getFormCombination($combinationId)
);
$result .= $this->renderView(
'PrestaShopBundle:Admin/Product/Include:form_combination.html.twig',
'@Product/ProductPage/Forms/form_combination.html.twig',
array(
'form' => $form->createView(),
)
Expand Down
10 changes: 5 additions & 5 deletions src/PrestaShopBundle/Controller/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ProductController extends FrameworkBundleAdminController
*
* URL example: /product/catalog/40/20/id_product/asc
*
* @Template("@PrestaShop/Admin/Product/catalog.html.twig")
* @Template("@Product/CatalogPage/catalog.html.twig")
* @param Request $request
* @param integer $limit The size of the listing
* @param integer $offset The offset of the listing
Expand Down Expand Up @@ -251,7 +251,7 @@ public function catalogAction(Request $request, $limit = 10, $offset = 0, $order
* The full page that shows products list will subcall this action (from catalogAction).
* URL example: /product/list/html/40/20/id_product/asc
*
* @Template("@PrestaShop/Admin/Product/list.html.twig")
* @Template("@Product/CatalogPage/Lists/list.html.twig")
* @param Request $request
* @param integer $limit The size of the listing
* @param integer $offset The offset of the listing
Expand Down Expand Up @@ -317,7 +317,7 @@ public function listAction(Request $request, $limit = 10, $offset = 0, $orderBy
'is_shop_context' => $this->get('prestashop.adapter.shop.context')->isShopContext(),
);
if ($view != 'full') {
return $this->render('PrestaShopBundle:Admin:Product/list_' . $view . '.html.twig', array_merge($vars, [
return $this->render('@Product/CatalogPage/Lists/list_' . $view . '.html.twig', array_merge($vars, [
'limit' => $limit,
'offset' => $offset,
'total' => $totalCount,
Expand Down Expand Up @@ -375,7 +375,7 @@ public function newAction()
/**
* Product form
*
* @Template("@PrestaShop/Admin/Product/form.html.twig")
* @Template("@Product/ProductPage/product.html.twig")
* @param int $id The product ID
* @param Request $request
* @return array|Response Template vars
Expand Down Expand Up @@ -566,7 +566,7 @@ public function formAction($id, Request $request)

//If context shop is define to a group shop, disable the form
if ($shopContext->isShopGroupContext()) {
return $this->render('PrestaShopBundle:Admin/Product:formDisable.html.twig', ['showContentHeader' => false]);
return $this->render('@Product/ProductPage/disabled_form_alert.html.twig', ['showContentHeader' => false]);
}

// languages for switch dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function refreshProductSupplierCombinationFormAction($idProduct, $supplie

$form->add($simpleSubForm);

return $this->render('PrestaShopBundle:Admin:Product/Include/form-supplier-combination.html.twig', array(
return $this->render('@Product/ProductPage/Forms/form_supplier_combination.html.twig', array(
'suppliers' => $suppliers,
'form' => $form->getForm()['step6']->createView()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function refreshProductWarehouseCombinationFormAction($idProduct)

$form->add($simpleSubForm);

return $this->render('PrestaShopBundle:Admin:Product/Include/form-warehouse-combination.html.twig', array(
return $this->render('@Product/ProductPage/Forms/form_warehouse_combination.html.twig', array(
'warehouses' => $warehouses,
'form' => $form->getForm()['step4']->createView()
));
Expand Down
4 changes: 2 additions & 2 deletions src/PrestaShopBundle/Resources/config/admin/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ services:
- "@prestashop.core.admin.module.repository"
- "@prestashop.adapter.legacy.configuration"
- "@doctrine.dbal.default_connection"

# PRESTATRUST
prestashop.adapter.module.prestatrust.checker:
class: PrestaShop\PrestaShop\Adapter\Module\PrestaTrust\PrestaTrustChecker
arguments:
- "@doctrine.cache.provider"
- "@prestashop.addons.client_api"
- "@translator"

prestashop.adapter.module.prestatrust.eventsubscriber:
class: PrestaShop\PrestaShop\Adapter\Module\PrestaTrust\ModuleEventSubscriber
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
{# Display a range input with min/max controls #}
<script>
$(document).ready(function() {
var sliderInput = $('#{{ input_name }}');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{#**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
<div class="row">
{% block product_catalog_filter_select_all %}
<div class="col-md-1">
<label class="form-check-label">
<input
class="form-check-input"
type="checkbox"
id="bulk_action_select_all"
onclick="$('#product_catalog_list').find('table td.checkbox-column input:checkbox').prop('checked', $(this).prop('checked')); updateBulkMenu();"
value=""
>
{{ "Select all"|trans({}, 'Admin.Actions') }}
</label>
</div>
{% endblock %}

{% block product_catalog_filter_bulk_actions %}
<div
class="col-md-2"
bulkurl="{{ path('admin_product_bulk_action', {'action': 'activate_all'}) }}"
massediturl="{{ path('admin_product_mass_edit_action', {'action': 'sort'}) }}"
redirecturl="{{ path('admin_product_catalog', {'limit': limit, 'offset': offset, 'orderBy': orderBy, 'sortOrder': sortOrder}) }}"
redirecturlnextpage="{{ path('admin_product_catalog', {'limit': limit, 'offset': offset+limit, 'orderBy': orderBy, 'sortOrder': sortOrder}) }}"
>
{% set buttons_action = [
{
"onclick": "bulkProductAction(this, 'activate_all');",
"icon": "radio_button_checked",
"label": "Activate selection"|trans({}, 'Admin.Actions')
},
{
"onclick": "bulkProductAction(this, 'deactivate_all');",
"icon": "radio_button_unchecked",
"label": "Deactivate selection"|trans({}, 'Admin.Actions')
}
] %}

{% set buttons_action = buttons_action|merge([
{
"divider": true
},
{
"onclick": "bulkProductAction(this, 'duplicate_all');",
"icon": "content_copy",
"label": "Duplicate selection"|trans({}, 'Admin.Actions')
}
]) %}


{% set buttons_action = buttons_action|merge([
{
"divider": true
},
{
"onclick": "bulkProductAction(this, 'delete_all');",
"icon": "delete",
"label": "Delete selection"|trans({}, 'Admin.Actions')
}
]) %}

{% include 'PrestaShopBundle:Admin/Helpers:dropdown_menu.html.twig' with {
'div_style': "btn-group dropup bulk-catalog",
'button_id': "product_bulk_menu",
'disabled': true,
'menu_label': "Bulk actions"|trans({}, 'Admin.Global'),
'buttonType': "outline-secondary",
'menu_icon': "icon-caret-up",
'items': buttons_action
}%}
</div>
{% endblock %}

{% block product_catalog_filter_by_categories %}
<div id="product_catalog_category_tree_filter" class="col-md-3">
<button
class="btn btn-outline-secondary"
data-toggle="collapse"
data-target="#tree-categories"
>
{{ 'Filter by categories'|trans({}, 'Admin.Actions') }}
<i class="material-icons">expand_more</i>
</button>
<div id="tree-categories" class="collapse pt-1">
<a
class="categories-tree-actions"
href="#"
name="product_catalog_category_tree_filter_expand"
onclick="productCategoryFilterExpand($('div#product_catalog_category_tree_filter'), this);"
id="product_catalog_category_tree_filter_expand"
>
<i class="material-icons">expand_more</i>
{{ 'Expand'|trans({}, 'Admin.Actions') }}
</a>
<a
class="categories-tree-actions"
href="#"
name="product_catalog_category_tree_filter_collapse"
onclick="productCategoryFilterCollapse($('div#product_catalog_category_tree_filter'), this);"
id="product_catalog_category_tree_filter_collapse"
>
<i class="material-icons">expand_less</i>
{{ 'Collapse'|trans({}, 'Admin.Actions') }}
</a>
<a
class="categories-tree-actions"
href="#"
name="product_catalog_category_tree_filter_reset"
onclick="productCategoryFilterReset($('div#product_catalog_category_tree_filter'));"
id="product_catalog_category_tree_filter_reset"
>
<i class="material-icons">radio_button_unchecked</i>
{{ 'Unselect'|trans({}, 'Admin.Actions') }}
</a>
<hr>
{{ form_widget(categories) }}
</div>
</div>
{% endblock %}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{#**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
<div class="row">
<div class="col-md-12">
<div class="float-right">
{{ renderhook('displayDashboardToolbarIcons', {}) }}
<a id="desc-product-export" class="list-toolbar-btn" href="{{ path('admin_product_export_action') }}">
{{ ps.tooltip(("Export"|trans({}, 'Admin.Actions')), 'cloud_upload') }}
</a>
<a id="desc-product-import" class="list-toolbar-btn" href="{{ import_link }}">
{{ ps.tooltip(("Import"|trans({}, 'Admin.Actions')), 'cloud_download') }}
</a>
<a id="desc-product-show-sql" class="list-toolbar-btn" href="javascript:void(0);" onclick="showLastSqlQuery();">
{{ ps.tooltip(("Show SQL query"|trans({}, 'Admin.Actions')), 'code') }}
</a>
<a id="desc-product-sql-manager" class="list-toolbar-btn" href="javascript:void(0);" onclick="sendLastSqlQuery(createSqlQueryName());">
{{ ps.tooltip(("Export to SQL Manager"|trans({}, 'Admin.Actions')), 'storage') }}
</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{#**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*#}
<form
name="product_catalog_list"
id="product_catalog_list"
method="post"
action="{{ path('admin_product_catalog', {'limit': limit, 'orderBy': orderBy, 'sortOrder': sortOrder}) }}"
orderingurl="{{ path('admin_product_catalog', {'limit': limit, 'orderBy': 'name', 'sortOrder': 'asc'}) }}"
newproducturl="{{ path('admin_product_new') }}"
>
<div class="row">
<div class="col-md-12">
<input type="hidden" name="filter_category" value="{{ filter_category|default('') }}" />
</div>
</div>

<div class="row">
<div class="col-md-12">
{% block product_catalog_form_table %}
{{ include('@Product/CatalogPage/Lists/products_table.html.twig', {
'limit': limit,
'orderBy': orderBy,
'offset': offset,
'sortOrder': sortOrder,
'filter_category': filter_category,
'filter_column_id_product': filter_column_id_product,
'filter_column_name': filter_column_name,
'filter_column_reference': filter_column_reference,
'filter_column_name_category': filter_column_name_category,
'filter_column_price': filter_column_price,
'filter_column_sav_quantity': filter_column_sav_quantity,
'filter_column_active':filter_column_active,
'has_category_filter': has_category_filter,
'activate_drag_and_drop': activate_drag_and_drop,
'products': products,
'last_sql': last_sql
})
}}
{% endblock %}
</div>
</div>

{% if product_count_filtered > 20 %}
<div class="row">
<div class="col-md-12">
{{ render(controller('PrestaShopBundle:Admin\\Common:pagination',
{'limit': limit, 'offset': offset, 'total': product_count_filtered, 'caller_parameters': pagination_parameters, 'limit_choices': pagination_limit_choices}))
}}
</div>
</div>
{% endif %}
</form>
Loading

0 comments on commit 26e9e56

Please sign in to comment.