Commit 05d901cf authored by git's avatar git Committed by ygerasimov

Issue #1268824 by Merco: Add ajax support.

parent 5c10a22c
......@@ -98,6 +98,13 @@ function draggableviews_view_draggabletable_form($form, $form_state, $style_plug
'#name' => 'save_order',
'#value' => t(isset($options['draggableviews_button_text']) ? $options['draggableviews_button_text'] : t('Save order')),
);
if($options['draggableviews_ajax']){
$form['submit']['#ajax'] = array(
'callback' => 'draggableviews_view_draggabletable_form_ajax'
);
}
$form['#submit'] = array('draggableviews_view_draggabletable_form_submit');
// Use pager information and all exposed input data to build the query.
......@@ -174,6 +181,20 @@ function draggableviews_view_draggabletable_form($form, $form_state, $style_plug
return $form;
}
/**
* Ajax submit handler
*/
function draggableviews_view_draggabletable_form_ajax($form, $form_state){
// Find the form element
$form_element = "form:has(input[name=form_build_id][value='{$form['form_build_id']['#value']}'])";
// remove warning and asterisk
return array('#type' => 'ajax', '#commands' => array(
ajax_command_remove("$form_element div.tabledrag-changed-warning, $form_element span.tabledrag-changed")
));
}
/**
* Implements hook_theme().
*/
......
......@@ -65,6 +65,11 @@ function draggableviews_tests_views_default_views() {
0 => 'repair',
'repair' => 0,
);
$handler->display->display_options['style_options']['draggableviews_ajax'] = array(
'use_ajax' => 0,
);
$handler->display->display_options['style_options']['tabledrag_expand'] = array(
'expand_links' => 0,
'collapsed' => 0,
......
......@@ -406,6 +406,8 @@ function theme_draggableviews_ui_style_plugin_draggabletable($variables) {
$draggableviews_repair = drupal_render($form['draggableviews_repair']);
$draggableviews_ajax = drupal_render($form['draggableviews_ajax']);
// build types table
$tabledrag_types_rows = array();
foreach (element_children($form['tabledrag_types']) as $id) {
......@@ -443,6 +445,8 @@ function theme_draggableviews_ui_style_plugin_draggabletable($variables) {
// inherited from plugin_table from plugin_draggableviews settings.
$output .= drupal_render_children($form);
// Append ajax options
$output .= $draggableviews_ajax;
// Append order settings.
$output .= $tabledrag_header;
$output .= $description_tabledrag;
......
......@@ -24,6 +24,7 @@ class draggableviews_plugin_style_draggabletable extends views_plugin_style_tabl
$options['tabledrag_hierarchy_visible'] = array('default' => array());
$options['draggableviews_depth_limit'] = array('default' => 0);
$options['draggableviews_repair'] = array('default' => array('repair' => 'repair'));
$options['draggableviews_ajax'] = array('default' => 0);
$options['tabledrag_types'] = array('default' => array());
$options['tabledrag_expand'] = array('default' => array());
$options['draggableviews_extensions'] = array('default' => array('extension_top' => 3, 'extension_bottom' => 3));
......@@ -268,6 +269,14 @@ class draggableviews_plugin_style_draggabletable extends views_plugin_style_tabl
'#default_value' => $current['draggableviews_repair'],
);
// Ajax handler:
$form['draggableviews_ajax'] = array(
'#type' => 'checkbox',
'#title' => t('Ajax'),
'#description' => t('If checked and javascript is enabled, the drupal ajax api is used to submit the form.'),
'#default_value' => $current['draggableviews_ajax'],
);
if (strcmp($this->view->base_table, 'node') == 0) {
// Tabledrag types (root/leaf).
// These fields will save the behaviour of a node-type (root, leaf).
......
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