Skip to content
Snippets Groups Projects
Commit 307b271e authored by andileco's avatar andileco
Browse files

Responding to issue 2869541: Only display libraries that are enabled as...

Responding to issue 2869541: Only display libraries that are enabled as options in the Charting Library options field.
parent 52c1c03f
No related branches found
No related tags found
No related merge requests found
......@@ -220,7 +220,12 @@ function charts_settings_form($form, $defaults = array(), $field_options = array
$charts_info = charts_info();
$library_options = array();
foreach ($charts_info as $library_name => $library_info) {
$library_options[$library_name] = $library_info['label'];
if (\Drupal::moduleHandler()->moduleExists($charts_info[$library_name]['module'])) {
$library_options[$library_name] = $library_info['label'];
}
}
if (count($library_options) == 0) {
drupal_set_message(t('There are no enabled charting libraries. Please enable a Charts sub-module.'));
}
$form['library'] = array(
'#title' => t('Charting library'),
......@@ -228,7 +233,7 @@ function charts_settings_form($form, $defaults = array(), $field_options = array
'#options' => $library_options,
'#default_value' => $options['library'],
'#required' => TRUE,
'#access' => count($library_options) > 1,
'#access' => count($library_options) > 0,
'#attributes' => array('class' => array('chart-library-select')),
'#weight' => -15,
'#parents' => array_merge($parents, array('library')),
......
......@@ -119,11 +119,10 @@ class ChartsPluginStyleChart extends StylePluginBase {
$dataFieldsCounter = 0;
foreach ($dataFields as $value) {
/*if (count(array_unique($plugin)) === 1 && end($plugin) === 0) {
$errors[] = $this->t('At least one data field must be selected in the chart configuration before this chart may be shown');
}*/
/*Skip title field no need to validate it and if data field is set add to dataFieldsValueState array state 1
otherwise add to same array state 0*/
/**
* Skip title field no need to validate it and if data field is set add to dataFieldsValueState array state 1
* otherwise add to same array state 0
*/
if ($dataFieldsCounter > 0) {
if (empty($value)) {
array_push($dataFieldsValueState, 0);
......@@ -133,8 +132,11 @@ class ChartsPluginStyleChart extends StylePluginBase {
}
$dataFieldsCounter++;
}
/*If total sum of dataFieldsValueState is less than 1, then no dataFields were selected otherwise 1 or more selected
total sum will be greater than 1*/
/**
* If total sum of dataFieldsValueState is less than 1, then no dataFields were selected otherwise 1 or more selected
* total sum will be greater than 1
*/
if (array_sum($dataFieldsValueState) < 1) {
$errors[] = $this->t('At least one data field must be selected in the chart configuration before this chart may be shown');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment