Issue #2329919 by lauriii, Cottser, lanchez | davidhernandez: Move views_ui classes from preprocess to templates.

8.0.x
Alex Pott 2014-10-18 13:57:53 +01:00
parent e41f90fa7e
commit 4722170f10
3 changed files with 26 additions and 19 deletions

View File

@ -8,13 +8,23 @@
* - actions: Action links such as "Add", "And/Or, Rearrange" for the content.
* - title: The title of the bucket, e.g. "Fields", "Filter Criteria", etc.
* - content: Content items such as fields or settings in this container.
* - name: The name of the bucket, e.g. "Fields", "Filter Criteria", etc.
* - overridden: A boolean indicating the setting has been overridden from the
* default.
*
* @see template_preprocess_views_ui_display_tab_bucket()
*
* @ingroup themeable
*/
#}
<div{{ attributes }}>
{%
set classes = [
'views-ui-display-tab-bucket',
name ? name|clean_class,
overridden ? 'overridden',
]
%}
<div{{ attributes.addClass(classes) }}>
{% if title -%}
<h3>{{ title }}</h3>
{%- endif %}

View File

@ -9,13 +9,25 @@
* - attributes: HTML attributes such as class for the container.
* - description: The description or label for this setting.
* - settings_links: A list of links for this setting.
* - defaulted: A boolean indicating the setting is in its default state.
* - overridden: A boolean indicating the setting has been overridden from the
* default.
*
* @see template_preprocess_views_ui_display_tab_setting()
*
* @ingroup themeable
*/
#}
<div{{ attributes }}>
{%
set classes = [
'views-display-setting',
'clearfix',
'views-ui-display-tab-setting',
defaulted ? 'defaulted',
overridden ? 'overridden',
]
%}
<div{{ attributes.addClass(classes) }}>
{% if description -%}
<span class="label">{{ description }}</span>
{%- endif %}

View File

@ -28,21 +28,10 @@ use Drupal\Core\Url;
* appended to the setting's description.
*/
function template_preprocess_views_ui_display_tab_setting(&$variables) {
// Add default class attributes.
$variables['attributes']['class'][] = 'views-display-setting';
$variables['attributes']['class'][] = 'clearfix';
// Put the primary link to the left side.
array_unshift($variables['settings_links'], $variables['link']);
$variables['attributes']['class'][] = 'views-ui-display-tab-setting';
if (!empty($variables['defaulted'])) {
$variables['attributes']['class'][] = 'defaulted';
}
if (!empty($variables['overridden'])) {
$variables['attributes']['class'][] = 'overridden';
$variables['attributes']['title'][] = t('Overridden');
}
@ -65,16 +54,12 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) {
function template_preprocess_views_ui_display_tab_bucket(&$variables) {
$element = $variables['element'];
$variables['attributes']['class'][] = 'views-ui-display-tab-bucket';
if (!empty($element['#name'])) {
$variables['attributes']['class'][] = drupal_html_class($element['#name']);
}
if (!empty($element['#overridden'])) {
$variables['attributes']['class'][] = 'overridden';
$variables['attributes']['title'][] = t('Overridden');
}
$variables['name'] = isset($element['#name']) ? $element['#name'] : NULL;
$variables['overridden'] = isset($element['#overridden']) ? $element['#overridden'] : NULL;
$variables['content'] = $element['#children'];
$variables['title'] = $element['#title'];
$variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : array();