Commit 49861ccc authored by alexpott's avatar alexpott

Issue #1838010 by dawehner | Bojhan: Remove redundant admin labeling on AreaPluginBase.

parent 924be51a
......@@ -47,22 +47,12 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
}
}
/**
* Get this area's label.
*/
public function label() {
if (!isset($this->options['label'])) {
return $this->adminLabel();
}
return $this->options['label'];
}
protected function defineOptions() {
$options = parent::defineOptions();
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
$options['label'] = array('default' => $label, 'translatable' => TRUE);
$options['admin_label']['default'] = $label;
$options['empty'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
......@@ -72,7 +62,7 @@ protected function defineOptions() {
* Provide extra data to the administration form
*/
public function adminSummary() {
return $this->label();
return $this->adminLabel();
}
/**
......@@ -81,12 +71,6 @@ public function adminSummary() {
*/
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
'#description' => t('The label for this area that will be displayed only administratively.'),
);
if ($form_state['type'] != 'empty') {
$form['empty'] = array(
......
......@@ -909,12 +909,7 @@ public function getHandlers($type) {
public function getFieldLabels($groupable_only = FALSE) {
$options = array();
foreach ($this->getHandlers('relationship') as $relationship => $handler) {
if ($label = $handler->label()) {
$relationships[$relationship] = $label;
}
else {
$relationships[$relationship] = $handler->adminLabel();
}
$relationships[$relationship] = $handler->adminLabel();
}
foreach ($this->getHandlers('field') as $id => $handler) {
......
......@@ -65,20 +65,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
}
}
/**
* Get this field's label.
*/
function label() {
if (!isset($this->options['label'])) {
return $this->adminLabel();
}
return $this->options['label'];
}
protected function defineOptions() {
$options = parent::defineOptions();
// Relationships definitions should define a default label, but if they aren't get another default value.
if (!empty($this->definition['label'])) {
$label = $this->definition['label'];
......@@ -87,7 +76,7 @@ protected function defineOptions() {
$label = !empty($this->definition['field']) ? $this->definition['field'] : $this->definition['base field'];
}
$options['label'] = array('default' => $label, 'translatable' => TRUE);
$options['admin_label']['default'] = $label;
$options['required'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
......@@ -99,13 +88,9 @@ protected function defineOptions() {
*/
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Identifier'),
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
'#description' => t('Edit the administrative label displayed when referencing this relationship from filters, etc.'),
'#required' => TRUE,
);
unset($form['admin_label']['#fieldset']);
$form['admin_label']['#weight'] = -1;
$form['required'] = array(
'#type' => 'checkbox',
......
......@@ -78,7 +78,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$base = $data[$relationship['field']]['relationship']['base'];
if ($base == $this->base_table) {
$relationship_handler->init($executable, $relationship);
$relationship_options[$relationship['id']] = $relationship_handler->label();
$relationship_options[$relationship['id']] = $relationship_handler->adminLabel();
}
}
......
......@@ -75,13 +75,13 @@ public function testUI() {
// Then setup a no empty label.
$labels[$type] = $this->randomName();
$this->drupalPost($edit_path, array('options[label]' => $labels[$type]), t('Apply'));
$this->drupalPost($edit_path, array('options[admin_label]' => $labels[$type]), t('Apply'));
// Make sure that the new label appears on the site.
$this->assertText($labels[$type]);
// Test that the settings (empty/label) are accessible.
// Test that the settings (empty/admin_label) are accessible.
$this->drupalGet($edit_path);
$this->assertField('options[label]');
$this->assertField('options[admin_label]');
if ($type !== 'empty') {
$this->assertField('options[empty]');
}
......@@ -169,7 +169,6 @@ public function testTitleArea() {
'table' => 'views',
'field' => 'title',
'admin_label' => '',
'label' => '',
'empty' => '0',
'title' => 'Overridden title',
),
......
......@@ -97,11 +97,14 @@ public function testUICRUD() {
}
$this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
$this->drupalPost(NULL, array(), t('Apply'));
$random_label = $this->randomName();
$this->drupalPost(NULL, array('options[admin_label]' => $random_label), t('Apply'));
$this->assertUrl('admin/structure/views/view/test_view_empty/edit/default', array(), 'The user got redirected to the views edit form.');
$this->assertLinkByHref($edit_handler_url, 0, 'The handler edit link appears in the UI.');
$links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', array(':label' => $random_label));
$this->assertTrue(isset($links[0]), 'The handler edit link has the right label');
// Save the view and have a look whether the handler was added as expected.
$this->drupalPost(NULL, array(), t('Save'));
......
......@@ -108,7 +108,7 @@ public function buildForm(array $form, array &$form_state) {
$base_fields = views_fetch_fields($base, $form_state['type'], $executable->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
$relationship_handler->init($executable, $executable->display_handler, $relationship);
$relationship_options[$relationship['id']] = $relationship_handler->label();
$relationship_options[$relationship['id']] = $relationship_handler->adminLabel();
}
}
......
......@@ -71,7 +71,7 @@ public function buildForm(array $form, array &$form_state) {
// Get relationship labels
$relationships = array();
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->label();
$relationships[$id] = $handler->adminLabel();
}
$form['fields'] = array(
......
......@@ -65,7 +65,7 @@ public function buildForm(array $form, array &$form_state) {
// Get relationship labels
$relationships = array();
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->label();
$relationships[$id] = $handler->adminLabel();
}
$group_options = array();
......
......@@ -957,10 +957,10 @@ public function getFormBucket(ViewUI $view, $type, $display) {
static $relationships = NULL;
if (!isset($relationships)) {
// Get relationship labels
// Get relationship labels.
$relationships = array();
foreach ($executable->display_handler->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->label();
$relationships[$id] = $handler->adminLabel();
}
}
......
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