commit e8074ec5cb608ebb0d3ab76aa29fdd41544f0ee6
Author: Patrick Plitzner
Date: Wed Jul 6 14:30:10 2016 +0200
#5890 Pass classification uuid and taxon uuid to csv export
diff --git a/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module b/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
index 0e5569ca..995fcdef 100644
--- a/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
+++ b/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
@@ -73,12 +73,12 @@ function cdm_csv_export_block_view($delta='') {
return $block;
}
-function taxon_selection_update($form, &$form_state) {
- unset($form_state['input']['taxon_select'], $form_state['values']['taxon_select']);
- $tree = $form_state['input']['taxonNode'];
- $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
- $form['taxon_select']['#value'] = '';
- return form_builder($form['#id'], $form['taxon_select'], $form_state);
+function update_classification_selected($form, &$form_state) {
+ unset($form_state['input']['csv_export_taxon_select'], $form_state['values']['csv_export_taxon_select']);
+ $tree = $form_state['input']['classificationUuid'];
+ $form['csv_export_taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
+ $form['csv_export_taxon_select']['#value'] = '';
+ return form_builder($form['#id'], $form['csv_export_taxon_select'], $form_state);
}
/**
@@ -90,17 +90,17 @@ function taxon_selection_update($form, &$form_state) {
*/
function cdm_csv_export_my_form($form_state) {
$tree = variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
- $form['combobox'] = array(
+ $form['csv_export_classification_select'] = array(
'#type' => 'select',
'#title' => t('Classification').':',
'#default_value' => $tree,
'#options' => cdm_get_taxontrees_as_options(FALSE, TRUE),
'#attributes' => array(
- 'name' => 'taxonNode',
+ 'name' => 'classificationUuid',
'onchange' => 'return validateForm()'
),
'#ajax' => array(
- 'callback' => 'taxon_selection_update',
+ 'callback' => 'update_classification_selected',
'wrapper' => 'taxon-selection',
'progress' => array(
'message' => '',
@@ -108,15 +108,26 @@ function cdm_csv_export_my_form($form_state) {
),
)
);
- $form['taxon_select'] = array(
+ $form['csv_export_taxon_select'] = array(
'#title' => t('Taxon'),
'#type' => 'textfield',
'#prefix' => '',
- '#suffix' => '
'
+ '#suffix' => '',
+ '#attributes' => array(
+ 'onchange' => 'return validateForm()'
+ ),
);
if(variable_get('cdm_dataportal_taxon_auto_suggest')){
- $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
+ $form['csv_export_taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
}
+ $form['taxonUuidStore'] = array(
+ '#type' => 'hidden',
+ '#value' => '',
+ '#name' => taxonUuid,
+ '#attributes' => array(
+ 'id' => 'taxonUuid',
+ )
+ );
$form['redListField'] = array(
'#type' => 'fieldset',
diff --git a/modules/cdm_dataportal/cdm_csv_export/js/cdm_csv_export.js b/modules/cdm_dataportal/cdm_csv_export/js/cdm_csv_export.js
index 22f69080..cc442e6c 100644
--- a/modules/cdm_dataportal/cdm_csv_export/js/cdm_csv_export.js
+++ b/modules/cdm_dataportal/cdm_csv_export/js/cdm_csv_export.js
@@ -32,12 +32,19 @@ function finishDownload() {
*
*/
function validateForm(){
- var select = document.getElementById("edit-combobox");
- if(select.value==null || select.value == -1|| select.value==""){
- //alert('Please select a valid classification');
- //jQuery('#edit-combobox').addClass("error");
- select.selectedIndex = 0;
- }
+ var classification_select = document.getElementById("edit-csv-export-classification-select");
+ if(classification_select.value==null || classification_select.value == -1|| classification_select.value==""){
+ classification_select.selectedIndex = 0;
+ }
+ var taxon_select = document.getElementById("edit-csv-export-taxon-select");
+ var taxon_uuid = document.getElementById("taxonUuid");
+ var selectedTaxon = taxon_select.value.toString();
+ if(selectedTaxon!=null){
+ uuid = selectedTaxon.substring(selectedTaxon.indexOf("[[")+2);
+ selectedTaxon = selectedTaxon.substring(0, selectedTaxon.indexOf("[["));
+ taxon_select.value = selectedTaxon;
+ taxon_uuid.value = uuid;
+ }
}
diff --git a/modules/cdm_dataportal/cdm_dataportal.search.php b/modules/cdm_dataportal/cdm_dataportal.search.php
index 7eb6dbb7..560cb53b 100644
--- a/modules/cdm_dataportal/cdm_dataportal.search.php
+++ b/modules/cdm_dataportal/cdm_dataportal.search.php
@@ -147,7 +147,7 @@ function cdm_dataportal_taxon_autosuggest($classificationNodeUuid = NULL, $areaU
$titleCache = $record->entity->titleCache;
preg_match('/(.*) sec.*/', $titleCache, $trimmedTitle); //remove sec reference
$trimmedTitle = trim($trimmedTitle[1]);
- $matches[$trimmedTitle] = check_plain($trimmedTitle);
+ $matches[$trimmedTitle.'[['.$record->entity->uuid] = check_plain($trimmedTitle).'[['.$record->entity->uuid;
}
drupal_json_output($matches);
}