Skip to content

Commit

Permalink
use ToggleColumn for active field
Browse files Browse the repository at this point in the history
  • Loading branch information
Šarūnas Jonušas authored and sarjon committed Oct 8, 2018
1 parent 7283c4e commit dba537c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Core/Grid/Column/Type/Common/ToggleColumn.php
Expand Up @@ -54,11 +54,11 @@ protected function configureOptions(OptionsResolver $resolver)
'field',
'primary_field',
'route',
'route_param_id',
'route_param_name',
])
->setAllowedTypes('field', 'string')
->setAllowedTypes('primary_field', 'string')
->setAllowedTypes('route', 'string')
->setAllowedTypes('route_param_id', 'string');
->setAllowedTypes('route_param_name', 'string');
}
}
Expand Up @@ -38,6 +38,7 @@
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Catalog\CategoryPositionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Filter\Filter;
use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection;
Expand Down Expand Up @@ -133,10 +134,13 @@ protected function getColumns()
'position_update_route' => 'AdminCategories',
])
)
->add((new DataColumn('active'))
->add((new ToggleColumn('active'))
->setName($this->trans('Displayed', [], 'Admin.Global'))
->setOptions([
'field' => 'active',
'primary_field' => 'id_category',
'route' => 'admin_webservice_status_toggle',
'route_param_name' => 'webserviceAccountId',
])
)
->add((new ActionColumn('actions'))
Expand Down
Expand Up @@ -127,7 +127,7 @@ protected function getColumns()
'field' => 'active',
'primary_field' => 'id_webservice_account',
'route' => 'admin_webservice_status_toggle',
'route_param_id' => 'webserviceAccountId',
'route_param_name' => 'webserviceAccountId',
])
)
->add((new ActionColumn('actions'))
Expand Down
Expand Up @@ -14,7 +14,7 @@
* 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
* versions in the future. If you wish to customize PrestaShop for your:thum
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
Expand All @@ -26,14 +26,14 @@
{% set id_primary_key = record[id_property_name] %}
{% set record_id = record[id_property_name] %}

{% set valid = (record[column.id] is same as('1')) %}
{% set isValid = record[column.id] is same as('1') %}

<div class="text-center">
<i
class="material-icons ps-togglable-row grid-toggler-icon-{% if valid == true %}valid{% else %}not-valid{% endif %}"
data-toggle-url="{{ path(column.options.route, {(column.options.route_param_id) : id_primary_key})}}"
class="material-icons ps-togglable-row grid-toggler-icon-{% if isValid == true %}valid{% else %}not-valid{% endif %}"
data-toggle-url="{{ path(column.options.route, {(column.options.route_param_name) : id_primary_key})}}"
>
{% if valid %}
{% if isValid %}
check
{% else %}
clear
Expand Down

0 comments on commit dba537c

Please sign in to comment.