Commit dee9ef66 authored by alexpott's avatar alexpott
Browse files

Issue #1929064 by damiankloip, dawehner: Refactor views_ui_rearrange_form() to...

Issue #1929064 by damiankloip, dawehner: Refactor views_ui_rearrange_form() to remove theme function for table render.
parent 5433aad7
......@@ -74,23 +74,23 @@ public function buildForm(array $form, array &$form_state) {
$relationships[$id] = $handler->label();
}
// Filters can now be grouped so we do a little bit extra:
$groups = array();
$grouping = FALSE;
if ($type == 'filter') {
$group_info = $executable->display_handler->getOption('filter_groups');
if (!empty($group_info['groups']) && count($group_info['groups']) > 1) {
$grouping = TRUE;
$groups = array(0 => array());
}
}
$form['fields'] = array(
'#type' => 'table',
'#header' => array('', t('Weight'), t('Remove')),
'#empty' => t('No fields available.'),
'#tabledrag' => array(
array('order', 'sibling', 'weight'),
),
'#tree' => TRUE,
'#prefix' => '<div class="scroll">',
'#suffix' => '</div>',
);
foreach ($display->getOption($types[$type]['plural']) as $id => $field) {
$form['fields'][$id] = array('#tree' => TRUE);
$form['fields'][$id]['weight'] = array(
'#type' => 'textfield',
'#default_value' => ++$count,
);
$form['fields'][$id] = array();
$form['fields'][$id]['#attributes'] = array('class' => array('draggable'), 'id' => 'views-row-' . $id);
$handler = $display->getHandler($type, $id);
if ($handler) {
$name = $handler->adminLabel() . ' ' . $handler->adminSummary();
......@@ -105,30 +105,29 @@ public function buildForm(array $form, array &$form_state) {
else {
$form['fields'][$id]['name'] = array('#markup' => t('Broken field @id', array('@id' => $id)));
}
$form['fields'][$id]['weight'] = array(
'#type' => 'textfield',
'#default_value' => ++$count,
'#attributes' => array('class' => array('weight')),
);
$form['fields'][$id]['removed'] = array(
'#type' => 'checkbox',
'#id' => 'views-removed-' . $id,
'#attributes' => array('class' => array('views-remove-checkbox')),
'#default_value' => 0,
'#suffix' => l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)),
);
}
// Add javascript settings that will be added via $.extend for tabledragging
$form['#js']['tableDrag']['arrange']['weight'][0] = array(
'target' => 'weight',
'source' => NULL,
'relationship' => 'sibling',
'action' => 'order',
'hidden' => TRUE,
'limit' => 0,
);
$name = NULL;
if (isset($form_state['update_name'])) {
$name = $form_state['update_name'];
}
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form');
return $form;
}
......
......@@ -242,38 +242,6 @@ function theme_views_ui_reorder_displays_form($vars) {
return $output;
}
/**
* Turn the rearrange form into a proper table
*/
function theme_views_ui_rearrange_form($variables) {
$form = $variables['form'];
$rows = array();
foreach (element_children($form['fields']) as $id) {
if (isset($form['fields'][$id]['name'])) {
$row = array();
$row[] = drupal_render($form['fields'][$id]['name']);
$form['fields'][$id]['weight']['#attributes']['class'] = array('weight');
$row[] = drupal_render($form['fields'][$id]['weight']);
$row[] = drupal_render($form['fields'][$id]['removed']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE));
$rows[] = array('data' => $row, 'class' => array('draggable'), 'id' => 'views-row-' . $id);
}
}
if (empty($rows)) {
$rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2'));
}
$header = array('', t('Weight'), t('Remove'));
$output = drupal_render($form['override']);
$output .= '<div class="scroll">';
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'arrange')));
$output .= '</div>';
$output .= drupal_render_children($form);
drupal_add_tabledrag('arrange', 'order', 'sibling', 'weight');
return $output;
}
/**
* Turn the rearrange form into a proper table
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment