Commit 7da4cad9 authored by catch's avatar catch
Browse files

Issue #1913718 by dawehner: Fixed Aggregation settings link generates AJAX error.

parent df92f7b4
......@@ -314,7 +314,6 @@ public function usesGroupBy() {
* Provide a form for aggregation settings.
*/
public function buildGroupByForm(&$form, &$form_state) {
$view = &$form_state['view'];
$display_id = $form_state['display_id'];
$types = ViewExecutable::viewsHandlerTypes();
$type = $form_state['type'];
......@@ -322,8 +321,8 @@ public function buildGroupByForm(&$form, &$form_state) {
$form['#section'] = $display_id . '-' . $type . '-' . $id;
$view->initQuery();
$info = $view->query->get_aggregation_info();
$this->view->initQuery();
$info = $this->view->query->get_aggregation_info();
foreach ($info as $id => $aggregate) {
$group_types[$id] = $aggregate['title'];
}
......
......@@ -35,15 +35,28 @@ public static function getInfo() {
function testGroupBySave() {
$this->drupalGet('admin/structure/views/view/test_views_groupby_save/edit');
$edit_groubpy_url = 'admin/structure/views/nojs/config-item-group/test_views_groupby_save/default/field/id';
$this->assertNoLinkByHref($edit_groubpy_url, 0, 'No aggregation link found.');
// Enable aggregation on the view.
$edit = array(
'group_by' => TRUE,
);
$this->drupalPost('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Apply'));
$this->drupalGet('admin/structure/views/view/test_views_groupby_save/edit');
$this->drupalPost('admin/structure/views/view/test_views_groupby_save/edit', array(), t('Save'));
$this->assertLinkByHref($edit_groubpy_url, 0, 'Aggregation link found.');
// Change the groupby type in the UI.
$this->drupalPost($edit_groubpy_url, array('options[group_type]' => 'count'), t('Apply'));
$this->assertLink('COUNT(Views test: ID) (ID)', 0, 'The count setting is displayed in the UI');
$this->drupalPost(NULL, array(), t('Save'));
$this->drupalGet('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by');
$views = $this->container->get('plugin.manager.entity')->getStorageController('view')->load(array('test_views_groupby_save'));
$view = reset($views);
$display = $view->getDisplay('default');
$this->assertTrue($display['display_options']['group_by'], 'The groupby setting was saved on the view.');
$this->assertEqual($display['display_options']['fields']['id']['group_type'], 'count', 'Count groupby_type was saved on the view.');
}
}
base_table: node
base_table: views_test_data
base_table: id
core: '8'
description: ''
status: '1'
......@@ -17,6 +18,12 @@ display:
type: default
row:
type: fields
fields:
id:
field: id
table: views_test_data
id: id
plugin_id: id
display_plugin: default
display_title: Master
id: default
......
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