commit cc009303f0a15cdb83b2f7648d90a111e7c86f16 Author: Joel Pittet Date: Sat Sep 6 13:58:55 2014 -0700 views re-arrange filters diff --git a/core/modules/views_ui/templates/views-ui-rearrange-filter-form.html.twig b/core/modules/views_ui/templates/views-ui-rearrange-filter-form.html.twig index 7f2ada2..c5de36d 100644 --- a/core/modules/views_ui/templates/views-ui-rearrange-filter-form.html.twig +++ b/core/modules/views_ui/templates/views-ui-rearrange-filter-form.html.twig @@ -4,32 +4,25 @@ * Default theme implementation for Views UI rearrange filter form. * * Available variables: - * - override: @todo. + * - form: A render element representing the form. * - grouping: A flag whether or not there is more than one group. - * - filter_groups_operator: @todo. - * - filter_groups_group: @todo. - * - ungroupable_table: @todo. - * - table: Filter's form table. - * - children: Child elements of the form that still need to be printed. + * - ungroupable_table: The ungroupable filter table. + * - table: The groupable filter table. * - * @see template_preprocess() * @see template_preprocess_views_ui_rearrange_filter_form() * * @ingroup themeable */ #} -{% if override %} - {{ override }} -{% endif %} -
+{{ form.override }} +
{% if grouping %} - {{ filter_groups_operator }} + {{ form.filter_groups.operator }} {% else %} - {{ filter_groups_group }} - {% endif %} - {% if ungroupable_table %} - {{ ungroupable_table }} + {{ form.filter_groups.groups.0 }} {% endif %} + {{ ungroupable_table }} {{ table }}
-{{ children }} + +{{ form|without('override', 'filter_groups', 'remove_groups') }} diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index 491a849..e024531 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -195,15 +195,15 @@ function theme_views_ui_build_group_filter_form($variables) { * * Default template: views-ui-rearrange-filter-form.html.twig. * - * @param array $vars + * @param array $variables * An associative array containing: * - form: A render element representing the form. */ -function template_preprocess_views_ui_rearrange_filter_form(&$vars) { +function template_preprocess_views_ui_rearrange_filter_form(&$variables) { $form = $variables['form']; $rows = $ungroupable_rows = array(); // Enable grouping only if > 1 group. - $grouping = count(array_keys($form['#group_options'])) > 1; + $variables['grouping'] = count(array_keys($form['#group_options'])) > 1; foreach ($form['#group_renders'] as $group_id => $contents) { // Header row for the group. @@ -270,13 +270,10 @@ function template_preprocess_views_ui_rearrange_filter_form(&$vars) { foreach ($contents as $id) { if (isset($form['filters'][$id]['name'])) { $row = array(); - $row[] = drupal_render($form['filters'][$id]['name']); $row[]['data'] = $form['filters'][$id]['name']; $form['filters'][$id]['weight']['#attributes']['class'] = array('weight'); - $row[] = drupal_render($form['filters'][$id]['weight']); $row[]['data'] = $form['filters'][$id]['weight']; $form['filters'][$id]['group']['#attributes']['class'] = array('views-group-select views-group-select-' . $group_id); - $row[] = drupal_render($form['filters'][$id]['group']); $row[]['data'] = $form['filters'][$id]['group']; $form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide'; @@ -323,32 +320,38 @@ function template_preprocess_views_ui_rearrange_filter_form(&$vars) { $rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2')); } - if (isset($form['override'])) { - $variables['override'] = $form['override']; - unset($form['override']); - } - - $variables['grouping'] = $grouping; - if ($grouping) { - $output .= drupal_render($form['filter_groups']['operator']); - } - else { + if (!$variables['grouping']) { $form['filter_groups']['groups'][0]['#title'] = t('Operator'); - $variables['filter_groups_group'] = $form['filter_groups']['groups'][0]; } if (!empty($ungroupable_rows)) { $header = array( t('Ungroupable filters'), t('Weight'), - array('class' => array('views-hide-label'), 'data' => t('Group')), - array('class' => array('views-hide-label'), 'data' => t('Remove')), + array( + 'data' => t('Group'), + 'class' => array('views-hide-label'), + ), + array( + 'data' => t('Remove'), + 'class' => array('views-hide-label'), + ), ); $variables['ungroupable_table'] = array( '#type' => 'table', '#header' => $header, '#rows' => $ungroupable_rows, - '#attributes' => array('id' => 'views-rearrange-filters-ungroupable', 'class' => array('arrange')), + '#attributes' => array( + 'id' => 'views-rearrange-filters-ungroupable', + 'class' => array('arrange'), + ), + '#tabledrag' => array( + array( + 'action' => 'order', + 'relationship' => 'sibling', + 'group' => 'weight', + ) + ), ); } @@ -356,7 +359,10 @@ function template_preprocess_views_ui_rearrange_filter_form(&$vars) { $variables['table'] = array( '#type' => 'table', '#rows' => $rows, - '#attributes' => array('id' => 'views-rearrange-filters', 'class' => array('arrange')), + '#attributes' => array( + 'id' => 'views-rearrange-filters', + 'class' => array('arrange'), + ), '#tabledrag' => array( array( 'action' => 'order', @@ -366,16 +372,10 @@ function template_preprocess_views_ui_rearrange_filter_form(&$vars) { ), ); - unset($form['filter_groups']); - unset($form['remove_groups']); - // When JavaScript is enabled, the button for adding a new group should be // hidden, since it will be replaced by a link on the client side. $form['actions']['add_group']['#attributes']['class'][] = 'js-hide'; - // Remove elements from the 'children' render array. - // @todo Refactor when http://drupal.org/node/1920886 is resolved. - $variables['children'] = drupal_render_children($form); } /**